Live data from Hacker News

Why OCaml, Why Now?

spyder.wordpress.com

81–90 of 106 posts

Re: Why OCaml, Why Now?

#81

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…

Okay, sounds like a misunderstanding about what "web app" means. Sorry about that!

I think of a web app as the client side alone, which can be quite a substantial amount of code with something like GMail or Google Maps. Of course on the server side, you can make a mostly-independent choice of language, RPC mechanisms aside. But for the client side, I'd choose a language based on how well it compiles to JavaScript and can use browser API's and JavaScript libraries.

I don't know whether OCaml is ahead of Haskell in this space. I've tinkered with Elm a little bit.

Re: Why OCaml, Why Now?

#82
post #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.

What's interesting about Haskell in this regard is due to the pure functional nature, the Church-Rosser theorem applies...every function call could be executed in its own thread without protecting any resources with locks/mutexes/etc! I haven't studied the compiler design of Haskell, do you know if the compiler can delegate function calls to a thread pool automatically?

Re: Why OCaml, Why Now?

#83
post #8

Earlier quoted context omitted.

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

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"?

Re: Why OCaml, Why Now?

#84
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.

Good to see work is being done on it, but until it's in the main implementation for at least a year...I wouldn't trust it on anything that matters.

The advantage of kernel threads is that they have way less overhead than a process (both in context size as well as more efficient memory caching at processor and OS level)...though more than a user-level thread. If there isn't any sort of message passing between two processes, the only mechanism I can think of of sharing data is shared memory (i.e and mmap) which is just as efficient as threads sharing the same process heap...but awkward (yes there are sockets, file IO, signals, queues, etc, but not as efficient). Even if OCaml provides a way to abstract that to be more palatable + safe -- my argument is that in a multicore world, kernel threads must be a first class citizen and the programmer shouldn't have to resort to tricks to harness it -- otherwise it's a major flaw that is going to prevent future adaptation. Also, as the number of cores increase, this is going to matter more and more...so hopefully this stuff gets out in the wild soon.

Re: Why OCaml, Why Now?

#85
post #25

"...Facebook created ... a statically typed PHP variant..." - so happy to see another major tech company understand the merits of static typing.

that's because PHP is such a horrible language you need static typing to make sense of the crap.

Re: Why OCaml, Why Now?

#86

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?

what saddens me is that aliceml [https://www.ps.uni-saarland.de/alice/] seems to have died. i've kept it vaguely in the back of my mind as "this looks like a very pleasant language, and as soon as i have a problem in its sweet spot i'll give it a good look", but the last time i went to look at it i realised the last mailing list post was in 2012, and the last home page update in 2007.

Re: Why OCaml, Why Now?

#87

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've played with Elm for a toy project before and I do have high hopes for it. I also think it's the greatest monad tutorial ever - you don't truly miss them until they're gone. (To clarify: At the time that I last used Elm, the Signal type was a functor, but was intentionally being kept from being a monad for design reasons. Working around this restriction tought me a lot on why I needed monads.

I didn't really understand applicative functors until I was playing with Elm. Working with Signals was pretty fun, and when I found out they were applicative functors, it was like a light bulb going off above my head.

Elm is a really fun way to start exploring purely functional programming.

Re: Why OCaml, Why Now?

#88

Earlier quoted context omitted.

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.

Re: Why OCaml, Why Now?

#89

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?

For me (the author), it's because SML as it was taught to me is a closed language. It can never and will never change. Perfect for education, perhaps not so useful as a career choice.

OCaml has been moving forward; GADTs were added recently, multicore support is coming, and who knows what else is on the horizon.

Re: Why OCaml, Why Now?

#90
post #9

How do those "to js" code generator behave when used together with frameworks like backbone or angular ? I know things like typescript or dart have special versions of the framworks, but i'm curious to know how the ocaml to js tools behave ( since i've searched for a decent strongly typed server side technology for years, that would be an argument for me to try that language).

OCaml has quite nice JavaScript integration; it has the ability to interact with JS objects, constructors, DOM objects, etc. See the "dom bindings" thread elsewhere in this discussion.

Most other AltJS languages I've seen are primarily based around FFI declarations, where all interaction with JS is done via functions declared in the native language as external and implemented in JS.

Post reply on HN