Linked by Thom Holwerda on Wed 3rd Apr 2013 15:41 UTC
Mozilla & Gecko clones Big news from Mozilla and Samsung today: the two have been working on a new browsing engine together, developed from the ground-up to be completely new, and it's written entirely in Rust, a new safe systems language developed by Mozilla. "Rust, which today reached v0.6, has been in development for several years and is rapidly approaching stability. It is intended to fill many of the same niches that C++ has over the past decades, with efficient high-level, multi-paradigm abstractions, and offers precise control over hardware resources. But beyond that, it is safe by default, preventing entire classes of memory management errors that lead to crashes and security vulnerabilities. Rust also features lightweight concurrency primitives that make it easy for programmers to leverage the power of the many CPU cores available on current and future computing platforms." The work is on-going, but of course, all code is out there right now.
Thread beginning with comment 557444
To read all comments associated with this story, please click here.
this language is fugly
by kristoph on Wed 3rd Apr 2013 17:16 UTC
kristoph
Member since:
2006-01-01

Rust

for ["Alice", "Bob", "Carol"].each |&name| {
..do spawn {
....let v = rand::Rng().shuffle([1, 2, 3]);
....for v.each |&num| {
......print(fmt!("%s says: '%d'\n", name, num))
....}
..}
}


Ruby (as an example)

["Alice", "Bob", "Carol"].each do | name |
..Thread.new( name ) do | name |
....[1,2,3].shuffle.each do | number |
.......puts "%s says: '%d'" % name, number
....end
..end
end


Why make a modern language so verbose and distasteful.

Edited 2013-04-03 17:29 UTC

Reply Score: 3

RE: this language is fugly
by Thom_Holwerda on Wed 3rd Apr 2013 17:26 in reply to "this language is fugly"
Thom_Holwerda Member since:
2005-06-29

Does that matter? Genuine question - I'm no programmer - but isn't its functionality and benefits more important than how it looks?

Reply Parent Score: 2

RE[2]: this language is fugly
by M.Onty on Wed 3rd Apr 2013 18:06 in reply to "RE: this language is fugly"
M.Onty Member since:
2009-10-23

If you can reach everything you need to in a room, and its not got mold, lice, cockroaches or rats, then any further cleanliness is theoretically pointless. And yet, for some reason, a clear room makes for a clear mind.

So strictly speaking no, it doesn't matter, except that it makes it easier to type quickly and understand when reading, which you'll get the hang of in time in any case. But in our minds a clean aesthetic to the language implies a clean aesthetic to the architecture and methods. That's quite important, especially when a programmer spends more time staring at the text file than the actual resultant program.

Reply Parent Score: 6

project_2501 Member since:
2006-03-20

Readability, expressability, logical conistency, avoiding ambiguity, synactic ease .. are all incredibly important.

You can do all you want with assessmbly language but you wouldn't.

Human considerations of readability and understandability by someone who wasn't the original author is really really important when doing anything above a certain human scale.

And even if it was a small human scale - ie just you coding - the ability to easily translate human ideas into code .. and back... is really key.

Python was popular for minimising the leap between human mind and code... other languages are great for supreme consistency and architectural logic.

Reply Parent Score: 7

lucas_maximus Member since:
2009-08-18

Generally yes. Readability is important, since most of your day is spent reading code rather than writing it (Today I maybe spent a solid 30 minutes writing code out of my 9 hour shift).

Ruby and the Rust Syntax demonstrated has some familiarities with Visual Basic. Most programmers hate Visual Basic mainly due to its syntax and partly because a lot of awful code is written in it.

I find that Syntax hard to read especially since the characters in both examples mean completely different things in C like languages, VB and Python (not sure about others).

Reply Parent Score: 4

RE[2]: this language is fugly
by renox on Thu 4th Apr 2013 08:26 in reply to "RE: this language is fugly"
renox Member since:
2005-07-06

but isn't its functionality and benefits more important than how it looks?


Not really, otherwise we would all be using Lisp..
Then again C++ syntax is not that good either..

Reply Parent Score: 2

RE[2]: this language is fugly
by darknexus on Thu 4th Apr 2013 09:41 in reply to "RE: this language is fugly"
darknexus Member since:
2008-07-15

Does that matter? Genuine question - I'm no programmer - but isn't its functionality and benefits more important than how it looks?

It's not looks so much as code readability. If you want to bring in new contributors eventually, you want your code to be as readable as possible with as little effort as possible especially when you're dealing with something as complex as a web rendering engine. A language can look like crap so long as it's readable but, if it's stuffed full of unnecessary syntactic elements as Rust is, it's counter-productive. It takes longer to read, longer to review, longer to code, and introduces a much greater chance for mis-typing a punctuation mark that really shouldn't be needed. The code snippet at the start of this thread is a perfect example: what in hell do you need with all those | and & signs when there are much simpler ways to express that concept? I shouldn't be surprised though. This is Mozilla at work, and these are probably the same people that thought the bloated beast known as XUL was a good idea for a cross-platform UI toolkit.

Reply Parent Score: 2

RE: this language is fugly
by Coxy on Wed 3rd Apr 2013 17:48 in reply to "this language is fugly"
Coxy Member since:
2006-07-01

Yeah, like ruby is so much more readable and concise lol

Reply Parent Score: 5

Bill Shooter of Bul Member since:
2006-07-14

I'd agree. They're both kind of fugly. If I had to choose, I'd probably prefer the rust syntax. Plus its supposed to be lower level, which is nice. But, I'm not in too big of a hurry to adopt a language that's "rapidly approaching stability".

Reply Parent Score: 3

RE[2]: this language is fugly
by kristoph on Thu 4th Apr 2013 02:19 in reply to "RE: this language is fugly"
kristoph Member since:
2006-01-01

Your really missing the point. Ruby may not be your cup of tea but it's syntactically consistent. Just read that Rust example ...

- what is the value of 'let'; obviously the compiler can implicitly identify new variables (notice there is no type declaration)

- why pair for and each, don't both implicitly mean the same thing (they do in most languages)

- why do I need to put do in front of a spawn which takes a closure as it's param (there is no good reason, it's just how they decided it should be)

If you try to learn Rust you'll see it's full of these dumb arbitrary decisions. It's like French and masculine and feminine verbs. There are some rules and then there is stuff that just is. French has an excuse, it's developed over thousands of years, a modern computer language should be better thought out.

Reply Parent Score: 2

RE: this language is fugly
by Rahul on Wed 3rd Apr 2013 19:04 in reply to "this language is fugly"
Rahul Member since:
2005-07-06

Well, Rust is at 0.6 and the syntax is at a rapidly evolving stage. So feel free to get involved if you are motivated enough to do something concrete.

Personally, I don't see how the Ruby syntax is going to be more appealing to C++ programmers which is the target of Mozilla.

Reply Parent Score: 2

cyrilleberger Member since:
2006-02-01

Personally, I don't see how the Ruby syntax is going to be more appealing to C++ programmers which is the target of Mozilla.


Personally I don't see how the rust syntax is going to be appealing to C++ programmers. Especially since Rust is meant as a replacement of C++, while Ruby is not. Personally, I use C++ and Ruby, but for different purposes, and I wouldn't use C++ for what I do in Ruby (ie scripting, prototyping) or Ruby for C++. Different purposes, different syntax.

Now why rust is not appealing for C++ developers (at least me), it is needlessly different from C++.

Rust: fn recursive_factorial(n: int) -> int
C++: int recursive_factorial(int n)

Rust: for(somevector.each |&name|)
C++: for(auto name : somevector)

And so on. Meaning that a C++ developers would have to anyway learn a new programming language.

It is true that having a new syntax is not necessarily a bad idea, however, from looking at the rust examples it looks as quirky as C++, but in different ways. So why jump ship from C++ to Rust if it is not for improvements ?

Reply Parent Score: 3

RE: this language is fugly
by Hiev on Wed 3rd Apr 2013 19:13 in reply to "this language is fugly"
Hiev Member since:
2005-09-27

Well smart ass, put the C++ equivalent and lets compare.

And what with these hipsters that see verbose as an insult?

Edited 2013-04-03 19:16 UTC

Reply Parent Score: 3

RE[2]: this language is fugly
by kwan_e on Thu 4th Apr 2013 00:14 in reply to "RE: this language is fugly"
kwan_e Member since:
2007-02-18

Well smart ass, put the C++ equivalent and lets compare.

And what with these hipsters that see verbose as an insult?


Actually, I think with C++11, you can write C++ in basically the same way as either of them with not that much more verbosity.

Reply Parent Score: 2

RE[2]: this language is fugly
by kwan_e on Thu 4th Apr 2013 03:04 in reply to "RE: this language is fugly"
kwan_e Member since:
2007-02-18

Rust:

for ["Alice", "Bob", "Carol"].each |&name| {
..do spawn {
....let v = rand::Rng().shuffle([1, 2, 3]);
....for v.each |&num| {
......print(fmt!("%s says: '%d'\n", name, num))
....}
..}
}


C++ (tested in Cygwin with GCC 4.7.x):

for( auto name : { "Alice", "Bob", "Carol", "David", "Enid",
           "Fr an", "Gunther", "Harold", "Iris", "Jen" } )
{
  std::async( std::launch::async, [name]()
  {
    std::vector<int> numbers { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    std::random_shuffle( std::begin(numbers), std::end(numbers) );
    for( auto number : numbers )
    {
      std::cout << name << " says: " << number << std::endl;
    }
  });
}


Edited 2013-04-04 03:07 UTC

Reply Parent Score: 3

RE: this language is fugly
by elvstone on Wed 3rd Apr 2013 20:05 in reply to "this language is fugly"
elvstone Member since:
2005-09-08

Seriously? _One_ example. A comparison to _one_ other programming language. And the difference is _one_ more line of code. And you discard the entire language as "verbose" and "distasteful"? I haven't even read about the language yet, but that's just ridiculous.

Reply Parent Score: 3

RE: this language is fugly
by panzi on Wed 3rd Apr 2013 20:45 in reply to "this language is fugly"
panzi Member since:
2006-01-22

I don't understand why people use that Ruby syntax. I think this is better (more concise, less of a finger twister on German keyboards and more readable):


for name in ["Alice", "Bob", "Carol"]
..Thread.new( name ) do | name |
....for number in [1,2,3].shuffle
.......puts "%s says: '%d'" % name, number
....end
..end
end


But then I also think that one of Rubys biggest problems is it's redundancies (in syntax and interfaces). It causes strange syntax errors (the crappy parser errors aren't any help either) and lower readability/consistency (one team member uses variant A, the other variant B - then they have to read and understand each other's code).

I like the philosophy behind Python much much more, even though a way to inline declare and pass a multiline anonymous function to another function would be nice (-> Ruby's blocks). But many things for which blocks are used in Ruby can be done with the with statement in Python and Python's generators are more powerful than anything in Ruby.

Reply Parent Score: 3

RE[2]: this language is fugly
by kristoph on Thu 4th Apr 2013 02:37 in reply to "RE: this language is fugly"
kristoph Member since:
2006-01-01

I was not really making a comment about the benefit/advantage of Ruby. I was just pointing out that it was much cleaner syntactically. Python is fine too (and even less verbose). Heck, even Objective C is nicer then Rust to my eye.

All I am saying is if your trying to build a new language make it VERY readable, do away with addition keywords and constructs that don't add tangible meaning, try to maintain consistency in syntax and not require arbitrary 'grammar' or abbreviations.

Reply Parent Score: 2

RE: this language is fugly
by chandler on Wed 3rd Apr 2013 20:46 in reply to "this language is fugly"
chandler Member since:
2006-08-29

Rust is a static, safety-oriented language targeted at the same niche as C++. It's a genuine achievement to have the Rust example demonstrate the same level of expressivity as the Ruby version.

Of course there's still too much special syntax in both versions. :-)

#lang typed/racket

(for ((name '("Alice" "Bob" "Carol")))
  (thread
   (thunk
    (for ((number (shuffle '(1 2 3))))
      (printf "~a says ~a\n" name number)))))

Edited 2013-04-03 20:47 UTC

Reply Parent Score: 3

RE[2]: this language is fugly
by moondevil on Thu 4th Apr 2013 06:43 in reply to "RE: this language is fugly"
moondevil Member since:
2005-07-08

There are static compiled versions of Ruby.

Check Crystal,

https://github.com/manastech/crystal

Reply Parent Score: 2

RE: this language is fugly
by vivainio on Wed 3rd Apr 2013 20:46 in reply to "this language is fugly"
vivainio Member since:
2008-12-26

Why make a modern language so verbose and distasteful.


Rust has to support much more stuff than Ruby; it has 3 pointer types for starters, IIRC.

Rust does ok IMO, considering the complexity of concepts it needs a way to express (dynamically typed languages without pointers get off easier in comparison).

Reply Parent Score: 3

RE: this language is fugly
by thesunnyk on Thu 4th Apr 2013 00:29 in reply to "this language is fugly"
thesunnyk Member since:
2010-05-21

As someone who's done embedded programming, I love Rust. So I'm really resisting the urge to say something nasty about your upbringing.

Ruby and Rust are completely different beasts. Rust is completely interoperable with C, and could conceivably be used in writing an operating system, or OS-level code. You'd have to compare it to something like Go as opposed to Ruby, and even Go would be considered higher level.

Considering where it sits on the spectrum of where you can execute Rust, the language is nicer than anything you could come up with.

And Ruby is a bloated, slow and awful language and you're a terrible person and I hope everyone gets cupcakes except you.

Reply Parent Score: 3