Live data from Hacker News

Why OCaml, Why Now?

spyder.wordpress.com

71–80 of 106 posts

Re: Why OCaml, Why Now?

#71
post #67
post #17

Felix is to C++ what F# is to C# http://felix-lang.org/share/src/web/tut/tutorial.fdoc (I am not the author, just excited about this language) OCaML programmers will feel immediately at home. It is a mature yet actively developed whole program optimized, strongly typed, polymorphic, ML like language that can interact effortlessly with C and C++ and has coroutines and threads baked in, although use of threads is somew…

AFAICT you mention Felix whenever OCaml comes up, generally saying more or less the exact same thing each time.

Absolutely correct, and for F# too. I do want to get the word out, it really needs some love and eyeballs, but perhaps I overdo it.

Re: Why OCaml, Why Now?

#72
post #20

I've found it interesting that OCaml hasn't had more interest given the amount of recent momentum in Haskell. Haskell is an Ivory Tower. The features that generally draw one to the language also tend to be the things that eventually push one away. Haskell has grown a lot over the years however as the language evolves to allow general programming within a pure framework. OCaml on the other hand tends to make a comprom…

So maybe "middle of the road" and "pragmatic compromises" are overrated.

Re: Why OCaml, Why Now?

#73
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…

The multithreading situation in Haskell is pretty exciting. Simon Marlow's Parallel and Concurrent Programming in Haskell is the best new programming book I've picked up in a long time. And there are new developments since he wrote it (http://www.haskellcast.com/episode/004-simon-marlow-on-paral...). It would be a shame to give all that up.

Re: Why OCaml, Why Now?

#74
post #65

Earlier quoted context omitted.

Not the original commenter but for me the big ones are purity and cheap direct access to C code.

You can program in pure mode in scala too(and scalaz framework helps in it). FFI is great but i don't miss it. For better performance there is the java collections and libraries.

Scalaz helps with the idioms but without the purity garuantees you miss out on all the optimizations and verifiability.

The java collections & libraries don't help me when I need to manage my own memory. I've spent entirely too much time in the unsafe package because the JVM doesn't allow me to do cheap ffi unlike Haskell or even Microsoft's CLI.

Re: Why OCaml, Why Now?

#75
post #20

I've found it interesting that OCaml hasn't had more interest given the amount of recent momentum in Haskell. Haskell is an Ivory Tower. The features that generally draw one to the language also tend to be the things that eventually push one away. Haskell has grown a lot over the years however as the language evolves to allow general programming within a pure framework. OCaml on the other hand tends to make a comprom…

I have to admit JavaScript isn't the only driver for my interest in OCaml. It is however the angle I'm pushing for using it in my day job :)

Re: Why OCaml, Why Now?

#76
post #33

Earlier quoted context omitted.

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…

The trouble with Ocaml is that you will probably get something like: $ ocaml o.ml File "o.ml", line 2, characters 0-13: Error: Unbound module Graphics And after you've googled for a while and had done: sudo apt-get install liblablgl-ocaml-dev The thing would install 23(!) packages. And after that you will get: $ ocaml o.ml Exception: Graphics.Graphic_failure "fatal I/O error". After which, if you've been in the indus…

The Graphics module is a core Ocaml library that is always available. In order to use it, it must be linked on the command line, similar to many other languages. Installing an unrelated OpenGL binding didn't magically make "ocaml o.ml" work. Based on this and the obvious trolling of your final paragraph, I'm hesitant to believe anything you said is true.

Re: Why OCaml, Why Now?

#77

Earlier quoted context omitted.

> 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…

Haste is a strong, useful, and impressively complete Haskell to JS compiler. Fay is used in production apps as well. PureScript is less mature still but pretty nice.

I looked at Haskell options - fay and haste are both good, but not complete (try compiling tagsoup). GHCJS works, but generates 5mb JavaScript files.

This is what I meant when I said "by virtue of support for existing libraries". js_of_ocaml translates compiled bytecode and can therefore make any pure OCaml library work in JavaScript without recompilation.

Re: Why OCaml, Why Now?

#78
post #19

Earlier quoted context omitted.

http://elm-lang.org/ for example. To display text in the browser you would use - main = plainText "Hello, World!" From the page: "Elm is a functional language that compiles to HTML, CSS, and JavaScript". So yes, technically this is working with the DOM. But you are not writing code that interacts with a "DOM binding" directly per se.

I'm excited for PureScript for the property that it compiles to sane javascript. http://purescript.readthedocs.org/en/latest/intro.html#hello...

Awesome, had not heard of this project before! Thanks for sharing.

Re: Why OCaml, Why Now?

#79
post #5

For me Scala has been the not-quite-as-good-as-haskell-but-more-industrially-acceptable language. I'd be very interested to see a more neutral comparison of functional languages for compile-to-JS, because if anything Haskell seems more popular for that - I hadn't heard anything about compiling OCaml to JS before this.

I've put a lot of work into a compile-to-JS evaluation for my day job. It's not suitable for public consumption, but of our top 5 choices:

- both Kotlin and ClojureScript don't compile code written in their "native" language (java) to JavaScript, limiting the ability to leverage existing libraries. - ScalaJS is still experimental. - Haskell looked promising, I asked a haskell programmer to run that evaluation for me, but fay/haste aren't complete enough for serious (non-ui) JavaScript work and GHCJS generates 5mb JS files. - OCaml had a viable project in about half the time I estimated it would take.

And on a personal note, Scala seemed great at first but after SML/OCaml I find the number of times that I have to tell the type checker what I'm doing immensely frustrating :)

Re: Why OCaml, Why Now?

#80
post #76

Earlier quoted context omitted.

The trouble with Ocaml is that you will probably get something like: $ ocaml o.ml File "o.ml", line 2, characters 0-13: Error: Unbound module Graphics And after you've googled for a while and had done: sudo apt-get install liblablgl-ocaml-dev The thing would install 23(!) packages. And after that you will get: $ ocaml o.ml Exception: Graphics.Graphic_failure "fatal I/O error". After which, if you've been in the indus…

The Graphics module is a core Ocaml library that is always available. In order to use it, it must be linked on the command line, similar to many other languages. Installing an unrelated OpenGL binding didn't magically make "ocaml o.ml" work. Based on this and the obvious trolling of your final paragraph, I'm hesitant to believe anything you said is true.

Seriously. You are so biased that it is easier for you to believe that other people are downright lying than to accept inconvenient truth. I was running it in the interpreted mode. Isn't that how one is supposed to run tutorials code? And obviously I've added the following:

  #load "graphics.cma";;
into the file first. And forgot about it, when writing the post. So no magic here. "Beautiful" syntax by the way.

And no, I wasn't trolling. I just wanted to see what that recursion would do. The code is not exactly crystal clear there, with names like start_x and such. But it really did not work. And the syntax is really ugly. And you can believe what you like.

Post reply on HN