Syntax Matters...?
31–40 of 44 posts
Re: Syntax Matters...?
#32It is important, however, to distinguish between syntax and expressiveness. I don’t care (too much) whether you write function(x) { ... }, \x -> ... or { |x| ... } to denote a closure, but there had better be a way to write a closure somehow! (Java, I’m looking at you here) Java is the refutation, IMO: it does have a way to express a closure, it's just that the syntax (anonymous class) is laborious. You need to wrap…
Re: Syntax Matters...?
#33Frankly, I've stopped using languages, or lost interest in learning languages, entire over "small" syntax issues. Syntax is a bigger potential deal-breaker to me than functionality in many cases - I spent many times more time reading code than molding my mental model of what I want to do into something I can write down as code in a particular language. If I can't read and scan code quickly, the language is dead to me…
I empathize. I have a hugely hard time reading code, which is why I tend to use Python wherever I'm able (and even Python's a bit hard for me to read, but it's certainly better than most). However, I also think it's a little sad to limit your selection of languages strictly due to syntactic concerns, without any consideration of features whatsoever. Some languages that are utterly unreadable (I'm looking at you, Hask…
Re: Syntax Matters...?
#34Earlier quoted context omitted.
I empathize. I have a hugely hard time reading code, which is why I tend to use Python wherever I'm able (and even Python's a bit hard for me to read, but it's certainly better than most). However, I also think it's a little sad to limit your selection of languages strictly due to syntactic concerns, without any consideration of features whatsoever. Some languages that are utterly unreadable (I'm looking at you, Hask…
I suspect you find Haskell difficult to read not because of its syntax--which is actually rather readable and surprisingly simple--but because it basically shares almost nothing with other languages you know (e.g. Python).
Re: Syntax Matters...?
#35Re: Syntax Matters...?
#36Its like you will not work for a company because it have clean toilets, but if they have dirty toilets you wont work for them
If you find this logic familiar, its because i am basing it on motivation theory
Re: Syntax Matters...?
#37It is important, however, to distinguish between syntax and expressiveness. I don’t care (too much) whether you write function(x) { ... }, \x -> ... or { |x| ... } to denote a closure, but there had better be a way to write a closure somehow! (Java, I’m looking at you here) Java is the refutation, IMO: it does have a way to express a closure, it's just that the syntax (anonymous class) is laborious. You need to wrap…
Java definitely has no syntax for closures, because it has no semantics for function types. It has interfaces and anonymous classes, which you can use to accomplish the same requirement, but the semantics of interfaces are not 100% the same as that of function types. A small example: there's only one function type for a function that takes one int and returns one int, whereas there are infinitely many interfaces you can define to represent that function type and none of them are necessarily interchangeable among themselves.
I think this distinction is important and that this is what the author is talking about when he says "there had better be a way to write a closure somehow!" In Java, there isn't.
Re: Syntax Matters...?
#38It is important, however, to distinguish between syntax and expressiveness. I don’t care (too much) whether you write function(x) { ... }, \x -> ... or { |x| ... } to denote a closure, but there had better be a way to write a closure somehow! (Java, I’m looking at you here) Java is the refutation, IMO: it does have a way to express a closure, it's just that the syntax (anonymous class) is laborious. You need to wrap…
You make a very good point. However, I think he addresses your concern over "syntactic weight" in this line: Basically, there are some languages whose syntax is so distinctive that it makes a qualitative difference to the experience of programming. I believe his argument then is that of the following three syntaxes (syntaxen?) to describe closures: function(x) { ... } \x -> ... { |x| ... } The differences are so slig…
Re: Syntax Matters...?
#39Earlier quoted context omitted.
You make a very good point. However, I think he addresses your concern over "syntactic weight" in this line: Basically, there are some languages whose syntax is so distinctive that it makes a qualitative difference to the experience of programming. I believe his argument then is that of the following three syntaxes (syntaxen?) to describe closures: function(x) { ... } \x -> ... { |x| ... } The differences are so slig…
The first | in the third example, i.e. {|x| ...}, is redundant. This is the first thing I noticed when I first read up about Ruby over 10 years ago, and it put me off what I now know is a fairly good language. The same thing happened with the leading __ and trailing __ for certain names in Python. Syntax matters as newcomers notice it.
{|x| x}
Trying to rewrite this in your syntax as: {x| x}
could cause ambiguity if you had defined a variable x somewhere up-scope: is that a bitwise OR or is it a closure? True, the correct behavior could probably (maybe?) be inferred from context, but that might require Rust to switch from a simple LR(1) parser to an arbitrary-lookahead parser, which would inflate compilation times.In any case, Ruby's hamburger-notation for closures is well-known by this point, and I'd hardly call it novel anymore. In the case of Python's __special__ methods, the whole point was to discourage people from heavily using them in the first place. Making ugly operations ugly, as it were.
Your point that newcomers might be turned off by a language's syntax remains valid, but you've also demonstrated that newcomers lack the context necessary to be aware of the tradeoffs necessary in language design. But hey, tough shit for language developers, huh? Yes, tough shit indeed. Languages must be familiar enough to attract people, but they must also be sufficiently expressive enough to retain the interest of the people in the community who really matter (the elite hackers and the devoted evangelists), while at the same time seeming novel enough to justify switching away from whatever language you were previously using in that domain.
TL;DR: It's a thorny issue, and simply saying "syntax matters" is an unjust simplification. :)
Re: Syntax Matters...?
#40Earlier quoted context omitted.
Lisp languages have virtually no syntax. Example: Write a function that generates a string of all the numbers in a range from a start and end value. Java (lots of syntax, many tokens): String rangeString(int start, int end) { String oni = ""; for(int i = start; i Clojure (almost no syntax): (defn [start end] (apply str (range start (inc end))))
Ah, okay. So by less syntax you mean fewer syntactic forms (parentheses, curly braces, do notation, etc.) and keywords (class, public, etc.) in the language. I think in general, languages with fewer syntactic forms also have fewer but more powerful abstraction features. Lisps are pretty high up by this measure. They basically only have one abstraction feature: lambda expressions. Other languages have powerful abstrac…