Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming

OCaml For the Masses 338

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.'"
This discussion has been archived. No new comments can be posted.

OCaml For the Masses

Comments Filter:
  • by Laz10 ( 708792 ) on Tuesday October 04, 2011 @02:24PM (#37601996)

    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.

  • by grimmjeeper ( 2301232 ) on Tuesday October 04, 2011 @02:27PM (#37602028) Homepage

    '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.

  • by gstoddart ( 321705 ) on Tuesday October 04, 2011 @02:27PM (#37602034) Homepage

    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?

  • by dkleinsc ( 563838 ) on Tuesday October 04, 2011 @02:31PM (#37602088) Homepage

    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).

  • Use F# (Score:3, Interesting)

    by alphabetsoup ( 953829 ) on Tuesday October 04, 2011 @02:47PM (#37602298)

    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.

  • Good news! (Score:3, Interesting)

    by toby ( 759 ) on Tuesday October 04, 2011 @02:54PM (#37602400) Homepage Journal

    We have found the problem with the software business.

    Bad news: It's you and your 100,000,000 ignorant & unwilling to learn clones.

  • by bondsbw ( 888959 ) on Tuesday October 04, 2011 @02:55PM (#37602426)

    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.

  • by Anonymous Coward on Tuesday October 04, 2011 @03:52PM (#37603296)

    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!

"Protozoa are small, and bacteria are small, but viruses are smaller than the both put together."

Working...