Functional programming

Discussion in 'Programming' started by LagadoMC, Jul 12, 2015.

  1. I'll keep this quick.
    I've been thinking about taking a look at functional programming, just to get a feel for a different paradigm apart from procedural and object-oriented programming.
    Anyone have any favourite languages in that area?

    I don't have any specific domain in mind. I won't be making anything useful, I just want a new thing to play around with a bit.
  2. Java came out with fully-working functional programming in 8, so you could take a look at that.
  3. Try Haskell. It's extremely different and honestly I attribute being a lot better now than I was before simply because you absolutely have to think differently. Immutability, recursion, pattern matching, all really neat stuff that you don't appreciate until you use it extensively. One of my favourite features is list comprehensions. If I wanted to make a list that was all the numbers from 1 to 1 million, I can write:


    or every even number from 1 to 100


    or every odd number


    or every number that is divisible by 10

    [ x | x <- [1..100], x `mod` 10 == 0]

    The possibilities for really neat code that is short and sweet are simply endless with Haskell. It is just. so. nice. to reason about your code when there is less of it. It is statistically proven that more code == more problems, period. Strip away the boiler plate crap and you are left with what is actually wrong with your thinking and nothing else.

    Best place to start learning is here:
    • Like Like x 1
  4. Lisp? I use it to customise my Emacs
  5. Just no. Java 8's lamba addition adds support for partial functional programming, by adding lambda's as a way to have function literals in java. Unfortunately, java has no current nor planned way of dealing with code as data, therefore until then can't be classified with full function programming support. Instead the lambdas give the developer a small power of functional programming which can ease development and the nastiness of pre java 8 source code. eg. mapping, filtering, and collecting via java 8 is significantly less eye raping than a bunch of for loops. Though java's implementation makes some things more difficult (cough spigot timings).
    • Agree Agree x 1
  6. As someone who comes from Haskell in terms of functional programming, my main issue would be that impure code is mixed with pure code. I know that it is not canonical of Java to do this, but it is quite evident in the functional community that drawing a line between a pure function and something that involves impure state changes etc is a very good concept to which Java simply does not employ.
  7. In my honest opinion, I feel Java 8's lambdas were added not as a way to add the functional paradigm to Java, but to enrich the multi-paradigm design Java follows.
  8. I was more directing those criticisms towards learning functional programming through Java; not Java's overall paradigm.
  9. XD my bad on that one, wasn't that obvious when i first read it.

    I totally agree with that. It'd just be plain stupid to say you understand functional programming, and all you've done is Java
  10. I'll give Haskell a try then, thanks :)
    • Like Like x 1