Live data from Hacker News

Teaching OCaml

ocaml.org

1–10 of 34 posts

Re: Teaching OCaml

#2
I think "all of Ocaml compiles to JS " is a bit optimistic. AFAIK, code using Jane Street's Core stdlib doesn't work. But a lot of Ocaml code should be fine.

Re: Teaching OCaml

#3
> OCaml is a high-level language that supports […] object-oriented programming style

AFAIK OCaml only support records, which are like C’s structs.

Edit: no, it has real objects, as stated in comments below.

Re: Teaching OCaml

#4
post #3

> OCaml is a high-level language that supports […] object-oriented programming style AFAIK OCaml only support records, which are like C’s structs. Edit: no, it has real objects, as stated in comments below.

Just looking at the table of contents here

http://caml.inria.fr/pub/docs/manual-ocaml/objectexamples.ht...

seems to state otherwise. That said, I think the common advice is to not use most of that and to restrict yourself to just records as they are almost always the better choice.

Re: Teaching OCaml

#5
In the "suggested textbooks" section, #3 is Real World OCaml which has Jason Hickey as an author and is available for free online, and #4 is Jason Hickey's notes for a course, is marked "Draft. Do No Redistribute", and at first glance its table of contents looks similar to Real World OCaml.

Isn't the latter redundant and in violation of whatever?

Re: Teaching OCaml

#6
post #3

> OCaml is a high-level language that supports […] object-oriented programming style AFAIK OCaml only support records, which are like C’s structs. Edit: no, it has real objects, as stated in comments below.

OCaml has a sophisticated object system. See:

https://realworldocaml.org/v1/en/html/objects.html

You can do a lot of traditional 'OO'-style things with functors and modules, though, so you don't need objects necessarily to get a lot of OO features.

Re: Teaching OCaml

#7
post #3

> OCaml is a high-level language that supports […] object-oriented programming style AFAIK OCaml only support records, which are like C’s structs. Edit: no, it has real objects, as stated in comments below.

OCaml is (somewhat unconventionally) object-oriented; it has classes, inheritance, what-have-you. The 'O' in the name stands for "objective". Perhaps you're thinking of SML?

See: http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual005.ht...

Re: Teaching OCaml

#8
I'm surprised EPITA (France) is not on the school list. OCaml is the first language you learn there. Fantastic introduction to algorithms.

Re: Teaching OCaml

#10

I think "all of Ocaml compiles to JS " is a bit optimistic. AFAIK, code using Jane Street's Core stdlib doesn't work. But a lot of Ocaml code should be fine.

This is because Core relies on OS/FFI. I think as long as it isn't using OS/FFI it can compile, although I may be wrong on that count.
Post reply on HN