A brief introduction to OCaml
lexicallyscoped.com
A brief introduction to OCaml
1–10 of 39 posts
Re: A brief introduction to OCaml
#2Re: A brief introduction to OCaml
#3I usually advise people to pretend that double semicolons don'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 "_" name.
let _ = print_string "hi"
Then you can think of ;; as merely a fancy way of hitting the return key in the interactive REPL. There'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.
https://github.com/diml/utop/issues/131Re: A brief introduction to OCaml
#41. OCaml compiles to a binary like Go and Rust do
2. The type system is helpful without being a huge burden on learning/productivity (unlike Rust and Haskell)
3. Garbage collection
4. Pattern matching and algebraic data types (like Rust)
5. OCaml is plenty fast at CPU bound work(slower than Rust, faster than Go) despite not being parallel (yet)
Those are my takeaways of what I enjoy about OCaml so far. It has been the most approachable typed functional language that I've looked at yet! Depending on the type of things you want to learn and problems you want to solve, Your Mileage May Vary.
Re: A brief introduction to OCaml
#5also, 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's good they're there but i'm just loosing interest too quickly if you don't show me code.
Re: A brief introduction to OCaml
#6It'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's a few things I like so far and why I think anyone that uses Go or Rust should give OCaml a look: 1. OCaml compiles to a binary like Go and Rust do 2. The type system is helpful without being a huge burden on learning/productivity (unlike Rust and Haskell) 3. Garbage collection 4. P…
And Haskell.
>2. The type system is helpful without being a huge burden on learning/productivity (unlike Rust and Haskell)
What? The type system is partly why my coauthor can use Haskell, unlike JS or Java. Haskell was her first time ever programming and now she's teaching Haskell to her 10 year old son.
I use Haskell in my day job, I couldn't do my job without the type system!
So in terms of learning and productivity in Haskell (can't speak for Rust), I will strongly disagree here.
The rest of the points apply for Haskell as well.
Haskell doesn't need to be hard to learn at all, it hasn't had the learning resources it deserves and expectations weren't being set properly. It's more like learning a new way to program (functionally) rather than a dialect of an existing paradigm (imperative, but we give you a map and a reduce function).
That paradigm (functions alone) is very simple but the implications are non-obvious and require a method of introduction that involves a lot of exercises.
Re: A brief introduction to OCaml
#7Thanks
Re: A brief introduction to OCaml
#8It'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's a few things I like so far and why I think anyone that uses Go or Rust should give OCaml a look: 1. OCaml compiles to a binary like Go and Rust do 2. The type system is helpful without being a huge burden on learning/productivity (unlike Rust and Haskell) 3. Garbage collection 4. P…
>1. OCaml compiles to a binary like Go and Rust do And Haskell. >2. The type system is helpful without being a huge burden on learning/productivity (unlike Rust and Haskell) What? The type system is partly why my coauthor can use Haskell, unlike JS or Java. Haskell was her first time ever programming and now she's teaching Haskell to her 10 year old son. I use Haskell in my day job, I couldn't do my job without the t…
Re: A brief introduction to OCaml
#9It'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's a few things I like so far and why I think anyone that uses Go or Rust should give OCaml a look: 1. OCaml compiles to a binary like Go and Rust do 2. The type system is helpful without being a huge burden on learning/productivity (unlike Rust and Haskell) 3. Garbage collection 4. P…
>1. OCaml compiles to a binary like Go and Rust do And Haskell. >2. The type system is helpful without being a huge burden on learning/productivity (unlike Rust and Haskell) What? The type system is partly why my coauthor can use Haskell, unlike JS or Java. Haskell was her first time ever programming and now she's teaching Haskell to her 10 year old son. I use Haskell in my day job, I couldn't do my job without the t…
Re: A brief introduction to OCaml
#10Earlier quoted context omitted.
>1. OCaml compiles to a binary like Go and Rust do And Haskell. >2. The type system is helpful without being a huge burden on learning/productivity (unlike Rust and Haskell) What? The type system is partly why my coauthor can use Haskell, unlike JS or Java. Haskell was her first time ever programming and now she's teaching Haskell to her 10 year old son. I use Haskell in my day job, I couldn't do my job without the t…
I'm sorry if this sounds rude, but what's the point you're trying to make? I can't quite figure it out.