News for hackers. Stuff that matters.
Re:OCaml Compiler Hacking: how to add a primitive by adultSwim on Thursday August 06, 2015 @03:13PM (#10018682)
I highly recommend checking it out. The great thing is that it's not the fancy features that (pushing the boundaries) that make it a good language. The core of ML is the real gold. I content that it would be a good choice as a default programming language for most programmers.

If you are coming from Python, ML is going to seem pretty weird. The code doesn't look too different but the compiler will be yelling at you a lot. Press on. (As a big fan of Python,) my feeling is that with Python it's easy to start programs and with OCaml (ML) it's easy to finish them.

If you are learning ML, in the beginning try to avoid using fancy features and really avoid non-functional features (i.e. mutable variables). These have a place but most of the time aren't needed. Using them gets in the way of learning this new great style.

I've heard good things about Real World OCaml (haven't read it myself - came out after I'd learned the language).

Re:OCaml Compiler Hacking: how to add a primitive by noblethrasher on Thursday August 06, 2015 @04:18PM (#10019139)
> I content that it would be a good choice as a default programming language for most programmers.

Strongly agree. I now write all of my everyday “glue code” in F#, and use C# for the low-level algorithmic/library stuff. This is directly opposed to the received wisdom, but I find that it works far better (although I think in ML no matter what language I’m using).

My theory as to why this works is that designing and writing robust “line-of-business apps” is really tantamount to designing and implementing a protocol, which, in turn, requires writing something like a parser or recognizer, and it just so happens that ML is really good for writing parsers and recognizers.

> my feeling is that with Python it's easy to start programs and with OCaml (ML) it's easy to finish them.

I’m stealing this.

Re:OCaml Compiler Hacking: how to add a primitive by gnuvince on Thursday August 06, 2015 @11:26PM (#10020813)
> The core of ML is the real gold.

I think that's the thing that keeps me interested in OCaml and is making me interested in F#: the core ML language is not very complex, and it can carry you a long way before you start requiring advanced features. I wrote a few compilers in OCaml using only the core language and very simple modules (basically just signature + struct, no functors) and the end result was very easy to read and modify. I think very few languages can make a similar claim: either the language doesn't get you all the way and you need external help (e.g. C and its pre-processor) or overshoots into too much complexity (e.g. C++).

ML is not a language for all tasks (I am learning Rust for those times when OCaml is not appropriate), but I think that ML languages could be used beneficially in many more applications today.

Re:OCaml Compiler Hacking: how to add a primitive by adultSwim on Thursday August 06, 2015 @03:15PM (#10018690)
One warning. Some functional programming materials (books, tutorials, etc) can be way too theoretical. However this has changed a lot in recent years.

The language itself isn't rocket science. If whatever you're reading isn't a good fit, try to find something else.

Re:OCaml Compiler Hacking: how to add a primitive by vegabook on Thursday August 06, 2015 @03:22PM (#10018736)
Yes it seems to attract a high-end CS crowd - there's lots of graduate-level CS assumption going on in some of the tutorials. But one of the things I really appreciate is the REPL ("toplevel") which let's you hack around and mess with examples in an interactive way. So good for a compiled language.
Re:OCaml Compiler Hacking: how to add a primitive by klibertp on Thursday August 06, 2015 @04:33PM (#10019240)
Much better in this regard than Haskell, though. Being impure and eager makes the most die-hard academics go for Haskell instead.
Re:OCaml Compiler Hacking: how to add a primitive by ufo on Thursday August 06, 2015 @09:13PM (#10020446)
Ocaml stuff seems to be a bit more down to earth in my experience. As long as you stay away from GADTs :)
Re:OCaml Compiler Hacking: how to add a primitive by rdc12 on Thursday August 06, 2015 @09:28PM (#10020481)
I have had a quick skim (10 - 15 minute reads at a random points, until I have time to read it properly) of Real World Ocaml.

So far it looks great, and is very pragmatic and also covers useful tools for working in Ocaml (imho that should be in every modern specific programming language book, but it probably will date faster the rest of the book).

Re:OCaml Compiler Hacking: how to add a primitive by ignoramous on Friday August 07, 2015 @01:08AM (#10021005)