3 ms·
I hate to sound extremely petty, but I just can't stand a modern language that insists on using semicolons. Just Don't Do It, please.
by singular 16y ago
I hate to sound extremely petty, but I just can't stand a modern language that insists on using semicolons. Just Don't Do It, please.
- pcwalton 16y agoRust developer here. In Rust, the semicolon is the expression sequencing operator (like in ML), not a statement terminator. "a;b" means "evaluate a, throw away the result, and return the result of evaluating b". So the semicolon is more than just boilerplate. I guess we could do some sort of automatic semicolon insertion like JavaScript, but I'm not sure that the benefits outweigh the complexity.
- singular 16y agoHey - I know this is trivial, but I just find it takes away from the clarity of the code when you must terminate lines with a semicolon. It's obviously very useful to use ';' in the scenario you mention, I think a good comparison is F# which doesn't force semicolons but does permit usage like that. I guess, e.g.:- foo bar baz implies foo |> ignore; bar |> ignore; baz Oh, and just to make it very clear, I am talking about something really rather petty, I do not mean to do down rust in any serious way - I'm a wannabe-language designer myself, so major respect to you guys :)
- ajb 16y agoThere was a longish discussion on the bitc language development list on exactly this issue. I think this is the first message: http://www.mail-archive.com/bitc-dev@coyotos.org/msg02389.html http://www.mail-archive.com/bitc-dev@coyotos.org/msg02389.ht.... Looks like they ended up with automatic insertion: http://www.bitc-lang.org/docs/bitc/spec.html#layout http://www.bitc-lang.org/docs/bitc/spec.html#layout
- singular 16y agoCool; interesting to see how it's done elsewhere. In go:- http://code.google.com/p/go/source/browse/src/cmd/gc/go.y http://code.google.com/p/go/source/browse/src/cmd/gc/go.y /* * Go language grammar. * * The Go semicolon rules are: * * 1. all statements and declarations are terminated by semicolons. * 2. semicolons can be omitted before a closing ) or }. * 3. semicolons are inserted by the lexer before a newline * following a specific list of tokens. * * Rules #1 and #2 are accomplished by writing the lists as * semicolon-separated lists with an optional trailing semicolon. * Rule #3 is implemented in yylex. */ But obviously this is very language-specific and given the case discussed above likely not to work in quite the same way.
- dkarl 16y agoI'm a longtime C++ (semicolons everywhere) and Python (no semicolons) programmer who has also used and very much enjoyed Common Lisp and Scheme (no semicolons, but parens everywhere.) Right now I'm learning Scala (semicolons usually optional but occasionally required.) After my experience with all those languages, honestly, I don't care at all whether Rust uses semicolons or not. I like Python's meaningful whitespace, but the lack of semicolons is only a side effect of that, not the primary benefit. Optional semicolons in Scala actually seem like a bit of a wart since you get used to leaving them out but on rare occasions have to include one to make the code mean what you want. Putting them in all the time provides a nice visual cue and doesn't cost anything. Like the parens in Lisp, they disappear as long as they're where you expect them.
- jemfinch 16y agoI hate automatic semicolon insertion. They complicate the language. Here's the rule for a language that uses semicolons to terminate statements: 1. Semicolons terminate statements. Look at the rules for Go semicolon usage[1] or Javascript semicolon usage[2] or Python newline usage[3]. They're not simple. Entire essays can be and have been written describing the complexity introduced by saving programmers that single keystroke. Maybe I'm crazy, but I want my tools to be simple. I would much rather type a thousand extra semicolons than spend extra hours internalizing the statement termination rules of the languages I use. [1] http://groups.google.com/group/golang-nuts/browse_thread/thread/5ee32b588d10f2e9 http://groups.google.com/group/golang-nuts/browse_thread/thr... [2] http://inimino.org/~inimino/blog/javascript_semicolons http://inimino.org/~inimino/blog/javascript_semicolons [3] http://docs.python.org/reference/lexical_analysis.html http://docs.python.org/reference/lexical_analysis.html
- onan_barbarian 16y agoYou know, I've got a bike shed that doesn't look the best. What color do you reckon we should paint it?
- singular 16y agoI see what you're saying, but to me syntax isn't a bikeshedding issue. And I did preface my comment with 'I hate to sound extremely petty'.