Earlier 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…
Syntax Matters...?
41–44 of 44 posts
Re: Syntax Matters...?
#42It 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…
While I agree with your ideas about the "syntax weight", I think that you're wrong about Java. 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 fun…
For example, C# supports function types, but it can have hundreds of function types (it calls them delegate types) for a function that takes one int and returns one int:
delegate int Func1(int x);
delegate int Func2(int x);
delegate int Func3(int x);
and so on; all these function types are incompatible with one another.I believe the distinctive feature of closures is closing over (hence the name) the outer lexical environment and binding to variables in the outer environment, in such a way that those variables are available during evaluation. Which is exactly what an anonymous class lets you have (so long as locals in the outer scope are declared final).
Re: Syntax Matters...?
#43Earlier 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…
Haskell's actual syntax is actually quite readable — I'd say it's maybe second to Python. Where Haskell gets hard to read is in library code with lots of custom operators, where you have to remember the difference between **> *> *>* >*> >** But that's not really Haskell's syntax, it's just a combination of libraries with lots of unfamiliar operators.
Re: Syntax Matters...?
#44Frankly, 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…
Haskell was a particularly obnoxious one - I love a lot of the concepts, but I find it horribly slow for me to read. I got so frustrated with it that I implemented a small little lambda calculus interpreter to play with the concepts because that ended up being an easier way for me to learn them than to wrestle with Haskell.
Personally I don't think Haskell will ever become mainstream to a large extent because it is too hard to read for people who are not maths geeks.