4 ms·
Clojure made me realize that both of these styles are silly. Why do you need hashrockets, colons, or even commas? Why do you need a key/value separator AND a pa
by jcromartie 15y ago
Clojure made me realize that both of these styles are silly. Why do you need hashrockets, colons, or even commas? Why do you need a key/value separator AND a pair separator?
They might be useful as separators sometimes, but why are the absolutely required? They seem like noise. Anyway... I'll stick with hashrockets because the colon at the end is just confusing.
- yock 15y agoNot everything is about simplification or minimization. Much like serifs on fonts, syntax aids readability and therefore understanding. Not needing to study the wider context to determine if some collection declaration is a list or hash is invaluable to my time.
- chc 15y agoClojure's Lisp roots make its minimalistic hashes possible. There is a possible reason for separators in a language that doesn't have special syntax for function application (e.g. function calls can be written as "foo bar" rather than "(foo bar)" or "foo(bar)"), but Ruby doesn't take advantage of it. Take this map: { foo: capitalize bar, baz: sanitize quux } Without the punctuation, it would be very ambiguous: { foo capitalize bar baz sanitize quux }
- rayiner 15y agoI cringe at the thought of whitespace as an infix operator...
- chc 15y agoThat's not really the right way to look at it. Function application is just the default interpretation of two juxtaposed symbols. It's not any worse than "new MyObject()", which has whitespace acting just as much like an infix operator. There's no inherent reason why you'd need a special operator to apply "capitalize" but not "-" or "new" or "def". That's just how C does it, and by an accident of history most mainstream languages just parrot C by default.
- jcromartie 15y agoI don't know about Ruby 1.9, but in 1.8, you can't do (for example): { :foo => rand 40 } It requires parens. So Ruby seems to enforce some limit where it's too ambiguous.