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.

OCaml 4.02: Everything else

98 pointsby yminskyabout 11 years ago

6 comments

amirmcabout 11 years ago
Since I haven&#x27;t seen any discussion here (yet), I went and looked at the reddit submission. Thought others might find it interesting.<p><a href="http://www.reddit.com/r/programming/comments/25vr5t/ocaml_402_everything_else/" rel="nofollow">http:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;programming&#x2F;comments&#x2F;25vr5t&#x2F;ocaml_40...</a>
cheepinabout 11 years ago
At what point is the language going to get serious adoption? It&#x27;s mature, unbloated, elegant, and fun to write. The only thing I really think needs improvement is its multicore stuff.
评论 #7765450 未加载
zerrabout 11 years ago
Slight off-topic: Judging from H1B stats [0], Jane Street pays quite below the market rate (for NYC finance sector). Also, they haven&#x27;t sponsored any H1B&#x27;s for the last 3-4 years. I wander if these stats are reliable... Or maybe, JS puts more emphasis into bonuses (on top of the base salary), in order to not to disclose salaries?<p>[0]: <a href="http://www.myvisajobs.com/Visa-Sponsor/Jane-Street-Capital/281915_Salary.htm" rel="nofollow">http:&#x2F;&#x2F;www.myvisajobs.com&#x2F;Visa-Sponsor&#x2F;Jane-Street-Capital&#x2F;2...</a>
评论 #7766229 未加载
thinkpad20about 11 years ago
I&#x27;ve been a Haskell user for about a year now, and am pretty comfortable with the language. Ocaml has a lot of things that I like (the module system seems great; strict evaluation is a win; mutability&#x2F;loops&#x2F;etc without having to jump through hoops). But every time I look at the actual code, I&#x27;m really turned off by a few things:<p>* <i>let</i>s everywhere, even at top-level. Haskell doesn&#x27;t do this, which is a lot nicer.<p>* <i>let rec</i>. Wut?<p>* Apparently to produce code to run at top-level main loop you just assign it to a <i>let _ = ...</i>, which looks really hacky.<p>* Double semicolons.<p>* Type variables annotated with <i>&#x27;a</i>. In Haskell, lowercase type names are variables, uppercase are constants (or type classes, but those aren&#x27;t mixed).<p>* Mix of semicolons and <i>end</i>.<p>Haskell seems syntactically more elegant, has type classes which are (at least on the surface) more straightforward than modules, though I don&#x27;t know which is more useful at the end of the day. Haskell&#x27;s <i>do</i> syntax is very nice.<p>That said, in many ways OCaml <i>seems</i> much more like &quot;my kind of language&quot;. But there are a number of turnoffs.
评论 #7767861 未加载
andrewstuartabout 11 years ago
I&#x27;d like to like ocaml but its not clear to me why I would choose it above anything else to write an application. I have the sense vaguely it might be a good thing. A little reading and examination of some example source hasn&#x27;t thrown much light.<p>What&#x27;s it good for? Why should I use it? Why is it a better choice than language X or Y?
评论 #7765298 未加载
评论 #7765839 未加载
评论 #7765906 未加载
评论 #7765666 未加载
评论 #7766014 未加载
评论 #7765482 未加载
评论 #7769327 未加载
评论 #7765954 未加载
jordwalkeabout 11 years ago
A couple of people have asked why you might choose OCaml over other languages. I&#x27;ve not done as much OCaml work as others on this thread (I work primarily on ReactJS (Facebook&#x2F;Instagram&#x27;s) functional UI framework), but I can offer a different perspective as someone who is outside of the OCaml community, but asking the same questions. Here are some of my personal findings.<p>I&#x27;ll narrow any comparison down to the ML family of languages. Java&#x2F;C++&#x2F; and many other languages are just now beginning their slow, but inevitable evolution into <i>becoming</i> a dialect of ML (which IMHO is a sort of admission of the ML&#x2F;functional family superiority).<p>Once you embrace the power of pattern matching, it&#x27;s hard to use anything but an ML family language (StandardML&#x2F;Haskell&#x2F;F#&#x2F;OCaml). I would program in any one of those languages over Java&#x2F;C++&#x2F;Objective-C&#x2F;JS.<p>Practical reasons why you might choose OCaml:<p>- OCaml&#x27;s records aren&#x27;t as elegant as SML&#x27;s but OCaml has labeled arguments with optional default values which can satisfy many of the reasons why you&#x27;d use records as arguments in the first place (and may be even more powerful in some cases).<p>- Two modes of compilation (fast native executable XOR fast compilation). Who doesn&#x27;t like options.<p>- All the benchmarks I can find show that OCaml is very fast (around as fast as C++).<p>- Excellent JS target and and apparent commitment to maintaining it (as someone building a JS library, this is very important to me) (and as someone who wants to build apps and be able to instantly share them with everyone in the world.)<p>- Someone has built an autocomplete plugin for Vim&#x2F;Emacs (merlin). (&quot;VimBox&quot; (<a href="https://github.com/jordwalke/VimBox/" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jordwalke&#x2F;VimBox&#x2F;</a>) has configured it to complete as you type - like in Visual Studio etc.)<p>- On very rare occasion, you&#x27;ll run into a problem that is inherently better suited to OO (dynamic dispatch). I can usually find a way to solve it with functors&#x2F;modules, but it&#x27;s nice to know that you have OO in your back pocket in case you ever need it. It&#x27;s also nice to know you probably won&#x27;t have to.<p>- Finally, a common package manager (OPAM) is becoming standard. I look forward to seeing how OPAM helps make the new dev experience and the code-sharing&#x2F;development experience seamless.<p>- The module system is very powerful (SML&#x27;s). Haskell does not have this, and strangely F# dropped it. (I hear, Haskell&#x27;s type classes fulfill similar roles (but with more sugar)).<p>- There&#x27;s usually ocamlyacc grammars for most languages. Most examples of languages, type systems, parsers are already in OCaml (or ML). It&#x27;s a nice (but small) perk.<p>- Predictability. OCaml is not lazy by default. Lazy computations could become problematic for low-latency applications (such as UIs) if a lot of computation becomes is deferred until the moment a final dependency has been satisfied, but by that time you may be close to your screen refresh deadline and it may lead to a dropped frame. It would have been better to have been computing while waiting for a final dependency. I&#x27;m not sure if Haskell (a lazy language) has had this problem. You can opt into laziness in OCaml if you would like to.<p>- Mutability. I feel strange saying this, as such a huge proponent of immutability, but sometimes you just need to hack something in place, mutate some state and come back to clean it up later. (You can still use monads in OCaml).<p>- Tagged Variants (no need to predeclare variants, just pattern match on them and OCaml ensures that only properly matched values ever make their way into that expression).<p>- Industry use is growing. OCaml is used here at Facebook and many other places as mentioned.<p>- There are many abstractions to choose from (Records, Objects, Modules, Functors, First Class Modules, GADTs, ...).<p>OCaml Cons: - There are many abstractions to choose from (Records, Objects, Modules, Functors, First Class Modules, GADTs, ...).<p>(Edited for formatting)
评论 #7766908 未加载
评论 #7766357 未加载
评论 #7768285 未加载