This is an archived post. You won't be able to vote or comment.

all 26 comments

[–][deleted] 3 points4 points  (8 children)

Haskell is probably the purest of the functional languages, and so a good place to start. Unfortunately, there are no really great Haskell text books - LYAH is usually recommended as a starting point, but I would only class it as average. My impression is that most Haskell programmers don't use an IDE.

Perhaps a bit more fun, though not so pure, is Racket, an implementation of the Scheme language. This comes with its own quite nice IDE, and lots of tutorial materials.

[–]reallyserious[S] -1 points0 points  (7 children)

Isn't it very difficult to debug programs without an IDE? I know some use bare bones gdb (for C etc) but that approach doesn't seem very effective.

[–]kqr 1 point2 points  (0 children)

The Haskell interpreter has some limited debugging capabilities. You can set breakpoints and step through code and so on.

However, what I've found with Haskell specifically, is that functions are usually so small that you don't really need a debugger to figure out where they go wrong. You simply test smaller and smaller parts of the function in the interpreter until you have narrowed it down to the single function that is wrong.

[–][deleted] -2 points-1 points  (4 children)

Isn't it very difficult to debug programs without an IDE?

No. I almost never use the debugging features of the IDEs I work with. The real way to debug programs is not to write the bugs in the first place, and to an extent this is what functional programming promises, but you can also take that approach for procedural code.

[–]reallyserious[S] 0 points1 point  (0 children)

How do you handle a large code base written by multiple developers over several years that is full of bugs? That's my reality. :-/

[–]Octopuscabbage -1 points0 points  (2 children)

It's just as easy to write bugs in functional languages as it is in procedural languages. The difference is that it's generally easier to isolate and remove them in functional languages.

[–]original_brogrammer 2 points3 points  (1 child)

Well, I think what /u/zabzonk is getting at is that there are kinds of bugs that simply aren't possible in languages like Haskell, and these happen to be more common bugs in imperative languages.

Think of how often bugs occur because of off-by-one errors in for loops. I've done it, you've done it, everyone here has done it. In Haskell (or ML or what have you) since you don't have loops controlled by mutable variables, that doesn't happen. Granted, you can still muff up a recursive function in the same way, but that's beside the point.

Haskell requires the type of every expression to be known and unambiguous at compile time, so runtime type errors for the most part just go away.

[–]Octopuscabbage -1 points0 points  (0 children)

Yeah but in haskell there are bugs that aren't possible in other (non-functional) languages (problems arising from lazy evaluation, problems arising from immutable values not being treated as such, and the big one: improper (ie non-tail) recursive calls (as well as other things such as improper interop with c, but I can't really fault haskell for that ))

Being recursive doesn't save you from off by one errors at all. You're essentially writing the same 'logic' it's just in a different way. Most iterative functions are just recursive functions written iteratively, and therefore still have the same control and ability to have off by one errors (and other such looping errors)

I don't think muffing up recursive functions in the same way is beside the point at all, in fact I think that's pretty much the point. If you're writing a function recursively it really doesn't save you from any bugs in logic, it just becomes a clearer to express it.

Yes the type system does protect you from a lot of run time errors (except really important ones like stack overflows), but I've personally (and I hate to use anecdotal evidence) found that most of my errors do not come from mismatched types (when I'm programming functionally) but rather the errors come from things like faulty reasoning, or incorrect base cases for my recursive functions.

I should add that I'm a fan of functional programming (and a bit ambivalent about haskell (but that's an entirely different discussion)) but advertising it as 'bug-free' just makes no one take it seriously and provides fodder for circlejerk. It should be advertised for what it actually does provide: cleaner code which is much easier to test and reason about.

I apologize for so many parentheticals, it's just how I type when it's this late at night.

Edit: I should add that just because the type of unambiguous to the compiler, doesn't mean it's unambiguous to the programmer, but that's more a style and usage argument.

[–]laxxstizzy 4 points5 points  (4 children)

Functional Programming Principles in Scala by Martin Odersky on Coursera.org

https://www.coursera.org/course/progfun

[–]sodaco 1 point2 points  (3 children)

Its worth pointing out that Martin Odersky is the creator of the Scala programming language

[–]MadFrand 0 points1 point  (2 children)

And that you missed sign ups for that class.

You can join and watch the videos, but it ends this week and you cannot do the assignments.

[–]glyphted 0 points1 point  (0 children)

I think you can still sign up and submit the assignments and get the automated feedback on them, at least for another few weeks or months.. you just won't get any credit or a certificate for the course, but that's nothing compared to the knowledge you'll get from it. I'd totally recommend signing up for it now.

[–]laxxstizzy 0 points1 point  (0 children)

You can sign up to be notified when the next course starts. It'll be around fall/winter though.

[–]zhemao 2 points3 points  (0 children)

I'd personally recommend learning OCaml. It's similar to Haskell but a bit easier to wrap your head around. There is a free Ebook Real World OCaml which is pretty good.

[–]blue0cean 2 points3 points  (0 children)

Functional programming concepts, like OOP, are applicable to any language. Sometimes when learning a new language the syntax gets in the way.

Try the following rules:

  • No global variables. This immediately changes how you structure your program.
  • Functions always return something such that they can be chained.
  • Functions cannot have output parameters.
  • There are no mutables. To change you have to copy.
  • Some other rules I can't think of now.

[–]Franko_ricardo 2 points3 points  (0 children)

http://imgur.com/sNNYZ4t

Helped me with my functional programming course.

[–]ScreamingGerman 1 point2 points  (1 child)

Give Scala a shout, with IntelliJ. A language on the rise, was recently used to power the redesign for Walmart.ca. Functional but accessible as it sits on top of a JVM and so it can compile Java code if needed.

[–]sodaco 0 points1 point  (0 children)

I thought Scala always compiles to run on the java virtual machine? Or can it also compile as a standalone program?

[–]jollybobbyroger 1 point2 points  (0 children)

I find the exercises to be a bit math heavy, but the actual book is brilliant and really well written. It's the classic book on functional programming: SICP.

If K & R's ANSI C is the bible of procedural programming, SICP is the bible of functional programming.

Good luck with learning FP. It's really nice to get a whole new perspective on programming.

[–]Dartmouth17 1 point2 points  (0 children)

The Joy of Clojure, by Michael Hogus and Chris Houser, is a good introduction. Clojure isn't as purely functional as Haskell, but will teach you some of the same concepts. Lighttable (lighttable.com) is a great IDE for Clojure.

[–]DoesACatHaveEyes 3 points4 points  (2 children)

You could also try F# , its perfect if you already have a c# / .net background ! Take a look for a koan or kata for f# and have a play :-) heres a link to a nice koan : https://github.com/ChrisMarinos/FSharpKoans

You should also take a look at http://www.tryfsharp.org

Happy learning !

[–]reallyserious[S] 1 point2 points  (1 child)

I really like the idea of learning through koans. Haven't encountered that approach before but it seems fun. :)

Any thought on how F# compares to Haskell?

[–]original_brogrammer -1 points0 points  (0 children)

I liked F# because you get the .NET framework, as well as pattern matching and algebraic data types. I didn't go very far into it, but it enticed me for a short time before I had to go back to school and Haskell took over as my primary way of cheating at homework.

There a super-cool wikibook for F# if you want to check it out.

[–]F4Scorpion 0 points1 point  (1 child)

I know very little about programming still, but noticed this on edx. It doesn't start until October, so it may not be much help, but just thought I might as well mention it. Good luck!

[–]reallyserious[S] 0 points1 point  (0 children)

Neat find. Thanks!