4 ms·
As a day-to-day developer, but one who wants to learn as much as I can outside of my domain, you are spot on. I generally work in an OO language (C# specifical
by AdeptusAquinas 9y ago
As a day-to-day developer, but one who wants to learn as much as I can outside of my domain, you are spot on.
I generally work in an OO language (C# specifically) and have long wanted to get into functional programming. I am finally making headway, but after false starts in lisp (racket, clojure) ultimately I am using F#. Partially, admittedly, due to the .NET aspect (its even shipped as part of default dotnet core) but also because of the lack of parenthesis.
One of the reasons to go functional was to get away from the excessive syntax and formality of a C-based language, and replacing every curly bracket with 20 parenthesis (minor hyperbole) doesn't achieve that for me.
- nocman 9y ago"replacing every curly bracket with 20 parenthesis (minor hyperbole)" It isn't even minor hyperbole, it's just plain false. It has been my experience that, generally speaking, the combination of curly brackets { }, square brackets [ ], and parens ( ) in languages with C-like syntax is at worst roughly equivalent to the number of parens in most lisp dialects. Some people freak out because they see a function in a lisp that ends with: some-final-expression))))) But they think that it is totally fine when a C-like langauge ends with: some_statement_or_expression } } } } } If the stacks of parens at the end bother you so much, there is nothing in most lisps preventing you from indenting them on lines too: some-final-expression ) ) ) ) ) I wouldn't advise it, but you can do it. I think more than anything, people are just unwilling to accept that lisps look different than the X number of curly-bracket-style languages they are used to. It looks weird to them at first, because of past experience, so to some degree they are looking for a reason to write them off from the beginning. When I was in college, I had this initial reaction, and didn't even consider anything lisp-like for many years. It was only my frustration with the limitations of C-like langauges that led me to reconsider lisps years later, and man am I ever glad I did. [EDIT for additional comment]: and btw, I'm a "day-to-day developer" also.
- AdeptusAquinas 9y agoYou 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.
- craigsmansion 9y ago> I wouldn't advise it, but you can do it. That's basically how I write functions in Lisp, with indentation levels and every closing parenthesis on a separate line. The thing is, when you're done writing a (leaf)function in Lisp, you're done: it works. Since you won't need to revisit it (unless the functional design changes), you clean it up for compactness by grouping all closing parenthesis together. I could be the only one, but I've always found it normal and practical to develop with indentation, and regroup when I'm done.