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 for the Masses (2011)

304 pointsby alanfranzover 6 years ago

20 comments

jasimover 6 years ago
I for one can&#x27;t wait for Typed FP to become mainstream as soon as possible. I think the prevalence of scripting languages in large systems today is a quirk of history.<p>In early 2000s, as the web was growing to be an application delivery platform, the only practical statically typed language was Java. It didn&#x27;t have generics or lambdas at the time, and was infested with the sprawl of J2EE. Choosing Ruby&#x2F;Python over Java was at the time an act of rebellion and a show of technical superiority. To quote pg: &quot;if they wanted Perl or Python programmers, that would be a bit frightening-- that&#x27;s starting to sound like a company where the technical side, at least, is run by real hackers.&quot;<p>The static type system in Java is object-oriented: the only way to create a type is to create a class. I believe it was limited in abstraction power and everyone attributed it to the rigidity of static types. Java has come a long way since, but the sense that dynamic typing is superior to static types lingers.<p>But OCaml&#x27;s static types are a completely different kind of type. There is a kind of &quot;procedural&quot; static typing in Go, C, and to some extent C++ where primitives are typed and you can construct structs and unions without much ceremony. Then there is object-oriented static typing in Java and C#, which traces its origin back to Simula through C++ where types and classes are the same. Then you have functional static types where types are just and only about data. Almost all Typed FP languages use a form of Hindley-Milner inference, support algebraic data types and pattern matching, have generics (they were invented by Milner for ML in 1973), and allows for code organization and encapsulation through modules and opaque types.<p>Algebraic data types alone is a tool for thought like no other. You&#x27;ll start reifying concepts that would&#x27;ve otherwise gone implicit in your codebase thanks to ADT. The languages are solid, ecosystems are vibrant but small and that can only be fixed with more people. Come on in, the water is fine!
评论 #18533446 未加载
评论 #18532849 未加载
评论 #18532803 未加载
评论 #18532546 未加载
评论 #18533219 未加载
评论 #18533190 未加载
评论 #18532914 未加载
评论 #18532577 未加载
评论 #18533069 未加载
评论 #18535093 未加载
评论 #18533527 未加载
评论 #18536170 未加载
评论 #18533444 未加载
yminskyover 6 years ago
Hey, author of the linked post here.<p>A few thoughts, since some things have changed since that post was written:<p>First, the tooling limitations that I mentioned in the article have gotten a lot better. In particular:<p>Merlin now provides IDE-like functionality for your editor of choice (including code, vim, and emacs).<p>Also, Dune is an excellent build system for OCaml that does an enormous amount to simplify the build process, and tie a bunch of different tools in the ecosystem together. One great thing about Dune is it does a lot to unify the experience we&#x27;ve long had inside of Jane Street with the open-source OCaml experience. It&#x27;s really a big upgrade.<p>We&#x27;ve also made some progress on debugging tools, like the spacetime allocation profiler. There&#x27;s also active work on making GDB&#x2F;LLDB debugging in OCaml really first class.<p>Also, OCaml has had some major industrial uptake. Notably, Facebook has several major projects built in OCaml (Hack, Flow, Infer) as well as their own syntactic-skin-plus-tooling on top of OCaml, in the form of Reason. Reason has gotten a lot of traction in the webdev world, which is awesome. Bloomberg, and Docker are some other big names that have real dependencies on OCaml, along with some more names you probably don&#x27;t know like Ahrefs, LexiFi, and SimCorp.<p>People sometimes feel like Jane Street is the only real user of OCaml, so they imagine that Jane Street&#x27;s needs are the ones that drive the language priorities. So, the thinking goes, if you&#x27;re not a trading firm, you should look elsewhere. But this is the wrong picture. First, there are other serious users, as discussed above. Besides, the community doesn&#x27;t just roll over and do what we say. If you don&#x27;t believe it, go and see how often our PRs to OCaml get rejected.<p>And even our interests in the language have grown beyond what you might imagine a trading firm would care about. We use OCaml for building traditional UNIX system software, like MTAs, for designing hardware (via HardCaml), and for building dynamic browser-based applications (via Incr_dom).<p>For sure, there are still challenges of being a minority language (and there&#x27;s still no multicore GC, despite some exciting progress). But I believe OCaml is a yet better choice than it was in 2011 when I wrote the article.
评论 #18535993 未加载
评论 #18536322 未加载
rkangelover 6 years ago
If people want to move towards functional programming, I would recommend Elixir as the first step.<p>There is a fantastic web framework called Phoenix built in Elixir. This provides a way that you can immediately build something useful, and it teaches you how to use Elixir well: the documentation is good, the generated code that you start working with is a great example of how to use the language properly, and when you start understanding the design of the framework it&#x27;s a great example of functional systems design (e.g. the Plug.Conn structure that gets passed around).<p>Not having to deal with a full ML (or Haskell) like type system takes away a large barrier to entry, but you still have to change your mindset about how you implement things. And then the dialyzer is there, when you later want to start using gradual typing.
评论 #18532651 未加载
评论 #18534680 未加载
raphinouover 6 years ago
I&#x27;m currently looking for the language and framework to use for a project, and I&#x27;d like to go with a functional language.<p>I really, <i>really</i> want to do my next project in Ocaml, but... I find the ecosystem seriously lacking. You find Ocaml libs for a lot of needs, but a lot of those a unmaintained and have their last commit a couple of years ago. I&#x27;m afraid that choosing Ocaml would mean spending quite some time on libraries I need, and less on the app I want to develop.<p>There&#x27;s F# and the SAFE stack, but I don&#x27;t feel home there. A lot of docs&#x2F;libs still are (or have quirks due to having been) Windows specific, and joining the most popular f# community communication channels requires you to join the F# Software Foundation....<p>Then there&#x27;s Scala, with functional programming and access to Java&#x27;s ecosystem. But I prefer the ML style of Ocaml and F#.
评论 #18532781 未加载
评论 #18533408 未加载
评论 #18537396 未加载
评论 #18532799 未加载
评论 #18532721 未加载
评论 #18538041 未加载
prossercjover 6 years ago
&gt; <i>Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function.</i> - John Carmack<p>This mirrors a discussion I&#x27;ve had with my boss a number of times. Most of our products are written in C++, and we complain about how often developers (usually coming from Java) think that everything needs to be inside a class hierarchy. The procedural parts are still there for a reason: the CPU is procedural. A procedure or function is a closer mapping to what the CPU is actually going to do when the code runs.<p>On the other hand, I&#x27;ve never done serious work with a pure functional language like OCaml. I would welcome the chance, though I wonder if one finds the same kind of dogmatism as in the OOP world...(&quot;it <i>must</i> be a pure function!&quot;)
评论 #18533378 未加载
评论 #18533303 未加载
评论 #18534374 未加载
评论 #18534049 未加载
zengidover 6 years ago
I&#x27;m personally having a lot of fun learning Rust, which seems to have been largely inspired by OCaml. Algebraic data types and pattern matching are a revelation!
评论 #18533874 未加载
christophilusover 6 years ago
I would love to see something more like SML, with OCaml compile times, and a Go-like standard library. If that could be accomplished, I think we would see statically typed functional programming go mainstream.
adultSwimover 6 years ago
Python makes it easy to start a program. OCaml is easy to finish one.
lovebesover 6 years ago
ReasonML is going to bring Ocaml to the masses. Massively popular React apps can be created from ReasonML. Ocaml + syntactic sugar = ReasonML.
tybitover 6 years ago
The masses won’t be coming to ocaml unless it comes to them. ReasonML seems like a much more likely approach to succeed to me.
评论 #18532852 未加载
评论 #18532500 未加载
remifyover 6 years ago
Great writing.<p>By the way, How is it that HN readers always heavily promote OCaml related threads ?
评论 #18532475 未加载
评论 #18532532 未加载
评论 #18532698 未加载
评论 #18533690 未加载
ynnivover 6 years ago
I want to spend more time in OCaml, but without threads it&#x27;s a tough sell. Modern performance requires parallelism with shared memory, and the current mainline solutions don&#x27;t offer that.<p>Where threads aren&#x27;t part of the equation, OCaml has become suddenly popular. That&#x27;s telling.
评论 #18532952 未加载
评论 #18533024 未加载
donpdonpover 6 years ago
Elm is the langauge that showed me a functional language can be amazing. It clicked in my head like no other language. I did a substantial web app in it, and came to appreciate it more and more. I only wish it were available as a general purpose language. I used to call elm a gateway-drug to ocaml but I have a hard time swallowing a lot of ocaml syntax. Reason seems to be a good way around that. I&#x27;m also keeping an eye on the Grain language.
twoquestionsover 6 years ago
Is F# still being used&#x2F;developed, or has MS started to leave it out to dry?
revskillover 6 years ago
The problem with Reason is non-automatic understanding 3rd party Javascript codebase. It&#x27;s the pain to implement correct type to use in Reason program with existing JS codebase.
justaaronover 6 years ago
is there any NON-garbage-collected functional programming language? Something suitable for real-time or deterministic timing usage?
评论 #18537293 未加载
评论 #18537439 未加载
thibranover 6 years ago
These kind of blog posts are one of the reasons why I love the internet, and why Hacker News is such a great place.
devitover 6 years ago
It seems like Rust would have been an even better choice, had it been available at the time they chose OCaml.
评论 #18534878 未加载
G4BB3Rover 6 years ago
I am still waiting a friendly backend language similar to Elm. OCaml is hard and lost timing.
评论 #18536091 未加载
fileoffsetover 6 years ago
OCaml is not for the masses, it never has been