Hacker News new | ask | show | jobs
by lmm 4476 days ago
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.
4 comments

I just started at a Microsoft shop a few months ago (first time for everything), and I actually quite like F#, now that I've had a little while to play with it. It's a good contender for the NQAGAHBMIAL throne.

Having used CMUCL/SBCL for a while, I always found ocaml's "well, you can compile your code, but then you can't run it in the REPL" to be off-putting. (For my purposes the CLR JIT compiler for F# is good enough.)

Posted 20 minutes ago, and this post already shows up when you google "NQAGAHBMIAL". Impressive...
And now yours. And nothing else.

Is it "not quite as good as Haskell but maybe it's alright language"?

From the parent, "not-quite-as-good-as-haskell-but-more-industrially-acceptable language". Not intending to be obscure.
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 :)

Did you examine Ceylon? It seems to avoid the problem you describe with Kotlin and ClojureScript by explicitly abandoning the Java native library.
I haven't, no. We excluded the vast majority of AltJS languages as the size of community and availability of third-party libraries was a significant factor in the evaluation.
Having had Camllight as my first functional language, ML language family got a special place on my heart.

I have three issues with Scala:

- Having to wrap free functions in objects

- I feel Haskell type system is easier to understand than Scala's

- The concept of open and closed case classes for sum types feel wrong

So in the end I actually enjoy more using F# in general, and Clojure when targeting the JVM.

Now back to reading "Real World OCaml". :)

What are you mean at "not-quite-as-good-as-haskell"? What are the killer features of haskell?
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.