
Ok, so I'm doing things somewhat backward. I've been using Haskell for a while now, whenever I get a chance to. But in order to become more involved in high-performance computing projects at my work, I need to learn C. I've heard a lot of people say that experience in Haskell can improve one's abilities in other languages, but I also wonder how different the C "way of doing things" is different from Haskell's. My question is, as I learn C, are there any particular Haskell concepts I should keep in the back of my mind, or is it better to approach C from scratch? Thanks in advance! Preparing for a foot-shooting, Chad

Chad Scherrer wrote:
My question is, as I learn C, are there any particular Haskell concepts I should keep in the back of my mind, or is it better to approach C from scratch?
One thing from Haskell I'd try keep in mind is to minimize side effects and keep the scope of side effects as contained and local as possible. So avoid mutating global variables, try not to write to the same file from multiple different subroutines, etc. And if you start getting seg-faults, you'll probably want a tool to help you, since reasoning and debug by printf on pointers can only take you so far in a language like C. http://www.gnu.org/software/libc/manual/html_node/Allocation-Debugging.html http://perens.com/FreeSoftware/ElectricFence/ http://valgrind.org/ Greg Buchholz

On 6/12/06, Chad Scherrer
Ok, so I'm doing things somewhat backward. I've been using Haskell for a while now, whenever I get a chance to. But in order to become more involved in high-performance computing projects at my work, I need to learn C. [snip] My question is, as I learn C, are there any particular Haskell concepts I should keep in the back of my mind, or is it better to approach C from scratch?
Sounds like you would be an almost ideal user for Jekyll. Too bad it's only in the alpha stages: http://jekyllc.sourceforge.net/ You might find it useful to study how Haskell's familiar product and sum types would be represented in unfamiliar C. If I recall correctly you can find examples of the translation in the Jekyll presentations/documentation. So even if you never used it, it would be a worthwhile read. Good luck, Jason

Thanks for all the replies - this has helped a lot!
Chad
On 6/12/06, Chad Scherrer
Ok, so I'm doing things somewhat backward. I've been using Haskell for a while now, whenever I get a chance to. But in order to become more involved in high-performance computing projects at my work, I need to learn C.
I've heard a lot of people say that experience in Haskell can improve one's abilities in other languages, but I also wonder how different the C "way of doing things" is different from Haskell's.
My question is, as I learn C, are there any particular Haskell concepts I should keep in the back of my mind, or is it better to approach C from scratch?
Thanks in advance!
Preparing for a foot-shooting, Chad
-- Chad Scherrer "Time flies like an arrow; fruit flies like a banana" -- Groucho Marx

I did the transition the other way, and even now the real-world keeps me using more C-like languages (Java, Python). Unlike the transition from imperative languages to Haskell, I don't think there's much you have to unlearn or rethink. But I suspect you may feel a degree of frustration at how incredibly primitive C may seem after learning to use the power that Haskell makes available. Where you can map Haskell idioms into C, I think they may serve you well (I've found this to be the case with Python, but the gap from Haskell to C is somewhat greater). You mention "high performance" computing. I think there are two ways of achieving this: the C way might be described as "micro optimization" -- getting the small but important things to run as efficiently as possible The Haskell was is more a case of "macro optimization" -- getting the overall algorithmic approach to be as smart as possible. There's a place for both, but once you get involved in micro-optimization it can be very difficult to go back and fix the macro performance issues. So you might do well to first code algorithms in Haskell first, and experiment with the algorithms, if only as a way of specifying the solution to be implemented in C. #g -- Chad Scherrer wrote:
Ok, so I'm doing things somewhat backward. I've been using Haskell for a while now, whenever I get a chance to. But in order to become more involved in high-performance computing projects at my work, I need to learn C.
I've heard a lot of people say that experience in Haskell can improve one's abilities in other languages, but I also wonder how different the C "way of doing things" is different from Haskell's.
My question is, as I learn C, are there any particular Haskell concepts I should keep in the back of my mind, or is it better to approach C from scratch?
Thanks in advance!
Preparing for a foot-shooting, Chad
------------------------------------------------------------------------
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Graham Klyne For email: http://www.ninebynine.org/#Contact
participants (4)
-
Chad Scherrer
-
Graham Klyne
-
Greg Buchholz
-
Jason Dagit