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.

A brief introduction to OCaml

136 pointsby fredyralmost 10 years ago

8 comments

rubiquityalmost 10 years ago
It&#x27;s cool to see a link about learning OCaml so high on HN. I started teaching myself OCaml a few months ago and I really like it. Here&#x27;s a few things I like so far and why I think anyone that uses Go or Rust should give OCaml a look:<p>1. OCaml compiles to a binary like Go and Rust do<p>2. The type system is helpful without being a huge burden on learning&#x2F;productivity (unlike Rust and Haskell)<p>3. Garbage collection<p>4. Pattern matching and algebraic data types (like Rust)<p>5. OCaml is plenty fast at CPU bound work(slower than Rust, faster than Go) despite not being parallel (yet)<p>Those are my takeaways of what I enjoy about OCaml so far. It has been the most approachable typed functional language that I&#x27;ve looked at yet! Depending on the type of things you want to learn and problems you want to solve, Your Mileage May Vary.
评论 #9713558 未加载
评论 #9713947 未加载
评论 #9713327 未加载
评论 #9713449 未加载
jordwalkealmost 10 years ago
This is also great cheat sheet for someone still getting used to the OCaml syntax.<p>I usually advise people to pretend that double semicolons don&#x27;t exist for anything but the interactive top level. In source files, you can forget about double semis entirely as long as you just remember to always assign the result of an imperative statement to the dummy &quot;_&quot; name.<p><pre><code> let _ = print_string &quot;hi&quot; </code></pre> Then you can think of ;;&lt;enter&gt; as merely a fancy way of hitting the return key in the interactive REPL. There&#x27;s also a way to use a different key mapping (control+enter) instead of ;; in utop, so there would be no reason to even acknowledge the existence of double semis. <a href="https:&#x2F;&#x2F;github.com&#x2F;diml&#x2F;utop&#x2F;issues&#x2F;131" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;diml&#x2F;utop&#x2F;issues&#x2F;131</a>
评论 #9713725 未加载
评论 #9714069 未加载
glaszalmost 10 years ago
im quite amazed that ocaml seems to be on a rise (judging from how often i&#x27;ve recently seen it on here). it reminds me of the time i started to dig into it more than a decade ago when mldonkey [0] was a thing.<p>also, this is the way to briefly introduce a programmer to a new language. just show the commented syntax. i just hate reading all the prefaces and texts of language manuals. it&#x27;s good they&#x27;re there but i&#x27;m just loosing interest too quickly if you don&#x27;t show me code.<p>[0] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;MLDonkey" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;MLDonkey</a>
评论 #9714657 未加载
amirmcalmost 10 years ago
There are also more links&#x2F;resources on the OCaml website.<p><a href="http:&#x2F;&#x2F;ocaml.org&#x2F;learn&#x2F;books.html" rel="nofollow">http:&#x2F;&#x2F;ocaml.org&#x2F;learn&#x2F;books.html</a>
arocksalmost 10 years ago
It seems `int_of_float` and `float_of_int` are deprecated by the Jane Streets Core library. It even throws errors on utop. I believe they need to be replaced by `Int.of_float` and `Float.of_int` respectively.<p>EDIT: Some more corrections:<p>1. `List.hd []` doesn&#x27;t raise an error as its return type is an option. So the result is a `None`.<p>2. `List.map` and `List.filter` arguments should be reversed. First argument should be a list and the second should be the mapping function.
评论 #9720139 未加载
jnbichealmost 10 years ago
I do really like OCaml, although Rust is the one I&#x27;m starting to look to where in the past I&#x27;d consider OCaml (yes, two different languages, but similar in practical function approach and safety).<p>The one things that I absolutely can&#x27;t stand about OCaml is the lack of an easy, available, include-in-the-standard-library, debugging function. Every damn time I work with OCaml, I end up having to write annoyingly time-consuming &quot;print_blah_blah&quot; functions to handle debugging. And such a debugging feature should handle errors already, and not return the Option type. I shouldn&#x27;t have to write a function to handle errors on a debugging statement.<p>And yes, I&#x27;m sure there are some nice versions of this already available in 3rd-party libraries, but this should be in the standard library.
freditupalmost 10 years ago
How does OCaml compare to F# from a language point of view?
评论 #9713890 未加载
评论 #9713761 未加载
评论 #9714096 未加载
odealmost 10 years ago
How does concurrency in OCaml compare to Go, Clojure, Rust, etc?<p>Thanks
评论 #9714082 未加载
评论 #9713565 未加载