Live data from Hacker News

A brief introduction to OCaml

lexicallyscoped.com

1–10 of 39 posts

Re: A brief introduction to OCaml

#3
This is also great cheat sheet for someone still getting used to the OCaml syntax.

I 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/131

Re: A brief introduction to OCaml

#4
It'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. 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

#5
im quite amazed that ocaml seems to be on a rise (judging from how often i'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.

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's good they're there but i'm just loosing interest too quickly if you don't show me code.

[0] https://en.wikipedia.org/wiki/MLDonkey

Re: A brief introduction to OCaml

#6

It'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 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

#8

It'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…

I'm sorry if this sounds rude, but what's the point you're trying to make? I can't quite figure it out.

Re: A brief introduction to OCaml

#9

It'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…

If I could go back and remove one word from my post it would be the word "Haskell" because at the time I wrote it I suspected it would incite a reply like yours.

Re: A brief introduction to OCaml

#10
post #8

Earlier 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.

OP suggests Haskell's type system interferes with productivity. GPP disagrees.
Post reply on HN