Slashdot Mirror


OCaml For the Masses

CowboyRobot writes "Yaron Minsky of Jane Street argues that the time has come for statically-typed functional languages like OCaml and Haskell. He cites many reasons and illustrates what he says is the most important, concision: 'The importance of concision is clear: other things being equal, shorter code is easier to read, easier to write, and easier to maintain.'"

338 comments

  1. haskell for the masses? sure, but only... by tulcod · · Score: 4, Insightful

    haskell for "the masses" is possible as soon as "the masses" has a degree in mathematics. java and php are copy-and-paste languages, functional languages simply take more thinking to compile at all, and i think many programmers are not prepared to do that to the required degree, although i'd love to be proved wrong.

    1. Re:haskell for the masses? sure, but only... by gstoddart · · Score: 1, Interesting

      Yeah, every now and then I've known someone who firmly believed we should all be writing in Haskell and the like.

      Mostly it seems like they're suggesting it because they're geeky people who like some of the features they claim the language has, and because this meets some level of mathematical elegance that resonates with them.

      My recollection of functional programming from university was that it was kind cute, seemed to be geared to solving a problem domain I never found a use for, but that ultimately I hated the syntax and structure of it. I never really "got it", or really understood what it was supposed to be useful for.

      Other than someone doing an Othello game in lisp, I'm not sure I've ever actually seen these languages used for anything ... at least, not outside of AI type things or university.

      But, that was a long time ago. To me it's mostly theorists talking about how clean and pretty the code is, but it just doesn't seem like it's all that useful in the real world.

      And, really, let's face it ... I don't recall ever seeing "wanted, one haskell programmer". So, do people actually use it for commercial software?

      --
      Lost at C:>. Found at C.
    2. Re:haskell for the masses? sure, but only... by Anonymous Coward · · Score: 0

      Haskell is only for professors. No one does real work in Haskell, unless it is experimental work (i.e., in an experimental research language, focused on the "theory of the perfect programming language", whatever that is... arguments mainly).

    3. Re:haskell for the masses? sure, but only... by Anonymous Coward · · Score: 0, Informative

      haskell for "the masses" is possible as soon as "the masses" has a degree in mathematics. java and php are copy-and-paste languages, functional languages simply take more thinking to compile at all, and i think many programmers are not prepared to do that to the required degree, although i'd love to be proved wrong.

      Functional languages are very easy to master, much much easier than Java or C++; and no you certainly don't need a degree in mathematics to understand and program in Scala or Haskell or Ocaml.
      The problem is the mas of sunday day programmers out there that think that javascript or php are the end all to computer languages.

    4. Re:haskell for the masses? sure, but only... by makapuf · · Score: 1

      Functional languages ... Err code editors perhaps (emacs) ? Games (jak & daxter) ?

    5. Re:haskell for the masses? sure, but only... by sourcerror · · Score: 1

      I've been programming Prolog quite a lot (a bit CLP too), but still don't get monads, so I just shrug off your snobbish nonsense.

    6. Re:haskell for the masses? sure, but only... by Anonymous Coward · · Score: 0

      I'm sorry to say that you're mistaken. Please read up some more on how and for what people use Haskell, before saying such things (without proof).

    7. Re:haskell for the masses? sure, but only... by Anonymous Coward · · Score: 1

      http://www.haskell.org/haskellwiki/Haskell_in_industry

    8. Re:haskell for the masses? sure, but only... by alphabetsoup · · Score: 1

      Modern imperative languages are constantly adding elements from functional languages. For example, take C++ templates - template metaprogramming is a pure functional style of programming. C++ 1x has added lambdas. Also things like STL algorithms such as accumulate and for_each or boost::bind - are essentially functional programming. C++ 1x was to have concepts which was removed but will hopefully return in the next standard. C# has added async and await. So your "masses" cannot avoid functional programming - they will be forced to learn it - since all imperative languages are going in that direction.

      The advent of multicore programming will force this issue. Functional programs are much easier to execute in parallel. C++ has Microsoft PPL or Intel Threads libraries which are essentially functional algorithms. parallel_for with a lambda is one of the most useful parallel programming techniques. The equivalent imperative program will be far more verbose and cumbersome.

      I actually believe C++ with the addition of Concepts and pure functions will make a very useful functional language. Yes it will be much more verbose than Haskell. Everything is. But then we will be able to use imperative style where required and functional style everywhere else. The functional parts can be easily parallelized. They can throw exceptions with impunity. Of course, there are some issues as to what constitutes "pure objects" and how to work around C++'s lack of a garbage collector. However people are already working on it. I believe Andrei Alexandrescu was working on something similar for D, which may be adopted to C++.

    9. Re:haskell for the masses? sure, but only... by rvw · · Score: 2

      I'm sorry to say that you're mistaken. Please read up some more on how and for what people use Haskell, before saying such things (without proof).

      If I enter "Haskell" in Monsterboard, I get zero results. You probably refer to academic work, but where in the commercial world is Haskell used?

    10. Re:haskell for the masses? sure, but only... by gstoddart · · Score: 2, Funny

      See, as an old school user of vi, emacs doesn't make the case for a functional language being useful.

      In fact, quite the opposite. :-P

      --
      Lost at C:>. Found at C.
    11. Re:haskell for the masses? sure, but only... by gilleain · · Score: 2

      I'm sorry to say that you're mistaken. Please read up some more on how and for what people use Haskell, before saying such things (without proof).

      Oh please no - that proof ... it doesn't have to be written in Haskell, does it?

    12. Re:haskell for the masses? sure, but only... by gilleain · · Score: 1, Insightful

      I've been programming Prolog quite a lot (a bit CLP too), but still don't get monads, so I just shrug off your snobbish nonsense.

      Me either; I don't even think that the higher order concept like monads or arrows are even relevant to most programming. Also, I find actual maths easier to read than Haskell or lisp - it's not just a question of not 'getting' the language; it's not very gettable.

      (I hope no-one from lambda-the-ultimate comes across this comment thread or they'll be irritated.)

    13. Re:haskell for the masses? sure, but only... by Anonymous Coward · · Score: 0

      Other than someone doing an Othello game in lisp, I'm not sure I've ever actually seen these languages used for anything

      erlang is used pretty heavily in the financial and telecom sectors.. (though, more for its parallelism) it's also a functional language.

    14. Re:haskell for the masses? sure, but only... by bbn · · Score: 1

      I get monads. But Prolog? I never learned to do more than asking what color is the ball in the third hut? Can you actually make real programs with that?

    15. Re:haskell for the masses? sure, but only... by TuringTest · · Score: 1

      It took me a while to grasp why monads use is so widespread in Haskell. But that's not primarily because of their inherent complexity (one understood, they're a rather simple Abstract Data Type) but because the uncountable monad tutorials make a terrible work at explaining their context, why they're useful for, and in which cases you should use them. These tutorials usually introduce monads with super-abstract metaphors and mathematical descriptions, that aren't useful for someone with a background in programming.

      The lead paragraph of the Wikipedia article for monads tries to explain this context in terms that are familiar to a general programmer. Basically a monad is a framework to handle side-effects (or other complex control flows) in a small imperative block (the infamous do-block) inside your pure functional, side-effect-free Haskell language. Any state that you could get embedded in the semantics of an imperative language, you can model it explicitly in your library instead - the monad exposes into Haskell definitions the inner workings of the imperative engine.

      Once this is understood, they're a pretty effective way to implement the problems that are simple to program in an imperative language but get complicated by a pure functional approach.

      --
      Singularity: a belief in the "God" idea with the "demiurge" relation inverted.
    16. Re:haskell for the masses? sure, but only... by Anonymous Coward · · Score: 0, Interesting

      Why does everything have to be "for the masses"?
      The masses are willingly dumb, willingly ignorant, and willingly living in a walking daze.
      If they like it, let them be, and enjoy the competitive advantage, will ya? :)

      I am a Haskell programmer, and I don't have a degree in anything! Just a will to learn and a healthy interest in the world. Especially that which empowers me in a emergent way! (Very generally applicable knowledge.)
      (In fact I left school 2 years too early because I wanted to learn more useful stuff. And I had all my jobs because of it!)

      I know for a fact, that every human has those abilities. It's just that most people got drilled in their head that they would not be able to reach that high, calling those who do "smartasses".
      Like a society of people lying around like vegetables, calling those who walk around normally "smartasses", because they think it would be that impossible for "normal people" to just walk.

      And the combination of a computer and Haskell is the "god" of emergent all-encompassing information processing. It's the teaching material that's bad.

      I'll give you a free lesson about ALL that monads are, in Java terms, so that you understand the whole concept, *right now*:
      A monad is a interface containing a set of operators. But those operators are used on *functions*. like you say "1 + 1", you can say "function1 >> function2". What that does is entirely up to you. But there's a basic idea of using them to be able to define a order of execution. First function1, then function2, for example.
      But those functions you use with those operators, are special. They return "actions". Which is just another name for pretty normal functions that take one parameter and return one parameter: The current state. In case of the IO monad, it's the state of the "outside world". (But you're free to use that passed-through thing however you like.) The idea is to string actions together so that the output of one is the input of the other, resulting in the sequencing of actions.
      Makes sense, no? You string up actions. And pipe a data structure through them that is changed. The same thing that you do in Java.
      The functions are
      ">>", which just sequences,
      ">>=", which also takes the last result *out* of the state and passes it to function2,
      "return", which also puts a value *into* the state

      That's it! Seriously!

      Now suddenly, something like "open file >> read file >>= \content -> print content >> close file >> return content" makes perfect sense, doesn't it?
      Itâ(TM)s the same thing as "open file; (anonymousFunction(content) { print content; close file; return content; }) (read file);"
      And the "do" notation is just some sugar to make it look like Java again and to confuse people. ;)
      Here's the same thing in "do" notation:
      do
          open file
          content - read file
          print content
          close file
          return content

      There! You, the supposedly average Joe Java-Programmer, have now mastered the supposedly hardest problem newbies encounter with Haskell! The rest is a cakewalk in comparison.

      P.S.: TO ALL HASKELL PROGRAMMERS: STOP THE FUCK FROM USING MEANINGLESS IDENTIFIERS LIKE "a" OR "xs"! OR POINTFREE SYNTAX! OR TYPES THAT NOBODY CAN FUCKING READ BECAUSE THEY ARE MADE OF 80% PUNCTUATION CHARACTERS AND THEY LOOK LIKE SOMEBODY LEANED ON THE KEYBOARD! JUST BECAUSE YOU CAN, DOESN'T MEAN YOU SHOULD!

    17. Re:haskell for the masses? sure, but only... by sourcerror · · Score: 1

      Well, Prolog is like Lisp with syntax and backtracking, so if a problem is suitable for Lisp, then it's suitable for Prolog as well. So it's good for domain specific languages (and you get additional goodies custom operator precedence, custom prefix, postfix, infix operators etc.)
      Also, all Prolog implementations come with a few Constraint Logic Programming libraries, so if you have logistics/scheduling problems it's pretty good for that too. Also CLP(R) libraries also feature various optimization algortihms like simplex, but you can make it to solve harder problems too, and it'll intelligently prune the problem space. So if you're into mathematical optimizations/operations research then you'll find it useful.

    18. Re:haskell for the masses? sure, but only... by John+Courtland · · Score: 1

      DGC : Prolog :: Monad : Haskell

      --
      Slashdot is proof that Sturgeon's Law applies to mankind.
    19. Re:haskell for the masses? sure, but only... by Darinbob · · Score: 2

      Lisp is used for just about everything possible. Compilers, editors, games, window systems, etc. Lisp isn't really in the same category as pure functional languages like Haskell. But pure functional languages have been used to do a whole lot of larger applications as well, editors, compilers, etc.

      The big problem is that in a lot of programs you need more than just the pure functions; you need I/O and other side-effects. Functional languages have these but they often feel like odd bits tacked on that corrupt the simple language rules.

    20. Re:haskell for the masses? sure, but only... by HiThere · · Score: 1

      That definitely depends on what you're doing. Every time I've looked at a functional language I've bounced. Usually over random access read-write files. IIRC, even doing ordinary IO in Haskell (or possibly it was OCaML) required dropping into C. (Monads have no state, or some such.)

      If I were to choose a functional language it would be one of the Scheme family...unless there's something that I really don't understand about Haskell or OCaML. But I have a hard time mapping Scheme variables into byte layouts in a random access file. Still, it is, in principle, doable. Not sure it's doable even in principle in Haskell or OCaML.

      FWIW, just yesterday I was looking at Oz (Mozart) again. (Another strange languge, I think it's functional, but their emphasis is on constraint programming.) I bounced on their lack of file IO capability. (This time all I could find documented was text streams that were either input or output, not both.) Well, Oz has an excuse. It's design was finalized over a decade ago, and it's doesn't appear intended for other than academic use.

      As far as I'm concerned, though, you can send your monads back to Leibnitz. He got some mileage out of them, but they sure don't appear worth the trouble to me. Except for a severely limited range of problems...and even then there's usually a better way to do things. Final variables, e.g. (I'd say immutable, but I'd mean the way D (Digital Mars D) uses them, which I don't really understand, and which most people won't even have been exposed to. Basically you assign the variable a value at creation time, and it can never change. But immutability can't be cast away, and creation time isn't compile time, so it's not the same as const.or, I think, final.)

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    21. Re:haskell for the masses? sure, but only... by HiThere · · Score: 3, Insightful

      You misunderstand thing. General purpose languages, such as the C or Algol family (which includes, among others Java, Python, and Ruby) do, indeed, include concepts from functional languages. But they don't RESTRICT you to those concepts. It's the insistence that everything be unchanging that is the weakness in the purely functional languages. The Scheme family is the only group of that to have any measurable use. (Note that Lisp is NOT a functional language, even though the concept originated via a subset of Lisp.)

      There's much to be said for having the ability to have invariant elements in functions. There's very little in having the requirement that everything be that way. Note that many existing languages that have invariant strings ALSO have mutable strings. Java to name just the most popular example. So by all means allow functions to declare their values invariant. This allows lots of different kinds of optimization. But don't insist that all functions do so. And definitely don't insist that everything be invariant.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    22. Re:haskell for the masses? sure, but only... by sourcerror · · Score: 1

      Also, I get how Lisp handles IO as a separate type that indicates that those operation is "dirty" and order matters, what I don't get what's inside the arrow operator, as it's syntactic sugar for a series of primitive operations. Honestly, I have spent a weekend figureing it out, and all I got was headache. I just don't like when there's too much magic happening behind the scenes. Also, Oz seemed much easier to understand, and I just thought I know enough exotic languages to warrant my geek card, so I just passed on Haskell.

    23. Re:haskell for the masses? sure, but only... by gstoddart · · Score: 1, Offtopic

      The big problem is that in a lot of programs you need more than just the pure functions; you need I/O and other side-effects.

      See, a computer language without IO is generally something which doesn't do anything useful. If all they are is something which is elegant and pretty, it's hard not to write them off as something that academics crow over but which have no actual value.

      Obviously, that's a gross overstatement, but usually I get the impression that people fawn over it because it's pretty and plays into a certain aesthetic that only a very few people I've ever known are swayed by.

      Mostly it was a former co-worker who occasionally got the notion in his head that everything we'd done over the last few years should be thrown away and started from scratch, because he had read something in an academic journal that made him rethink the world and that we were All Horribly Wrong and that he'd Seen The Light.

      Obviously, management and other people mostly treated it as an academic indulgence and told him that what he said was great in theory, but had no relation to the real world. It was mostly about how elegant the language would be, and how it would solve a bunch of issues which nobody had identified as needing to be solved.

      In no way shape or form did it relate to the actual shipping products we had, what we were trying to accomplish, or how we actually generated revenue. Eventually when he brought up the topic, people just tuned him out. He's a smart guy, but after a while he was saying stuff that was more about something purely theoretical and irrelevant.

      --
      Lost at C:>. Found at C.
    24. Re:haskell for the masses? sure, but only... by sourcerror · · Score: 1

      "Also, I get how Haskell handles IO "

      "get what's inside the arrow operator" or is it "DO" operator? I don't really remember.

    25. Re:haskell for the masses? sure, but only... by Anonymous Coward · · Score: 0

      F# has been said to prepare the programmer for the C# 3.0. It's apparently used in the financial industry. The tie-in with the .Net object model is probably not a bad thing for businesses having .Net legacy code, or a programmer well-versed in using it. The next generations of GPUs bring the programmability to the level that they can support functional languages. Erlang and scala are quite popular in certain domains. And Autodesk used lisp as a scripting language in the autocad for a long time. I'm not sure if they do still.
        Language specific job adds tend to be sprinkled around the languages user groups similar to the adds you might find at the universities. The employers appear to look people with specialty from the places associated with that specialty.

    26. Re:haskell for the masses? sure, but only... by nschubach · · Score: 1

      (I hope no-one from lambda-the-ultimate comes across this comment thread or they'll be irritated.)

      I'm sure they're already here... in numbers. ;)

      --
      Every time I start to have faith in humanity, I ruin it by driving to work between 7 and 8 am.
    27. Re:haskell for the masses? sure, but only... by sourcerror · · Score: 1

      "C, even doing ordinary IO in Haskell (or possibly it was OCaML) required dropping into C. (Monads have no state, or some such.)"
      I'm not a Haskell programmer, but I'm sure you can do IO in Haskell, but the idea is that Haskell maintains information which function does IO and which doesn't, and does all kind of optimizations/rearranging/paralellization on non-IO functions. So if your function calls an IO function, your function becomes an IO function as well, so this property spreads to the caller.
      Remember Pascal? You had "procedure" and "function", both of which map to functions in C. The idea was in Pascal to use "function" for computations which doesn't change state, and use "procedure" for things that alter state. But the compiler doesn't actually enforced that statelessness for "function", it trusted you, and handled both the practically the same way.
      In Haskell if you say your function is stateless, the compiler will enforce that; that's why you have a bunch of operators to denote state change.

    28. Re:haskell for the masses? sure, but only... by sourcerror · · Score: 1

      I guess you meant DCG (Definite Clause Grammar).
      DCG is not a distinct conept in Prolog, just a syntactic sugar for
      foo1(In1,Out1),foo2(Out1,Out2),foo3(Out2,Out3) ...

    29. Re:haskell for the masses? sure, but only... by DragonWriter · · Score: 1

      Remember Pascal? You had "procedure" and "function", both of which map to functions in C. The idea was in Pascal to use "function" for computations which doesn't change state, and use "procedure" for things that alter state.

      Do you have a reference for this? As far as I've ever heard, the idea was to use "function" for computations which return a value and "procedure" for computations which don't return a value (equivalent to void functions in C), and the distinction wasn't intended to have anything to do with side effects. (Obviously, a procedure would only be useful if it had side effects, while a function could be useful without them, but that wasn't a side effect of the returns-a-value distinction, not the primary intended distinction.)

      But the compiler doesn't actually enforced that statelessness for "function", it trusted you, and handled both the practically the same way.

      No, functions and procedures were treated differently by Pascal compilers. Procedure calls, since they did not return a value, could not be used where a value was expected, and function calls, which did return a value, could only be used where a value (specifically, an rvalue) was expected.

    30. Re:haskell for the masses? sure, but only... by Anonymous Coward · · Score: 0

      java and php are copy-and-paste languages, functional languages simply take more thinking

      That's funny. I've always found C-style languages (that includes Java) too complex to learn and unnecessary, as long as you don't code close to the metal. Personal Home Page is the other extreme, extremely dumb but no less quirky syntax. I was so relieved when Ruby became popular. Haskell is a bit antiquated and has its idiosyncrasies, but I don't find the concepts much harder to grasp than good programming practices in procedural languages (which nowadays include functional concepts anyway). Sure, "give me teh codez" script kiddies will have a harder time with it. But they're not programmers anyway.

    31. Re:haskell for the masses? sure, but only... by sourcerror · · Score: 1

      Now just imagine having a complex expression involving several function calls, where the functions have side effects ...

      "No, functions and procedures were treated differently by Pascal compilers. Procedure calls, since they did not return a value, could not be used where a value was expected, and function calls, which did return a value, could only be used where a value (specifically, an rvalue) was expected."

      That's just nitpicking.

    32. Re:haskell for the masses? sure, but only... by Atzanteol · · Score: 0

      "My recollection of functional programming from university was that it was kind cute, seemed to be geared to solving a problem domain I never found a use for, but that ultimately I hated the syntax and structure of it. I never really "got it", or really understood what it was supposed to be useful for."

      Holy shit - you just described my experience with functional languages *exactly*. GET OUT OF MY HEAD!

      --
      "Ignorance more frequently begets confidence than does knowledge"

      - Charles Darwin
    33. Re:haskell for the masses? sure, but only... by FrootLoops · · Score: 1

      What functional language makes everything immutable always? Typically, immutability is the default behavior, but not the only behavior.

    34. Re:haskell for the masses? sure, but only... by TheRaven64 · · Score: 1

      Haskell has monads for I/O, which are very elegant. They also give you things like software transactional memory (which is great for concurrent code) in a way that's both easy to implement and easy to reason about.

      --
      I am TheRaven on Soylent News
    35. Re:haskell for the masses? sure, but only... by TheRaven64 · · Score: 1

      The problem with F# is that it isn't really a functional language, it's an imperative language with a load of irritating constraints.

      --
      I am TheRaven on Soylent News
    36. Re:haskell for the masses? sure, but only... by vlm · · Score: 1

      The problem is the mas of sunday day programmers out there that think that javascript or php are the end all to computer languages.

      The "good" news is all the 80s home computer microsoft basic programmers are age-discriminated out. Its gonna take awhile to get rid of the dotcommers.

      --
      "Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
    37. Re:haskell for the masses? sure, but only... by vlm · · Score: 1

      Ah you've taught them the syntax but not the reason why. Noob is going to look at that, and say WTF why not just write the main control loop in "bash" with vertical pipe bars between calls to the real programs? Or even worse, noob is going to see that, and say, why not use perl semicolons between your statements, whats the big deal.

      --
      "Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
    38. Re:haskell for the masses? sure, but only... by gknoy · · Score: 1

      Try looking more at how Emacs in built, rather than the keyboard conventions that it adopted. :-) The lisp code for a large portion of it is readable (er, "readable"?), for things like which menus are shown, how to color text, etc. The functional aspect of it is really flexible for things like adding color schemes or changing behavior.

    39. Re:haskell for the masses? sure, but only... by shutdown+-p+now · · Score: 2

      It's not a pure functional language, but most pragmatic FP languages aren't pure. OCaml is not pure, either.

      I'll grant you that F#'s object model (taken wholesale from .NET) is less suitable for this type of language than OCaml's one, but aside from that, what are the irritating constraints?

    40. Re:haskell for the masses? sure, but only... by Anonymous Coward · · Score: 0

      Everything is immutable in Haskell... but you can work inside a state monad and pretend you have mutable values if that's what you want.

    41. Re:haskell for the masses? sure, but only... by larry+bagina · · Score: 1

      Variables in erlang are single static assignment and, as such, immutable. There is a mutable process dictionary per thread or some such, but I've never needed to use it.

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    42. Re:haskell for the masses? sure, but only... by martin-boundary · · Score: 2

      Be specific man! There as in "come across this thread" or there as in "irritated"? Really, the next time you make a comment like that, is it too much to ask to bind the referenced variable that represents your meaning? Closures! Closures!

    43. Re:haskell for the masses? sure, but only... by Anonymous Coward · · Score: 0

      What is this obsession with bringing this or that programming language to the masses?
      Why would one care about doing this?
      Why would the masses care about this? (Is there an urge to switch away from the funniest video show, maybe?)

    44. Re:haskell for the masses? sure, but only... by aaaaaaargh! · · Score: 1

      But they don't RESTRICT you to those concepts. It's the insistence that everything be unchanging that is the weakness in the purely functional languages. The Scheme family is the only group of that to have any measurable use. (Note that Lisp is NOT a functional language, even though the concept originated via a subset of Lisp.)

      Scheme is by no means a purely functional language as you seem to suggest here. Scheme programmers perhaps tend to program in a more functional style than in the CL community, but just like LISP it allows for all kind of side-effects.

    45. Re:haskell for the masses? sure, but only... by fusiongyro · · Score: 2

      You missed the part about the author being at Jane Street Capital?

    46. Re:haskell for the masses? sure, but only... by Anonymous Coward · · Score: 1

      You ask if functional languages are useful in the real world and if they are used by anyone. Here's one simple answer:

      http://homepages.inf.ed.ac.uk/wadler/realworld/

      Notice the section on "Industrial" uses of functional languages. A significant example is Erlang, which is used extensively by Ericsson. So yes, they are useful in the real-world.

      Functional languages may not always be the best tool for every task, but to say that they are useless is just plain narrow minded. Just because you cannot think of how they could be applied to real-world problems only shows a limitation in your imagination, not a limitation of functional programming itself.

      Personally I believe that all programming paradigms are useful for different tasks, be it imperative, functional, object-oriented, logic, concurrent, etc. That's why I refer languages like Python and O'Caml that allow you to mix styles.

         

    47. Re:haskell for the masses? sure, but only... by Anonymous Coward · · Score: 0

      Actually, functional programming languages trace their origins to alonzo church's lambda calculus -
      which lisp was first implemented in order to experiment with (along with its application to AI concepts),
      and 'led the pack' until ML and others arrived on the scene in the mid 70's

      scheme was a refinement of this and essentially defined lisp's key 'eval' operation in terms of lambda,
      making for a mathematically clean operational semantics of the lambda calculous

      see also:

      http://en.wikipedia.org/wiki/Church%E2%80%93Turing_thesis

      etc

    48. Re:haskell for the masses? sure, but only... by AuMatar · · Score: 2

      So if it's simple in an imperative approach but difficult in a functional one- why the fuck are you using a functional one to begin with?

      That's why no functional language has ever been successful. It's a beautiful model that just doesn't work. And no number of epicycles like monads will ever fix the problem that you're off on your base assumptions.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    49. Re:haskell for the masses? sure, but only... by Bill,+Shooter+of+Bul · · Score: 2

      Yup, Haskell shops don't post job openings, they head hunt.

      --
      Well.. maybe. Or Maybe not. But Definitely not sort of.
    50. Re:haskell for the masses? sure, but only... by jedwidz · · Score: 1

      Java strings, as in instances of class String, are always immutable.

      Sure, there's a CharSequence interface that covers both immutable (String) and mutable (e.g. StringBuilder) strings, but it's not good style to take CharSequence arguments rather than String just for the sake of allowing mutable and immutable strings to be interchangeable.

      Haskell for one is pure functional but does have support for mutable values - arrays in particular. The catch is that you can only modify them in the context of a monad, which can be pretty inconvenient.

    51. Re:haskell for the masses? sure, but only... by blue+trane · · Score: 1

      So we can program our own video shows, video games, vr's...

    52. Re:haskell for the masses? sure, but only... by ioshhdflwuegfh · · Score: 1

      [...]

      The big problem is that in a lot of programs you need more than just the pure functions; you need I/O and other side-effects. Functional languages have these but they often feel like odd bits tacked on that corrupt the simple language rules.

      Type system of Haskell is powerful enough to do IO, state, "side-effects", etc purely functionally via monads, for instance.

    53. Re:haskell for the masses? sure, but only... by TheRaven64 · · Score: 1

      F#, like Scala, doesn't really give you any benefit from being a bit functional. It gives you higher-order functions, but object oriented languages have had these right from the start (both Simula and Smalltalk had them). The strength of functional programming comes from freedom from side effects (allowing the compiler to do some nice optimisations - especially related to parallelism - and making it easier to reason about the code), but F# lacks this, and just gives you an imperative language where you have to jump through hoops to do things that are easy in an imperative language without giving you the benefit of true functional programming.

      If I were creating a functional language to fit into an OO world, I'd use monads for interacting with the OO world, so you could run a computation in the functional world, collect a sequence of message send operations and then apply them to the OO world (or reject them, depending on the outcome).

      --
      I am TheRaven on Soylent News
    54. Re:haskell for the masses? sure, but only... by b8_bavard · · Score: 1

      Haskell is beautiful for researchers only. Instead of spending time commenting OCaml articles in Slashdot, Haskell groupies should start writting real-life applications: the Haskell Industrial Group has never been above 3 or 4 members, while the Caml Consortium has 12 members, and is increasing every year.

    55. Re:haskell for the masses? sure, but only... by Pionar · · Score: 1

      The problem with Haskell, OCaml, and the like is that, despite what this author tries to beg you to believe, is that they are NOT readable, and don't boost developer productivity any more than any other language/framework.

      The author has a bias - it's extremely readable to him because he's been working with it for 10 years. I imagine most of us developers would be fluent in a language after using it that long.

      Personally, I think the most productive languages are the statically typed object-oriented languages (C#,Java, etc). Having dynamic typing (ruby, python) leads to a lot of runtime errors and slows down development because the developer has to think about what a method is returning, while with static type function declaration he just has to look at it.

    56. Re:haskell for the masses? sure, but only... by Axman6 · · Score: 1

      Hmm, I wonder what the job I got at a high frequency trading firm using haskell exclusively was then. I don't think we published any papers; in fact, we only had one PhD, and he got the PhD long after he joined the company. I guess we didn't really make all that money after all.

      The amount of ignorance in the comments here regarding functional languages, especially Haskell, is astounding. People actually think you can't do IO in Haskell? I, and many others, believe it's by far one of the best languages to do IO in. You get to think about what actually needs to be in IO, and what doesn't, and it turns out a hell of a lot of what people using other languages think needs to use IO really doesn't. Writing highly concurrent systems in haskell that are almost trivial to prove correct in terms of interacting threads is certainly not uncommon, and it's mainly because of the pure by default nature of the language.

      I guess ignorance isn't bliss, it just leads to people making comments that make them sound just as stupid as they are.

    57. Re:haskell for the masses? sure, but only... by Axman6 · · Score: 1

      Your ignorance is laughable. Of course haskell has mutable variables (that are actually very awesome to use, thanks to the purity of the rest of the system), several different kinds. There ones which act like a box that can be either empty of full and allow for blocking reads and writes (MVars). Or there's the whole Software Transactional Memory system, which allows you have composable, ACID compliant transactions on mutable memory. There's mutable arrays for use in the IO monad, both boxed and unboxed (array of pointers to elements or array of elements), and there's even the ST monad, which allows you to write algorithms that are more efficient with mutability, but are really pure functions, and the compiler can guarantee that the mutation will never affect any other part of the system (functions written using the ST monad look like normal pure functions to the rest of the system).

      Anyway, I think it would be worth your while for you to go and learn even a smidgen of information about a topic before making such ridiculous claims. You'll look like less of a fool.

    58. Re:haskell for the masses? sure, but only... by Anonymous Coward · · Score: 0

      I don't recall ever seeing "wanted, one haskell programmer". So, do people actually use it for commercial software?

      Yes, they do: Tsuru Capital, Galois, Google, and a bunch of startups. A lot of investment banks are starting to use functional languages for algorithmic trading.

    59. Re:haskell for the masses? sure, but only... by shutdown+-p+now · · Score: 1

      F#, like Scala, doesn't really give you any benefit from being a bit functional.

      They both give you a baggage of features that aren't strictly FP-related, but have historically being associated with FP, such as pattern matching or currying. F# also gives you pervasive type inference (not limited to method boundary), except where method calls are concerned - though OCaml had true type inference for its OOP as well.

      Ultimately, F# is expressive enough to have FParsec. I'm not aware of anything like that for C# (you can have a parser combinator library there, of course, but not with syntax as concise and readable as in F#).

    60. Re:haskell for the masses? sure, but only... by Anonymous Coward · · Score: 0

      One of the "masses" here. Yeah, I just looked up some OCaml code on the internet, makes me want to vomit. I won't be switching to OCaml anytime soon!

    61. Re:haskell for the masses? sure, but only... by rtfa-troll · · Score: 1

      Do you know any examples of people doing this in a reasonably big system?

      --
      =~ s,(.*),<sarcasm>$1</sarcasm>,g if any_point_you_wish();
    62. Re:haskell for the masses? sure, but only... by rtfa-troll · · Score: 1

      I still think the Wikipedia explanation is a disaster. It's trying to explain what they are rather than what they do. Let me try one

      In a fully functional language without side effects, we aren't allowed to change anything inside our function. Whilst this is elegant and makes the programming easier and better, it's a bit of a downer when we actually want to use a program to do something. A monad is a work around which lets us get around this. The monad represents a state of the world. If you pass in the state of the world to a function, the function will give you a new world back where the thing you want done has been done. Now, to achieve something you simply write a program which knows how to take the world you have and give you back the world you want.

      Now this might well show my misunderstanding, so excuse that. However, if I'm right then this is seems to me a much clearer explanation than I have seen in any of the language texts.

      --
      =~ s,(.*),<sarcasm>$1</sarcasm>,g if any_point_you_wish();
    63. Re:haskell for the masses? sure, but only... by HiThere · · Score: 1

      No. Haskell has single element arrays that contain references to one item. When you "change" that item what you are doing is replacing the old reference with a new one. I believe items holding the old reference continue to hold it. But the items are just as immutable as Java strings. You can't change them, you can only replace them.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    64. Re:haskell for the masses? sure, but only... by HiThere · · Score: 1

      It depends. I'm not talking about simple read/write to console, or even redirected equivalent. Yeah, that they could all do. But many languages seem to feel that "stream" is a sufficient concept. It is, indeed, a very flexible concept that can deal with many situations. But it doesn't handle others at all well. (And read-write stream is a violation of the idea that made streams a preferable abstraction over files. Other reasons have since been added, but the restriction to readable OR writable was a big part of the original concept.)

      When I just checked yesterday OCaML, or possibly it was Haskell, had the ability to write single bytes, or built in types (short, long, etc.). But there was no indication that one could build things up in buffers and write that. The other could do that, but it required building things up in a mutable byte string, byte by byte, and then converting it to a immutable byte string. And I STILL have no idea how much disk space writing a buffer containing n bytes would require. Apparently some type information gets written at the same time (but I'm not even really certain of that). This makes it difficult to plan a random access IO file. And one comment I ran across made it seem that every time I tried to access the length of the byte string, it would traverse the entire string, counting bytes. This *can't* be correct, but that's what it looked like.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    65. Re:haskell for the masses? sure, but only... by TuringTest · · Score: 1

      Because of referential transparency, which you can't get in imperative and is number one reason to go functional.

      --
      Singularity: a belief in the "God" idea with the "demiurge" relation inverted.
    66. Re:haskell for the masses? sure, but only... by TuringTest · · Score: 1

      That's a good explanation, but it's not unique to monads. Any temporal logic shares that "world-in / new-world-out" working.

      What's specific to monads is that they can be used to different uses other than state changes - they are a building block to create any sequence of actions, not just state changes.

      --
      Singularity: a belief in the "God" idea with the "demiurge" relation inverted.
    67. Re:haskell for the masses? sure, but only... by badkarmadayaccount · · Score: 1

      C++ has pointer arithmetic. That makes a lot of things harder because some programmers want to feel "hardcore".

      --
      I know tobacco is bad for you, so I smoke weed with crack.
    68. Re:haskell for the masses? sure, but only... by ygslash · · Score: 1

      Haskell is beautiful for researchers only... Haskell groupies should start writting real-life applications

      This is just not true.

      Haskell use is growing quickly at my company. I am working on a large enterprise system for the aerospace industry, in Haskell. Others in my company have produced other kinds of applications, such as web apps, in Haskell that have been very successful. Management has been very happy about the effect of introducing Haskell-based technologies to our tool chest.

      We are hearing of more and more companies, start-up and enterprise, that are using Haskell successfully.

      the Haskell Industrial Group has never been above 3 or 4 members, while the Caml Consortium has 12 members, and is increasing every year.

      The company that runs the IHG, Well-Typed, is too busy writing real-life applications to be able to spend their time recruiting members. I'd say 12 members in the CC isn't very many either; it's certainly not representative of the success OCaml and related languages have been enjoying during the past few years.

    69. Re:haskell for the masses? sure, but only... by Anonymous Coward · · Score: 0

      Referential transparency seems to be the value equivalent of the LSP.

    70. Re:haskell for the masses? sure, but only... by rtfa-troll · · Score: 1
      Okay, so let's try again.

      In a fully functional language without side effects, we aren't allowed to change anything inside our function. Whilst this is elegant and makes the programming easier and better, it's a bit of a downer when we actually want to use a program to do something. A monad is a work around which lets us get around this. The monad represents a state of the world. If you pass in the state of the world to a function, the function will give you a new world back where the thing you want done has been done. Now, to achieve something you simply write a function which knows how to take the world you have and give you back the world you want. Even better, the monad that you get back can be passed to another function and so you can define a series of functions which will apply in order as steps to get whatever you want done.

      --
      =~ s,(.*),<sarcasm>$1</sarcasm>,g if any_point_you_wish();
    71. Re:haskell for the masses? sure, but only... by ThePhilips · · Score: 1

      If only Haskell had some decent tutorials.

      I have read a couple, and while reading the second one, I have seen something interesting and I wanted to code it and see how it runs. It was only then I realized that I have read 1.5 Haskell tutorials and I yet can't write/run even Hello World in it. Because none of them even bothered to define what the hell a Haskell program is.

      Haskell might be nice, but judging a language by type of articles about it, both Lisp and Erlang are light years ahead. They explain how to solve problems at hand - and waste much much less pages signing odes how beautiful and concise the syntax is.

      Returning to Haskell. I haven't found a single decent explanation of what the hell monad is. Most concise to date is "a monad is a monoid in the category of endofunctors". But neither that has advanced my understanding of Haskell or monads any further.

      --
      All hope abandon ye who enter here.
    72. Re:haskell for the masses? sure, but only... by ThePhilips · · Score: 1

      "My recollection of functional programming from university was that it was kind cute, seemed to be geared to solving a problem domain I never found a use for, but that ultimately I hated the syntax and structure of it. I never really "got it", or really understood what it was supposed to be useful for."

      Holy shit - you just described my experience with functional languages *exactly*. GET OUT OF MY HEAD!

      I can't believe it... I'm not alone!!

      My cure was this. The 3rd chapter in particular. After reading few chapters I have finally realized that there was, after all, a programming language invented which is much more powerful than the assembler. Not that I need it - but definitely cleared my head off the overdoze of Haskell learning material which failed even to explain how to write/compile a program in it.

      --
      All hope abandon ye who enter here.
    73. Re:haskell for the masses? sure, but only... by Anonymous Coward · · Score: 0

      Pretty good, actually. Are you witing your own monad tutorial? :-) You won't be a functional-jedi until you write you own.

      Just one detail that will help you understand what you read about this topic:

      the monad is not the value you pass around between functions, it is the piping code that handles the passing around. The values themselves are called monadic values. For example the State monad is the control code that knows how to handle objects of "world" type, but you can get other types of monads to handle types other than changing the state of the world.

    74. Re:haskell for the masses? sure, but only... by ioshhdflwuegfh · · Score: 1

      If only Haskell had some decent tutorials.

      I have read a couple, and while reading the second one, I have seen something interesting and I wanted to code it and see how it runs. It was only then I realized that I have read 1.5 Haskell tutorials and I yet can't write/run even Hello World in it. Because none of them even bothered to define what the hell a Haskell program is.

      $ ghci
      GHCi, version 6.12.1: http://www.haskell.org/ghc/ :? for help
      Loading package ghc-prim ... linking ... done.
      Loading package integer-gmp ... linking ... done.
      Loading package base ... linking ... done.
      Prelude> putStrLn "Hello world!"
      Hello world!
      Prelude> 1+1
      2
      Prelude> map (\x -> x*x) [1..10]
      [1,4,9,16,25,36,49,64,81,100]
      Prelude> foldl1 (+) [1..10]
      55
      Prelude> :t map
      map :: (a -> b) -> [a] -> [b]
      Prelude> :t 1
      1 :: (Num t) => t
      Prelude> :t [1..10]
      [1..10] :: (Num t, Enum t) => [t]
      Prelude> :t \x->x*x
      \x->x*x :: (Num a) => a -> a

      Haskell might be nice, but judging a language by type of articles about it, both Lisp and Erlang are light years ahead. They explain how to solve problems at hand - and waste much much less pages signing odes how beautiful and concise the syntax is.

      Have you tried Learn You a Haskell for Great Good! ?

      Returning to Haskell. I haven't found a single decent explanation of what the hell monad is. Most concise to date is "a monad is a monoid in the category of endofunctors". But neither that has advanced my understanding of Haskell or monads any further.

      That's very funny stuff! As for category theory, you don't have to
      know it to use monads effectively, so I hope the link will be helpful.

    75. Re:haskell for the masses? sure, but only... by ioshhdflwuegfh · · Score: 1

      I haven't found a single decent explanation of what the hell monad is. Most concise to date is "a monad is a monoid in the category of endofunctors"

      It just occured to me that this is not correct definition of monads in Haskell.
      Haskell monads are less general than monads in category theory, because Haskell is *not*
      describing an arbitrary category, but itself is only an instance of so-called
      Cartesian closed categories.

      Yeah, it hasn't cleared things up a lot, just a tiny bit up to using category lingo
      in a less powerful formalism, so if anybody bothers you again with too much category
      stuff in the context of Haskell just send him to me.

    76. Re:haskell for the masses? sure, but only... by aberg92 · · Score: 1

      A degree in mathematics certainly isn't required, a friend of mine is well known in the Haskell community, and he is terrible at math.

    77. Re:haskell for the masses? sure, but only... by angel'o'sphere · · Score: 1

      Well, Prolog is like Lisp with syntax and backtracking, so if a problem is suitable for Lisp, then it's suitable for Prolog as well.

      That reverses what is in fact true. You can create a bad prolog program, that only consists of clauses that behave like procedures, no back tracking, no unification, just "imperativ" programmed.

      However the key of prolog is that you describe the solution, not the way how you want to come to the solution. Then you give the facts to the system and ask it if it can solve / analyze the facts and find the solution(s) you have described.

      Prolog is a declarative programming language, like SQL. You don't use it to define an algorithm. The algorithm(s) are already in the runtime system.

      While in SQL the algebra in the runtime system is "the relational algebra", consisting of selection, join and projection as basic "operations", Prolog is based on logic.

      Lisp however, while it is functional, is just another imperative programming langue, used to describe algorithms.

      Prolog and Lisp are completely different beasts (albeit as stated above, Prolog can be abused to behave more or less like Pascal).

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    78. Re:haskell for the masses? sure, but only... by angel'o'sphere · · Score: 1

      If I enter "Haskell" in Monsterboard, I get zero results. You probably refer to academic work, but where in the commercial world is Haskell used?

      Not quite Haskell ;D and in fact not much ofered right now, but:
      http://functionaljobs.com/jobs/79/senior-engineer-java-ocaml-scala-datalog-at-contemplate

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    79. Re:haskell for the masses? sure, but only... by sourcerror · · Score: 1

      "Prolog is a declarative programming language, like SQL. You don't use it to define an algorithm. The algorithm(s) are already in the runtime system."

      And when it isn't there, you program it in procedural style. Prolog has web server, semantic reasoners, etc. These stuff had to be programmed procedural style. Any IO you do, you have to do it procedural style, unless you use it together with a different language to do the IO/GUI.
      Prolog never strived for the same level of declarative purity as Haskell, so in this respect it's more similar to Lisp.

    80. Re:haskell for the masses? sure, but only... by angel'o'sphere · · Score: 1

      No,

      in such situations you don't use Prolog at all, except Prolog is the only language you are fluent in.

      Calling prolog similar to lisp only shows you have no experience in either of them. As well you could say Pascal is similar to Assembler as both ... are ... hm, a record in pascal is the same as a DATADEF in assembler, or not?

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    81. Re:haskell for the masses? sure, but only... by sourcerror · · Score: 1

      Next time try some logical argument, ad hominems won't suffice.

      Also see:
      http://en.wikipedia.org/wiki/Homoiconicity

    82. Re:haskell for the masses? sure, but only... by angel'o'sphere · · Score: 1

      Why not?
      If you dont speak from personal experience, which is completely obvious from your "made up" arguments, why am I not allowed to point that out?
      You have no clue, your point is wrong ... should I not say: you have no clue?

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    83. Re:haskell for the masses? sure, but only... by sourcerror · · Score: 1

      You remind me the guy who told me this week that Glassfish sucks and nobody uses it, we need a stable proven technology like PHP/MySQL.

      http://www.swi-prolog.org/pldoc/doc/swi/library/http/http_dispatch.pl?show=src
      http://www.swi-prolog.org/pldoc/doc/swi/library/semweb/sparql_client.pl?show=src

    84. Re:haskell for the masses? sure, but only... by angel'o'sphere · · Score: 1

      Sorry,
      I don't get what the two links should show me?
      Lisp is like Prolog because you can write a web server in Prolog?
      The discussion was not about web and prolog, but about functional versus logical programming versus procedural programming versus Lisp is the same as Prolog.

      Lip is not the same as Prolog ... sorry if that confuses you.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    85. Re:haskell for the masses? sure, but only... by sourcerror · · Score: 1

      1, Prolog's main use is logical reasoners, especially the description logic (OWL/RDF/SPARQL etc.)
      2, If you do something related to semantic web, it's useful to have a web server. As ISO Prolog defines high level networking interfaces, it it's not a really hard thing to do anyway.

      But you would have known this, if you had any experience as a Prolog programmer.

      Also see homoiconicity, I won't link it here again.

    86. Re:haskell for the masses? sure, but only... by angel'o'sphere · · Score: 1

      Well,
      I assume we either had a misunderstanding or you answered to me by misclicking. Exactly what you wrote in your last post is basically what I pointed out to my parent, before you interfered and answered to me.
      My parent claimed that Prolog is just another version of Lisp. I pointed out prolog is for logical programming, or on another dimension of categorization, a descriptive, declarative programming language, like SQL.

      THEN you came and said, IIRC, Prolog is procedural as you can program a web server in it ...

      Sorry ... I dont see a connection between Lisp ... Prolog just on the basis that you can program a web server in either language.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    87. Re:haskell for the masses? sure, but only... by sourcerror · · Score: 1

      Because both are homoiconic AI languages.
      It takes about 100 lines to write a Prolog parser in Lisp, or to write a Lisp parser in Prolog. You can't do that for C-Lisp or C-Prolog combination.
      Also, it would help if you actually read my posts. They're really short, it doesn't take much effort.

      http://web.student.tuwien.ac.at/~e0225855/lisprolog/lisprolog.html
      http://treewalker.wordpress.com/p-lisp-a-lisp-interpreter-in-prolog/

    88. Re:haskell for the masses? sure, but only... by angel'o'sphere · · Score: 1

      Sorry,
      I don't get about what you are nitpicking constantly. The original parent poster claimed Prolog "is the same" as Lisp, which it clearly is not.
      That you can write a parser/interpreter for another language should be obvious. However you are right in the case of Lisp/Prolog that this is surprising easy and the "guest language" fits so nice into the host language.
      BTW: I usually read posted links otherwise I would not find gems like this ;D https://sites.google.com/site/prologsite/prolog-problems I wished that had existed when I studied CS, I guess more people would love prolog then.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    89. Re:haskell for the masses? sure, but only... by sourcerror · · Score: 1

      I never said Prolog and Lisp are the same, just they're generally suited for the same problem domain. And they both have strong metaprogramming/symbolic computation features. (And I could have mentioned Oz, which combines the two paradigm, and is also homoiconic, but that's relatively new language)

      When using pure Prolog (ISO or Edinborough) you rarely can enjoy the benefits of the logic style (i.e. just stating the problem and the computer solving it for you). When you're doing a theorem prover, you will write that procedural style, as the actual way of execution matters a great deal in performance, but the user of you theorem prover will use it declarative style. (I.e. inside procedural, outside API declarative). And that's very similar how you do it in Lisp. (See PDDL)
      People in US tend to use Lisp, people in EU use Prolog for the same type of problem, however established domains decide for a particular language and stick with it. So constraint programming went with Prolog, PDDL with LISP.

  2. Needs platform adoption first. by Kenja · · Score: 0

    Until I can write a useful, stand alone application for a popular platform, I cant really bring myself to care about OCaml or simular languages. Without adoption by a mainstream platform they will remain in the fringe, talked about by comp-sci majors and few others.

    --

    "Have you ever thought about just turning off the TV, sitting down with your kids, and hitting them?"
    1. Re:Needs platform adoption first. by Anonymous Coward · · Score: 0

      OCaml (From wikipedia):

      The native code compiler is available for many platforms, including Unix, Microsoft Windows, and Apple Mac OS X. Excellent portability is ensured through native code generation support for major architectures: IA-32, IA-64, AMD64, HP/PA; PowerPC, SPARC, Alpha, MIPS, and StrongARM.

    2. Re:Needs platform adoption first. by StormShaman · · Score: 1

      Pandoc is written in Haskell, but you can download a 3MB Windows installer for it.

    3. Re:Needs platform adoption first. by Laz10 · · Score: 3, Interesting

      This is why I think Scala will succeed.

      Scala has all the advantages that the article mentions AND you can integrate and reuse your old Java or .NET code and libraries.

      It's there. The tooling doesn't suck half bad anymore. The world just needs to find out.

      I personally think that Scala will win over the 10% best Java programmers as soon as the tooling is comparable to Javas.
      And that might happen within the next 1-2 years.

    4. Re:Needs platform adoption first. by bondsbw · · Score: 1

      F# is an OCaml variant built to run in .NET. While not 100% compatible with OCaml, many programs can be cross-compiled.

      F# includes features such as units of measure (numeric parameters) and computation expressions. It has many more, those are just the ones I like most.

      --
      All my liberal friends think I'm a conservative, all my conservative friends think I'm a liberal.
    5. Re:Needs platform adoption first. by bondsbw · · Score: 1, Interesting

      Ah, and I forgot, F# 3 will have type providers, which gives you a hook into the compiler to provide types however you please. It is mostly used to create statically-typed elements from a dynamic resource such as a cloud database.

      --
      All my liberal friends think I'm a conservative, all my conservative friends think I'm a liberal.
    6. Re:Needs platform adoption first. by Anonymous Coward · · Score: 0

      Until I can write a useful, stand alone application for a popular platform, I cant really bring myself to care about OCaml or simular languages. Without adoption by a mainstream platform they will remain in the fringe, talked about by comp-sci majors and few others.

      F# would fit that bill as it is a mainstream platform and is an ML based functional language with good tooling support. YMMV as you may or may not want to target .Net personally. However your requirement statements prove to be met.

    7. Re:Needs platform adoption first. by Anonymous Coward · · Score: 0

      Scala has all the advantages that the article mentions

      Not really. For example, Scala's local, flow-based type inference is not as powerful as the Hindley-Milner type inference found in OCaml and Haskell. And while Scala's syntax is much less cluttered with boilerplate and ceremony than is Java's, Scala's syntax is still not as clean and concise as OCaml's. In both of these instances, the weakness of Scala relative to OCaml is the result of conscious choices to allow for easy interoperation with the whole Java ecosystem -- which OCaml doesn't do. So, in the end you need to pick which features/capabilities are most important to you, because there isn't one language that is the best at everything. My choice is Scala, but the isolation of Jane Street's code and their critical need for very strong type inference and checking (especially exhaustiveness checks) means that OCaml is a better choice for them.

    8. Re:Needs platform adoption first. by Electricity+Likes+Me · · Score: 1

      The Unison file synchronizer is written in OCaml.

    9. Re:Needs platform adoption first. by Stormtrooper42 · · Score: 0

      Support? Sure.
      Adoption? Not so much.

  3. It's all about state by Alomex · · Score: 0

    From TFA: A complete commitment to immutability is a commitment to never building anything real.

    If only all other functional languages learned this....

    1. Re:It's all about state by Anonymous Coward · · Score: 0

      A complete commitment to immutability is a commitment to never building anything real.

      Erlang would suggest otherwise, although it is a logic-based language.

    2. Re:It's all about state by Laz10 · · Score: 2

      Take a look at Scala collections.

      Scala lists look and feel immutable, but under the covers they are really mutable to remain more performant.

    3. Re:It's all about state by Anonymous Coward · · Score: 0

      And it's not pure functional. That's not a bad thing, but it's the truth. That's also why it's less brain bending than Haskell when you want to do something real.

    4. Re:It's all about state by TheRaven64 · · Score: 1

      Take a look at any functional programming language implementation for the last 30 years. The same is true. Something Scala and Ruby have in common: they both claim decades old ideas are new and exciting.

      --
      I am TheRaven on Soylent News
  4. To prove its usefullness, by Anonymous Coward · · Score: 1

    A pac-man clone-game should be written in this language and it should be called, "Nom Nom Nom Chomsky"!

    1. Re:To prove its usefullness, by Anonymous Coward · · Score: 0

      Challenge accepted.

    2. Re:To prove its usefullness, by chromas · · Score: 2

      First ghost!

  5. They're not equal though... by Anonymous Coward · · Score: 5, Insightful

    The importance of concision is clear: other things being equal, shorter code is easier to read, easier to write, and easier to maintain.

    All other things are not equal though, are they? Procedural programming is easier for humans to understand: most of us do no not think in a way that maps easily to functional programming.

    1. Re:They're not equal though... by Anonymous Coward · · Score: 3, Insightful

      Or most of us didn't learn to program in a functional language, so our brains are used to thinking imperatively. Or were you born understanding code?

    2. Re:They're not equal though... by Anonymous Coward · · Score: 1

      Procedural programming is easier for humans to understand: most of us do no not think in a way that maps easily to functional programming.

      That's just an artifact of training and experience. Referential transparency and the quarantining of shared, mutable state in functional programming means that both machine and human understanding of and reasoning about functional code is actually easier than for comparable imperative code with which most programmers are more familiar.

    3. Re:They're not equal though... by m50d · · Score: 2

      All other things are not equal though, are they? Procedural programming is easier for humans to understand: most of us do no not think in a way that maps easily to functional programming.

      Quite the opposite actually, and that's the real advantage of functional programming; I don't think "do this to the first item in the list, then do it to the second, then...", I think "do this to every item in the list". Procedural was popular because it corresponded to what the computer was doing, and in the early days knowing exactly what the computer was doing was very important, but functional maps much more closely to human reasoning.

      --
      I am trolling
    4. Re:They're not equal though... by Waffle+Iron · · Score: 3, Insightful

      Or most of us didn't learn to program in a functional language, so our brains are used to thinking imperatively. Or were you born understanding code?

      Our brains think imperatively because life is imperative.

      Imperative languages dominate computing because the real world is imperative.

    5. Re:They're not equal though... by TheRaven64 · · Score: 1

      Understanding code, no, but understanding imperative programming? Absolutely. Children are given sequences of instructions to follow from a very early age. If you can understand a recipe, you can understand imperative programming. Functional programming requires a much more detailed understanding of mathematics.

      --
      I am TheRaven on Soylent News
    6. Re:They're not equal though... by Anonymous Coward · · Score: 0

      Yeah, I can see it: Pour water in kettle. While weight less than 1 kg: put potato on scale. End while. For each potato do: peel potato. Put potato in kettle. End loop. Put kettle on stove. Turn stove on. Wait for 15 minutes. Pour water into sink.

    7. Re:They're not equal though... by DragonWriter · · Score: 1

      Procedural programming is easier for humans to understand: most of us do no not think in a way that maps easily to functional programming.

      I think procedural programming is easier for humans who have spent prior time studying procedural and/or imperative programming to understand. I'm not convinced its any easier to understand starting from scratch, though.

    8. Re:They're not equal though... by Anonymous Coward · · Score: 0

      Imperative languages dominate computing because the real world is imperative.

      Wait, I thought the real world was Object-Oriented. Haven't they been saying that the past two decades? That OOP models the world? So, you're saying the world is actually based on recipes? Those silly physicists and mathematicians, trying to model the world with their fancy equations.

    9. Re:They're not equal though... by Anonymous Coward · · Score: 0

      I don't think "do this to the first item in the list, then do it to the second, then...", I think "do this to every item in the list".

      In functional progamming you don't do anything to any item in the list.

    10. Re:They're not equal though... by Waffle+Iron · · Score: 3, Insightful

      god no, why do you asset that life is imperative?

      Because each of us exists as one location in 4-dimensional spacetime. Our existence is a single thread moving uniformly forward through time, attending to one task at a time. Almost nothing in the real wold is stateless or immutable. Our brains evolved to deal with this reality.

      but apart, remember programming isn't something natural of the human, is learned.

      When I looked at the first BASIC program listing I encountered almost 40 years ago, I immediately understood what it meant. I didn't have to learn anything to relate to it. It's a list of steps to take, just like we do every day in the physical world.

      Most CS students struggle for a long time just to get a grasp on recursion, much less the various high-powered concepts from functional languages.

    11. Re:They're not equal though... by Anonymous Coward · · Score: 0

      Understanding code, no, but understanding imperative programming? Absolutely. Children are given sequences of instructions to follow from a very early age. If you can understand a recipe, you can understand imperative programming. Functional programming requires a much more detailed understanding of mathematics.

      Actually a recepie is very much like a functional program.
      Same inputs, same output. Every time. No side effects.
      Try explaining to a kid why a function accepting the same arguments can give different results in different parts of a program. This is highly non intuitive.

    12. Re:They're not equal though... by TheRaven64 · · Score: 1

      I don't think "do this to the first item in the list, then do it to the second, then...", I think "do this to every item in the list".

      Uh, both of those are imperative operations. In a functional programming language the equivalent natural language statement would be 'a list can be created by the application of this transform to this list', which is a much less human-friendly way of thinking.

      Note to Scala and Python programmers: just because your language has map operations does not make it a functional programming language. Smalltalk had map and fold operations on collections that used closures in 1976 and no one would pretend that it was a functional language...

      --
      I am TheRaven on Soylent News
    13. Re:They're not equal though... by vlm · · Score: 1

      (bad) Object oriented code is syntactic sugar on top of imperative code. Most of it is, in fact bad. Much as the ancient saying about "you can write fortran (or basic) in any language".

      --
      "Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
    14. Re:They're not equal though... by gknoy · · Score: 1

      Sure you can. You frequently do things like apply a function to all the elements in a list. You may not affect the originals, often, but you still Do Something /with/ every element. So you're technically correct but it was somewhat disingenuous.

    15. Re:They're not equal though... by TheRaven64 · · Score: 1

      Nonsense. A recipe has sequential ordering and the steps have side effects. When you're cooking a cake, you have a sequence of steps in a specific order. There are lots of side effects in any recipe - if there weren't then what would you eat at the end?

      --
      I am TheRaven on Soylent News
    16. Re:They're not equal though... by White+Flame · · Score: 1

      The human perception & understanding of the real world is more akin to fuzzy pattern matching, with exemplars, relations, and exceptions (not throw/catch, but "A is like B except for..." or adding "except when..." clarifications to well-understood general rules), with expectations of consequences related to those pattern matches. This has absolutely nothing to do with chains of imperative commands, but is more like declarative programming.

      Problem is, all this knowledge & understanding is wrapped up in a huge tangled web of vague concepts & familiarity links. A person can't sit down and communicate absolutely everything they know to make an objective decision, no matter what language is used, or else training of people would get a whole lot easier too.

    17. Re:They're not equal though... by Anonymous Coward · · Score: 0

      I am not fully convinced that "the world" is imperative. Nor that such a comparison is relevant.
      I guess, we are chasing a common goal. Write efficient/correct/maintainable programs.
      These categories, imperative/functional are however misleading. That's because a programming language is a lot more than functional or imperative. It offers a complex set of features that put together lead to very different tradeoffs, depending on the programmer, the program ... the context.

      You often see reasoning like this one: 'My friend bob coded this is scheme, it didn't go well => scheme is functional => functional bad'
      Or: "I tried haskell at school, monads are too complicated => haskell complicated => functional programming complicated"
      Except that, maybe, it didn't go well because scheme is dynamically typed, because it is interpreted (most of the time), because it follows a strict evaluation order etc ...

      There can be many different reasons why a programming language didn't fit well.
      What strikes me:
      - Every time someone is bashing functional programming, it turns out they don't know functional programming very well.
      - I have met many programmers who became functional programmers, I have never ever ever seen it happen the other way around. I have yet to meet someone, who invested 1 year to learn OCaml or Haskell, and whose conclusion was, Nahh ... Not for me.
      Once you become productive in OCaml, you are 10x more productive than in anything else. From this point, there is no turning back.

    18. Re:They're not equal though... by _|()|\| · · Score: 1

      most of us do no not think in a way that maps easily to functional programming.

      I'm kind of surprised that virtually all of the comments so far focus on concision and functional programming. To me, the overriding theme of the article is that static typing is good, and that type inference makes it less annoying.

      Sure, it's a debate older than Emacs vs. vi, but this is Slashdot. Although Perl, PHP, Python, Ruby, JavaScript, and others have swung the pendulum towards dynamic typing, I'm really sympathetic to static typing. Unfortunately, Java makes a less than compelling case without type inference. I gather that C# and Go provide it to some extent.

      Steve Maguire's Writing Solid Code makes a pretty good argument for catching as many mistakes as possible in the compiler, and making liberal use of asserts to verify preconditions. Most of my time is spent with dynamically typed languages, and I'm increasingly frustrated by bugs that could have been caught by a compiler in another language.

    19. Re:They're not equal though... by KeithIrwin · · Score: 1

      Most people didn't really think in either way before they learned to program. Most people are terrible at writing intricate and correct lists of instructions. Learning to program required learning to think imperatively: to communicate exact instructions rather than just intent.

      In some places, they've taught functional programming languages first. Students don't seem to have found it any harder to start with functional programming languages than imperative. What is hard is shifting paradigms. Programmers who have mostly written in imperative languages find it hard to switch to functional languages, but the opposite is true as well.

    20. Re:They're not equal though... by mbkennel · · Score: 1

      The world is not exactly imperative.

      However, the world, and more specifically, the physics of economically accessible computing apparatus is intensely stateful.

      You are moving electrons from here to there. Newton's most important contribution is to clearly understand the concept of state and state evolution through differential equations as governing the physics of everything.

      Clever and efficient algorithms are those which take advantage of the nature of this fact. For example, if I want to compute a singular value decomposition well, I'd look up and implement the methods in LAPACK. This will work much better than trying to assert properties of the result and hope that the smart compiler will turn a state-less description into good stateful operations on stateful hardware.

      The Communciations of the ACM is full of results where very clever humans use externally known facts about mathematics, often quite unobvious, and properties of common stateful hardware to craft efficient and effective stateful algorithms.

      The lack of state makes programming functional languages difficult, not the 'functionality'.

      Without state it is easy to write down an answer, and when the compiler works well then that's fine. But when the compiler turns out to generate something very inefficient it is even harder to write code in a state-is-very-discouraged language, because then not only do you have to model the problem in a stateless way, but you have to be smart enough to predict the algorithms and heuristics of a sophisticated compiler and guess whether it will make efficient code or not with very indirect assumptions.

      Jane Street Capital undoubtedly uses it as a "are you in the ultra-extreme tail of IQ" filter for hiring.

    21. Re:They're not equal though... by mbkennel · · Score: 1

      "Referential transparency and the quarantining of shared, mutable state in functional programming means that both machine and human understanding of and reasoning about functional code is actually easier than for comparable imperative code with which most programmers are more familiar."

      Translation:

      *) understanding invariant, state-less properties of programs is easier when they are expressed in a state-less programming language.

      *) understanding state-dependent properties of programs is easier when they are expressed in a stateful programming language.

      Both are true.

      However, the physics of existing computing hardware breaks the symmetry: it is stateful, not stateless. Memory is expressed as an array of fixed size of persistent and time-mutable bits; overwriting memory causes previously extant state to disappear into thermodynamic noise---in a literal physical sense.

    22. Re:They're not equal though... by Anonymous Coward · · Score: 0

      Procedural programming is easier for humans to understand [...]

      By what measure is it easier to understand? Are you thinking in terms of the time that it takes a person to write something that compiles and runs? Or are you thinking in terms of the time that it takes to write a program that is actually correct? My point is that

      If the programmer is the kind of person who would feel that functional languages are harder to work with, then what confidence can we have in their procedural [imperative] programming?

    23. Re:They're not equal though... by qxcv · · Score: 1

      Imperative languages dominate computing because the real world is imperative.

      I sure hope not. I was under the impression that the world was concurrent ;)

      Whilst I understand that the concepts are not mutually exclusive, imperative programming alone does not seem like a great fit for the real world.

      --
      "The most dangerous enemy of a better solution is an existing codebase that is just good enough." -- Eric S. Raymond
    24. Re:They're not equal though... by ioshhdflwuegfh · · Score: 1

      Or most of us didn't learn to program in a functional language, so our brains are used to thinking imperatively. Or were you born understanding code?

      Our brains think imperatively because life is imperative.

      Imperative languages dominate computing because the real world is imperative.

      Thus spoke Waffle Iron.

    25. Re:They're not equal though... by blue+trane · · Score: 1

      "Try explaining to a kid why a function accepting the same arguments can give different results in different parts of a program. This is highly non intuitive."

      Natural language is intuitive, and it's context-sensitive...

    26. Re:They're not equal though... by Anonymous Coward · · Score: 0

      I disagree: when you ask a question, make a request, even add an order, you are really declaring what you want done, not how you want it, you don't give specific instructions.
      I think that the real reason your "average" programmer can't understand functional languages (though I'd say that most re:ally just never try to learn), is for the same reason pascal/simula never really "hit". They are just very academic languages, but this goes beyond the concept of functional programming.
      It just so happens that companies pay for the next Cobol/Java, a language marketed at them, but not simple or elegant or good to use at all.

    27. Re:They're not equal though... by Anonymous Coward · · Score: 0

      Imperative languages dominate computing because the real world is imperative.

      I find this remark amazing. Is the "real world" imperative at what level? Machine code? Electronics? Newtonian physics? Quantum mechanics?

      Or is it really that imperative languages dominate because it much easier to write interpreters/compilers that run in the limited resources we had for the first 40 years of IT....?

    28. Re:They're not equal though... by angel'o'sphere · · Score: 1

      Smalltalk had map and fold operations on collections that used closures in 1976 and no one would pretend that it was a functional language...

      Just scroll 30 posts back. There is a guy claiming Simula and Smaltalk had "higher order functions" ...

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    29. Re:They're not equal though... by TheRaven64 · · Score: 1
      A higher order function is one that either takes a function as an argument, or returns a function. Assuming you count instances of the BlockClosure class as functions (if they don't bind to any local variables, then they are semantically equivalent to functions), Smalltalk-80 did have higher order functions. It also has higher-order messages, which are basically curried message sends. For example, you can do:

      uppercase := array map toUpper.

      And the new array will be the result of sending the #toUpper message to every element in the original array (we also support this and similar operations in the EtoileFoundation framework in Objective-C and Pragmatic Smalltalk). Smalltalk still isn't a functional language.

      --
      I am TheRaven on Soylent News
  6. Give me a call when... by Suiggy · · Score: 0

    ...the compiler toolchain and libraries for Ocaml or Haskell are more mature, have support for compiling directly to native machine code and interfacing with platform specific ABIs, and aren't tied to decrepit virtual machines such as the JVM or .NET framework.

    1. Re:Give me a call when... by tuffy · · Score: 2, Informative

      Both Ocaml and Haskell can compile directly to native machine code and aren't tied to decrepit virtual machines. In particular, Haskell's compiler is written in Haskell for optimal bootstrappy fun.

      --

      Ita erat quando hic adveni.

    2. Re:Give me a call when... by Anonymous Coward · · Score: 2, Informative

      You mean like right now? Haskell's pretty mature, and it's been able to compile to native code for years. It's pretty straight forward to talk to C (the universal ABI) with Haskell (well, as straight forward as anything is in Haskell).

      OCaml has been mature for nearly a decade, by the way. Without the success it's had, languages such as Haskell and F# wouldn't be around. It also can compile to native code, and has been able to since inception.

      PS, the .NET VM isn't really decrepit, it's much more performant than the JVM is. Sadly, mono isn't nearly as mature as the actual .NET virtual machine.

    3. Re:Give me a call when... by Unknown+Lamer · · Score: 1

      Request granted (at least for calling C). SML has an even nicer FFI and most certainly builds native executables.

      Adhering to the platform ABI makes little sense -- the "platform" ABI on e.g. UNIX is meant for C programs and is not expressive enough for other languages (keep in mind the only types in C are bytes, half-words, words, double words, ...).

      --

      HAL 7000, fewer features than the HAL 9000, but just as homicidal!
    4. Re:Give me a call when... by Anonymous Coward · · Score: 0

      But can we write SkyNet with it?

    5. Re:Give me a call when... by Nimatek · · Score: 2

      They compile to native machine code, FYI.

    6. Re:Give me a call when... by Anonymous Coward · · Score: 0

      What types does the CPU support that the platform ABI doesn't?

    7. Re:Give me a call when... by Vanders · · Score: 2

      the "platform" ABI on e.g. UNIX is meant for C programs

      Huh? No it isn't. The API may most often be expressed in C, but the ABI is language agnostic.

      keep in mind the only types in C are bytes, half-words, words, double words

      Huh? The C standard doesn't define anything in terms of "bytes", "half-words" or "double words". In fact those terms are largely meaningless in the context of C: the standard offers very few guarantees about the width and endianess of it's native types. C didn't even gain portable fixed-width types until C99.

    8. Re:Give me a call when... by Korin43 · · Score: 2

      Glascow Haskell Compiler:

      GHC compiles Haskell code either directly to native code or using LLVM as a back-end. GHC can also generate C code as an intermediate target for porting to new platforms. The interactive environment compiles Haskell to bytecode, and supports execution of mixed bytecode/compiled programs.

    9. Re:Give me a call when... by iusty · · Score: 1

      Not sure what you mean by "native code". Haskell and Ocaml can both be compiled down to native code. What exactly do you want and is lacking in these two?

    10. Re:Give me a call when... by Soluzar · · Score: 1

      That post was a statement, not a question. The subject line was inherited. You'll need to look further up the thread to find the post to which yours is admittedly a completely valid reply.

    11. Re:Give me a call when... by Unknown+Lamer · · Score: 1

      The ABI defines how data is represented at the machine level, how functions are called, etc. The C ABI is insufficient for representing languages like Common Lisp, OCaml, Haskell, ... for a number of reasons. One is that the calling convention is not powerful enough for them, another is that it is difficult to express types from these languages in terms of the C ABI. It could probably be done, but then you'd need a lot of run time support and it would be really difficult for a human to actually call things from C. Then you have things like the stack -- SML/NJ at least doesn't even use the C control stack (opting instead to keep a list of activation frames on the heap -- this makes call/cc O(1) instead of O(N) proportional to the length of the activation chain).

      As long as they provide a main entry point does it really matter?

      --

      HAL 7000, fewer features than the HAL 9000, but just as homicidal!
    12. Re:Give me a call when... by TheRaven64 · · Score: 1

      LLVM supports the GHC calling conventions now, so it's also relatively easy to call into Haskell from other languages.

      --
      I am TheRaven on Soylent News
    13. Re:Give me a call when... by Vanders · · Score: 1
      What C ABI? There is no "C" ABI: just the ABI of the platform the code is running on. The machine ABI is, by it's very nature, a very low level construct: it defines things like which CPU registers are used to pass arguments, which registers may be clobbered during a call etc. How would you propose to implement an ABI in say, Haskell, that doesn't eventually describe how the CPU registers are used, or doesn't describe how the stack is used, or any other very low level details you must cover to implement a usable ABI?

      Eventually, all languages become individual CPU instructions. That's the level that the machine ABI deals with.

      As long as they provide a main entry point does it really matter?

      Yes, very very much. Even defining enough of an ABI to even get to the executables entry point is a pretty big task!

    14. Re:Give me a call when... by iusty · · Score: 1

      Sorry, indeed realised after posting. I'm still surprised about the original parent's statement though (.net and JVM in relation to OCaml and Haskell??)

    15. Re:Give me a call when... by Anonymous Coward · · Score: 0

      calling jvm decrepit is plain stupid. the jvm is incredibly optimized and very very close to native code performance (hotspot dynamic optimization) and memory management so much better

    16. Re:Give me a call when... by Unknown+Lamer · · Score: 1

      The common ABI of all platforms in wide use today were designed only with C in mind (extended slightly, in an incompatible manner, to support C++). If even C++ cannot link directly with C, why would Ocaml et al have to? These things have their own internal binary interfaces and so I don't see what the problem is. The lack of a shared library format?

      --

      HAL 7000, fewer features than the HAL 9000, but just as homicidal!
    17. Re:Give me a call when... by Vanders · · Score: 1
      You said

      the "platform" ABI on e.g. UNIX is meant for C programs

      Now you're talking about language ABIs, which is a different matter entirely. How Haskell or OCaml or C++ handle one function calling another function within the same process is entirely up to the language designer. That isn't anything to do with the platform ABI.

      Externally however, you have to conform to the platform ABI because you have to run on the platform. The platform ABI is language agnostic. There is absolutely nothing C specific about the x86-64 ELF ABI, for example.

    18. Re:Give me a call when... by Unknown+Lamer · · Score: 1

      Ok, we were actually having an argument about different things ;)

      ELF is a separate concern — I do agree that it would be nice if binaries from other languages were encapsulated in ELF more (Guile Scheme has made motions toward this). You can already do things like dump Common Lisp binaries that include a minimal C bootstrap runtime. Getting more than a main entry point so that they can be run as programs, however, is one of those really difficult things — the C language ABI is basically mandated.

      --

      HAL 7000, fewer features than the HAL 9000, but just as homicidal!
  7. It's also easier to test... by Anonymous Coward · · Score: 0

    I'm learning Clojure recently and, honestly, the fact that it is dynamic is a gigantic drawback. There are a few projects for adding more "typing" to Clojure (it's a Lisp-1 dialect after all, so you can do *anything* ; ) but I'm seriously considering Haskell now.

    Type inference rocks. People have been killed due to inches/centimeters programming mistakes. I for the f**ck of my life cannot understand why people agree to pass things they're not supposed to to methods/functions. This kind of uber-stupidity should be caught at compile time (wait, no, even better: at editing time, because you're IDE/Emacs/whatever *should* be able to compile even an impartial AST and tell you immediately that you got your types wrong).

    And, no, I don't buy the argument that "you don't really need type in truly dynamic languages".

    Read Tony Morris's (ex-IBM JVM engineer) weblog on Haskell and understand how very little you know about programming...

    Also, the reason why, you, as a programmer, aren't making the $$$ that TFA author is making, is because you don't understand why OCaml and Haskell obviously rock big times.

    1. Re:It's also easier to test... by Oligonicella · · Score: 1

      "Also, the reason why, you, ... is because you don't understand ...."

      So, if I find a programmer making more money than TFA author, his language of choice is perforce better than OCaml and Haskell?

    2. Re:It's also easier to test... by Anonymous Coward · · Score: 0

      you, as a programmer, aren't making the $$$ that TFA author is making, is because you don't understand why OCaml and Haskell obviously rock big times.

      I'm making pretty good money, probably because I'm not wasting my time converting business processes from a list of processes into a recursive series of functions.

      Then again, I'm also not using dynamically typed procedural languages either.

    3. Re:It's also easier to test... by garyebickford · · Score: 1

      (wait, no, even better: at editing time, because you're IDE/Emacs/whatever *should* be able to compile even an impartial AST and tell you immediately that you got your types wrong).

      I would like to agree with this (long ago I even work with an 'Interactive Incremental Compiler' for FORTRAN that did the syntax checking on a line by line basis as you typed). But there is a major problem - the editor basically has to include a complete, correct copy of the language compiler/interpreter in its own logic. Since most languages these days are built based on various token-tools, perhaps it would be possible to base the checking on the input definitions to those tools (sorry I can't remember what they are called.) That would be an interesting exercise, and might make it possible to build a multilanguage editor that had that capability.

      Many editors (Vim, e.g.) have pretty good syntax coloring which is a good half-step in this direction. And the APL environment worked that way, and there have been others. I think languages that have adopted C-like syntax will be the last because C syntax is so ... baroque.

      --
      It's easier to be a result of the past, but more fun to be a cause of the future! http://www.spacefinancegroup.com/
  8. Ah Haskell by Haedrian · · Score: 1

    I remember using it during my uni times and finding it very cool.

    However it is less useful than Iteratative or OOP languages unless you NEED to use mathematics and recursion all the time, in which case its easier.

    I disagree, it'll always be a niche language which isn't for 'the masses'.

    1. Re:Ah Haskell by Lemming+Mark · · Score: 1

      Part of the problem there is in the teaching of it though; my university taught Standard ML and almost went out of their way to avoid teaching us how to write anything in it that would be useful in the real world. There are some quite practical real-world software packages written in ML / OCaml / Haskell. Plus I find functional-style constructs incredibly useful to sprinkle in Python code I write.

  9. Another functional programming fan by Animats · · Score: 1

    OK, somebody posted their resume.

    Python is similarly terse, and isn't statically typed. So this isn't about static typing. It's another functional programming fan.

    Functional programming is a good fit to a certain class of algorithms. For the 65 programmers of a trading house, it makes sense.

    Functional programming has its downsides. It tends to result in heavily nested code. It's hard to fan out results, so programs tend to be trees with a single result. Persistent state and I/O don't fit well with the functional model.

    OCaml has some features that ought to be in more languages, like Djykstra's "guards" for choosing multiple alternatives.

    1. Re:Another functional programming fan by shutdown+-p+now · · Score: 1

      The nice thing with OCaml is that it has all the good old imperative goodness - it even has while and for loops. It's just that immutability is default, and you have to sprinkle "mutable" in your data structures where you actually need it.

      One thing that I personally find awesome about OCaml, though, is not so much its FP side, but rather it's 100% structural OOP approach. This lets them do pervasive type inference, even for operations such as method calls. And yet their object model is very powerful - it has multiple inheritance, parametric types etc.

    2. Re:Another functional programming fan by dkleinsc · · Score: 5, Interesting

      My favorite code to read is OOP stuff written by coders who understand and make use of functional programming concepts. They know how to write things that are stateless when that makes sense, and use state in an appropriate manner when that makes sense.

      And yes, by all means use it when appropriate. But don't think that Lisp is always the right language for scripting your text editor (dodges blow from Emacs partisan).

      --
      I am officially gone from /. Long live http://www.soylentnews.com/
    3. Re:Another functional programming fan by Lemming+Mark · · Score: 1

      Agreed that Python is similarly terse, that's one reason I like it. But static typing does eliminate a whole class of errors if done properly. The ML family and Haskell languages do have an amazing static type system, which provides guarantees that I don't have when I program in Python. It's more powerful than the type systems of other statically typed languages whilst being not verbose.

      To a large extent, for some functions, when something got through the ML typechecker correctly I generally found most of the bugs were already gone.

      The RPython language, which is used by PyPy, does do type inference and then static compilation. I'd quite like to see how good the type checking in that is, as a programming tool.

    4. Re:Another functional programming fan by Animats · · Score: 1

      It's just that immutability is default, and you have to sprinkle "mutable" in your data structures where you actually need it.

      That's a related idea to functional programming - single-assignment languages. The idea is that all (or at least most) names are "const" - they can only be assigned a value once. This works a lot like functional programming, but there's not so much nesting, and most things have names, rather than being anonymous within some nested expression.

      Pure functional languages force programs into a tree form, with one output. A single assignment language forces programs into directed acyclic graph form, with multiple outputs, but no loops in the graph. (At least if you have some way to get multiple values returned from a function.)

      Many newer "functional" languages are really single-assignment languages. This avoids getting buried in deeply nested parentheses, as with LISP.

    5. Re:Another functional programming fan by shutdown+-p+now · · Score: 1

      Many newer "functional" languages are really single-assignment languages.

      Can you give some examples of such?

      E.g. OCaml is not single-assignment - its mutables actually are mutable. Haskell, on the other hand, is more strict than SSA.

    6. Re:Another functional programming fan by chgros · · Score: 1

      But don't think that Lisp is always the right language for scripting your text editor (dodges blow from Emacs partisan).
      Lisp is functional, but not statically typed. Loses most of the benefit IMO.

    7. Re:Another functional programming fan by White+Flame · · Score: 1

      Lisp is not a functional programming language any more than any other language with a GC is.

    8. Re:Another functional programming fan by Anonymous Coward · · Score: 0

      Totally agree. Side effects are what makes maintenance/debugging really hard, and makes it easy for layers of hacks to accumulate. OO code organizes things into logical pieces in a practical way for big projects. But pure functional code has too much recursion and nested lambdas (ugh, debugging those is not fun) and OO code without discipline becomes a spaghetti bowl of side effects.

    9. Re:Another functional programming fan by Fourier · · Score: 1

      Functional programming has its downsides. It tends to result in heavily nested code.

      Beginner functional programmers nest their code too deeply, in exactly the same way that beginner C programmers nest their code too deeply. It's not an inherent property of the language.

      It's hard to fan out results, so programs tend to be trees with a single result.

      I have no idea what "hard to fan out results" is supposed to mean, but the conclusion is trivially disproven by the existence of lots of functional programs that do more than compute a single result.

      Persistent state and I/O don't fit well with the functional model.

      Persistent state works fine, it's just managed more explicitly: you take the "previous" state as input, and you return the "next" state as an output. Practical functional programming languages have a "functional update" syntax for struct/record types that makes it easy to do this sort of thing.

      I agree regarding I/O. But OCaml is not a purely functional language, and the I/O implementation uses imperative syntax. It works just like it does in C. (Well, with the notable exception that printf actually type-checks its arguments at compile time.)

      OCaml has some features that ought to be in more languages, like Djykstra's "guards" for choosing multiple alternatives.

      The "guards" are a minor detail compared to the use of pattern matching for operating over sum types. It's the presence of a first-class sum type which makes these languages so effective at a wide variety of practical problems, because it gives the programmer a truly effective way to express the invariant that "either the data is of this type, OR the data is of that type, but not both". This is not mathematical bullshit, this is basic business-logic programming that happens all the time. In the mainstream programming languages, you don't have anything better to work with than a tagged union; that's a crappy solution.

      The article, of course, elaborates on this. You should consider reading it.

    10. Re:Another functional programming fan by ioshhdflwuegfh · · Score: 1

      My favorite code to read is OOP stuff written by coders who understand and make use of functional programming concepts. They know how to write things that are stateless when that makes sense, and use state in an appropriate manner when that makes sense.

      And yes, by all means use it when appropriate. But don't think that Lisp is always the right language for scripting your text editor (dodges blow from Emacs partisan).

      I don't think functional programming is what you think it is.

    11. Re:Another functional programming fan by ioshhdflwuegfh · · Score: 1

      [...]

      Python is similarly terse, and isn't statically typed. So this isn't about static typing. It's another functional programming fan.

      [...]

      Wow, what a convoluted reasoning (if this could be called reasoning at all). You must be programming in Python?

    12. Re:Another functional programming fan by ioshhdflwuegfh · · Score: 1

      Lisp is not a functional programming language any more than any other language with a GC is.

      It is "more" functional than C and "less" functional than Haskel, but not (only) because of GC. You can have GC also in an imperative language.

    13. Re:Another functional programming fan by ioshhdflwuegfh · · Score: 1

      Lisp is not a functional programming language any more than any other language with a GC is.

      Oh, of course. Reading other posts I totally forgot about subtleties of logical reasoning, so, yes, I agree with you.

    14. Re:Another functional programming fan by ioshhdflwuegfh · · Score: 1

      The nice thing with OCaml is that it has all the good old imperative goodness - it even has while and for loops. It's just that immutability is default, and you have to sprinkle "mutable" in your data structures where you actually need it.

      So nice! It let's you program imperatively in a purely functional language. Oh, wait..

    15. Re:Another functional programming fan by shutdown+-p+now · · Score: 1

      It's not a purely functional language.

      And yes, it's nice, because it lets you code parts that make more sense imperatively that way, and leave functional for the rest (or vice versa).

    16. Re:Another functional programming fan by ioshhdflwuegfh · · Score: 1

      It's not a purely functional language.

      And yes, it's nice, because it lets you code parts that make more sense imperatively that way, and leave functional for the rest (or vice versa).

      Ok, and what do we get then? A program with: functional parts + imperative parts = LISP.

      Same goes with the latest C++ getting lambdas. I mean great, but is that really an innovation?

      As if nothing changed from the beginning of times.

      So the real deal then are purely functional languages. And APL kinds, with their ultra-terseness.

    17. Re:Another functional programming fan by shutdown+-p+now · · Score: 1

      Ok, and what do we get then? A program with: functional parts + imperative parts = LISP.

      You forget static typing.

      Same goes with the latest C++ getting lambdas. I mean great, but is that really an innovation?

      C++ lambdas are fairly low-level - e.g. they don't extend the lifetime of variables they capture, so you either have to capture-by-copy or else do your own memory management. So they're much less transparent than lambdas normally are - and that is one of the big selling point of lambdas.

      But no, lambdas themselves aren't innovation. Nor is FP. The problem isn't in inventing new stuff - we have loads of it - the problem is getting it into mainstream coding. Sometimes this means dumbing it down.

      So the real deal then are purely functional languages. And APL kinds, with their ultra-terseness.

      I'm unconvinced that "purely anything" is ever going to be mainstream. Ultimately, different approaches are good for different things. If I'm writing a parser, give me Haskell and Parsec. If I'm writing UI, give me some imperative language, preferably with coroutines or other way to do async yields (e.g. C# 5.0 where async/await is part of the language, or Python where it can be implemented on top of generator methods). And so on. Going forward, languages which combine these techniques, letting you have "islands" of pure functional algorithms in the middle of procedural/OO code are likely to be most popular, in my assessment. That means OCaml, Scala, F# etc - not Haskell.

    18. Re:Another functional programming fan by White+Flame · · Score: 1

      But the only way it's "more" functional than C is that it has a GC, allowing functional style without worrying about cleanup. Pretty much everything else in Lisp corresponds to C's functionality, barring the additional primitive datatypes (complex numbers, etc). Even tail-call optimization is not part of the Common Lisp specification and a number of Lisps don't have it.

      Haskell is a functional language, with some pseudo-imperative trickery to be able to actually express behavior. Lisp is an imperative language, though its ease of list creation and GC makes it pretty easy to write in functional style for cons-based data. However, once you get beyond lists and have to use real object-building functions & constructors, the "functional" programming you do in Lisp is not all that different in flow from something like Java (though with far less verbosity). The core of the language is not functional at all, unlike Erlang or Haskell; all Lisp composite datatypes are mutable by default, and there are no call semantics that I'm aware of that rely on functional optimization (TCO optionally notwithstanding).

    19. Re:Another functional programming fan by ioshhdflwuegfh · · Score: 1

      Ok, and what do we get then? A program with: functional parts + imperative parts = LISP.

      You forget static typing.

      Well, there are all kinds of static typing. Already several modern implementations of LISP have it
      implemented following the standard (so no extensions) so well that in most cases you get
      the speed of C (or, if you will, have to tune the C code to get an edge), and still have all the rest of
      high-level construct and GC, and all running fast and stable.

      Types are better in OCaml, and even bigger advance was made in Haskell (and other modern FP
      languages like Coq.)

      Same goes with the latest C++ getting lambdas. I mean great, but is that really an innovation?

      C++ lambdas are fairly low-level - e.g. they don't extend the lifetime of variables they capture, so you either have to capture-by-copy or else do your own memory management. So they're much less transparent than lambdas normally are - and that is one of the big selling point of lambdas.

      But no, lambdas themselves aren't innovation. Nor is FP. The problem isn't in inventing new stuff - we have loads of it - the problem is getting it into mainstream coding. Sometimes this means dumbing it down.

      So the real deal then are purely functional languages. And APL kinds, with their ultra-terseness.

      I'm unconvinced that "purely anything" is ever going to be mainstream. Ultimately, different approaches are good for different things. If I'm writing a parser, give me Haskell and Parsec. If I'm writing UI, give me some imperative language, preferably with coroutines or other way to do async yields (e.g. C# 5.0 where async/await is part of the language, or Python where it can be implemented on top of generator methods). And so on. Going forward, languages which combine these techniques, letting you have "islands" of pure functional algorithms in the middle of procedural/OO code are likely to be most popular, in my assessment. That means OCaml, Scala, F# etc - not Haskell.

      Sure you can look for mixing of paradigms to get what you want, but mixing language
      features (languages) is currently hard to do beyond FFI stuff, which for me is sufficient so
      I haven't followed much what's going on in this area, although this direction is interesting.

      Mainstream will always lag behind the purists in terms of the theory behind their languages.
      This won't matter so long as they invent a language and write the code that does the stuff, until
      they start asking questions about the language or their language matures (cases in point: Perl
      and Python), when purists will have an upper hand.

      The major development here that we see in last, say, 10 years is that languages
      like Haskel are getting all the cool theory stuff into writing the "real-life" code for all scales
      and domains, so noone can anymore whine "it's academic", and that makes life interesting.

    20. Re:Another functional programming fan by ioshhdflwuegfh · · Score: 1

      But the only way it's "more" functional than C is that it has a GC, allowing functional style without worrying about cleanup. Pretty much everything else in Lisp corresponds to C's functionality, barring the additional primitive datatypes (complex numbers, etc).

      Yeah, like C has lists, lambdas, closures, parametric polymorphism, types as
      classes, multiple inheritance, macro transformers (I use this expression instead of
      saying just macros to avoid readers imagination running wild in thinking that macros
      in LISP and in C are somehow similar), then, meta-classes, and probably a few other
      things I forgot. (btw, I use complex numbers sometimes in my code, but let's leave
      that aside. Let's also leave aside rational numbers, bignums, bit fields (btw, I use
      those as well)).

      Wait, maybe then we should compare LISP to C++. Well, LISP has all of the above
      standardized like 20 years ago.

      Even tail-call optimization is not part of the Common Lisp specification and a number of Lisps don't have it.

      A number of available and actively maintained LISP implementations, be they commercial
      or open-source, have tail recursion implemented.

      Haskell is a functional language, with some pseudo-imperative trickery to be able to actually express behavior.

      You are obviously well informed about the type system of Haskel, category theory, monads, arrows, etc.

      Lisp is an imperative language, though its ease of list creation and GC makes it pretty easy to write in functional style for cons-based data. [...]

      LISP is a mixed-paradigm language (imperative, functional, OOP, MOP, generic prog. etc),
      so it's not functional in the modern sense of the word, and the word is: purely functional.

    21. Re:Another functional programming fan by White+Flame · · Score: 1

      Yes, the metaprogramming and runtime-compiler features are a glaring omission from my post, but other than that it still points towards not being functional. The fact that there are outlier Lisp implementations that don't perform common optimizations yet still conform to the standard simply shows that these are not Common Lisp artifacts but implementation-specific artifacts, so the language itself is not categorized by these.

      Regarding "the modern sense of the word", has functional ever meant (in a strict sense) anything other than pure functional when it comes to applying the term to a programming language itself? You can write in functional *style* in any language with a GC (primitive or "userspace"), just like you can write in OO *style* in any language with composite data types (or where it can be faked), but that doesn't mean that the language *itself* is a functional or OO language. When the language itself provides such tools as primitives or actively enforces the programming style, then the language itself bears the title. Lisp really does neither with functional programming, but as a general purpose imperative language (the other styles are substyles of imperative programming in this context due to the strict evaluation order, excluding metaprogramming where you can define your own rules) it's not hard to do functional style even without primitive support for it.

    22. Re:Another functional programming fan by ioshhdflwuegfh · · Score: 1

      Yes, the metaprogramming and runtime-compiler features are a glaring omission from my post, but other than that it still points towards not being functional. The fact that there are outlier Lisp implementations that don't perform common optimizations yet still conform to the standard simply shows that these are not Common Lisp artifacts but implementation-specific artifacts, so the language itself is not categorized by these.

      It is the difference between language specification and language implementation, just as
      different C compilers do optimizations differently. If you expect that the tail-recursion is a
      must-have feature, then use implementations that support it.

      Regarding "the modern sense of the word", has functional ever meant (in a strict sense) anything other than pure functional when it comes to applying the term to a programming language itself?

      Yes, people know for the longest time what pure functional means,
      but only recently we got purely functional languages. The classic problem was for instance how to get input-output operations purely functionally.

      You can write in functional *style* in any language with a GC (primitive or "userspace"), just like you can write in OO *style* in any language with composite data types (or where it can be faked), but that doesn't mean that the language *itself* is a functional or OO language. When the language itself provides such tools as primitives or actively enforces the programming style, then the language itself bears the title. Lisp really does neither with functional programming, but as a general purpose imperative language (the other styles are substyles of imperative programming in this context due to the strict evaluation order, excluding metaprogramming where you can define your own rules) it's not hard to do functional style even without primitive support for it.

      Sure you can use functional style here or there in any language, including assembler.

      If, however, by functional language you mean: recursion, functions as objects that can be passed around
      like any other objects, recursive data structures, well, a bunch but not all languages qualify.

      If, furthermore, by pure functional you mean: everything is a function, referential transparency,
      program is a composition of functions and only a composition of functions, well, you can't do it
      in LISP, C, C++,...long list..., but you can in Haskell. So they must have solved the problem
      of treating I/O purely functionally, and, indeed, there are these monads that melt peoples
      brains, so they pass it for devil's work, or, when try to do the same in other modern functional
      languages, they just can't do it.

      To make things even more interesting, we can't do OO in purely functional languages,
      but that's no problem since we don't need to.

    23. Re:Another functional programming fan by White+Flame · · Score: 1

      I find it a bit difficult to see your responses in terms of the question actually asked, so let's back up a bit. You had originally said that Lisp is "more" functional or "less" functional than other languages, even though it doesn't have any functional features or assumptions at all. Then you say it's "not functional in the modern sense of the word" (pure functional), implying it's functional in some other sense. I'm asking what sense that is.

      Recursion, first-class functions, recursive data structures, etc, are general purpose programming tools perfectly useful and applicable in any code, including stateful mutating imperative code.

      The things you list in your 2nd "if" paragraph are focused functional programming tools, but they obviously collide with stateful constructs if they were to coexist in the same language, tending to yield mutually exclusive language features. (See also Erlang's tenuous balancing act between the two concepts.) Common Lisp's language design doesn't wander into that territory at all. Everything in CL is mutable and there's no mechanisms for communicating functional usage or constraints into the system; they exist purely and solely as programmer discipline, not language features. A single setf inside some optimized loop somewhere in a utility function, or not realizing that something like 'sort' is allowed to trample its parameters, can screw your whole program up if you're trying to stick to functional style, forcing you do manually manage copies for different contexts. I'm not aware of any means for the compilers to detect and issue warnings about such intent breaches. And yes, I say this as somebody who develops commercial software using heavily functional style in Common Lisp: There is nothing functional about the language itself.

      I'm wondering why you consider it "more functional" than C or other non-pure-functional languages, especially given the age of Lisp and that actual pure functional languages are a recent development. It's a strictly ordered, fully mutable language, with some really cool metaprogramming, dispatch, runtime, math, and symbolic features among others. While it's very powerful, it's still completely imperative by nature with no inbuilt concessions to intrinsically support functional discipline. Functional style in Lisp is built on top of ordered imperative Lisp constructs (constructors & unconstrained in-order procedure calls, same as any other imperative language) and the GC.

    24. Re:Another functional programming fan by ioshhdflwuegfh · · Score: 1

      I find it a bit difficult to see your responses in terms of the question actually asked, so let's back up a bit. You had originally said that Lisp is "more" functional or "less" functional than other languages,

      Yes, I said that,

      [...] even though it doesn't have any functional features or assumptions at all. Then you say it's "not functional in the modern sense of the word" (pure functional), implying it's functional in some other sense. I'm asking what sense that is.

      I answered, and you got it:

      Recursion, first-class functions, recursive data structures, etc, are general purpose programming tools perfectly useful and applicable in any code, including stateful mutating imperative code.

      Exactly. Now C doesn't have first class functions, therefore it is less functional than LISP.

      The things you list in your 2nd "if" paragraph are focused functional programming tools, but they obviously collide with stateful constructs if they were to coexist in the same language, tending to yield mutually exclusive language features.

      Well, they are not just any new cool tools that you can link to or even extend your language with,
      they are defining features (of a pure functional programming language.) So they enforce
      a certain kind of programming, and exclude as you say some other kinds.

      (See also Erlang's tenuous balancing act between the two concepts.)

      (it's tenuous alright, I hope it does not fall down!)

      Common Lisp's language design doesn't wander into that territory at all. Everything in CL is mutable and there's no mechanisms for communicating functional usage or constraints into the system; they exist purely and solely as programmer discipline, not language features. [italics added]

      I agree, and in this sense functional and pure functional differ, as I write in the previous post,
      as well as you write in the last and this post. Example:

      A single setf inside some optimized loop somewhere in a utility function, or not realizing that something like 'sort' is allowed to trample its parameters, can screw your whole program up if you're trying to stick to functional style, forcing you do manually manage copies for different contexts.

      This is then the matter of discipline not to use this technique or to use that technique to
      keep coding within a certain style of programming. There's no setf in the functional world,
      so one shouldn't use it. For sort one then should always use copy constructor
      on the argument.

      I'm not aware of any means for the compilers to detect and issue warnings about such intent breaches.

      Because it is a matter of style that is not enforced by the language, hopefully that's clear.

      And yes, I say this as somebody who develops commercial software using heavily functional style in Common Lisp: There is nothing functional about the language itself.

      I'm wondering why you consider it "more functional" than C or other non-pure-functional languages, especially given the age of Lisp and that actual pure functional languages are a recent development.

      Apart from the reasons mentioned, it let us program stuff that's hard or impossible in C(++),
      for example passing lambdas around (I pass them a lot, it's invaluable). It's not just that
      functional programming restricts, it also offers certain techniques of programming, like
      continuation-passing.

      [LISP is] a strictly ordered, fully mutable language, with some really cool metaprogramming, dispatch, runtime, math, and symbolic features among others. While it's very powerful, it's still completely imperative by nature with no inbuilt concessions to intrinsically support functional discipline. Functional style in Lisp is built on top of ordered

    25. Re:Another functional programming fan by shutdown+-p+now · · Score: 1

      Well, there are all kinds of static typing. Already several modern implementations of LISP have it
        implemented following the standard (so no extensions) so well that in most cases you get
        the speed of C (or, if you will, have to tune the C code to get an edge), and still have all the rest of
        high-level construct and GC, and all running fast and stable.

      Last I checked, standard Common Lisp doesn't have static typing. It has type hints, which is not the same thing (they are not statically verified - they're only used to optimize). Or are you referring to something else?

    26. Re:Another functional programming fan by ioshhdflwuegfh · · Score: 1

      Well, there are all kinds of static typing. Already several modern implementations of LISP have it implemented following the standard (so no extensions) so well that in most cases you get the speed of C (or, if you will, have to tune the C code to get an edge), and still have all the rest of high-level construct and GC, and all running fast and stable.

      Last I checked, standard Common Lisp doesn't have static typing. It has type hints, which is not the same thing (they are not statically verified - they're only used to optimize). Or are you referring to something else?

      Yes, you are right, my bad, it's certainly not a static type system (let alone a-la Haskell or ML),
      just type annotations specified by the standard, which some compilers (like SBCL), however,
      take more seriously and do type inference and emit warnings about type mismatches during compiling.

    27. Re:Another functional programming fan by White+Flame · · Score: 1

      Yes, I think it's a difference in definitions. There's a lot of redundancy coming up, just to be utterly clear in my understanding of the disconnect.

      I obviously agree that immutable/functional programming style has great benefits, and that most languages do not enforce the style as Haskell does.

      I do NOT see the specific language features of anonymous procedures+closures (which is what Lisp "lambdas" really are), recursion, continuation passing style, and the like as having *anything at all to do with functional programming*. I've used lots of these (or built-up equivalents) as organizational tools managing *fully mutable state* in C++, Java and other non-"functional" languages, to the same organizational benefit as they yield in functional contexts. None of these require functional programming or are indicators that functional style is being used. You can use them to the exact same benefit without functional programming. They're orthogonal concepts.

      So the these particular features have nothing to do with being used functionally, nor do their presence in a language make the language any "more" or "less" functional, which was what I started this on.

      For example:

      It's not just that functional programming restricts, it also offers certain techniques of programming, like continuation-passing.

      Continuation-passing style has nothing to do with functional programming, and is available & just as useful in mutable contexts. Functional programming does not "offer" CPS; it's an independent idiom available anywhere, functional or not. Same thing with first-class functions, TCO, etc. They have no connection with functional programming, beyond the connection that the less-than operator has to functional programming (ie, they're used by it, but every style can use it so there's no real link).

      I've also used the features in question heavily in strictly immutable contexts in Lisp and Erlang, taking full advantage of MVCC and thread-safety gained from immutability. They're truly general purpose idioms and features, not bound to a particular style. They do not beckon "functional" into their use by their nature and are fully compatible with mutability, offering the *exact* same benefits to both mutable and immutable programming.

      Other language features which do beckon "functional" into their use by their nature are not compatible with mutability (all the Haskell differentiations, basically), I agree. You call these "pure functional" features, but I don't think ANY "functional" features which are not "pure functional" actually exist as such. All the ones discussed so far are exactly as useful in mutable/stateful contexts and thus don't have anything to do with being "functional" themselves (first-class procedures, continuation passing, etc).

      So I can agree to disagree. I disagree that "C doesn't have first class functions" leads to "therefore it is less functional than Lisp", as the presence or use of first class functions neither indicates nor requires functional style or its benefits. In the other direction, I think you've not considered the value of these features as part of mutable solutions where they're just as great. This fact enforces the orthogonality which breaks your "therefore".

      (gotta run, the above could probably have been edited more)

    28. Re:Another functional programming fan by ioshhdflwuegfh · · Score: 1

      Yes, I think it's a difference in definitions. There's a lot of redundancy coming up, just to be utterly clear in my understanding of the disconnect.

      From our exchange so far I think you are too stuck on mutability, while I insist on using some programming techniques whenever programming language allows them.

      I obviously agree that immutable/functional programming style has great benefits, and that most languages do not enforce the style as Haskell does.

      I do NOT see the specific language features of anonymous procedures+closures (which is what Lisp "lambdas" really are), recursion, continuation passing style, and the like as having *anything at all to do with functional programming*.

      I've no problem in seeing things this way, but the problem in defining things negatively like this is that it does not answer the question: what *does* have to do with (pure or not) functional languages?

      An answer I offered was: a purely functional program is made of composition of (no side-effects) functions, and has referential transparency. Category theory offers us an even more general definition.

      I could grant you that referential transparency and immutability are about the same thing (although I prefer referential transparency), but generally you are way too negative:

      I've used lots of these (or built-up equivalents) as organizational tools managing *fully mutable state* in C++, Java and other non-"functional" languages, to the same organizational benefit as they yield in functional contexts. None of these require functional programming or are indicators that functional style is being used. You can use them to the exact same benefit without functional programming.

      Indeed. The point is clear: LISP, C, C++, Java are all to some extent mixed-paradigm languages, and you can do whatever language allows you to do. Nobody forces programmer to think about programming he does as being done functionally, imperatively, OO,....

      But then mutability is no holly cow either. Consider your example of LISP sort which mutates data. If, for instance, one does sort just to bring data to some canonical order, then actually it does not matter whether the data is actually mutated or some new sorted data created. The two cases are indistinguishable.

      This holds for purely functional Haskell too: if you make some State that has some internal value of some type that represents state, well, you might just as well think of it as being an internal variable that is being mutated as functions dealing with that state are being called.

      They're orthogonal concepts.

      So the these particular features have nothing to do with being used functionally, nor do their presence in a language make the language any "more" or "less" functional, which was what I started this on.

      For example:

      It's not just that functional programming restricts, it also offers certain techniques of programming, like continuation-passing.

      Continuation-passing style has nothing to do with functional programming, and is available & just as useful in mutable contexts. Functional programming does not "offer" CPS; it's an independent idiom available anywhere, functional or not. Same thing with first-class functions, TCO, etc. They have no connection with functional programming, beyond the connection that the less-than operator has to functional programming (ie, they're used by it, but every style can use it so there's no real link).

      I've also used the features in question heavily in strictly immutable contexts in Lisp and Erlang, taking full advantage of MVCC and thread-safety gained from immutability. They're truly general purpose idioms and features, not bound to a particular style. They do not beckon "functional" into their use by their nature and are fully compatible with mutability, offering the *exact* same benefits to both mutable and immutable progra

    29. Re:Another functional programming fan by White+Flame · · Score: 1

      (Just to be fully clear, I view this as an interesting semantic dive, not a heated argument; I hope you consider it the same)

      From our exchange so far I think you are too stuck on mutability, while I insist on using some programming techniques whenever programming language allows them.

      First part, yes, I've been using mutability as a contrast to your point. (The core of my programming is in functional style.) Your statement was that first class functions, etc, are indicators that a language is "more functional" because of them. I say it's not a measure of how functional it is because it's a completely independent language feature, orthogonal to and irrelevant to functional vs not, fitting in just as comfortably with mutable & imperative languages/styles by example.

      Second part, I agree with you, and that's not a concept I took issue with. The above is.

      You keep deferring to the use of the features, but your suspect statements were about intrinsic properties of the features themselves, and of the languages which contain those features, not their use.

      I've no problem in seeing things this way, but the problem in defining things negatively like this is that it does not answer the question: what *does* have to do with (pure or not) functional languages?

      In this, I didn't define features negatively. I just said that they're cool language features. That's it. You seem to have invented the term "functional but not 'pure functional' language feature" but I haven't seen that actually work; the stuff brought up so far has no distinction making it "functional" at all. CPS, first-class functions, TCO, have their own definition as plain-Jane normal regular features, and can be individually added to or removed from pretty much any language regardless of functional programming support, style, or usage (from either the programmer or the language itself).

      If a language itself provides features specific to functional programming, those would be things which allow the user to communicate, and the compiler/runtime to take advantage of, the implications of referential transparency, which is likely the most important differentiator of that programming style: Arbitrary evaluation order, arbitrary short-cutting, arbitrary memoization, arbitrary parallelism, enforcement or containment of immutability, etc. Most functional features are semantic and don't manifest in syntactic language constructs, because stateful/mutating/imperative programming languages already contain the primitives needed for expressing the actual computation; functional languages don't need to do anything new there.

      An answer I offered was: a purely functional program is made of composition of (no side-effects) functions, and has referential transparency. Category theory offers us an even more general definition.

      Your original statement was not about a program, but if a language itself was "more functional" or "less functional" based on the presence of first-class functions, TCO, CPS, and the like. All the other stuff you've brought up I tend to agree with; that original point of a scalar "functional" property is what I keep pointing back to. ;-)

      Regarding "functional but not 'pure functional'" language features, I don't think they exist but solely due to the lack of examples. Since none was given, I would accept the definition as "a feature which is generally useful only to functional programming, but can freely coexist in a language that is mutable and imperative." That which meets the former but not the latter would be a "pure functional" feature, and that which meets the latter but not the former is just a general feature (or a purely imperative/mutable feature). Does this align with your line of thinking, as you brought the distinction up?

      First class functions, TCO, CPS, are exactly as useful outside of functional style as within it, so they just fall back to being general features by

    30. Re:Another functional programming fan by angel'o'sphere · · Score: 1

      You can write in functional *style* in any language with a GC (primitive or "userspace") ...

      Sorry, but this is just nonsense.
      Functional has absolutely nothing to do with GC.

      The question is: what is your first class citizen. C only has adresses and structs. Adresses can be pointers to data or to code (functions). But those functions are not the same thing as functions in functional languages (thats why I called it pointers and adresses).

      In other words in C you can "call" a function and assign the result to a variable, or you can take the address of the function and assign that address to a variable (a pointer).

      In C++ you can do more as you can define classes that define "operator ()". So you can more or less program "functional" ... with some restrictions ... in C++, but not in C.

      And you don't need a GC ...

      In functional languages your prime data type is not a struct or record or a class, but a function.

      In ordinary languages the operations your language allows operate basically only on bytes and words and use addresses/pointers to address them. A variable in C or Java is nothing more than a fancy name for a piece of memory. In a functional language it might be an alias for a function, not the address of the code of the function but a variable holding the function as if the function was a value. So you have operations that combine such functions with each other to yield new functions. In an oo language the analogon are objects that hold references/pointers to other objects.

      While in oo languages those objects are still mainly data, in a functional language those objects are "code".

      And again: that has nothing to do with GC or not GC, however I agree that a functional language without GC makes very likely not much sense.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  10. Shorter code? by value · · Score: 1

    Perl also has shorter code, and it's not easier to read.

    1. Re:Shorter code? by shmlco · · Score: 4, Insightful

      If shorter, more concise code was always better, we'd have switched to APL years ago.

      We didn't.

      --
      Any sect, cult, or religion will legislate its creed into law if it acquires the political power to do so.
    2. Re:Shorter code? by Anonymous Coward · · Score: 2, Insightful

      True, so on one end you have bloated, verbose languages like Java and Cobol and on the other end you have terse, unreadable languages like Perl and APL. So the key is finding the right balance. Ideally you want a language which is both readable and expressible. One that encourages reduction of repetitious code. One that allows you to build the abstractions to best express your intent as a programmer in a maintainable way.

      I'm of the opinion that C syntax is not best suited for this. Lisp is better, but everyone screams about the parens despite the fact that you have curly braces, parens, square braces and semicolons all over the place in the C languages.

    3. Re:Shorter code? by Anonymous Coward · · Score: 0

      If shorter, more concise code was always better, we'd have switched to APL years ago.

      We didn't.

      Obligatory quote :

      "APL is a mistake, carried through to perfection. It is the language of the future for the programming techniques of the past: it creates a new generation of coding bums. -- Edsger Dijkstra"

    4. Re:Shorter code? by garyebickford · · Score: 1

      APL FTW! :D Occasionally described as the first 'Write-only language'. But it was remarkably good at describing the pure problem efficiently, without all the syntactic fiddling most languages require. Cross-product was just 'cross-product' - no nested for loops. But the programmer had to think completely in terms of the abstract problem being solved, not piecewise refinement of all the fiddly details.

      --
      It's easier to be a result of the past, but more fun to be a cause of the future! http://www.spacefinancegroup.com/
    5. Re:Shorter code? by ioshhdflwuegfh · · Score: 1

      If shorter, more concise code was always better, we'd have switched to APL years ago.

      We didn't.

      We did.

    6. Re:Shorter code? by Toonol · · Score: 1

      I don't know why nobody considers forth anymore. Well, I understand... forth is old and creaky, and needs a serious rewrite from the core out to fit with modern techniques... but it has a lot of unique advantages, also. It has no superfluous syntax at all. It has a serious elegance to the language, kind of like lisp does.

  11. Two line summary of TFA by idontgno · · Score: 1

    I have the perfect hammer.

    Everything should be a nail.

    --
    Welcome to the Panopticon. Used to be a prison, now it's your home.
    1. Re:Two line summary of TFA by Anonymous Coward · · Score: 2, Informative

      I have the perfect hammer.

      Would that be the C family of languages used all over the place?

    2. Re:Two line summary of TFA by mbone · · Score: 1

      No, no no. It should be:

      I have the perfect hammer.

      Everything is a nail.

    3. Re:Two line summary of TFA by Duhavid · · Score: 1

      With C/C++, everything can be!

      --
      emt 377 emt 4
    4. Re:Two line summary of TFA by Anonymous Coward · · Score: 0

      Everything is a nail.

      [citation needed]

  12. Most comments are missing the point... by Anonymous Coward · · Score: 1

    TFA gives a wonderful example where the type system detects that the list function is missing one case. This is huge. This is huger can you can imagine if you don't understand what it's all about.

    The problem is that we've got "programmers" that have no formation whatsoever in computer science and that play cry-babies as soon as something looking a tiny bit like some kind of mathematical notation appears. It's really, really, very sad. The list example in TFA is spot on and is simply wonderful.

    1. Re:Most comments are missing the point... by Anonymous Coward · · Score: 0

      Well, I did understand the example that the author gave, and I can understand that it's quite amazing that the compiler catches the missing condition, but would you care to explain how exactly it's "HUGE", and its relationship to mathematics.

  13. Fix Ocaml threading.. by Anonymous Coward · · Score: 0

    so it really works and we'll look at it. We've been looking at a plan-b
    in case oracle screws up java beyond use. Right now it looks like
    Erlang.

    1. Re:Fix Ocaml threading.. by Medievalist · · Score: 1

      We've been looking at a plan-b in case oracle screws up java beyond use. Right now it looks like Erlang.

      Well, if a thousand unbelievably crappy, unstable, and resource-inefficient erlang programs hit the streets in a couple of years, I'll know it wasn't actually the Java language that was the problem after all, it was the Java programmers. Which is what I suspect, frankly.

  14. Practicality drives use by grimmjeeper · · Score: 2, Interesting

    'The importance of concision is clear: other things being equal, shorter code is easier to read, easier to write, and easier to maintain.'

    But there's the rub. Other things are not equal. Functional languages require the developer to approach problems with an entirely different mindset. There is a steep learning curve to really understand how they work. And I'm not talking about just the syntax. Functional languages are fundamentally different than procedural languages. Truly understanding how they work requires a lot more brainpower than procedural languages.

    While it's admirable to espouse what you see to be a more elegant and "better" solution, you need to be pragmatic. Getting the millions of software developers in the world to put the effort to completely change their way of thinking just isn't going to happen. The cost/benefit ratio is questionable at best, given that a lot of people could train for a long time and still have difficulty with the basic concepts of functional languages.

    Procedural languages are the norm because they're a lot simpler. Procedural languages (including "C with classes" and the like that masquerade for OOP/OOD) are useful to many more people simply because there is less to understand about how they work. It's easier for people to approach problem solution in a procedural way than it is for them to think about it functionally. And that's why functional languages, no matter how elegant or "great" they may be, will never really break into the mainstream.

    1. Re:Practicality drives use by mbone · · Score: 4, Insightful

      'The importance of concision is clear: other things being equal, shorter code is easier to read, easier to write, and easier to maintain.'

      That was the idea behind APL. You could do amazing things in one line of code. I never, however, knew anyone who used it who thought it was easier to read, easier to write or easier to maintain.

    2. Re:Practicality drives use by grimmjeeper · · Score: 1

      Agreed. In fact, just about everywhere I work has a coding standard that says you shouldn't cram a whole lot of stuff into one line of code specifically because it's hard to write correctly, not to mention difficult to read and maintain. Perhaps that's a symptom of the chosen languages but I suspect it goes deeper than that. It's been my experience that one needs to be able to strike a balance between complexity/elegance and readability. I've been known to write code so clever and elegant I have no idea what it does just months after I write it.

    3. Re:Practicality drives use by Anonymous Coward · · Score: 0

      To me, functional languages are actually more intuitive.

      My problem is that they tend to want to assume hardware doesn't exist,or should be abstracted away.

      This comes up in all sorts of ways: I/O is a pain in haskell, both it and ocaml are behind in concurrency and parallellism, and scala is wedded to the jvm (which is fine in itself, but not designed for scala) in a frankenstein arrangement.

      If the functional world wants first-class status, it has to start embracing hardware, not badmouthing it as somehow being lower class.

    4. Re:Practicality drives use by Anonymous Coward · · Score: 0

      This is all true but OCaml and other such languages don't achieve concision like that.
      They essentially allow you to remove a lot of useless boiler plate, code duplication etc.
      For instance, type inference is really nice. It lets you write code like in python where you are not writing types on every line in a rather verbose way and at the same time your expressions are more precisely typed than in Java (Ocaml has serious 'generics').

      There is also support for object data structures and pattern matching that makes for really concise algorithm code. And at the same time it's quite readable (3 or 4 rules describing the structure of input and what to do to in based on that is usually more readable than a bunch of if-then-else).

      In the end I am still doing python stuff as it's more mainstream and the lack of type inference is manageable for the stuff I do. But I have often wondered if I should not use ocaml or something like that instead...

       

    5. Re:Practicality drives use by goertzenator · · Score: 1

      It's easier for people to approach problem solution in a procedural way than it is for them to think about it functionally. And that's why functional languages, no matter how elegant or "great" they may be, will never really break into the mainstream.

      What's easiest is what you're used to. The most popular programming system on earth is Excel, which is firmly in the functional camp.

    6. Re:Practicality drives use by grimmjeeper · · Score: 1

      I don't know if you've ever tried teaching functional languages to novices with no math background. To say it's not easy is a colossal understatement. What is far easier is getting them up and running with procedural languages. The concepts are just far easier for the average layman to grasp than the concepts of functional languages. Protest all you want but that's just the way it is.

    7. Re:Practicality drives use by Anonymous Coward · · Score: 0

      In fact, just about everywhere I work has a coding standard that says you shouldn't cram a whole lot of stuff into one line of code specifically because it's hard to write correctly, not to mention difficult to read and maintain.

      The idea isn't to cram as much as you can into one line of code. That does lead to poor maintenance. Instead, the idea is for your language to encourage the type of programming where you abstract away from repetition in your code and are able to cleanly express your intent. In that case, the coed is easier to read and maintain. And if you find that the language helps you express your thinking instead of getting in your way with boiler plate and jumping through various hoops to get things done, it's also easier to write.

    8. Re:Practicality drives use by grimmjeeper · · Score: 1

      Sounds to me like you're in a situation where a language like that is a viable tool with which to implement a solution. But only because the nature of the problem lends itself to being solved with that specific tool. And when it's the right tool to use, I'm sure it's a fantastic language. But that's just it. How often are people working on problems where it's the best tool? I don't often run into situations where a functional language is the best choice. I'm glad I have it in my tool box along with so many other languages and tools for the few times I need it. But I, and so many other people in the world, just don't work on the kinds of problems where functional languages are really the best tool to apply.

    9. Re:Practicality drives use by grimmjeeper · · Score: 1

      To me, functional languages are actually more intuitive.

      I know a lot of academic types for whom that is the case. But I've met far more people who have enough trouble understanding basic procedural language concepts. I don't even want to think of trying to teach them a language that requires a solid understanding of advanced math just to be able to use.

      And that's my point. Functional languages have their place, but they will never reach the mainstream because the mainstream just doesn't have the desire (or ability in many cases) to understand the underlying theory that makes it work.

    10. Re:Practicality drives use by Anonymous Coward · · Score: 0

      I haven't seen a line of APL in my life (out to do it in a minute, Wikipedia is already waiting in another tab...), but I have seen lots of regular expressions and perl, and hell yes, it can be hard. BUT, I don't think concise code is not the same as terse code. Concision is about avoiding extraneous information (syntactic noise), while terse code is about reducing things to the minimum required for the _machine_ to understand.

    11. Re:Practicality drives use by grimmjeeper · · Score: 1

      Sure. But I can do that in a procedural language too. In fact, that's one of the points of OOD. You abstract away your layers with a proper design and your code is small and concise. Of course, it's rare to find that type of design done well but it's possible.

    12. Re:Practicality drives use by secretsquirel · · Score: 0

      After reading all the posts in this thread, I think the excel reference is what made the whole functional thing click in my head.

      Excel is sure a whole lot nicer with vba though.

    13. Re:Practicality drives use by yminsky · · Score: 1
      Agreed that concision is not an absolute value. As I wrote in the next line in the article:

      There are, of course, limits: no good is done by reducing all your function names to single characters, but brevity is nonetheless important, and OCaml does a lot to help keep the codebase small.

      And yet, I would argue that OCaml gives you concision in a way that enhances rather than detracts from readability. There's a limit to how convincing any 3000-word article can be on the topic. If you really want to understand the difference, you need to spend real time with a language like OCaml and see what it lets you do.

    14. Re:Practicality drives use by SirSlud · · Score: 1

      "If it's hard to write, it should be hard to read!"

      --
      "Old man yells at systemd"
    15. Re:Practicality drives use by KeithIrwin · · Score: 1

      As someone who's written code in a lot of different languages, I find that writing correct code in a type-inferring statically-typed functional language requires maybe a tiny bit more thinking than it does in a procedural language or a dynamically typed functional language. But it still requires less thinking than debugging non-obvious problems in procedural code. Debugging statically-typed functional language code is a little less thinky because functions are better localized and also, because debugging is a lot less common, I just don't wind up spending the same amount of total time thinking about it.

      On the other hand, writing slapdash "it probably works, I think" code in procedural languages is much less thinky than in type-inferring statically-typed functional languages, but I'm not convinced that that's a good thing.

      I've written projects in Logo, BASIC, Pascal, Prolog, C, C++, Fortran, HyperTalk, SML, Common Lisp, Java, Perl, Ocaml, Python, Actionscript, and Javascript. Out of all of these, I strongly prefer Ocaml and if I'm choosing my own language will use it for pretty well any project. I make that choice because I find that it minimizes the total time that it takes me to write, test, and debug the code to get to the point where the project has no bugs which are relevant to me and that I can feel assured that it is logically correct. This standard may not produce the same preference for all coders as not all coders are equal. However, I believe that the biggest reason that many programmers don't make this same choice is that they haven't actually learned a language like Ocaml or Haskell and developed projects in it. It's easy enough to say "Well, it's too complex", but until you actually try it out on a serious project and get some experience with it, it's tough to really evaluate a language.

    16. Re:Practicality drives use by ioshhdflwuegfh · · Score: 1

      'The importance of concision is clear: other things being equal, shorter code is easier to read, easier to write, and easier to maintain.'

      That was the idea behind APL. You could do amazing things in one line of code.[...]

      You still can. Well, maybe not you.

    17. Re:Practicality drives use by ioshhdflwuegfh · · Score: 1

      [...] I've been known to write code so clever and elegant I have no idea what it does just months after I write it.

      So one can write then unreadable code in any programming language? What that has to do with functional programming?

    18. Re:Practicality drives use by Anonymous Coward · · Score: 0

      Functional languages require the developer to approach problems with an entirely different mindset. .

      Ocaml can be written in as procedural form as you like. Some problems map better to a procedural code and other to functional. And you can do both with it. It has wonderful constructs that make writing code a lot more pleasurable in it than
      in, say, c++. Almost like python. The main weakness of the language is that it lacks industry level tooling. Oh, wait, there's f#. If you have visual studio 2010 you have it available. And it has complete integration with all the libraries in the .net environment and it has an interactive interpreter integrated to the IDE. I think people saying functional programming is too hard haven't actually spent any hours whatsoever trying to learn anything about it from decent materials. Well, bad tools and bad tutorials will leave newcomers probably frustrated. The main stepping stone is finding the best practically oriented material available and moving on from there.

    19. Re:Practicality drives use by Anonymous Coward · · Score: 0

      Yet, the people at Jane Street seem to think that OOP is harder. It's harder to figure out which foo() implementation is called when myObj.foo() is called. I think that a lot of people just don't realize that what they say is hard is simply something they have not taken the time to learn. Would you say that Spanish is a hard language if you never actually learned and used it for a long period of time?

    20. Re:Practicality drives use by Anonymous Coward · · Score: 0

      That's not the whole story. Try learning OCaml and I suspect you'll change your position a bit.

      There's not really a balance between elegance and readability. Elegance doesn't detract from readability. Complexity does, of course. But the idea is to take the complexity of the problem domain and break it down into simple parts. Simple here means small, not dumb. And concision helps makes things small.

      The other reason OCaml code is shorter is because the cost of creating and using abstractions is lower than in, say, Java. It's just easier to D-R-Y your code up in OCaml.

      Here's an incredibly basic example. The Haskell code's shorter because Java's unable to capture the common pattern of modifying every item in a collection.

      Haskell (so not golfed. OCaml is similar):

      numbersToDouble = [1,3,5,7]
      doubleEachElement theList = map (*2) theList
      main = print doubledNumbers
              where doubledNumbers = doubleEachElement numbersToDouble

      Java:

      public class SomeClass {

              public static final int[] NUMBERS_TO_DOUBLE = { 1, 3, 5, 7 };

              public static int[] doubleNumbers(int[] numbersToDouble) {
                      if (numbersToDouble==null) {
                              throw new IllegalArgumentException("numbersToDouble may not be null");
                      }
                      int[] doubledNumbers = new int[numbersToDouble.length];
                      for (int i = 0; inumbersToDouble.length; i++) {
                              doubledNumbers[i] = numbersToDouble[i] * 2;
                      }
                      return doubledNumbers;
              }

              public static void main(String[] argv) {
                      for (int item : doubleNumbers(NUMBERS_TO_DOUBLE)) {
                              System.out.println(item);
                          }
              }

      }

  15. multicore by Dr.+Tom · · Score: 0

    but can haskell effectively leverage multicore? one school of thought suggests that parallel processing is perfect for non-deterministic functions, which can be trivially implemented in Haskell. But I read that about Prolog. Not Haskell.

    1. Re:multicore by Anonymous Coward · · Score: 0

      prolog can do parallel processing trivially; these days it's actually faster in many cases to run a non-deterministic computation using a breadth-first strategy and finding the solution that way; serial attempts are of course very slow. Not that parallel programming is easy, just easier in a language that supports non-determinism

    2. Re:multicore by sourcerror · · Score: 1

      My only problem with non-determinism and Prolog was that it was really hard to find where unnecessary choicepoints are. (e.g. you get the same results multiple times) Prolog could definitely use better debugging tools.

    3. Re:multicore by Anonymous Coward · · Score: 0

      > parallel processing is perfect for non-deterministic functions

      You mean deterministic functions? Haskell is great for deterministic functions.. which are yes, easy to run in parallel.
      As you can see from the snippets, the extra code is quite minimal.
      http://www.haskell.org/ghc/docs/6.4/html/users_guide/concurrent-and-parallel.html

  16. OCaml vs Javascript by Colin+Smith · · Score: 1

    Place your bets.

     

    --
    Deleted
    1. Re:OCaml vs Javascript by KeithIrwin · · Score: 1

      I don't know about anyone else, but now that it exists and seems stable, my next web project is going to be written in Ocaml using Ocsigen and js_of_ocaml. My code is way more likely to be correct, that way.

    2. Re:OCaml vs Javascript by Anonymous Coward · · Score: 0

      There is now a compiler from OCaml to Javascript! No need to use JS anymore! You can write everything using a high level strongly typed language ...
      And even call functions from JS libraries.

      It's also very convenient to write a whole Web application in OCaml, with some parts executed on the server and others on the client.

      See http://ocsigen.org

    3. Re:OCaml vs Javascript by Anonymous Coward · · Score: 0

      There is now a compiler from OCaml to Javascript :)
      No need to use JS any more!
      You can write antything using a hight level strongly typed language. With all the features like pattern matching and variant types.

      It's also convenient to write a whole Web appli fully in OCaml, with some part executed on client side and other on server side.

      See http://ocsigen.org

    4. Re:OCaml vs Javascript by Anonymous Coward · · Score: 0

      I bet on Ocaml and Javascript: js_of_ocaml

    5. Re:OCaml vs Javascript by lmo · · Score: 1

      There is now a compiler from OCaml to Javascript! No need to use JS anymore! It is now possible to write anything using a high level language, with full static typing, pattern matching, variant types, etc! You can also write both parts of a Web site using OCaml (See http://ocsigen.org/ ).

  17. Concision? by digitig · · Score: 2

    APL is very concise and is famously easy to read and maintain. Oh, wait...

    --
    Quidnam Latine loqui modo coepi?
    1. Re:Concision? by lorinc · · Score: 1

      I also have a bunch of very concise sed scripts. Funny though, the permissions on these files are write only since the other rights were useless. Talk about maintainability...

    2. Re:Concision? by digitig · · Score: 1

      Even execute rights? Hmm, maybe...

      --
      Quidnam Latine loqui modo coepi?
    3. Re:Concision? by Anonymous Coward · · Score: 0

      The argument that code becomes more maintainable _because_ it is terse(r) is unspeakably idiotic.
      If the language is expressive, then it could be a different story, but in practice it is more "what you do with the language" rather than "what the language is".
      An idiot with a bazooka is still an idiot.

    4. Re:Concision? by dhammabum · · Score: 1

      ConcisionMan = {
            v > speeding bullet;
            F > locomotive;
            1 leap > tall building;
            ! bird;
            ! plane;
      }

      --
      I am not a robot. I am a unicorn.
    5. Re:Concision? by Tablizer · · Score: 1

      Amen! The skill of the writer is of bigger importance than the language or paradigm used. I'd rather maintain a COBOL program from the best COBOL coder than a C-minus-grade Python programmer's app that does the same thing.

  18. academic language by Anonymous Coward · · Score: 0

    Ocaml was designed by academics, for academics. I've used it for a few years, it does what it does pretty good, but unless you're into formal proofs and all that it's not worth your time. It might be useful for very specific applications but the "for the masses" is a huge joke.

    Also its concision and very static typing means that it's a mostly write-once.

    1. Re:academic language by lmo · · Score: 1

      Well ... This article precisely tells that OCaml is used by companies ... And they never want to go back to other languages ...

  19. Use F# by alphabetsoup · · Score: 2, Interesting

    F# is essentially OCaml for .Net, so you get the full access to the .Net library. Also the best thing about F#, in my opinion, is since it is a .Net language, you can mix and match it with C#. So you can use functional approach for most part of your program, yet drop to C# when you require.

    1. Re:Use F# by b8_bavard · · Score: 1

      F# is only a small kernel of what the OCaml language provides. It has no modules, no functors, no polymorphic methods, no polymorphic variants, no labels on arguments, no optional arguments, no first class modules, and the list is long of what is missing in F# from OCaml. The result is that programs written in F# are not completely type-safe, so you may benefit from the expressiveness of OCaml, but not of its safety... And F# is not portable: it only works correctly on Windows, and using it on other systems is just a pain.

  20. Good news! by toby · · Score: 2, Interesting

    We have found the problem with the software business.

    Bad news: It's you and your 100,000,000 ignorant & unwilling to learn clones.

    --
    you had me at #!
    1. Re:Good news! by Anonymous Coward · · Score: 0

      The problem isn't the entire world, the problem is you.

    2. Re:Good news! by Anonymous Coward · · Score: 0

      In Soviet Russia, the problem is the entire world.

  21. F# by Anonymous Coward · · Score: 0

    I thought F# was Ocaml for the masses...

    1. Re:F# by lmo · · Score: 1

      No. It is just OCaml by Microsoft ...

  22. Functional languages and RDBMS? by FoolishOwl · · Score: 1

    I'm no developer, and only a novice with programming and databases, so this may be a naive question.

    I remember reading about Object-relational impedance mismatch. I thought, if object oriented programming is a poor fit, conceptually, with the relational database model, perhaps functional programming would be a better fit: the code leaves the management of state to the database, which is its specialty.

    Does that make any sense?

    1. Re:Functional languages and RDBMS? by purpledinoz · · Score: 1

      The Object-Relational Impedence Mismatch has nothing to do with OOP vs Functional programming. There's an intrinsic difference between how data is represented in a database, and how it is represented in code. For example, what type would you use for a 32-bit integer in Oracle? NUMBER(10) would fit all 32-bit integers, but it can also contain numbers that are larger than a 32-bit Integer. NUMBER(9) will guarantee that anything in the database will fit into a 32-bit Integer, but will not be able to store all possible values of 32-bit integers. There are a ton of other issues, but I don't see how functional programming would solve any of them.

    2. Re:Functional languages and RDBMS? by FoolishOwl · · Score: 1

      I can see that sort of mismatch as a serious problem.

      However, the Wikipedia article I reference was definitely discussing a difference in design philosophies between OOP and RDBMS, which I understood to be essentially that objects are understood to be both function and data structure, but databases are concerned only with data structures, which complicates moving data back and forth.

    3. Re:Functional languages and RDBMS? by Anonymous Coward · · Score: 0

      Yeah, integer vs number isn't the object-relational impedence mismatch. Inheritance is a bigger issue. Logic is a bigger issue. Relations, logic, functions and maths have a simple relationship. Objects not so much.

      I don't know what I saw in them.

    4. Re:Functional languages and RDBMS? by Anonymous Coward · · Score: 0

      its not something I understood, but here is database interaction from a functional perspective (haskell)
      http://www.youtube.com/watch?v=wJIpI0Fj6Hg

    5. Re:Functional languages and RDBMS? by Anonymous Coward · · Score: 0

      A mismatch in how numbers and other basic data types are represented is not unique for OO vs. relational. It's a different distinction. The mismatch between decimal vs. binary number formats will not be a problem in OO COBOL, which supports decimal numbers.

      The OO-relational mismatch is caused by the fundamentally different ways in which data gets structured in both worlds (objects vs. tables), the scope of operations on data that are natural in both worlds, and the way related data is referred to (the lack of pointers in the relational world can be seen as a type mismatch, but the way I see it the essence of the mismatch is not that pointers are represented in a different way, the point is that they aren't used at all, they don't make sense in a relational context).

      The OO-relational mismatch doesn't occur when you don't use OO. There may be other issues, but it's not the same thing.

    6. Re:Functional languages and RDBMS? by mswhippingboy · · Score: 1

      what type would you use for a 32-bit integer in Oracle?

      Umm... INTEGER? (or maybe PLS_INTEGER if you want to be Oracle specific).

      In any case, I really don't think the mapping of datatypes has anything to do with OR impedance mismatch. It has to do with how data structures are represented in code vs how data is stored in an RDBMS (OOD vs relational tables). For instance, the concept of inheritance does not exist in an RDBMS. While tables can be constructed to implement the concept, it's generally a bit of a kludge, a kludge that ORM middleware was invented to mask from the programmer, largely unsuccessfully IMO.

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    7. Re:Functional languages and RDBMS? by phreakocious · · Score: 1

      SQL is a functional language, and is the language of choice for interacting with most large RDBMS's. Good call. :)

    8. Re:Functional languages and RDBMS? by phreakocious · · Score: 1

      Sorry, SQL is declarative, not functional.

    9. Re:Functional languages and RDBMS? by DragonWriter · · Score: 1

      what type would you use for a 32-bit integer in Oracle?

      Umm... INTEGER?

      You'd think so, but no; "INTEGER", "INT", and "SMALLINT" all are, in Oracle, converted to NUMBER(38).

      In Postgres, though, "INTEGER" will get you a 32-bit signed integer.

    10. Re:Functional languages and RDBMS? by Tablizer · · Score: 1

      Root data types are only a small part of the general "mismatch" problem. The philosophies of the two paradigms (or techniques) is just different in so many ways. For example, object models tend to be nested in a component-subcomponent way, while relational does not generally "hard nest" entities: any nesting is merely a temporary projection of information.

      Related to the starting comment, I have been kicking around the idea of a "dynamic relational" language that borrows from SQL and functional programming.

      I used to use a lot of xBase (dBASE), and for certain kinds of apps, it made code simpler and shorter (in ways somewhat related to the APL comments nearby). But, it had some architectural warts that eventually scared it away. I'd like to borrow the good but not the bad. It was on to something and I'd like to tease that out into something more modern.

    11. Re:Functional languages and RDBMS? by mswhippingboy · · Score: 1
      While it's true that INTEGER in Oracle is treated as NUMBER(38), from a programming standpoint (and DDL standpoint) INTEGER is what one would use. Incidentally, NUMBER(38) doesn't mean that Oracle is allocating storage for 38 digits. The 38 indicates the maximum precision of the value.

      Internally, Oracle stores NUMBER values as variable length values with leading (and trailing) zeros removed.

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    12. Re:Functional languages and RDBMS? by DragonWriter · · Score: 1

      While it's true that INTEGER in Oracle is treated as NUMBER(38), from a programming standpoint (and DDL standpoint) INTEGER is what one would use. Incidentally, NUMBER(38) doesn't mean that Oracle is allocating storage for 38 digits.

      No, but it does mean that it is possible for values that won't fit in a 32-bit integer to be stored in that value, which means that the database type doesn't match the intent, and you can't rely on the database enforcement of its type system to keep values compatible with the application using a 32-bit integer, so you need some additional checking somewhere to keep things safe (assuming that there are other ways than the application at issue to interact with the database.)

    13. Re:Functional languages and RDBMS? by mswhippingboy · · Score: 1

      True. I get your point. A CHECK constraint would be needed to ensure the range was within -2**31 to 2**31.

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    14. Re:Functional languages and RDBMS? by j+h+woodyatt · · Score: 1

      Ssh. You'll wake the baby.

      --
      jhw
    15. Re:Functional languages and RDBMS? by rycamor · · Score: 1

      That has long been one of my thoughts. For example, PG'OCaml looks very promising.

    16. Re:Functional languages and RDBMS? by FoolishOwl · · Score: 1

      I occasionally find myself wanting to say, like Miranda in Forbidden Planet, "I can see that was probably very clever,
      but I don't seem to understand it."

    17. Re:Functional languages and RDBMS? by Anonymous Coward · · Score: 0

      Yes it makes sense. Functional data structures aren't exactly the same as relational structures but they're closer than either are to objects.

    18. Re:Functional languages and RDBMS? by badkarmadayaccount · · Score: 1

      Packed binary decimal coding? Though you are gonna need new primitive types, or else use COBOL. Or maybe someone can make a sane, library based, programmer friendly database (with OOT C++ and Lisp APIs). Don't look at me like that - Unix has file locks and semaphores - the rest you can do with NFS.

      --
      I know tobacco is bad for you, so I smoke weed with crack.
    19. Re:Functional languages and RDBMS? by badkarmadayaccount · · Score: 1

      Do you mean prototype inheritance, or polymorphism?

      --
      I know tobacco is bad for you, so I smoke weed with crack.
    20. Re:Functional languages and RDBMS? by Tablizer · · Score: 1

      Both of those are essentially hierarchical.

    21. Re:Functional languages and RDBMS? by badkarmadayaccount · · Score: 1

      Prototype inheritance is a superset of multiple inheritance, so that's an interesting definition of hierarchical.

      --
      I know tobacco is bad for you, so I smoke weed with crack.
  23. Ahem by toby · · Score: 1

    "Procedural languages are the norm because they're a lot simpler"

    Maybe you haven't seen Scheme.

    Procedural programming isn't simpler. Its popularity and mindshare (like that of say, Windows) is accidental, and needs to end for the industry to move forward. Minsky's not the first or last to point this out.

    --
    you had me at #!
    1. Re:Ahem by grimmjeeper · · Score: 1

      I have, and my point still stands. A minimalist Lisp language may have a simpler syntax but that's not what I'm referring to when I call the languages simpler. The point is that the concepts behind building software with procedural languages are far more simple than using functional languages. The average office worker can cobble together enough thought process to write basic macros in a spreadsheet. Try getting those same people to use a functional language to do the same thing and then tell me how "simple" those functional languages are.

    2. Re:Ahem by Alomex · · Score: 1

      Maybe you haven't seen Scheme.

      Or maybe he has like all other people who took programming languages in their (CS undergrad (and (completely '(hated it))))

    3. Re:Ahem by Anonymous Coward · · Score: 0

      Accidental? I'd say it's more an artifact of how machines operate. Hardware is not functional. Computers were first programmed with hex and/or asm. Most early languages were designed to be like the hardware they ran on.

    4. Re:Ahem by grimmjeeper · · Score: 1

      We didn't cover Scheme in my CS class. We did straight LISP (Lost (In (Superfluous (Parenthesis)))).

    5. Re:Ahem by Anonymous Coward · · Score: 0

      Scheme is a simpler language, but that doesn't make it simpler to program in. I mean, Turing machines are really simple too, but have you tried writing anything complicated in them?

      And if you look at Minksy's article, you'll see that he really argues against many of the features that Scheme has. Arguably, Scheme isn't even a functional programming language because many of its data types (including lists) are mutable.

    6. Re:Ahem by jellomizer · · Score: 1

      Functional programs are great when you know what your program will do.
      In real life it is making a program that does what we think it should do, then go back and alter it to do what really needs to be done.

      When ever I work with someone fresh out of college, they argue how my code doesn't follow a strict structure a lot of the time and my defense is we will probably will need to make modifications when the specs change. And my experience in those areas the specs will change so I code them to quickly adjust for new specs. They get angry with me as it seem I don't care about good form for an area that may or maynot change.

      However when the specs do change, my code is fixed very quickly, while the newgrad is pulling overnight rewriting everything because he was coded into a hole.

      Functional programming languages makes your code too tight for real life where you write programs that you don't know what they are used for.

      --
      If something is so important that you feel the need to post it on the internet... It probably isn't that important.
    7. Re:Ahem by Anonymous Coward · · Score: 0

      You know what the average office worker finds even easier than macros? Writing spreadsheet formulas. Which is more or less purely functional.

  24. Wrong question: by toby · · Score: 1

    The real question is, can NON-FP systems effectively leverage multicore? Functional programming has extremely powerful tools to exploit new hardware. Pthreads and explicit locking do not. Have you heard of Erlang?

    --
    you had me at #!
  25. Déjà vu by toby · · Score: 1

    All the fear and uncertainty coming from those who've never tried functional languages here sound just like the mobs in 1965 insisting 'compiled languages will never catch on'.

    Smell the coffee. Learn something. The industry needs to change.

    --
    you had me at #!
  26. Any studies to back up the "small code" thesis by istartedi · · Score: 2

    Are there any studies to back up the "smaller code is better" thesis? My own experience and that of many others leads us to diasgree; but our anecdote and/or sentiment is no better than theirs.

    1. Quantify terseness.
    2. Assign terseness value to language.
    3. Quantify qualities of interest (maintainability, etc.).
    4. ???
    5. Science!

    --
    For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
    1. Re:Any studies to back up the "small code" thesis by Anonymous Coward · · Score: 0

      No studies necessary. It's simply easier to maintain a smaller code base. You can memorize it. Smaller code is better. It just is. If you've ever tried to maintain a large project, you know this.

    2. Re:Any studies to back up the "small code" thesis by gknoy · · Score: 1

      There are some interesting code metrics, such as Cohesion and http://en.wikipedia.org/wiki/Cyclomatic_complexity , which reward code which is terse and un-complex. Presumably the research backing these metrics would have already done much of what you're looking for, but I could be wrong.

    3. Re:Any studies to back up the "small code" thesis by istartedi · · Score: 2

      That's interesting but I think the question is more along the lines of whether or not

      (c1 ? f1 : f2) , (c2 ? f3 : f4)

      is more or less error prone than the if-else example they used. Imagine a hypothetical terseness maximizing language where the () may be ommitted if there are no arguments

      Actually you don't have to imagine that. The code would be more compact in point-free style which doesn't require the parens (like Forth):

      f1 f2 c1 if drop f3 f4 c2 if drop

      Not sure if that's valid Forth; but you get the idea. Once again, very compact. Understandable? Less error prone? The cyclomatic complexity is the same; but the programmer has to manage a stack in their head. I think that would be more error prone.

      --
      For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
    4. Re:Any studies to back up the "small code" thesis by Tablizer · · Score: 1

      At the C2.com wiki, I asked for similar evidence from the Functional Programming fans there, and all heck broke loose.

      I took a coded running example that generally mirrored a real-world need instead of just a "lab toy" example, and asked them to make it more than 5% compact (less code) than the original. (It was written in VB-script, used only because it existed already, not because I like VB.)

      The bottom line is they couldn't do it, but made up some really odd and "creative" reasons why it couldn't be done.

      It was a strange debate, but clear that we don't see eye-to-eye. Might as well been an Emacs vs. Vi debate. Good luck...

    5. Re:Any studies to back up the "small code" thesis by Anonymous Coward · · Score: 0

      Some languages are concise for bad reasons (perl etc.): two much weird syntax very difficult to understand.

      Ocaml is concise because it is very expressive and is using type inference. That's very different. This makes possible to write complex things in few lines of code.

    6. Re:Any studies to back up the "small code" thesis by Anonymous Coward · · Score: 0

      Alreay done. It's called Algorithmic Information Theory. Google Gregory Chaitin.

  27. shorter code is begging the question by Anonymous Coward · · Score: 0

    If you start doing anything in Haskell like using SQL databses, networking, regex matching, etc you won't be any more terse than any other language. It's just terse because the only thing you do with it is Scheme-like sample programs. People complain Perl is hard to read, too, but then they point to other languages like Python which don't have regexes or string processing built into them. If you write a string processing program in Python with a lot of regexes, it will be as hard to read as Perl. Programs that do anything non-trivial are going to be non-trivial. I haven't looked at Haskell as much as Erlang, but Erlang is the only serious programming language I've ever seen that implements the COME FROM statement in INTERCAL - flow of control magically gets transferred to a point in the program for no obvious reason. Takes a very special person to grok that kind of weird stuff.

    What will happen is what always happens - the best ideas will be co-opted by Java and C# once they prove themselves.

  28. No way by TuringTest · · Score: 1

    Are you aware that there is a State object in the Haskell library just to represent mutable objects? There's nothing in functional languages preventing you to handle state, not even in the purest ones, at least since the application of monads to programming.

    With monads you can create sequences of pseudo-imperative actions ("do blocks") that behave like a language with mutable states, but where the only possible side-effects are the ones you have previously embedded in the monad declaration; every other side effect is logically impossible.

    Basically a monad is an implementation for an imperative micro-machine that handles one particular type of state changes. What this buys you is simplifying the number of cases you have to take care of (you avoid race conditions, exceptions thrown by rare cases in the input data...)

    The cost for it is that you must know what you're doing - you have to know how to create a miniature programming language, so it's not a job for the typical java copy-paste-debug programmer.

    --
    Singularity: a belief in the "God" idea with the "demiurge" relation inverted.
    1. Re:No way by Alomex · · Score: 1

      Yup, I know about monads. A clear step forward particularly in terms of reasoning about state in an immutable language, but still a bit of a kludge.

      By the way, observe that functional language != immutable language. People often confuse the two.

    2. Re:No way by TuringTest · · Score: 1

      A clear step forward particularly in terms of reasoning about state in an immutable language

      which comes particularly handy when trying to debug a stateful complex program.

      but still a bit of a kludge

      To that I concur. Trying to handle two different states by boxing/unboxing data with monad transformers is a pain.

      observe that functional language != immutable language. People often confuse the two

      Yup, that's why I added a remark about the "purest ones", which use immutable descriptions to represent mutable objects (much like logic and math).

      --
      Singularity: a belief in the "God" idea with the "demiurge" relation inverted.
    3. Re:No way by vlm · · Score: 1

      you avoid race conditions

      If you try hard enough you can still create deadlocks and race conditions at a higher level. Arguably this is worse for the programmer, if you create/detect/fix 100 simple small deadlocks, then a major architectural design flaw of the same type is just... a bigger one, no problemo. If you can't make the little mistakes because of language design, you'll be hopeless at fixing bugs in your individual architectural design.

      Maybe its a good language once you learned the hard way why its a good language by working with others.

      --
      "Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
    4. Re:No way by dkf · · Score: 1

      If you can't make the little mistakes because of language design, you'll be hopeless at fixing bugs in your individual architectural design.

      That's ridiculous.

      The issue is that programming is done on many levels. The high level is the program's architecture, and then there are lower levels than that (the number depending on the level of abstraction, how many libraries are used, etc.) until you get down to the base level of the machine code itself. Why does this matter? Simple: the lower levels can only ever add bugs; they can't compensate for problems at the higher levels. If your program architecture is a buggy POS (and high-level deadlocks would be a good indicator that this is indeed the case; large-scale resource management is always a key aspect of architectures) then whatever you implement that architecture with is still going to result in a buggy POS.

      Of course, what's really hard is that it is difficult to work at very high levels of abstraction. Easy to make a subtle mistake, hard to detect the error, hard to correct it consistently through the other levels. Thus bugs are very easily introduced...

      Maybe its a good language once you learned the hard way why its a good language by working with others.

      The hair shirt approach to programming? Or perhaps the "get off my lawn" school?

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
  29. Data vs algorithm by Hentes · · Score: 2

    Functional languages are good for inplementing algorithms and imperative languages are good for handling data. It happens that in most real-life situations we need the latter.

    1. Re:Data vs algorithm by Anonymous Coward · · Score: 0

      That's a funny statement. Do you think algorithms don't, oh, maybe... operate on data? That the bread and butter of CS classes about algorithms aren't analysis of searching and sorting?

    2. Re:Data vs algorithm by dkf · · Score: 1

      That's a funny statement. Do you think algorithms don't, oh, maybe... operate on data?

      In the real word, most programs operate via the use of many different algorithms applied to data that's been organized into state. Moreover, the requirements for what those programs do will change, and quite rapidly. (Customers tend to not appreciate what a program can do for them until they see the work-in-progress, and then they think of more things for that program to do. That's human nature.)

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
  30. Correction: by Anonymous Coward · · Score: 0

    Oops, obviously that should have read: "content >- read content"

  31. Whiners by Anonymous Coward · · Score: 0

    Let me preface this with a disclaimer: I have no degree in computer science, mathematics, EE, or any other hard science. I started to learn to program in the "soft" languages like Javascript, Perl, PHP, etc. I am not a professional programmer.

    Having said that, I honestly don't understand why so many programmers bitch about how hard it is to program in functional languages. Functional programming is not harder than imperative programming. I have taught functional programming to many football players at a major university (with a bigger reputation for football than academics), and they learn the general principles just fine.

    The benefits of learning a (statically typed) functional language far outweigh the few weeks it takes to learn the main ideas.

  32. Real-life Experience with functional programming? by purpledinoz · · Score: 1

    I have no experience in functional programming languages, so I'm curious to hear from those who have developed real applications. How does functional programming do when having to create UIs? Or reading/writing to a database and dealing with transactions? Or creating a web-service? Or enforcing business logic?

    Functional programming seems ideal for writing algorithms, but does it have any drawbacks?

  33. Functional programming is great! by Anonymous Coward · · Score: 0

    Static typing and idiot-savant syntax, however, not.

  34. After VBA anything seems like deliverance by Coward+Anonymous · · Score: 1

    The guy started his career writing in VBA and moved to OCaml via Java. Is it any wonder he finds OCaml so great?

    1. Re:After VBA anything seems like deliverance by FrootLoops · · Score: 1

      Wow, your reading comprehension is poor. He had learned OCaml in grad school, not at work: "Why OCaml? I had learned it in grad school and fell in love with the language then." He also never says he wrote a line of VBA. Perhaps he did, though he doesn't say so. He does call himself part of the scrapped Java rewrite, for what that's worth.

  35. Other things being equal? by englishknnigits · · Score: 1

    Sooo...shorter code that is identical to longer code, except for length, is better? I don't think it is possible to change length and hold everything else constant. Even if you could hold everything else constant, separating code into sections that are actually longer than a more compact form can be more readable. Longer code can be easier or harder to read, easier or harder to maintain, and easier or harder to write. The only conclusion that can be made is: It depends.

  36. Disappointed by Anonymous Coward · · Score: 0

    What? Not a single Joe Camel joke? Shame on you, /.

    1. Re:Disappointed by niftymitch · · Score: 1

      If you got em -- smoke em.

      --
      Truth is stranger than fiction, but it is because Fiction is obliged to stick to possibilities; Truth isn't. Mark Twain.
  37. Re:Real-life Experience with functional programmin by alain_frisch · · Score: 1

    Our main application (LexiFi Apropos) is almost entirely written in OCaml. Some years ago we had kernel algorithms implemented in OCaml and some GUI + business logic in C#, and we decided to switch everything to OCaml. We are very happy about this choice.

    In my opinion, the most important language features that exist in OCaml (and Haskell, etc) and which are still missing from mainstream languages are sum types (tagged union with parameters) and pattern-matching. Honestly, I don't understand why such powerful and simple constructs are still reserved to functional languages... Probably the bad heritage of C-like languages where you can easily multiply types (structures = product types) but not add them (sum types). Addition is as basic as multiplication!

    Then I could cite various means that OCaml offers to factorize and share the code: structural objects, functors, first-class modules. These are great and really allowed us to reduce the size of our code base and increase its maintainability a lot.

    For the UI, we use CSML which is a kind of high-level FFI between OCaml and .Net. We use directly the Windows Forms API from our OCaml code as we would do from C#. On top of that, we have developed higher-level layers to facilitate GUI development. In particular, we have some libraries to generate automatically entry screens from OCaml type definitions (see http://www.lexifi.com/product/technology/automatic-generation-of-user-interfaces).

    Same for databases: we use exactly the same low-level programming model as we would do it we were programming in an imperative or OO language (OCaml is imperative and OO, btw). On top of that, we have an ORM again based on OCaml type definitions. Nothing really specific to functional programming here.

  38. Disjoint reality by FrootLoops · · Score: 1

    As a mathematician, TFA's argument appeals to me. Types made up of disjoint unions and Cartesian products, type inference (which, incidentally, mathematicians often do implicitly: eg. let f(x) = 1/x; it's implied that x is real and non-zero), pattern matching--these are all things I'm used to and even enjoy. That doesn't sound promising for widespread adoption, though. For all its power, most people hate math, and something this math-y has a serious hill to climb. That the author simply assumed his readers would have any idea what a disjoint union is (see the set theory definition for his usage) is a great example of the article's lack of realistic consideration of who "the masses" are.

    If you want a programming language to gain widespread adoption, you really only have one option: allow the programmer to think less than they have had to in the past. Migrations from C to C++ to Java to scripting languages like Python all progressively took care of more and more details for the programmer--organizing objects, hiding pointers, doing automatic garbage collection, and getting rid of static types, to name a few. Does using OCaml allow you to think less than using another modern language? Almost certainly not. Therefore, the language will not gain widespread adoption "for the masses".

    That said, some higher-end coders could probably benefit from using functional languages more often. They're certainly beautiful and powerful in the right hands (while in the wrong hands they're just confusing). Perhaps that's all the author really meant to advocate--that competent people check to see if a functional language they might otherwise ignore is a good fit for their problem.

  39. Well I am still reading... by Anonymous Coward · · Score: 0

    Well I am still reading about Haskell
          http://book.realworldhaskell.org/
    Customers need well written applications that work correctly.
    Maintenance programmers ($$$) need to be spending their considerable
    time and effort on code that can be clearly and quickly understood also
    quickly repaired should a bug slip in.

  40. wtf Re:Shorter code? by Fubari · · Score: 1
    Ok... why is longer, uglier code a win?
    An OCaml example from The Fine Article: (both of these do the same thing)

    let map f (x,y,z) = (f x, f y, f z)
    Here, map is defined as a function with two arguments: a function f and a triple (x,y,z). Note that f x is the syntax for applying the function f to x.

    Now consider what this would look like in C# 4.0. The C# code, while functionally equivalent, looks cluttered, with the real structure obscured by syntactic noise.
    Tuple<U,U,U> Map<T,U>(Func <T,U> f, Tuple<T,T,T> t)
    {
    return new Tuple<U,U,U>(f(t.item1), f(t.item2), f(t.item3));
    }

    And this isn't just to harsh on C#, the next example shows 15 lines of OCaml sized up against 50 lines Java
    (or, if you strip whitespace, 258 chars of OCaml vs. 1,124 chars in java).

    Somehow TL;DR doesn't apply to code? Maybe our species is irreparably stupid.

  41. Is the ACM link mirrored somewhere? by Anonymous Coward · · Score: 0

    I'd like to read Minsky's article, but http://queue.acm.org/detail.cfm?id=2038036 gives me HTTP status 500 errors.

    1. Re:Is the ACM link mirrored somewhere? by yminsky · · Score: 1

      Should be fixed now!

  42. From Personal Experience... by Anonymous Coward · · Score: 0

    I wrote a rule engine in C/C++, Prolog, and Haskell and found the latter to be the most flexible, transparent, resistant to errors, and satisfying, but definitely the most demanding. The C code was about 20,000 lines; the Prolog code was about 1,000 lines, and the Haskell code was under 100.
    Now here's the rub: It took me just as long to write the 100 lines of Haskell code as it did for me to write the 20,000 lines of C/C++ because I had to re-learn the predicate calculus in order to do so.

  43. Scientific Process of Testing "Goodness" by Tablizer · · Score: 1

    Prove it's better with objective metrics and real-world scenarios FIRST. Being "elegant" or "cool" or "clever" doesn't necessarily result in "better". We're just asking for the scientific process: test, measure, repeat, and document. Programming hasn't made science obsolete, has it? (I've heard some interesting arguments that it has, but that's further along the flame-war curve :-)

    1. Re:Scientific Process of Testing "Goodness" by badkarmadayaccount · · Score: 1

      Not enough people got past step one.

      --
      I know tobacco is bad for you, so I smoke weed with crack.
  44. Re:wtf Re:Shorter code? by AwesomeMcgee · · Score: 1

    This c# code is stupid. 3 elements of the same type would be in an array not a tuple and would then read fine

  45. OCaml Sucks by Anonymous Coward · · Score: 0

    http://sds.podval.org/ocaml-sucks.html

    1. Re:OCaml Sucks by lmo · · Score: 1

      But this article states: "Make no mistake: Java/C/C++/C#/Perl are much worse than OCaml! " And contains many mistakes. It has been written especially to feed trolls ... Without any convincing argument. It easy to take some very special issues and conclude that something sucks ... You can do this for everything.

  46. OCaml build and integration with other languages by Cato · · Score: 1

    Unfortunately for those who like cross-platform languages, OCaml is well behind F# in a couple of areas:

    1. Toolchain - getting a simple OCaml program to compile is horribly complex involving various separate tools such as omake, ocamlbuild, ocamlfind, etc - there is no one way to do things and it's really hard even for someone used to building open source packages in many languages (I've built KDE in the past which uses CMake but did work OK)

    2. Integration with other languages - see this tutorial for the various issues to be covered: http://www.linux-nantes.org/~fmonnier/OCaml/ocaml-wrapping-c.php - and this for the build sequence: http://stackoverflow.com/questions/2807021/compiling-c-lib-and-ocaml-exe-using-it-all-using-ocamlfind/2809086#2809086

    I think OCaml is a very impressive implementation and language, and is one of the few languages which can compile to real machine code with performance competitive with C, yet at the same time provide the productivity of a much higher level language such as Python, Ruby, etc. For heavy computation on limited hardware where the right third party libraries exist, it can really work well. But the OCaml community needs to make it easier to get started....

  47. They are already here by Moondevil · · Score: 1

    There are already quite a few projects making use of Scala, Clojure, Erlang, F#. Ocaml and Haskell tend to not be so used as the former three.

    One small thing that might disklike Microsoft bashers is that F# is developed by Microsoft and Ocaml and Haskell communities do have quite a few developers employed by Microsoft Research.

  48. why I use Haskell by j1m+5n0w · · Score: 1

    I use Haskell for personal projects and use C at work. The reasons I use Haskell when I have a choice is that a) I like the typechecker to catch my mistakes, b) the language is performant enough for what I want to do, c) I can get a lot done with not very much code, d) the language is aesthetically appealing and e) using Haskell is fun. If "d" and "e" were the only reasons, I wouldn't use Haskell. I'm lazy, and if I just want to get something done, I'll usually do it the easiest way I know how. For many problems, Haskell is the easiest way I know.

    I don't expect people who haven't used Haskell to understand this. I didn't, until I had used the language for awhile and found to my surprise (writing my first large Haskell program) that restricting file access to the IO monad not only didn't restrict me in any significant way, it actually made the design of the program cleaner than what I would have come up with had that restriction not been in place. "Clean design" may sound like an aesthetic issue, but for some reason cleanly designed programs seem to consistently work better than programs that aren't cleanly designed. (I'm not claiming that writing in Haskell is the only way to achieve clean design, just that the language seems to encourage it.)

    Some programs I've written in Haskell are the glome raytracer (available on hackage), a web-app, and an environmental simulator. I would consider these, if not "real world" programs, then at least representative of real world programs. I could have written them in other languages... but I didn't. Glome is the most complicated piece of software I've ever written by far (meaning that it does a lot, not that is internally complex), and I don't think it's a coincidence that it was written in the most powerful language I know.

    1. Re:why I use Haskell by Jurily · · Score: 1

      The problem with Haskell is that it forces you to solve a problem. You don't write for loop, because that's a solved problem, it's a function called "map". You don't write synchronization logic, because that's a solved problem, it's a function called "atomically".

      To write Haskell, you have to get off your ass and solve your own problem. (Or reimplement an existing library, but that's hard to explain to the boss.)

    2. Re:why I use Haskell by j1m+5n0w · · Score: 1

      I'm not sure exactly what you're trying to say, but it sounds like something along the lines of "We already have for loops and spinlocks and they work. Why would anyone want anything else?", so I'm just going to assume that's what you meant.

      Haskell doesn't use for loops because they don't make any sense in a pure-functional execution model. "You want to cause a side effect N times? What is this "side-effect" that you speak of? What do you mean the body of the for loop doesn't have a value?" Haskell does have a sort of for loop for monadic code called forM_, if that's what you really want. Ignoring the restrictions of the Haskell model of computation, if we take a look at the for loop construct, there are few things in its favor and a few that aren't so great. It is simple and it is possible to express a surprising variety of common patterns with the for loop, thus freeing the programmer from learning to use a larger number of special purpose constructs (like map, fold, zip, etc...) that you might use in a language like Haskell. On the downside, though, for loops are rather verbose, they tend to be lousy at abstracting away the details of iterating over data structures, and the compiler often has to make fairly conservative about how it optimizes the loop. It may be a "solved problem", but technology isn't just about running with the first solution that happens to work. Sometimes, it's worthwhile asking if we're using the best abstractions. I'm sure Alta Vista thought search was a "solved problem" before Google showed up.

      As for spinlocks, they certainly do work but they're pretty easy to misuse. Common mistakes include forgetting to grab a lock in the first place before reading or writing some shared variable and getting into deadlocks by acquiring multiple locks in an inconsistent order. You can't make either of those mistakes in STM, and it comes with an added benefit that it's possible to take two existing atomic operations and combine them into a single atomic operation without having to re-write the original two operations.

      This is assuming you use STM, but in Haskell you don't have to. If you like spinlocks, then you'll be right at home with the MVar interface. Alternatively, it is possible to parallelize pure code without using locks at all, using par, parMap, pseq, etc... The neat thing about going the pure route is that you get parallel code that is deterministic. Pure functions are guaranteed to always return the same value given the same arguments, even if the function is implemented internally as a parallel computation. It's these sorts of invariants that make Haskell programs rather easier to reason about. If you know a certain class of bug won't happen, you don't have to be always on your guard.

  49. Re:wtf Re:Shorter code? by ioshhdflwuegfh · · Score: 1

    This c# code is stupid. [...]

    Exactly!

  50. F# by Ed+Avis · · Score: 1

    I'm surprised the article talks about C# but not F#, which is an Ocaml-like strict functional language running on the .NET runtime. The F# compiler was made free software a year or so ago, I believe.

    --
    -- Ed Avis ed@membled.com
  51. Re:wtf Re:Shorter code? by AwesomeMcgee · · Score: 1

    I call gotcha reporting!

  52. Useful, but not terribly elegant by eagee · · Score: 1

    'Just saying, these are very useful tools - but lack some of the elegance that makes OOP work (misuse of multiple inheritance aside). Some of the design principles that make OOP so great just aren't as readily applicable in functional languages, so while I think they're cool - I'd just assume something more robust mature out of them over time before I adopt them full time.

  53. OCaml... by Frederic54 · · Score: 1

    I remember learning it in university in the 90s, I didn't really understand it :)

    --
    "Science will win because it works." - Stephen Hawking
  54. If and only if... by meburke · · Score: 1

    Functional languages, particularly LISP and Haskell, have one advantage that I like: I can design programs that do ONLY what I want them to do. On my last couple projects my main problem was covering all wanted program behaviors, because if I left it out the program simply died elegantly and told me it couldn't do what I asked. (These are control programs, not learning programs.)

    Of course, this has resulted in my finding a myriad of bugs shipped with manufacturer's devices. I have had to replace PROMS and drivers that were not well designed. The accumulated error count from one component to the next is truly scary! It is no wonder that control software (Utilities, SCADA, sensors, etc.) is such a good target for destructive hacking.

    --
    "The mind works quicker than you think!"