Parinfer and Paredit: embrace or avoid?


#21

FWIW I’m on the “avoid” side of this, for myself (a long-time lisper) and for my students (who are often new programmers).

While I think it’s swell for others to use paredit or parinfer if they like them, some of the reasons that I don’t want them in my teaching or development editing environments are:

  • I often cut/paste and/or edit code in non-linear ways as I’m thinking through a problem, with my code being in syntactically invalid states at many points along the way. Paredit/parinfer makes this frustrating or impossible.

  • My students already know how to type and manipulate text, and requiring that they learn new ways to do this on top of everything else (basic programming concepts, functional programming, Clojure, AI, etc.) seems cruel and counterproductive. I’ve witnessed considerable exasperation stemming even from some of the less invasive “helpful” interventions in some editors, e.g. auto-typing of closing brackets, or wrapping rather than replacement of a selection when typing an open bracket. Having paredit prevent character insertions in some situations, or having parinfer add/delete brackets that may be distant from the insertion point, are much worse.

  • Clojure cares about brackets, not about whitespace. So it seems to me that programmers should also care primarily about brackets, not whitespace, or at least have brackets, not whitespace, foremost in their minds. Whitespace is a terrific visual guide to structure, and IMNSHO every Lisp editor must have an auto-reindentation feature that can be manually triggered by the programmer to make the whitespace conform to the programmer-typed brackets. And programmers should routinely invoke this feature on everything they write. But my preference is for the programmer to specify the brackets, and use auto-reindentation to clean up indentation and spot problems.

Again, I can see why people like paredit and parinfer, which I definitely agree are clever, and if people find them helpful then I think it’s great for them to use them. But I think there are good reasons to avoid them too, and I hope that tool developers will keep these in mind, providing ways to avoid them in their editors while nonetheless supporting auto-reindentation and bracket matching.


#22

Hey! I’ll chime in.

If I were going to start over today with what exists now, I’d go with Parinfer. It is really nice that you don’t have to learn a whole bunch of commands. I’ve used Parinfer in a Clojure workshop and it was great. The experienced programmers grumbled a bit as they got used to it, but it worked super well for beginners. I noticed two things:

  1. Beginners were having trouble finding the braces keys, even for those who could touch type. Honestly, how often do you type curly braces when you’re not coding? They couldn’t find them. Having half the number of braces to type really helped. And not having to count the closing things and get them in the right order saved a lot of headaches.

  2. Beginners don’t know how spacing, indentation, etc work. Having a system where an instructor could easily help them nest using only the space bar or tab key was really helpful. If the instructors had had to sit down with them to count closing parens, it may have been a “good, character-building exercise”, but the broader purpose of the workshop would have been lost.

I use Paredit and I’m comfortable with it, but it took a lot of time on my part and a lot of evolution on the part of the implementors to iron out some wrinkles. For instance, now Paredit will detect if you’re unbalanced and let you type in closing parens. It didn’t do that when I started. It would not let you do anything! You had to know how to bypass it.

Parinfer is on more solid foundation, with separate indentation and braces modes.

Eric


#23

Well, I must say that for a newcommer to the Clojure and LISP world like me, Parinfer is a game changer! While Clojure felt really natural to me from the start and I kind of fell in love with the language, I found the parentheses, brackets and braces frustrating. Trying to align everything correctly so as to make my code readable and understandable was difficult and I spent too much time thinking about typing rather than programming.

When I discovered Parinfer and installed its plugin in LightTable, it made Clojure much more fun to work with. I write code instead of balancing characters. It makes incremental complexity easier too, since adding a nested function is taken care of very neatly.

I’d be curious to try out frame-based editing though! Clarity is always a good thing!


#24

There’s nothing more frightening than when I open a file in Atom and it says "parinfer needs to make some changes to this file, 100 changes"
But as I’ve gotten better at following the style guide I’ve had less fights with it while I’m writing code.

However it does make copy/pasta code kind of a pain but also a fun learning experience when you are trying to get it to work


#25

Embrace!

We use paredit all the time at work though some devs still hold out against it occasionally. It’s far more productive and perfectly intuitive with only a bit of effort at the start.

But I love that Zach Oakes has implemented Parinfer into his fantastic pure browser editor Paren Soup. For newbies or non technical people this is the editor they like as otherwise getting parens right can be really discouraging. I use it too at quick tech discussion sessions to demo clojure stuff :slight_smile:

http://oakes.github.io/paren-soup/

Might try to use Parinfer over paredit soon but there are some edge cases that Parinfer struggles with where Clojure departs from conventional Lisp syntax I believe.


#26

Don’t know if anyone using the emacs package lispy. The emacs parinfer implementation have the functionality to combine lispy, parinfer and evil (vim modal editing) together.

I’m trying to combine vim’s insert normal state with parinfer’s indent and paren modeThen maybe change some vim’s normal state keybindings into lisp’s. The efficiency is promising if we can manage combining these three together.


#27

Hi there,
Despite being a long time lisper and emacsian, I resisted paredit as well as many emacs packages… But being pushed by the younger generation I’ve finally managed to adopt smartparens… I have a shortcut to switch to and from strict mode so I can alternate between the old and the new me at will…