TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Why OCaml, Why Now?

106 pointsby croydabout 11 years ago

13 comments

mas644about 11 years ago
Look, I love OCaml and it&#x27;s my favorite language syntax-wise, but the real big elephant in the room is not its JS-backend maturity. Rather it doesn&#x27;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 is talking about having hundreds of cores on a single die by next decade and having programs that can&#x27;t take advantage of that is extremely limiting.<p>Xavier Leroy (the creator of OCaml) and his team at INRIA didn&#x27;t think this was a big deal because when they were writing this stuff, processors were single core and had been since the beginning. Sure there were multiprocessor machines (not the same as multicore as there are multiple die), but those were only meant for servers&#x2F;workstations. OCaml seemed very promising around 2006, the peak and end of the single core era with the Intel Pentium 4. What made OCaml so impressive was not only was it this beautifully simple, high-level functional language, but that the native compiler produced very fast code that was comparable to C&#x2F;C++ performance. However, as multicore processors were introduced (Intel Core, Core 2), not having this capability made writing new code in OCaml less appealing. There are solutions like MPI, but that&#x27;s lame. The same excuses you hear in the Python world about having true multithreading you hear in the OCaml world. Microsoft was able to do it with F#, which is essentially a clone of Caml by targeting their .NET CLR. Haskell is able to do it with GHC.<p>I still think OCaml is a wonderful language -- not having true multithreading doesn&#x27;t make it useless. However, to me it has become more like a statically-typed Python which I can use for scripting. Having to use hacks like MPI to do multicore processing is a huge turn off in a multicore world. This is again nothing against the language, but the standard implementation needs a concurrent garbage collector and kernel threads. Otherwise I think OCaml may be doomed to irrelevance in the long run, which would be truly sad.
评论 #7417366 未加载
评论 #7418557 未加载
评论 #7417367 未加载
评论 #7418530 未加载
评论 #7417898 未加载
chimeracoderabout 11 years ago
I&#x27;m glad that the author is picking up a new functional programming language, but choosing OCaml over Haskell because of support for the Javascript implementations strikes me as choosing a BMW over a Mercedes[0] because of the number of cupholders it has.<p>If you don&#x27;t have a particular goal in mind (ie, &quot;I work at Jane Street and need to be compatible with our existing code&quot;), there are a number of other factors in the OCaml vs. Haskell discussion that are far more important.<p>&gt; JS is the only realistic way to write web apps<p>Javascript is the only realistic way to write <i>the front-end</i> of webapps. But that doesn&#x27;t mean you&#x27;re wedded to it for your backend technology. And I don&#x27;t think <i>either</i> OCaml or Haskell have sufficiently advanced DOM bindings, etc. that I&#x27;d recommend using either one for client-side work in the browser.<p>[0] I&#x27;m not sure if this is a flamewar topic for car nerds - my point is to pick two high-end luxury cars that are both well-respected and each have their own merits.
评论 #7416626 未加载
评论 #7416627 未加载
评论 #7418509 未加载
评论 #7417868 未加载
评论 #7418184 未加载
评论 #7417011 未加载
评论 #7420570 未加载
评论 #7417512 未加载
评论 #7416456 未加载
sreanabout 11 years ago
Felix is to C++ what F# is to C# <a href="http://felix-lang.org/share/src/web/tut/tutorial.fdoc" rel="nofollow">http:&#x2F;&#x2F;felix-lang.org&#x2F;share&#x2F;src&#x2F;web&#x2F;tut&#x2F;tutorial.fdoc</a> (I am not the author, just excited about this language) OCaML programmers will feel immediately at home.<p>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 somewhat discouraged. It has type-classes as well as modules. Functions written in it may be exported as a CPython module. This might be useful if one wants to gradually transition from a Python based src tree.<p>It uses a mix of lazy and eager evaluation for performance and compiles down to C++. Execution speed is comparable to hand written C++, mostly better. Its grammar is programmable in the sense that it is loaded as a library. So in the same way that languages may acquire libraries, Felix may acquire domain specific syntax.<p>It is also mostly a one man effort but with a feverish pace of development so it comes with its associated advantages and disadvantages.<p>Tooling info is here <a href="http://felix-lang.org/share/src/web/ref/tools.fdoc" rel="nofollow">http:&#x2F;&#x2F;felix-lang.org&#x2F;share&#x2F;src&#x2F;web&#x2F;ref&#x2F;tools.fdoc</a><p>The author likes to call it a scripting language but it really is a full-fledged statically compiled language with a single push button build-and-execute command. <a href="http://felix-lang.org/" rel="nofollow">http:&#x2F;&#x2F;felix-lang.org&#x2F;</a> The &quot;fastest&quot; claim is a bit playful and tongue in cheek, but it is indeed remarkably fast.
评论 #7418482 未加载
评论 #7417835 未加载
bootheadabout 11 years ago
If ocaml is a language waiting for a killer app, this might be it: <a href="http://www.openmirage.org/" rel="nofollow">http:&#x2F;&#x2F;www.openmirage.org&#x2F;</a><p>There was a presentation at the FP eXchange in London last Friday about mirage and many a mind was blown!
评论 #7417155 未加载
评论 #7417933 未加载
lholdenabout 11 years ago
I&#x27;ve found it interesting that OCaml hasn&#x27;t had more interest given the amount of recent momentum in Haskell.<p>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.<p>OCaml on the other hand tends to make a compromise, acknowledging that the programmer occasionally needs a different tool for the job. OCaml allows the programmer to opt into things like mutability and objected oriented code when the need arises. These compromises can also be seen as the languages downside however.<p>I find it interesting that the driver for the author into OCaml is JavsScript... but it&#x27;s nice to see OCaml come up a bit more often. :)
评论 #7417104 未加载
评论 #7418718 未加载
评论 #7418552 未加载
评论 #7423371 未加载
lmmabout 11 years ago
For me Scala has been the not-quite-as-good-as-haskell-but-more-industrially-acceptable language. I&#x27;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&#x27;t heard anything about compiling OCaml to JS before this.
评论 #7416474 未加载
评论 #7418823 未加载
评论 #7417961 未加载
评论 #7417943 未加载
jlukecarlsonabout 11 years ago
OCaml is actually taught in the second level computer science course at my university. I think its a great language for learning topics like recursion especially with its pattern matching. Its also a great intro to functional programming
fnbrabout 11 years ago
This might be entirely superficial of me, but I always preferred Haskell over OCaml simply because OCaml required me to type &quot;;;&quot; after every line.<p>The only real reason that I can see to choose OCaml over Haskell is that if you learn OCaml, you might be able to work at Jane Street. Is there a strong argument for abandoning my Haskell-ing for OCaml?
评论 #7416355 未加载
评论 #7416429 未加载
marktangotangoabout 11 years ago
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.<p>Does anyone have any insight into why OCaml rose to (relative) prominence and not SML?
评论 #7417247 未加载
评论 #7419468 未加载
评论 #7419333 未加载
bunderbunderabout 11 years ago
Considering how strongly opposed the author is to dynamic typing, I&#x27;m actually kind of surprised they&#x27;d consider OCaml&#x27;s type system to be acceptable.<p>Technically, yes, it&#x27;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&#x27;t do this is a language that can&#x27;t be taught to understand the difference between 12 meters and 12 Newtons.
评论 #7417605 未加载
评论 #7417590 未加载
评论 #7418195 未加载
评论 #7423391 未加载
CmonDevabout 11 years ago
&quot;...Facebook created ... a statically typed PHP variant...&quot; - so happy to see another major tech company understand the merits of static typing.
评论 #7417623 未加载
评论 #7419260 未加载
bsaulabout 11 years ago
How do those &quot;to js&quot; code generator behave when used together with frameworks like backbone or angular ?<p>I know things like typescript or dart have special versions of the framworks, but i&#x27;m curious to know how the ocaml to js tools behave ( since i&#x27;ve searched for a decent strongly typed server side technology for years, that would be an argument for me to try that language).
评论 #7416655 未加载
评论 #7419474 未加载
qzwxecrvtbabout 11 years ago
Here&#x27;s the plan -- eliminate perl, python, ruby, php or java or any slow-starting jvm-based language(the featureless landscape of clojure for example), and use just bash, sed, awk, ocaml(to replace the fear of &#x27;C&#x27;), and we can also do f# on windows, so there would be crossover between the worlds and peace throughout the land.