4 ms·
LISP-style syntax needs to die. Too many parentheses. Balancing {} can be annoying enough without having to worry about every single line with lisp-style (). Y
by azinman2 12y ago
LISP-style syntax needs to die. Too many parentheses. Balancing {} can be annoying enough without having to worry about every single line with lisp-style ().
Yey for python for stepping forward on this issue, minus points for their incorrect approach to (multiline) anonymous functions.
(I know people will flame this and assume I'm trolling, but this is just my POV as someone who's programed in LISP and ~10 other languages for 20 years now).
- fizixer 12y ago"Smart" text editor should help with parentheses. Two ideas come to mind: - It should be aware of S-expression grammar, and actively monitor what the user is typing. (Think of it as an s-expression expert watching over your shoulder). - The line or code block that the cursor is on at a given time, could swtich to multiline view on the fly, with parentheses replaced with indentations, and some color coding. When you move cursor up using the arrow key, the multiline S-expression automatically collapses, and the one above expands. In any case, text editors need to be "fully" aware of the language, e.g., even if the editor does syntax highlighting, it is doing that based on the complete parsing cabability of the syntax, instead of just bunch of rules in editor's script (like vimscript in vim). It would also help if the source file is saved as an AST of the code, instead of raw code. This would also help with code formatting on the fly, and personalized settings for the user of the text editor (e.g., one use always prefers to see S-expressions in multiple lines, another always prefers collapsed view.) Going further. Text editor should allow you to replace any language token with your favorite token, e.g., '(' and ')' could be replaced with '{' or '}' or something else (or maybe even just indentations). As a user preference, not as something that is saved in the AST file. I hope to see something like this for C, something that I like to call "semantic C" programming. I guess I went off on a tangent.
- tomp 12y agoOne problem with storing AST are comments. There are ways to deal with them, e.g. Go's `fmt` tool will parse your code into an AST and output it again, but it doesn't leave all comments in the same space. But I agree that it's the way forward!
- Dewie 12y agoWhy do you have to worry about balancing parens when you can use things like paredit?
- oxryly1 12y agoAs another long-time LISPer, I kind of agree. I just wish there were an actual alternative. And as for Python's multiline lambdas... I'll be a lambda heretic and say list comprehensions are the superior approach.
- Morgawr 12y ago>I'll be a lambda heretic and say list comprehensions are the superior approach. If all you use lambdas for is list comprehensions then... sure?
- DenisM 12y agoI vaguely recall that Haskell has some really neat features to fight the parentheses problem, so you might want to take a look.
- oxryly1 12y agoYes, I think Haskell is the right way forward, generally. It does have some significant whitespace which might be an unfortunate necessity. Another option is autoformatting a la Go.
- vezzy-fnord 12y agoREBOL's syntax is pretty much Lisp without the parentheses. Very pleasing to read. Example here: http://www.rebol.net/cookbook/recipes/0057.html http://www.rebol.net/cookbook/recipes/0057.html Another one that sort of resembles Lisp in ALGOL's clothing, is Dylan: http://opendylan.org/ http://opendylan.org/
- azinman2 12y agoI agree... REBOL is nice to read. A version of LISP that's more legible IMHO. Too bad it never took off, it had a lot of really nice concepts and lots of python-style "batteries included."
- dorfsmay 12y agoWhy are people so concerned about anonymous functions? The facts that you ca Defoe a function inside a function, and that they are object make named functions as good as anonymous ones.
- ptx 12y agoBut you still have to come up with a name for it every time, and, more importantly, you can't do it inside an expression.
- azinman2 12y agoYa exactly. If you're trying to do a functional map, then it doesn't make sense to have to def it especially because your def will go before the actual execution of it which always looks unideal
- stefantalpalaru 12y agoThere's already an indentation based syntax for S-expressions: http://readable.sourceforge.net/ http://readable.sourceforge.net/
- azinman2 12y agoThat is an improvement. Edit: Why the down vote? I appreciated someone's work to address the issues I have with LISP?!
- andrewflnr 12y agoYou may also find "z-expressions" interesting. http://chrisdone.com/z/ http://chrisdone.com/z/
- cicero 12y agoI've enjoyed using Racket and Clojure, and I see definite advantages to Lisp-style syntax. There are also disadvantages, but I don't think too many parentheses is the main problem, at least not for me. The simple syntax means there are fewer visual cues for language elements, and I think this reduces readability. Clojure is a move in the right direction because it makes more use of punctuation. Edit: I forgot to add that whatever the disadvantages of Lisp-style syntax, saying it has to die is ridiculous. It is sufficiently useful that it has survived all of these years, and will continue to survive for a long time.
- escherize 12y agoI find it hard to believe you have done much lisp if you are complaining about balancing parens. If you had done a lot of lisp, then you would never care about balancing parens, because there are tons of context-aware tools that do it for you. Not just that - these tools [paredit, smartparens, etc.] make it impossible for one to ever unbalance parens because they're contextually aware.
- azinman2 12y agoTo you and the other posters: You still gotta read the code later. It's not just about input time. The () just cloud things up and can make it slower to understand what's going on IMHO. This is just my opinion/brain, but I also dislike the RP-style notation. 3 + 5 is easier for me to read than + 3 5, especially when you start combining things like (/ 15 (* (+ 3 5) 4)).
- white-flame 12y agoI've not experienced that. I see the indentation more than the parens, in terms of looking at scopes. Browsing through the source code with the cursor highlights matching parens and directly shows which expression you're in. I do agree partially about the math, though. (+ 1 2 3 4 5 6 7) is easier to read for me than 1 + 2 + 3 + 4 + 5 + 6 + 7, but most mixed-operation expressions are easier to human-read infix. S-expressions are also more explicit, eschewing punctuation for an AST representation of code. For example, a[2] becomes (aref a 2). Yes, this explicitness is more verbose, but because it's more regular I'd say it's easier to read when things get complex. However, once you taste the ability to programmatically generate source code right in your code itself, and that becomes part of your common workflow, the benefits of AST s-expressions blow away any of these relatively minor downsides. You can code in an idealized representation, then macro that ideal into actual executing code.
- wz1000 12y agoAfter ~3 years of learning Lisp, I find the second style extremely easy to read.
- progman 12y ago
- ptx 12y agoI like both Python and anonymous functions, but how would you suggest anonymous functions should work in Python if done "correctly", given the indentation-based syntax?