←back to thread

Learn OCaml

(ocaml-sf.org)
203 points smartmic | 1 comments | | HN request time: 1.654s | source
Show context
mtlynch ◴[] No.44401433[source]
As someone interested in learning OCaml, this felt like a pretty inaccessible introduction.

Having seen "A tour of Elm,"[0] I really prefer that style. The left-hand side (what English readers read first) is an explanation of the concept, then the right side is the code, and the explanation gives you enough details to complete the code.

This introduction doesn't really explain anything, as I guess it assumes you've learned OCaml elsewhere and are just here to practice.

I tried the first exercise, and it felt more like a math problem than an exercise to teach a programming concept:

>Suppose that a variable x exists and is an integer.

>Define a variable x_power_8 that uses three multiplications to calculate x to the power of 8. The only function you are allowed to call is the (*) operator.

>Hint: use auxiliary variables.

So, at first I thought I was supposed to just call multiply eight times, and then I realized that they said you can only call multiply three times. So, you're supposed to do let a = x * x; let b = a * a; let x_power_8 = b * b. But that feels really contrived to me and not like anything I'd write in a real application, even a toy one. If the idea is teaching variables, why not just ask me to declare a variable that represents x plus 1?

[0] https://a-tour-of-elm.axelerator.de/#JSFunctions

replies(7): >>44401712 #>>44402055 #>>44402103 #>>44402781 #>>44403072 #>>44403338 #>>44403850 #
1. ggerules ◴[] No.44402103[source]
Clicking on the introduction dropped you directly into a programming problem... where you actually needed to know some ocaml.

Context is needed... at least some explanation or bridge examples, like... why and what do I need to navigate this particular web landing page.

Website feels like an author exercise in ocaml for js web plugin.