Re:Rust creator Graydon Hoare is now at Apple working on Swift
by sfilargi on Tuesday January 31, 2017 @02:06PM
(#13534047)
> 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?
Re:Rust creator Graydon Hoare is now at Apple working on Swift
by darksaints on Tuesday January 31, 2017 @02:11PM
(#13534106)
Yes. 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.
Re:Rust creator Graydon Hoare is now at Apple working on Swift
by saghm on Tuesday January 31, 2017 @02:49PM
(#13534533)
The 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.
Re:Rust creator Graydon Hoare is now at Apple working on Swift
by dllthomas on Wednesday February 01, 2017 @03:12PM
(#13544609)
> the structure of English sentences
Or possibly French sentences...
Re:Rust creator Graydon Hoare is now at Apple working on Swift
by saghm on Saturday February 04, 2017 @01:30PM
(#13568201)
Good 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.
Re:Rust creator Graydon Hoare is now at Apple working on Swift
by lobster_johnson on Tuesday January 31, 2017 @02:47PM
(#13534504)
As 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.)
Re:Rust creator Graydon Hoare is now at Apple working on Swift
by milesrout on Tuesday January 31, 2017 @07:10PM
(#13536797)
Using any capital letters in code is an instant point away from a language IMO. Having to press Shift sucks.
Re:Rust creator Graydon Hoare is now at Apple working on Swift
by mookid11 on Tuesday January 31, 2017 @02:42PM
(#13534447)
I think this is the first time I see anyone like the OCaml syntax.
Re:Rust creator Graydon Hoare is now at Apple working on Swift
by macintux on Tuesday January 31, 2017 @03:03PM
(#13534666)
I'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.
Re:Rust creator Graydon Hoare is now at Apple working on Swift
by chwind on Tuesday January 31, 2017 @03:10PM
(#13534736)
what is a function head?
Re:Rust creator Graydon Hoare is now at Apple working on Swift
by ZephyrP on Tuesday January 31, 2017 @03:23PM
(#13534836)
In 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.
Re:Rust creator Graydon Hoare is now at Apple working on Swift
by macintux on Tuesday January 31, 2017 @06:26PM
(#13536454)
If 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).
Re:Rust creator Graydon Hoare is now at Apple working on Swift
by aaron-santos on Tuesday January 31, 2017 @03:30PM
(#13534896)
Pattern matching can be used in the parameter list of function's definition.
Re:Rust creator Graydon Hoare is now at Apple working on Swift
by sfilargi on Tuesday January 31, 2017 @02:59PM
(#13534627)
I think I like Reason's syntax better, but can't say I dislike Ocaml's.
Re:Rust creator Graydon Hoare is now at Apple working on Swift
by kibwen on Tuesday January 31, 2017 @04:37PM
(#13535492)
And I believe Reason's syntax was inspired by Rust, so we've come full circle. :P
Re:Rust creator Graydon Hoare is now at Apple working on Swift
by querulous on Tuesday January 31, 2017 @02:31PM
(#13534346)
early rust looked a lot like an ocaml/erlang hybrid. green threads and immutability were the entire concurrency story for a long time, in my recollection. it wasn't until later that rust started to look like a safer c++
While I wouldn't say that it wasn't a systems language, I would say that it was far more focused on higher level coding than the current rust is. Which is fine IMO...the world can benefit from a new safe low level language far more than it needs a new application-level language. But for someone who really liked the early ideas of rust, swift makes a lot of sense as a substitute.