Live data from Hacker News

OCaml Programming: Correct and Efficient and Beautiful

cs3110.github.io

41–50 of 251 posts

Re: OCaml Programming: Correct and Efficient and Beautiful

#41
post #21

Earlier quoted context omitted.

OCaml vs All: Good luck finding developers that will write quality code and not cost a fortune each.

It's not getting things done that matters. It's feeling superior to others that matters.

Hey, it's not a feeling. It's a fact.

Re: OCaml Programming: Correct and Efficient and Beautiful

#42
post #17
post #3

My introduction to programming course in my university was in OCaml. It was all downhill from there when it comes to the programming languages I had to use.

Which university? Does the course have a public webpage?

Cambridge does this (or did when I was there); https://www.cl.cam.ac.uk/~lp15/MLbook/ is the book for the course (available online).

Re: OCaml Programming: Correct and Efficient and Beautiful

#43
post #2

I learned some Haskell years ago but it didn't stick with me. Lately, I want to get back into functional programming to see whether I'm missing out on something. This book looks nice, and so does OCaml. Any suggestions on books, courses, or resources on this subject? Also, just to get proper motivation, why should I learn functional programming as a capable Software Engineer?

The OP is a great book to learn OCaml. There is also a corresponding set of lecture videos on YouTube.

Re: OCaml Programming: Correct and Efficient and Beautiful

#44
post #15

Every time I use recent "functional" languages (Rust, modern Typescript) I realise how great OCaml is

Have you tried F#?

Nope, I must say I have only used a small subset of languages from the FP-language-zoo, so my opinion on OCaml might be biased

But as an example when writing Typescript, I feel so frustrated of not having a clean way of doing pattern-matching

Re: OCaml Programming: Correct and Efficient and Beautiful

#45
post #27

I found my experience trying to work with a large OCaml base a nightmare — when signatures changed in an unstable dependency (e.g. function argument removed and nested inside another), the errors spat out by the typechecker were utterly incomphrehensible. This was largely due to automatic currying in OCaml — if I have a function call "some_function arg1 arg2" and "some_function" adds a third argument, that call becom…

FWIW, F# is very similar to OCaml, but its error message in this case is usually quite clear. E.g. This expression was expected to have type 'int' but here has type 'string -> int'

yes, that would be a straightforward error message!

But I got the error message

    Error: This expression has type
         ((locl_ty * Tast.pos * ('ex, 'fb, 'en) Aast.expr_) list ->
          Result_set.t)
         list
       but an expression was expected of type Result_set.t list
       Type
         (locl_ty * Tast.pos * ('ex, 'fb, 'en) Aast.expr_) list ->
         Result_set.t
       is not compatible with type Result_set.t 
Which is not half as readable.

Re: OCaml Programming: Correct and Efficient and Beautiful

#46
post #27

I found my experience trying to work with a large OCaml base a nightmare — when signatures changed in an unstable dependency (e.g. function argument removed and nested inside another), the errors spat out by the typechecker were utterly incomphrehensible. This was largely due to automatic currying in OCaml — if I have a function call "some_function arg1 arg2" and "some_function" adds a third argument, that call becom…

Do you have a more precise example in mind? The example that you are describing should emit an error message of the form This expression has type type_of_arg_3 -> return_type but an expression of type return_type was expected which seem alright to me. (But I cannot not be called an OCaml aficionado). The type error might be delayed in sufficiently polymorphism context but that is a more infrequent occurrence (outside…

yup, specific error message is here: https://news.ycombinator.com/item?id=31861450

Re: OCaml Programming: Correct and Efficient and Beautiful

#48
post #40
post #27

I found my experience trying to work with a large OCaml base a nightmare — when signatures changed in an unstable dependency (e.g. function argument removed and nested inside another), the errors spat out by the typechecker were utterly incomphrehensible. This was largely due to automatic currying in OCaml — if I have a function call "some_function arg1 arg2" and "some_function" adds a third argument, that call becom…

> when signatures changed in an unstable dependency The problem is not OCaml here.

I have a good point of contrast: I'm doing a similar task with an unstable Rust dependency, and when APIs change the error messages from the typechecker are crystal clear about why things are incompatible.

Re: OCaml Programming: Correct and Efficient and Beautiful

#49
A quick scroll through the comments and it looks like no one is actually talking about the book itself, so I will. I came across it at a really good time in my computer science self education. It helped me learn about some essential data structures and algorithmic analysis. The video lectures interspersed in the text augment the text and vice versa. The sections without videos were tougher for me to digest, but are written clearly and bear revisiting and study. If you, like me, are looking for a good next step after Grossman’s PL MOOC, I recommend spending some time with this incredible free resource.
Post reply on HN