News for hackers. Stuff that matters.
Re:Rust 1.0: Status report and final timeline by pcwalton on Friday February 13, 2015 @03:21PM (#9046944)
The natural thing to want in a C-like syntax is the "arrow function" closure syntax (like ES6 or C#), but that required too much lookahead to parse. Having a keyword discourages functional style, which would be a shame in a language with a powerful iterator library. So Rust went with the Ruby/Smalltalk-style bars, which are nice, concise, and easy to parse.
Re:Rust 1.0: Status report and final timeline by alextgordon on Friday February 13, 2015 @06:16PM (#9047827)
It seems like the human parser should be given priority over the computer parser, when considering what is easy and what is hard. The machines work for us!
Re:Rust 1.0: Status report and final timeline by gnuvince on Friday February 13, 2015 @07:50PM (#9048206)
As far as I know, Rust now has an LL(1) grammar, which means that writing parsers for it can be done by hand (or with the more powerful LALR(1) and LR(1) parser generators). This is very important for humans too, because it means more people are likely to write tools to process Rust code. If you hope to have automatic indentation, auto-completion, refactoring, formatting tools, etc. keeping the syntax simple is really important.
Re:Rust 1.0: Status report and final timeline by nostrademons on Friday February 13, 2015 @08:52PM (#9048399)
Can't they just expose the parser as a library? Actually, it looks like they did, with the rustc crate.

Hand-writing a parser for some other language leads to madness - just ask the folks who've done SWIG, GDB, or most IDE syntax-checkers. You'll inevitably get some corner-cases wrong, or the language definition will change underneath you long after you've ceased to maintain the tool. Instead, the language should just expose its compiler front-end as a library, and then you can either serialize the AST to some common format for analysis outside the language or build your tools directly on top of that library.

Re:Rust 1.0: Status report and final timeline by jpgvm on Saturday February 14, 2015 @01:03AM (#9048896)
You missed the whole point.

By making the language simple you can easily implement your own parser. This opens up the ability to write native parsers in other languages, say vimscript. By keeping it super simple there -are- no corner-cases.

There are many benefits to this (like the formatters etc that others have alluded to) from things like IDE integration (imagine lifetime elision visualisation, invalid move notifications, etc) static analysis tools and more. None of these tools then need to be written in Rust. It also means it's easier to implement support in pre-existing multi-language tools.

Don't underestimate the necessity of a simple parseable grammar. Besides, people have endured much worse slights in syntax (see here Erlang).

Re:Rust 1.0: Status report and final timeline by nostrademons on Saturday February 14, 2015 @12:34PM (#9050157)
The vim formatters/syntax checkers I've used that actually try to parse the language - other than Lisp, which is the limiting case - are generally terrible. They all miss some corner case that makes them useless for daily work, since they generate too many false-positives on real code.

The ones I actually use all call out to the actual compiler - Python, Go, or Clang for C++.

Just because people write their own parsers doesn't make it a good idea. It may've been necessary when most compilers were proprietary and people didn't have an idea how to make a good API for a parser. But now - just don't do it. You'll save both you and your users a lot of pain.

Re:Rust 1.0: Status report and final timeline by erickt on Saturday February 14, 2015 @03:02AM (#9049085)
We are not quite ready to support users of libsyntax and librustc as we are very serious about keeping our stable api stable, and freezing those apis would really impact the future development of the compiler, so it will not be exposed in rust 1.0. We want to eventually get something for this purpose though.
Re:Rust 1.0: Status report and final timeline by ponce on Saturday February 14, 2015 @11:11AM (#9049966)
That's what D does, it has infinite look-ahead in cases and there are still multiple parsers available as libraries.
Re:Rust 1.0: Status report and final timeline by kibwen on Friday February 13, 2015 @06:24PM (#9047855)
This human parser happens to prefer Rust's closure syntax to any other language's. :) Well, for usage, anyway... the written-out type of a closure for use in function signatures is not nearly as concise.
Re:Rust 1.0: Status report and final timeline by tarblog on Friday February 13, 2015 @07:55PM (#9048228)
How much worse is it? Can parsing actually be so expensive that it dictates the syntax of the language?
Re:Rust 1.0: Status report and final timeline by Retra on Saturday February 14, 2015 @01:05AM (#9048900)
Parsing a context free grammar in general is O(n^3), but parsing an LL(1) grammar is O(n). That's a pretty huge difference, if you're not careful. Imagine you've got a million lines of code to parse.