6 ms·
> It seemed there was a lot of focus on the more ML-ish aspects of its roots, such as the module system. The language also had a convincing future story for bo
by sfilargi 10y ago
> It seemed there was a lot of focus on the more ML-ish aspects of its roots, such as the module system. The language also had a convincing future story for both green threads and garbage collection.
So, OCaml?
- darksaints 10y agoYes. In fact, the original compiler was written in OCaml. I would say the original intent was to be a lower level OCaml with optional safe control over allocation behavior and safe parallelism. I think he would probably have preferred OCaml syntax too. Notice some of the idioms, and even the capitalization/underscore norms (UpperCamelCase for types, snake_case for functions) are very similar to OCaml. But C syntax provides a theoretical adoption benefit, so I think he was willing to deal with that.
- mookid11 10y agoI think this is the first time I see anyone like the OCaml syntax.
- sfilargi 10y agoI think I like Reason's syntax better, but can't say I dislike Ocaml's.
- kibwen 10y agoAnd I believe Reason's syntax was inspired by Rust, so we've come full circle. :P
- macintux 10y agoI've not looked at OCaml, but when I discovered that ML's pattern matching works for function heads, I immediately became more interested. Pattern matching for function heads is magical. Thus sayeth the Erlang fanboi.
- chwind 10y agowhat is a function head?
- ZephyrP 10y agoIn some languages, a function can be defined multiple times with different signatures (multiple 'heads'). It will try each clause until it finds one that matches, allowing you to filter or change course on the basis of the value or characteristics of the arguments. This allows you to easily create special logic for corner cases and is generally extremely useful.
- aaron-santos 10y agoPattern matching can be used in the parameter list of function's definition.
- macintux 10y agoIf you look at the Wikipedia article for Greatest Common Divisor, you see this: gcd(a, 0) = a gcd(a, b) = gcd(b, a mod b) That, in effect, is what pattern matching + function heads gives you. You can copy that function directly into ML or Erlang, modulo a couple tiny bits of syntax. gcd(A, 0) -> A; gcd(A, B) -> gcd(B, A rem B).
- lobster_johnson 10y agoAs I recall, early Rust versions used lowercase for non-built-in type names, too, which I found unnerving. I'm glad they changed that, though I wish they'd also moved to use camelCase for non-type identifiers. (As an aside: Surely the capitalized version of snake_case is Snake_Case, not SnakeCase. Very few languages are consistent here.)
- milesrout 10y agoUsing any capital letters in code is an instant point away from a language IMO. Having to press Shift sucks.
- saghm 10y agoThe weirdest OCaml syntax (to me) is the way that that exceptions are essentially reversed camel case mixed with snake case (e.g `Not_found`, `Division_by_zero`). I assume that this was to try to imitate the structure of English sentences, but it feels bizarre to me when I see it in code.
- dllthomas 10y ago> the structure of English sentences Or possibly French sentences...
- saghm 10y agoGood point, I forgot that OCaml is French. On a related note, I've heard that might be related to why the common style is to prefix the colon used for type annotations with a space, whereas in some other languages with that syntax (e.g. Rust and Scala), it's more common to see no space before the colon.