12 ms·
The unbalanced brace is a disturbing choice. Why not go either full braces (C, Java) or full space significant (Python)? Fully capitalized keywords make my car
by hota_mazi 10y ago
The unbalanced brace is a disturbing choice. Why not go either full braces (C, Java) or full space significant (Python)?
Fully capitalized keywords make my carpal tunnel syndrome self recoil. Probably inspired from Modula 2 or BASIC?
At least I give the creator credit for picking a name that will be easy to search :-)
- pmontra 10y agoReally. I thought about that when I saw Ruby 10 years ago and didn't like to type end to close blocks. However 1. Space { } are three characters like e n d and using the idiomatic do when needed is only one more character (and the editor types end for me) 2. It looks better than an orphaned } Other solutions: 1) Erlang has , instead of ; and . instead of } A long list of .s is not idiomatic (doesn't happen) but it would be pointless (pun intended) in a language where it does. 2) swallow the pill and use both braces. Going the Python way (I suggest not using the : ) would be a radical change. I also don't like the shouted COBOLish keywords. Were they necessary? Thumbs up for the new regexp switch statement.
- hota_mazi 10y agoI prefer the braces over END not because of the character count but because my brain can't avoid reading "end" when I read the code, while closing braces don't cause a word to pronounced in my mind. Also, just like you, I find that closing cascade of ENDs in nested statements is visual noise.
- pmontra 10y agoA cascade of end or a cascade of } is a bad smell about the code. I try my best to avoid that. Python has a solution to that problem but I think it's worse than the problem. end and } never gave me as many bugs in 30 years as having to reindent in Python did in one year.
- innocentoldguy 10y agoI like Python's relevant whitespace. It forces sloppy coders to organize their code in a more readable fashion. People who use tabs throw a wrench into the works, of course, but forcing them to fix the issues they've caused typically ensures it won't happen again. I have written Python code since version 1.9 was first released, back in the 1990s, and I've worked on many large Python teams where we never ran into any issues with whitespace at all. We all set our tabs to 4 spaces, adhered to PEP8 formatting, and everything went as smoothly as any other language. I think it may just be what you're used to too.
- innocentoldguy 10y agoThat is an interesting reason. It may seem small, but I think it is a perfectly valid point. I'm of the opposite opinion, but for similar reasons. I type using the Dvorak layout, and typing curly braces is a bigger pain in the nipple than typing "end." For me, "end" also makes reading code blocks easier, because it looks like the end of a paragraph. In other words, the fact that it does read like a sentence makes it stand out more for me than curly-braces do; especially when coders, who obviously have no style, put the opening curly-brace on the same line as the function definition or control loop. Hehe. I think it is interesting to contemplate the subjective aspects of languages and syntax preferences. Probably not productive, but interesting none the less.
- pmontra 10y agoSpeaking of subjectivity, if (condition) { ... } is the only readable option :-) if (condition) { ... } drowns the code in a sea of (subjective) noise. There are many other variants https://en.wikipedia.org/wiki/Indent_style#Placement_of_braces https://en.wikipedia.org/wiki/Indent_style#Placement_of_brac... and wars have been fought over them. There are pros and cons for most of them. My tradeoff is the K&R style. I think editors can automatically convert among styles nowadays. The only thing that matters is consistency.
- kutkloon7 10y ago"Back in the days" when I was programming QBASIC, which uses capitalized keywords, it was really easy to spot typos in keywords. You could just write in lowercase, and the IDE would convert your keywords to uppercase if you didn't make a typo. While I admit that it looks kind of ugly, it is actually a huge practical advantage.
- nonsince 10y agoPython's colon is not for the sake of the compiler (you could theoretically parse a version of Python without them), there were studies that showed that it's easier for humans to read with it than without. A lot of Python's design decisions were made because it's easier for humans to read and write (keyword operators, whitespace syntax, explicit return).
- yxhuvud 10y agoPutting regexes in multi-choices like that is not a new idea - you can also do it in Ruby: case "foo" when /hello/ when /oo/ puts "hi" end I guess the new thing is having to state that it is a regex, which I assume is needed as the langauge here don't seem to have regex literals but are reusing strings (seriously, why do languages keep doing that? Did they learn nothing at all from Perl?)