TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Pretty Lisp

170 点作者 fogus大约 13 年前

27 条评论

lambda大约 13 年前
Huh. I wouldn't call this pretty. Why do you need a box around everything? One of the arguments about Lisp is how visually distracting the parentheses are (and yes, experience Lisp hackers learn to tune them out; that doesn't change the fact that they are visually distracting); the boxes are even more visually distracting. To use Tufte's terminology, this is decreasing the data-ink ratio, not increasing it.<p>Take a look at Slashdot comments, and compare them to Hacker News comments. Slashdot has a whole lot of extra chrome that doesn't increase the information density. Hacker News has very little on the screen beyond the actual content; it simply uses indentation to indicate nesting of threads.<p>Why do you need all of the boxes? Why not just use indentation, perhaps highlighting only the currently focused expression? Python has already shown that indentation is sufficient for readably delimiting nested blocks of code. Using indentation to delimit code blocks in plain text has some problems when moving code to a different nesting level, but if you have a structure editor like this in which the indentation is only for display, that's not a problem.
评论 #3650659 未加载
评论 #3650349 未加载
dfan大约 13 年前
It is odd that in the third screenshot there is no visual differentiation between the true and false blocks of an if statement. That's one place where I still kind of regret the genericness of Lisp syntax.<p>Perhaps place a green outline around the true block, a red outline around the false block (if any), and indent them both slightly or otherwise connect them to the predicate block so that the connections are clear.<p>Of course one issue with treating constructs like if specially is that in Lisp you can create your own macros that act just like if but then don't get the special visual treatment.
评论 #3649972 未加载
评论 #3649863 未加载
webjprgm大约 13 年前
Yuck. The parenthesis are much easier to read than the boxes with lots of padding. Only useful for beginning programmers. Anyone using lisp-based languages will quickly be able to read parens easier.<p>(Plus some IDEs have coloring based on matching parens and depth, like Racket's IDE, which keeps the same lisp code structure but adds subtle visual enhancements.)
评论 #3650117 未加载
spitfire大约 13 年前
I've been wanting this sort of thing for ages. Considering how sophisticated we think we are, how the hell are we still using tools like emacs, or even VS on a daily basis?<p>We should be indistinguishable from magic by now. This is a (small) step in the right direction.<p>Can we please live in the future already?
评论 #3649995 未加载
评论 #3649673 未加载
评论 #3649630 未加载
评论 #3650562 未加载
评论 #3650708 未加载
评论 #3649923 未加载
评论 #3649591 未加载
gnosis大约 13 年前
Am I just being a grumbly old man by preferring a decent editor like vim (or even emacs) over this?<p>I don't begrudge anyone who likes that kind of "web 2.0" bubbly aesthetic. But it's just not for me.
评论 #3650011 未加载
Arelius大约 13 年前
This is real neat, but expecting programmers to make such a large jump so quickly is a bit unrealistic.<p>My best suggestion is to integrate this well with programers existing editors, open a socket from an Emacs instance and use this as visualization. You will get much better traction that way.
评论 #3649971 未加载
gt384u大约 13 年前
Something I'd be curious to hear from the pretty lisp designers: what advantages do you feel this offers over an Emacs which just highlights the symbol of interest or region between the matched parens for a particular code block?<p>By way of context, I was a test subject for a perhaps related project called Code Bubbles <a href="http://www.andrewbragdon.com/codebubbles_site.asp" rel="nofollow">http://www.andrewbragdon.com/codebubbles_site.asp</a> a while ago. Since it was for Java, a language which is comparatively verbose and I often have difficulty getting decent code density with, this new IDE interaction was truly novel and I found often useful.<p>I test drove the Pretty Lisp Demo and felt myself wanting for code density in a language where I don't typically have those issues. It was just too hard to fit a useful quantity of code in a screen.
评论 #3649680 未加载
评论 #3650095 未加载
mark_l_watson大约 13 年前
Nuno did a nice job implementing this, but as an old(er) Lisp'er I like normally indented Lisp code (in Emacs, IntelliJ with Clojure plugin, etc.) After looking at parenthesis for over 30 years, I am used to them :-)<p>Still, a neat idea.
fractallyte大约 13 年前
Here's an interesting discussion of a s-expression editor: <a href="http://alan.dipert.org/post/445462664/the-s-expression-editor" rel="nofollow">http://alan.dipert.org/post/445462664/the-s-expression-edito...</a> (and a follow-up post: <a href="http://alan.dipert.org/post/17375691572/structural-editing-redux" rel="nofollow">http://alan.dipert.org/post/17375691572/structural-editing-r...</a>).<p>The above article refers to Interlisp (also mentioned elsewhere in this discussion), which still(?) survives in the form of Medley (<a href="http://www.venue-medley.com/" rel="nofollow">http://www.venue-medley.com/</a>). (I emailed Jill Sybalsky a few months back, but following the death of her husband, the product's future is rather uncertain...)<p>I came to Lisp from Smalltalk, so I'm already spoiled, having used the best IDE ever (hey, it's not just me: <a href="http://onsmalltalk.com/aha-moments-in-lisp" rel="nofollow">http://onsmalltalk.com/aha-moments-in-lisp</a>); adapting to Emacs/SLIME was quite an interesting contrast.<p>OpenGenera was a step in the right direction: a LispVM + LispOS which together created a very Smalltalk-like IDE. (The notion of 'synergy' has real meaning here!) Developing a modern version of this further with ideas for structural editing of s-expressions would be <i>quite</i> interesting...<p>But, of course, talk is cheap ;-)
mtraven大约 13 年前
Been done and a long time ago: see Boxer: <a href="http://www.mathedpage.org/t-and-m/turtle-and-mouse.html" rel="nofollow">http://www.mathedpage.org/t-and-m/turtle-and-mouse.html</a><p>Not to mention the BioBike VPL: <a href="http://nar.oxfordjournals.org/content/37/suppl_2/W28" rel="nofollow">http://nar.oxfordjournals.org/content/37/suppl_2/W28</a><p>Not that there's anything wrong with reinventing the recursively nested rectangular wheel.
brlewis大约 13 年前
This graphical representation of code structure seems reminiscent of <a href="http://scratch.mit.edu/" rel="nofollow">http://scratch.mit.edu/</a>
评论 #3650288 未加载
pshc大约 13 年前
Looking sweet. The future is in structural editors. The client-server separation is a nice bonus.<p>Unfortunately this is running up against the UI problem. How do you make this intuitive and powerful? A lot of hard work on usability is needed to get up to par with text editors. Very glad to see it being tackled.
评论 #3649817 未加载
评论 #3649707 未加载
abecedarius大约 13 年前
Boxer looked like this, though less on the ugly side, to my taste. Unfortunately it's so dead now I couldn't even find screenshots off the first couple of search results.<p><a href="http://edutechwiki.unige.ch/en/Boxer" rel="nofollow">http://edutechwiki.unige.ch/en/Boxer</a>
eta_carinae大约 13 年前
There are much less distracting ways than thick rounded boxes to indicate indentations, starting with simple spaces.<p>A lot of Lisp programs look a lot better if you apply Python's space indentation for sexprs, for example.
madhadron大约 13 年前
The boxes seem to be an unstable medium between the stable points of S-expressions and indentation as nesting. If there are lots of nested expressions, you either push them to multiple lines and it becomes indentation, or you keep them on one line and the top and bottom boundaries of the boxes run together until you effectively have parentheses.<p>Have you looked at Chuck Moore's ColorForth, though? It might be a neat direction to take this in.
trengof大约 13 年前
I love this idea. My knowledge of lisp is very basic but I wonder if optional declarations could be added to functions: e.g. f(Number) -&#62; (Number,Number) (sort of similar to haskell) and then these could be used in the pretty printing / presentation layer. This would help lisp from missing those implicit clues that are present in other languages without compromising its flexibility.
agumonkey大约 13 年前
Flip the keymap, I mean remove the prefix, especially in a browser where C-x becomes C &#60;pause&#62; x .. it negates the benefits of structural edition.<p>So intercept all keys, and make it vim like (i know i know, don't bite me), it will make it even more (touchtypist)DSL-like. btw , why not use &#60;tab&#62; for new element insertion ( cons cell )<p>anyway, keep digging, it's the one true path ;)<p>/me going back to reading 'On Lisp'
strags大约 13 年前
What you gain in "readability" here (debatable), you lose in terms of screen real-estate efficiency. The last screenshot has a function filling the entire screen that would, under ordinary circumstances, occupy about ten lines of code.<p>You're going to get frustrated having to page up and down continually in order to understand any remotely complex function.
ufo大约 13 年前
The demo only works on chrome :(
dwyer大约 13 年前
Interesting. I've often read discussions about how S-expressions could be made more readable. I never contribute much to such discussions because I've never had a problem with S-expressions. This is a neat idea though.
HarrietTubgirl大约 13 年前
Neat idea, although to be fair the examples are straw men. I think most people would indent their LISP much more readably.
bsmith大约 13 年前
Great idea.<p>I've thought of doing something similar for an HTML editor, because—like with Lisp—the nesting can become a nuisance.
CoffeeDregs大约 13 年前
Nice. Gotta admit that I was slightly disappointed that the client-side JS didn't appear to be ClojureScript or some lispy-script generated...<p>The application seems like a very good place to do Lisp-everywhere. In particular and because of the ability to modify the interpreter, it would be awesome to be able to use pretty-lisp client to edit the server-side code and see immediate changes.
jorgem大约 13 年前
PrettyLisp.com is available.
leeoniya大约 13 年前
why only chrome?
helveticaman大约 13 年前
Sacrilege!
vinodkd大约 13 年前
every time I see such a project show up I'm both happy and sad: happy to see one more soul arrive at the "there must be something better than text" thought and doing something about it; sad because they invariably create a visual/structural editor.<p>... and not a really good one, at that. Not to pick on this specific one, but if you're creating a UI for code editing that's not text, please design your interaction well. And yes, I know that this is probably version 0.1 and you plan to smoothen the rough edges, which is why i'll not pick on the fact that the editor for each structural element is not even in-place, for example. &#60;/end snarkiness&#62;<p>but that's not my point. writing code as text conflates two things (or 4, depending on how you think of duals):<p>1. source text has both syntax and meaning.<p>2. source text is both the display and storage format (this is the killer feature/bug).<p>my point is that every attempt to "solve" the "problem of coding using text" (on in this case the subset of lisp's umpteen parens getting in the way of understanding) focuses on the first half of #1 above.<p>as others have mentioned, there have been structural editors since the 80s. from the research i did (admittedly with limited acm access) they seemed to have died down due to two problems:<p>1. the scale problem: text packs the largest amount of information into the smallest amount of space. any visual/structural system better have a good way of dealing with large codebases.<p>2. the fluid use problem: it looks good, but is it easy to use when editing anything but a small enough piece of code this way? typically the amount of interaction "work" you have to do to jump between elements and so forth makes it very inefficient compared to text. the commonly cited example was "How do you change a for loop to a while?". in any text editor, you can take the characters apart easily to reform them into some other construct, but in a structural editor, you have to actually delete all or most of the old structure and re-form the new one. i did find research that refuted this specific claim (ask if interested), but that didn't help the adoption.<p>i have been thinking of "better ways to code" and structural editors in particular for about 3 years now and here're some of my conclusions to date:<p>1. text is king because of its universality - think cypher from the matrix saying "I don't even see the code. All I see is blonde, brunette, red-head"<p>2. We already have good structural editors. They're called vim and emacs. vim has the better interaction model, imo, while emacs has better support for creating new language modes (again, imho, no flame war intended). then there's the smalltalk ides that inspired the Visual Age products that inspired eclipse.<p>3. The additional overload of "chrome" in text the {}'s, ()'s and begin/ends are much less a hassle than that caused by a visual editor's chrome.<p>4. There is much more value in pursuing better ways of coding than just flogging the "text sucks" meme. Think Non-textual language workbenches, for example.<p>Finally, one specific commment about playing around with lisp's syntax. I've tried it (<a href="https://github.com/vinodkd/lispdown" rel="nofollow">https://github.com/vinodkd/lispdown</a>) and the one thing that stands out is: Lisp has no syntax, so it can <i>become</i> any syntax. I dont know how any structural editor can handle that in a meaningful way.