Hacker News new | past | comments | ask | show | jobs | submit login
How do I approach functional languages?
6 points by Senkwich on June 11, 2014 | hide | past | favorite | 8 comments
tl;dr how do I approach learning a functional language for real-world development where I can get my hands dirty quickly without much setup and can work without a heavy IDE to facilitate development? What language do you recommend?


Having read several older articles (https://news.ycombinator.com/item?id=2413816) and blog posts (http://japgolly.blogspot.com/2014/06/a-year-of-functional-programming.html), I've become more interested in attempting to learn - and I mean really learn - a functional language.

I'm having to learn Scala for work, but I don't really care for how much setup I have to go through to get a project going. Maybe I'm doing things the wrong way, but first-time setup of sbt (downloading all of the jars) and frameworks like Play irritate me simply because I want to get up and running quickly. Managing dependencies and working with what feels like embedded Maven syntax does not exactly excite me, mostly because I am not too familiar with Maven itself.

I'm trying to avoid losing interest, which typically comes about from uninteresting "Hello World" examples and annoying toolchain setup (usually around JVM-based languages). I have seen some really amazing work done through the JVM, but I always see developers using either a) Eclipse or b) IntelliJ as their work environment to manage all of the project-related material.

Which leads me to my last bit of background... I'm a terminal vim guy. I really enjoyed using it when I was introduced to it in academia and continued to use it ever since. Because of this, I found myself using a more terminal-oriented environment: XMonad as my window manager, rxvt as my terminal, vim plugins like Ctrlp for quick navigation between material, etc.

I've seen a lot of smart people on this site and am hoping to poke you for advice. I'd love to be able to use what I learn at work and also pass on what I learn to others.

Due to the 2000 character limit, I had to trim the above. Here's the excess for those interested.


My experience with functional languages is very limited. My university required one course that delved into both functional (Scheme) and logic (Prolog) languages along with context-free grammars through BNF. Because of the broad range of material, I can safely say that I did not take away much from the course (aside from an awareness of the subjects).

I'm coming from an academic computer engineering background of C and Verilog (embedded system development and software/hardware codesign) as well as an academic computer science background of Java. In my industry work, I've learned some Python, Ruby (Sinatra/Rails), and Javascript (both client-side and server-side through NodeJS).

I'm leaning towards Haskell simply because XMonad was written in it, meaning that I will finally understand my window manager's configuration script. I've also considered Erlang because of how powerful I've heard it is with concurrency (and is one of the best for the actor model).

I'm not a fan of Scala and I absolutely loath sbt, but I absolutely recommend the FP Coursera Functional Programming Principles course[1] that uses both of them. There's an edition already running now but close to the end, however you can still join and work through it. Because it's an online course you'll find other people also working through it and, depending on where you're based, maybe some real world study groups as well.

I'd argue that the pain of downloading jars with JMV isn't that bad. Sure, it's a real pita to download them, but afterwards they're cached and immediately available. Also, if you're using Scala or Clojure then it's really easy to jump into the repl and start playing with the language.

If you're looking for "real world" fp then those may be your best bet. Haskell is a beautiful language and becoming a lot more real-world, especially compared to it's history and reputation as only an academic language. I'm not really a Haskell expert but I worked through Learn You a Haskell for Great Good [2] and found it to be one of the most enjoyable texts about a PL that I've ever found. You can read it all online for free or buy it in real-world book form.

As well as those I've worked through SICP in Racket (a lisp), SICP is a classic and well worth taking a look at even if you don't want to lisp.

I've written in all of the above with Emacs where there's great support, I'm sure there are vim equivalents of the language support, although I'll have to rely on some other HNer to point them out.

Finally, elements of FP are seeping through into non-fp languages, you can already see them in Java 8, C#, JS, Python, Ruby and more. No one can really call these languages FP languages, but if you know some of them then it might make jumping into FP seem a little less alien.

[1] https://www.coursera.org/course/progfun [2] http://learnyouahaskell.com/

Thanks for the comment! I wish this site let initial posts be more than 2000 characters so I could have gone into more detail.

The main reason I am hesitant to work with Scala/SBT is because I've been using Docker to package/deploy a lot of the web applications I've written. Since Docker is a one-or-nothing for each line you execute, I am getting either all of the dependencies installed at once (which takes awhile the first time) or - if something fails - I get none of them. The caching that sbt offers is basically thrown out, which is really frustrating.

There's that, but I also just don't like how much weight there seems to be with Scala because of all of the large jars I have to download to do anything. At least, that's what it feels like for me.

So, I'm not sure what specific language you would recommend. You indicated that Scala/Clojure aren't too bad and offer repls to start playing, but how hard are they to really set up for a decent-sized project? One team that I'm working with has used Clojure for DSL-related work, but mostly use Java for their main application.

Haskell is the language that I've been reading about recently that seems to have more "meat" available each year (from Hackage), which is encouraging. Everyone (including yourself!) claims that it is a beautiful language, and quite a few believe that learning Haskell - and I mean really learning it - has redefined how they approach software development. That kind of change is what I'm hoping to discover if I delve into a functional language in a big way.

I'd forgotten that I had used DrRacket in academia at one point, but not enough to learn much of it. What exactly makes SICP a classic to you?

As for other languages that are beginning to exude some functional... functionality, I've noticed that (with Java 8 and Ruby), but I'm afraid that I'm not really grasping the strengths of said features. I'm trying to jump into a more functional language to really understand why they can be good and hopefully take away something really meaningful.

Thanks for the links! I'll check them out later today!

You could install a Clojure environment and try an editor-repl-based tutorial like https://github.com/swannodette/lt-cljs-tutorial

I highly recommend Lighttable ( http://www.lighttable.com/ ) as it's a very efficient repl/editor and it will get you up and running in no time (it will install/configure Clojure), but maybe you can find an approaching solution for vim?

Thanks for the links. Even if I'm a vim guy, I know it isn't realistic to expect everything to work with it. I'll check out the links later today.

Also, is there a reason you jumped to Clojure? Do you have any specific reasons as to why you would recommend it? I'm open to picking up just about any functional language as long as I can use it for more than implementing Fibonacci numbers.

I've not jumped in Clojure (yet)... but exposure to functional programming can do you good.

I'm using CoffeeScript (node & angular) currently, but Clojure has transformed the way I code (way less imperatively).

My only problem with Clojure: its syntax doesn't help me understand structure... so to me, Clojure is difficult to read.

But if you're prepared to think differently, you can learn how with a functional programming language, then apply everywhere...

Note: I've used Scala, I do like it, but it didn't make me a fp programmer... I guess I should give it another try someday. I prefer its syntax (over Clojure), except for types (and occasional syntax ambiguities). It was a mixed Java/Scala project, so I didn't use Scala collections much...

Those were my fears with sticking with something like Scala. I just know I would fall back on imperative programming rather than being forced to understand functional programming.

Scala itself doesn't seem bad, but my gripe is just getting a working project set up. With sbt, I know I have to create a few files just to get up and running. Not knowing Maven syntax - can be embedded in sbt, I think - or sbt itself, I don't find it appealing to learn that kind of tooling outside of work.

I used Scala for a project of mine, and I relied on Eclipse for the build environment... I didn't use sbt directly, and incremental compilation was very fast.

I've recommended Lighttable because it's a very dynamic editor: it has a REPL, it can evaluate every line you type. It makes it easier to learn: no apparent compilation.

I dream of using Lighttable to develop something... Check this video: it's in Javascript, but it shows why Lighttable is so amazing (https://www.youtube.com/watch?v=52SVAMM3V78)

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact