Writing kernel modules in Haskell
Writing kernel modules in Haskell
Posted Oct 7, 2009 17:53 UTC (Wed) by TomMD (guest, #56998)In reply to: Writing kernel modules in Haskell by shlomif
Parent article: Writing kernel modules in Haskell
1) You are comparing different algorithms.
Your algorithms for these two program are entirely different. Your Perl program will take one word, modify a map of counters, and then process the next word - a constant space algorithm. This is entirely doable in Haskell but you have decided not to. Instead, you read in the entire file, sort the words, group them, and count the resulting list lengths, requiring O(n) memory (actually more, given that you are sorting).
Your algorithms for these two program are entirely different. Your Perl program will take one word, modify a map of counters, and then process the next word - a constant space algorithm. This is entirely doable in Haskell but you have decided not to. Instead, you read in the entire file, sort the words, group them, and count the resulting list lengths, requiring O(n) memory (actually more, given that you are sorting).
2) You are using linked lists of linked lists for processing
Anyone serious about time and space would be using packed strings, from the bytestring package.
The first issue seems especially obvious, making me think this is done on purpose. Please don't troll on LWN.
