5 ms·
So many brackets. Resolving mismatched brackets seems to be just about the most pointless developer activity possible.
by andrewstuart 12y ago
So many brackets. Resolving mismatched brackets seems to be just about the most pointless developer activity possible.
- beeworker 12y agoI know right, I totally hate having to match Map<String, Map<String, Object>> foo = someMethod(withMethodArg1(), andTwo()); Let's all just use Forth, and implement washing machines as simply as: : WASHER WASH SPIN RINSE SPIN ;
- wyager 12y agoWhile that's a bit of an acerbic way to put it, I agree. The human brain has a very short stack depth, so we're no good at nested pattern matching. Indentation or delimiter based languages are much easier for me to parse than lisps.
- pjscott 12y agoThe usual solution is to indent your lisp code.
- lmm 12y agoWhy repeat myself? If the indentation contains the information, why can't I just use that?
- current_call 12y agoBecause then you end up with thinks like Python's one expression lambda.
- nialo 12y agoThe parens are the single point of truth, the indentation is just for display and is (almost entirely) mechanically generated.
- iopq 12y agoWhat I hate is when my delimiters are unmatched and I can't tell where. I haven't used Lisps, but it bothers me a lot even in C-like languages.
- Zelphyr 12y agoOne of the reasons I'm falling in love with Rebol and Red. Very Lispy but with out the hassle of the parens. Brackets, yes, but not nearly as bad.
- l4mbda 12y agoAs they say, “If you think paredit is not for you then you need to become the kind of person that paredit is for.”
- Crito 12y agoUnsurprisingly, working with balanced brackets is something computers are well suited for. Even in Vim, an editor not exactly built with Lisp development in mind, handing mismatched brackets is pretty trivial.
- orthecreedence 12y agoAgreed, I do all my lisping in vim and have for years. Mismatched parens has pretty much been the least of my worries from day one.
- andrewchambers 12y agoGenerally things like paredit force brackets to never go unmatched. There is also rainbow colored parens.
- davexunit 12y agoM-x paredit-mode
- kenferry 12y agoLisp uses the same number of parens as most languages per call – the only thing that's different is whether the paren goes before or after the first part of the call. (print "hello") vs print("hello") So to the extent Lisp is paren-heavy, it's more a stylistic thing. Lisp programmers tend to chain up calls more.
- rtpg 12y agoWhat about a paren-less calling mechanism? main = putStrLn "hello"
- eru 12y agoPossible, and nice. But you lose the ability to easily specify a variable number of arguments.
- Sanddancer 12y agoShell languages seem to do just fine using spaces to easily specify a variable number of arguments.
- eru 12y agoYes. I forgot to mention that Haskell also supports partial application. Shell doesn't, so that's easier. And that's just talking about syntax. The type system complicates matters further.
- jakub_h 12y agoWell, there's always the Smalltalk approach.
- UnquietTinkerer 12y ago(-b + sqrt(b*b - 4*a*c)) / (2*a) (/ (+ (- b) (sqrt (- (* b b) (* 4 a c)))) (* 2 a)) It does depend on your use case.
- fixxer 12y agoNothing raises the ire of HN devotees like the most mild criticism of Lisp aesthetics... Such a sensitive lot.
- orthecreedence 12y agoI'm sure if lispers started going into python threads and whining about "argg all the whitespace makes me want to gauge my eyes out!!!11" the response would be similar. Don't like parens? That's fine, really. Want to write off an entire class of languages because the syntax isn't plastered with curly braces? Go ahead! Just don't expect anyone to all that interested when you start blubbering about it.
- deleted 12y ago[deleted]
- Semiapies 12y agoIf a post on Python has more than a handful of comments, the whitespace discussion almost inevitably comes up, in my experience.
- deleted 12y ago[deleted]
- dang 12y ago> So many brackets. Resolving mismatched brackets seems to be just about the most pointless developer activity possible. It's precisely the other way around: finicky syntax issues consume far less time in Lisp. This isn't just a surface thing—when syntax occupies a block of resident memory in your head, you have that much less capacity to spend on the problem at hand. It takes a while to adjust to a more regular notation, but that's true of anything unfamiliar. And what you get in return is astonishing.
- muraiki 12y agoIf you edit s-expressions as text then yes, it's horrible. If you edit s-expressions as data structures using something like paredit you'll actually code very quickly, and it'll also be impossible to have unbalanced parens. Say you have this (| = cursor): (a b |c d) If you type ( you get balanced parens: (a b ()| c d) If you press Ctrl+Right twice you slurp in c and d: (a b (c| d)) If you then press Alt+Up you get back to: (a b c| d) As you can see, you manipulate code on the level of data structures instead of manually placing parentheses, and you are actually prevented from making unbalanced parens in paredit. You can likewise move through code in ways similar to moving by word or paragraph in vim vs moving by character, but I only showed basic editing above. I won't downvote you because I understand your complaint. But the problem is that you are unaware that you are using the wrong mode of editing for s-expressions. :) It's like editing photo using a hex editor: possible, but very much suboptimal.
- frozenport 12y agoAs opposed to checking the indent level? (Python)
- andrewstuart 12y agoI'm guessing you mean with Python? I have to say I've never once had a bug related to number of spaces.
- jquast 12y agoI billed 8 hours work to a company to fix a python bug that was exactly this problem. After a lot of refactoring by someone inexperienced in python, something was indented inside of a loop that should have been outside it. 8 hours work for de-denting one line of code.
- e12e 12y agoHere you go: http://pkg-build.racket-lang.org/doc/sweet/index.html http://pkg-build.racket-lang.org/doc/sweet/index.html
- krylon 12y agoThere are good text editors and IDEs for LISP-like languages that will help you matching braces. It stops being a problems very quickly. Also, like in other languages, you can make the structure of your code clear by indentation (good editors/IDEs will help you with that, too, of course). Also, in C/C++/Java/C#/whatever code, you can run into the same kind of problem on a smaller scale when editing deeply nested blocks and expressions, especially when dealing with complex arithmetic/logic expressions. (I basically only use Lisp when messing with Emacs, so I would not call myself a Lisp hacker, but when learning Lisp, the braces cease to be a problem after a month at most.)