[Haskell-cafe] Learning C after Haskell

Greg Buchholz greg at sleepingsquirrel.org
Mon Jun 12 16:13:02 EDT 2006


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


More information about the Haskell-Cafe mailing list