4 ms·
You might be right in aggregate counts, but the difference is that in a C-style language you have different types of fluff: curly braces, parenthesis, semi colo
by AdeptusAquinas 9y ago
You might be right in aggregate counts, but the difference is that in a C-style language you have different types of fluff: curly braces, parenthesis, semi colons etc. So the count of any one type is not overwhelming (unless you let your cyclomatic complexity get away from you). In Lisp its almost all parenthesis, so yes it is more.
Besides which my point is more that why have any of this at all? Only the insane write code without tab or space indentation, and if you are doing that anyway then an OCaml-esque language like F# where that serves as your grouping syntax is the saner option.
- nocman 9y ago"Only the insane write code without tab or space indentation" ^ um, and who exactly suggested that? Certainly not me. And if you think lisp style languages are generally written without tab or space indention, then you clearly haven't read much lisp code. I thought you said you tried Clojure? Clojure's data literals use curly braces (maps, sets), square brackets (vectors) and parens (lists). I think that's a good thing -- they function like parens but are just distinct enough to make the underlying type more obvious. Even so, the parens don't get in the way of scheme/lisp programmers. You really do get used to it (usually even like it) after a while (oh and many scheme's use square brackets for function arguments, etc). "why have any of this at all?" ^ because the parens serve a very important purpose. They group code and data in a very compact, clear, and easily parseable(sp?) way -- a way that allows for extremely powerful manipulation of both. The fact that you don't understand this is evidence that you haven't put in enough effort to appreciate the power of lisp-like languages. I'm not suggesting that you have to like lisp or its syntax, but to suggest that the way it is designed is "insane" is just ridiculous. Using indentation as grouping is by no means "saner" than using parens. Whitespace is too easy to get wrong or to misinterpret. Heaven help you if you try to implement macros that use whitespace for grouping.
- AdeptusAquinas 9y agoCriticising lisp was a mistake, and I should have already ripcorded my way out of this discussion thread already, but you make some good points, so I'll respond at my own peril: I didn't suggest you implied that lisp isn't written without indentation. Yes I have coded with lisp, and I know they use other syntax than just parens. Parens serve an important purpose with lisps, just like the semi colon does in c languages. As a C# programmer I can, and have, written long statements on one line; in particular, LINQ statements lend itself to this if you use the method syntax, which I use exclusively over its query syntax form. To make it readable you break it over lines but terminate with a semi colon to finish: it is still run as a single statement. This is powerful. In F# you can still do this, but it requires that the entire statement start at the appropriate indentation in order for the compiler to infer the closure. Indentation can cause misinterpretations, but I'd argue, at least for me, that the happy case (i.e. 99% of a given codebase) that using indentation instead of parens, curly braces or similar, is a less clutter free way of writing code. And, since its something that is generally done anyway, it makes curly braces/parens redundant. Note that in F# you can use parens as well to group code, if you need to enforce a closure, which is a good design decision: make them optional. C# would be much better, and I would argue (again at my peril) that if it was optional in a lisp-style language as well, that would be great.
- sedachv 9y ago> Yes I have coded with lisp, and I know they use other syntax than just parens... I would argue (again at my peril) that if it was optional in a lisp-style language as well, that would be great. The reason you are getting downvoted is not just because you are criticizing Lisp, it is also because you are posting a bunch of BS without understanding the difference between a context-free and a context-sensitive language. Please learn some basic parsing theory and then you will understand why your suggestion for a white space sensitive syntax for a homoiconic programming language is nonsense.
- leoc 9y agoWell, there was SRFI 49, which wasn't very popular but was supported by Matthias Felleisen.
- nocman 9y ago"parens ... make them optional ... and I would argue (again at my peril) that if it was optional in a lisp-style language as well, that would be great." ^ making parens optional in a lisp would IMHO make everything more complicated at best. Someone else in this thread mentioned SRFI 49. Personally I don't find it's syntax... define fac x if = x 0 1 * x fac - x 1 ... to be any easier to read or understand than the usual scheme syntax: (define (fac x) (if (= x 0) 1 (* x (fac (- x 1))))) In fact I much prefer the latter. I see absolutely no advantage to making the parens optional, and I see lots of disadvantages to removing them. Especially when it comes to implementing something like lisp macros, I think removing parens would greatly complicate that and open the door for tons of ambiguity, as well as making it far too easy to misinterpret what the code was doing. I agree with sedachv. Your "mistake" is not that you are criticizing lisp. It's just that those of us here that know lisp don't see your criticism as being valid, and we do not see your suggestions as being something that would make lisp better, but on the contrary would make it much worse.
- AdeptusAquinas 9y agoSRFI 49 went too far the other way. In F# the expression would be: let rec fac x = if x = 0 then 1 x * fac (x - 1) Or with pattern matching: let rec fac = match x with | 0 -> 1 | _ -> x * fac (x - 1)
- sedachv 9y ago> Only the insane write code without tab or space indentation, and if you are doing that anyway then an OCaml-esque language like F# where that serves as your grouping syntax is the saner option. Instead of making disparaging remarks about people's mental health, learn some basic parsing theory: https://en.wikipedia.org/wiki/Context-sensitive_grammar https://en.wikipedia.org/wiki/Context-sensitive_grammar