Live data from Hacker News

Why OCaml, Why Now?

spyder.wordpress.com

31–40 of 106 posts

Re: Why OCaml, Why Now?

#31

If ocaml is a language waiting for a killer app, this might be it: http://www.openmirage.org/ There was a presentation at the FP eXchange in London last Friday about mirage and many a mind was blown!

Haskell also has the analogous HaLVM: https://github.com/GaloisInc/HaLVM

Re: Why OCaml, Why Now?

#32
OCaml is Object Caml right? What about SML? I always loved SML, but it never got any traction at all. The O in Ocaml always turned me off, they cluttered up the syntax with all the object notation.

Does anyone have any insight into why OCaml rose to (relative) prominence and not SML?

Re: Why OCaml, Why Now?

#33
post #24
post #18

Earlier quoted context omitted.

Well, that explains a lot! I'm embarrassed I never got past that.

Don't feel too bad about it. The official OCaml tutorial is also confused: http://ocaml.org/learn/tutorials/structure_of_ocaml_programs... (someone really should go through these tutorials and fix the various misleading parts) Basically, the rule is to use "let () = ..." for your main block / top-level code and don't use ";;" ever.

For reference, here is the tutorial's example reformatted in a more reasonable way:

    open Random
    open Graphics

    let rec iterate r x_init i =
        if i = 1 then x_init
        else
            let x = iterate r x_init (i - 1) in
            r *. x *. (1.0 -. x)

    let main () =
        self_init ();
        open_graph " 640x480";

        for x = 0 to 639 do
            let r = 4.0 *. (float_of_int x) /. 640.0 in
            for i = 0 to 39 do
                let x_init = Random.float 1.0 in
                let x_final = iterate r x_init 500 in
                let y = int_of_float (x_final *. 480.) in
                Graphics.plot x y
            done
        done;

        ignore (read_line ())

    let () = main ()

Re: Why OCaml, Why Now?

#34

OCaml is Object Caml right? What about SML? I always loved SML, but it never got any traction at all. The O in Ocaml always turned me off, they cluttered up the syntax with all the object notation. Does anyone have any insight into why OCaml rose to (relative) prominence and not SML?

Ocaml was always the more pragmatic language and for a long time the implementation was significantly faster than anything SML offered. MLton came along very late in the game and offers excellent performance, but doesn't support separate compilation.

Edit: A more lengthy comparison: http://adam.chlipala.net/mlcomp/

Re: Why OCaml, Why Now?

#35
post #24
post #18

Earlier quoted context omitted.

Well, that explains a lot! I'm embarrassed I never got past that.

Don't feel too bad about it. The official OCaml tutorial is also confused: http://ocaml.org/learn/tutorials/structure_of_ocaml_programs... (someone really should go through these tutorials and fix the various misleading parts) Basically, the rule is to use "let () = ..." for your main block / top-level code and don't use ";;" ever.

Pull requests welcome:

https://github.com/ocaml/ocaml.org/tree/master/site/learn/tu...

Re: Why OCaml, Why Now?

#36

Earlier quoted context omitted.

It sounds like you have a very language-centric view of the world. In practice, deployment is everything. (Why do people write code in Objective C? Because iPhone.) Having a solid implementation for your target platform is very good reason to pick a language.

> It sounds like you have a very language-centric view of the world. > Having a solid implementation for your target platform is very good reason to pick a language. I'm not sure where you got that out of my comment; it was exactly the opposite. My point was that neither OCaml nor Haskell have particularly strong implementations in this area (to my knowledge). Last time I checked, the ability to write Javascript usin…

> Last time I checked, the ability to write Javascript using both languages was of experimental and/or novelty use only (hence the "cupholders").

Facebook uses an OCaml js_of_ocaml-based frontend for a large chunk of their production code editing. Not a great video, but here's the CUFP 2013 talk on the topic: http://www.youtube.com/watch?v=gKWNjFagR9k

Re: Why OCaml, Why Now?

#37
post #27

Look, I love OCaml and it's my favorite language syntax-wise, but the real big elephant in the room is not its JS-backend maturity. Rather it doesn't have kernel thread support...all threads are user-level just like Python due to a global lock for garbage collection. This means threads do not run concurrently across multiple cores. This is UNACCEPTABLE in 2014 - roughly 8 years since processors went multi-core. Intel…

Apparently multicore ocaml is worked on again: https://github.com/ocamllabs/compiler-hacking/wiki/Multicore... https://github.com/ocamllabs/compiler-hacking/wiki/Multicore...

That being said you can still use multiple cores by using multiple processes, and that doesn't necesarelly imply MPI. OCamlNet (and probably some other libraries) provide a way to communicate between multiple OCaml processes.

Re: Why OCaml, Why Now?

#38
post #27

Look, I love OCaml and it's my favorite language syntax-wise, but the real big elephant in the room is not its JS-backend maturity. Rather it doesn't have kernel thread support...all threads are user-level just like Python due to a global lock for garbage collection. This means threads do not run concurrently across multiple cores. This is UNACCEPTABLE in 2014 - roughly 8 years since processors went multi-core. Intel…

This won't be a problem for very long. See http://www.cl.cam.ac.uk/~sd601/multicore.md for the working design.

Re: Why OCaml, Why Now?

#39
post #34

OCaml is Object Caml right? What about SML? I always loved SML, but it never got any traction at all. The O in Ocaml always turned me off, they cluttered up the syntax with all the object notation. Does anyone have any insight into why OCaml rose to (relative) prominence and not SML?

Ocaml was always the more pragmatic language and for a long time the implementation was significantly faster than anything SML offered. MLton came along very late in the game and offers excellent performance, but doesn't support separate compilation. Edit: A more lengthy comparison: http://adam.chlipala.net/mlcomp/

Thanks for the perspective!

Re: Why OCaml, Why Now?

#40
Considering how strongly opposed the author is to dynamic typing, I'm actually kind of surprised they'd consider OCaml's type system to be acceptable.

Technically, yes, it's a statically typed system. But its use of structural typing instead of nominative typing effectively means it takes half the compiler assistance you can get out of static type checking and chucks it out the window. Using structural typing means that a type is nothing more than the sum of its parts; nominative typing makes it possible to add further specificity to types by naming them. This is huge. A language that doesn't do this is a language that can't be taught to understand the difference between 12 meters and 12 Newtons.

Post reply on HN