Live data from Hacker News

Why ML/OCaml are good for writing compilers (1998)

flint.cs.yale.edu

41–50 of 151 posts

Re: Why ML/OCaml are good for writing compilers (1998)

#41

Earlier quoted context omitted.

I've gone through all of those and although it's nice, it is not what I'd call beginner friendly at all. Python has books teaching you to program in Python which is a really good way to learn a programming language. Scott's tutorial using Frankenstein to explain Monads is interesting, but I need to see how to build simple programs and modules first. How does one organize a program using pure FP, or what's the best wa…

i am an expert and Scott's website is usually bananas to me. For some people his approach doesn't seem to click. A good beginner book for F# is a good idea.

Glad to hear I'm not the only one lol. I'd spend top dollar for a beginner's book focusing on creating short 1/2 page programs like guess my number, hangman, plotting graphs...etc and only mix in things like currying and monads later in the book along with C# interop.

Re: Why ML/OCaml are good for writing compilers (1998)

#42

For web developers who are looking for an industrial strength functional language instead of JS, OCaml probably has the best story here. Actually it has two OCaml->JS compilers of very high quality The first one, js_of_ocaml, could bootstrap the whole compiler several years ago(probably the first one there). The recent one, https://github.com/bloomberg/bucklescript , push the JS compilation into next level, it genera…

I'm optimistic about Reason, Facebook's new syntax "skin" on top of OCaml. I find OCaml's syntax to be quite gnarly; of the MLs, F# is probably the cleanest and most modern-feeling. Something like F# without the .NET stuff could have been amazing.

I find OCaml's syntax simple and clear. I don't get the reason for Reason, but hope it leads to more OCaml adoption.

Re: Why ML/OCaml are good for writing compilers (1998)

#43

After learning Elm I wanted to understand ML/OCaml a bit more, so I worked through some documentation from the OCaml site and walked away pleasantly surprised. After using it for a couple of weeks I am confused why ML/OCaml aren't more popular. They are safe, functional, stable, fast, and have great tooling. They seem poised to take over the functional domain. While the syntax took a little getting used to ( emphasis…

Crappy windows support for OCaml. F# is similar to OCaml, but is very difficult for beginners and those not familiar with .NET. I also don't see a lot of beginner material for OCaml.

OCaml from the Very Beginning is amazing beginner material.

Re: Why ML/OCaml are good for writing compilers (1998)

#44
post #6

The problem with this article is that it's missing an answer to why one would choose ML/OCaml over Haskell. Haskell has many more features, a more advanced type system, arguably superior syntax, and much better library support. However, I believe that OCaml/SML are often a better choice for a number of reasons. First of all, OCaml/SML are the best choice in terms of example code for compilers. They're historically th…

Haskell may indeed be one of the most advanced languages out there in terms of raw power, but it is very complex (how many monad tutorials does it seriously take to teach one of the most core pieces of the language) and how much category theory do you need to know to be moderately effective? Also, the ecosystem could use some work. An example is the main string library isn't used in favor of a different one. Using th…

> (how many monad tutorials does it seriously take to teach one of the most core pieces of the language) and how much category theory do you need to know to be moderately effective?

I believe the answer to both questions is zero. Unfortunately there is pedagogical cruft in the community that makes it appear this way. main :: IO () is comparable to public static void main(args[]) or whatever nonsense in Java.

Re: Why ML/OCaml are good for writing compilers (1998)

#45
post #2

For anyone interested and isn't aware yet Facebook is developing Reason, a layer over OCaml. I've been fiddling with it for the past couple of weeks and coming from JavaScript I personally found the experience generally enjoyable. https://facebook.github.io/reason/

Hah! Thanks for the link- I discovered this gem just now in their list of comparisons to JS syntax:

  Javascript    | Reason
  --------------+----------------------------
  const x = y;  | let x = y;
  let x = y;    | reference cells
  var x = y;    | No equivalent (thankfully)

Re: Why ML/OCaml are good for writing compilers (1998)

#46
Currently taking a compilers course that uses SML/NJ and it has been an absolute delight. The functional paradigm is a little strange to get used to at first, but after a while its strong suits make themselves known. The trivial type inferences and pattern matching capabilities make it easy to efficiently describe complicated and precise program situations.

Re: Why ML/OCaml are good for writing compilers (1998)

#47

After learning Elm I wanted to understand ML/OCaml a bit more, so I worked through some documentation from the OCaml site and walked away pleasantly surprised. After using it for a couple of weeks I am confused why ML/OCaml aren't more popular. They are safe, functional, stable, fast, and have great tooling. They seem poised to take over the functional domain. While the syntax took a little getting used to ( emphasis…

>After using it for a couple of weeks I am confused why ML/OCaml aren't more popular For me, the issue is the GIL, although that is being worked on as we speak.

What does the lack of multi core keep you from doing?

Re: Why ML/OCaml are good for writing compilers (1998)

#48
post #36
post #14

Earlier quoted context omitted.

I think MLs are kind of in limbo in regards to functional vs. imperative and OO vs. procedural programming. While they offer good OO, it's utilized very little. The functional features are used a ton, but don't dare approach the complexity of Scala, Haskell, etc., which is disappointing to a lot of more advanced functional programmers. They have reasonably good facilities for imperative programming, but these are mos…

I would actually argue the opposite: ML languages propose the sweet spot of having functional features but still being flexible. Mutability, OO and various other feature are all there just when you need them. You don't need, like in Haskell, to do incredible contortions to be able to express things naturally. Regardless which algorithm and API you want, there is a pretty good chance you can express it in OCaml natura…

So, what's your answer to the question being asked, "why ML/OCaml aren't more popular" ?

Sounds like you're in the same boat as the asker.

Re: Why ML/OCaml are good for writing compilers (1998)

#49
post #36

Earlier quoted context omitted.

I would actually argue the opposite: ML languages propose the sweet spot of having functional features but still being flexible. Mutability, OO and various other feature are all there just when you need them. You don't need, like in Haskell, to do incredible contortions to be able to express things naturally. Regardless which algorithm and API you want, there is a pretty good chance you can express it in OCaml natura…

So, what's your answer to the question being asked, "why ML/OCaml aren't more popular" ? Sounds like you're in the same boat as the asker.

I simply made my peace with the fact that popularity has little to do with merit. :)
Post reply on HN