News for hackers. Stuff that matters.
Re:Pretty Lisp by spitfire on Wednesday February 29, 2012 @03:33PM (#3649553)
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?

We should be indistinguishable from magic by now. This is a (small) step in the right direction.

Can we please live in the future already?

Re:Pretty Lisp by ken on Wednesday February 29, 2012 @05:17PM (#3649995)
I've given this a lot of thought, because I'm working on a couple of vaguely similar projects. My conclusion so far is that pretty-printing is great, but enforcing structural constraints in the editor (beyond perhaps something like ParEdit) tends to cause more trouble than it's worth.

Consider the transformations you might do on a piece of source code while you're playing around. A lot of these (for me, anyway) are things which change not just position or name, but the part-of-speech of words, or temporarily make a nonsensical expression. (I do it in my shell a lot, too.) Rigid structure-enforcing editors hinder this.

So for Lisp, either you end up with something that's less useful than Emacs, or something that's just a thin display layer on s-exps (which is fine, but not game-changing) and then users have to understand s-exp editing anyway. The fact that the names of special forms, functions, and variables are all symbols in Lisp is not mere coincidence.

This highlights one of the big frustrations I have with most programming languages: they optimize for making a section of code look good and concise, but as a programmer I want a language that also optimizes for my changes being concise. For example, C# can look pretty decent in many cases, but changes which are conceptually simple can be huge diffs. Quoting an expression in Lisp is literally one character, but it takes 5 lines to quote a print statement in C# <http://msdn.microsoft.com/en-us/library/y2k85ax6.aspx>, and anything nontrivial grows painfully fast. This is why it's impossible for me to truly assess something by looking at sample code, or a screenshot -- so don't take this as a criticism of Pretty Lisp!

It could be that as we move higher up the abstraction scale this becomes less important. After all, Mel wouldn't be happy at such a high level as "characters". But I think there's something fundamental about the concept of quoting symbols -- 'using something as something else' -- whether those symbols are bits or characters or round-rects. The #' in the screenshot here looks out of place, as if the author didn't know quite what to do with it.

I look forward to see what the author can make of this (new ideas and experimentation are great!) but I don't see anything here yet that jumps out at me as revolutionary, or must-have functionality.

Re:Pretty Lisp by ken on Wednesday February 29, 2012 @06:04PM (#3650179)
I guess that sounds like kind of a downer (even though I said I liked experimentation and didn't want to make it sound like criticism of this particular implementation). I think there are definitely paths forward here, and my hunch (which you shouldn't listen to, because I don't know anything) is that the most promising one would be some combination of some/all of:

- Not use Common Lisp as a base. Lisp is great, but reader macros and visualizations are a really tough combination.

- Come up with a good visualization for quoting. If your fundamental units of computation are "symbol/word" and "box" (a neat concept to build a language around), then incorporate quoting into those things somehow. I don't have a good answer for you here, but I think this is the key to unlocking the whole thing.

- Integrate with other tools (or upgrade them to this visual symbol/box world) that make good use of text today, like version control, sed/grep, or editor extensions (as in Emacs).

If there was a programming environment that offered the same level of flexibility and power that I have today, but which was visual (and beautiful), I could see that being a very compelling upgrade. I'm fascinated by visual languages, and I find it unfortunate that they all seem to acquire visuals by sacrificing power.

Re:Pretty Lisp by timmy-turner on Wednesday February 29, 2012 @06:40PM (#3650285)
> Consider the transformations you might do on a piece of source code while you're playing around. A lot of these (for me, anyway) are things which change not just position or name, but the part-of-speech of words, or temporarily make a nonsensical expression. (I do it in my shell a lot, too.) Rigid structure-enforcing editors hinder this.

I hope that this can be mitigated by using an incremental parser (pretty easy to write for a lisp), which gracefully switches to a plaintext representation if the underlying code cannot be parsed anymore. The advantages of an editor which understands the code (both, syntax and simple semantics) you are writing or reading are just too promising.

Re:Pretty Lisp by doty on Wednesday February 29, 2012 @07:06PM (#3650360)
I worked on a language once (now dead) which even had a syntactically valid form for parse errors, which allowed a structured editor to record a valid AST at all times. The "parse error" expression just raised a "parse error" exception at runtime, so you could even execute ill-formed expressions.

It turns out to be fantastically empowering.

Re:Pretty Lisp by spitfire on Wednesday February 29, 2012 @07:20PM (#3650391)
Which language?
Re:Pretty Lisp by doty on Friday March 02, 2012 @10:17AM (#3656829)
Re:Pretty Lisp by spitfire on Wednesday February 29, 2012 @06:43PM (#3650293)
You're absolutely correct. Right now we focus on moving text around. Where the magic will come in, as these sorts of things progress is developing interactions to move the ideas around. Moving further up the power curve is always a good thing.

My comment was based on the concept and my interpretation of those concepts in the future. Not necessarily on the reality right now.

Re:Pretty Lisp by jerf on Wednesday February 29, 2012 @11:19PM (#3650896)
We've done a lot of moving up the curve. Generally, when you move up the curve, there's a way to serialize it as text. Then, you might as well actually do so, and use all the advantages of a textual representation to use the abstraction. Compare a concise Haskell specification of something with the C equivalent.

The problem with people who seek to replace our glorified text editors that we use for source code editing is not that they don't understand the disadvantages of the format... it is that they don't understand the advantages. Consequently, proposals for replacement tend to throw away huge swathes of functionality without realizing it, then start from a functionality deficit nearly impossible to recover from. It's actually hard to beat text. There's a reason we're communicating in text right now, and it isn't a lack of creativity or lack of attempts at other solutions to the problem or any of the other memes trotted out every time this topic comes up.

Re:Pretty Lisp by Detrus on Thursday March 01, 2012 @02:07AM (#3651257)
I think it is a lack of creativity. Also a lack of serious attempts and minimal refinement in successful attempts like labview.

Take the simple case of naming. In plain text, the name of a function is its unique ID, more or less. Some language cultures love long descriptive names like BattleResourceMediator.getMediatorInstance(). Well such names can be broken up into tags. [Battle Resource] [Mediator].[get][Mediator][Instance]. Then when you don't need to know it's a mediator instance you'll see [Battle Resource].[get]. If you need to see what's a mediator and what's a factory, turn on some deeper editing mode and swim in verbose boilerplate.

You're not going far from text, just augmenting it with simple ideas we use in bookmarking. You can go further, add tags to sections of code to rate and label it as readable, hand optimized, quick & dirty, reviewed, etc. Simply a better UI for documentation, so in a zoomed out view of a project you can see at a glance how much is hand optimized.

Also watch this video https://vimeo.com/36579366 and notice the sorting code walkthrough. A simple case of refinement where you put output side by side next to the code and format it properly. We'll need a lot more refinements like this, which means more attempts, more creativity.

Re:Pretty Lisp by rml on Thursday March 01, 2012 @11:15AM (#3652678)
> Generally, when you move up the curve, there's a way to serialize it as text.

Agreed. I think this has something to do with the fact that programming is not about the objects on screen themselves, it's about the interaction that occurs between those objects and the mind of the person looking at them. The objects are not real, but mere representations.

Therefore, the interaction I have with a block of code is defined by my experience wrestling with the problem at hand in the language of that block, during which my brain has "mapped" from the text to a sort of abstract visualization of its value (or "serialized", as you put it).

I don't think a tool that makes a "picture-block" for me will ever help. My brain has to do the work of understanding those blocks by compressing each text block into a form (block? graph node? neither?) that I can hold in my head.

Strangely enough, if the above is correct, that means that there is more value in implementing a tool like this (for the implementor) in $LANGUAGE than there is for a potential user. Perhaps this is why programmers keep writing them, and users keep on not using them.

As the user, I need to learn something either way, and learning is usually hard/expensive. Therefore, why learn the (imperfectly-mapped) "picture-block" abstraction at all?

It'd be interesting to see if programmers feel the need to keep using these sorts of tools them once they've written them. My guess is no.

Re:Pretty Lisp by idlephilosopher on Thursday March 01, 2012 @01:48AM (#3651218)
What would you list as the advantages of text-based editing that replacements miss?
Re:Pretty Lisp by tincholio on Wednesday February 29, 2012 @03:58PM (#3649673)
Because Emacs (and Vim, but when talking LISP, especially Emacs) is already magic. The visualization proposed is nifty, but it's hard to beat Emacs for any code editing, let alone for LISP.

Also, check this out: http://www.foldr.org/~michaelw/emacs/mwe-color-box.el (you can see a screenie in http://www.foldr.org/~michaelw/emacs/color-box.png)

Re:Pretty Lisp by colonel_panic on Wednesday February 29, 2012 @06:36PM (#3650276)
Now I'm disturbed by the lack of parens. What about situations where I have one pair of parens exactly contained in another, like in a one-argument defmethod?

Edit: Now I see that I didn't notice that this situation happens in the "let maxcol 0" line in that image. I need to compare the colors on the line below to make sure I'm mentally parsing that line correctly.

Re:Pretty Lisp by simonb on Thursday March 01, 2012 @09:20AM (#3652132)
(setq mwe:color-box-hide-parens nil)
Re:Pretty Lisp by tikhonj on Wednesday February 29, 2012 @03:50PM (#3649630)
Emacs is already indistinguishable from magic :).

Seriously though, I actually prefer working with text, even here.

Also, I think this could be improved by making "meta" symbols like defun into different shapes rather than just including them as words. So a definition would look like a different box than a normal statement. Probably the same for &optional. Of course, this wouldn't work for user-defined macros or functions, but it would be nice if just for the standard ones.

Re:Pretty Lisp by Arelius on Wednesday February 29, 2012 @03:55PM (#3649661)
Yes, not having that feature is a bit perplexing, I already have emacs do something similar with font-lock. Among others, lambda gets replaced with λ.
Re:Pretty Lisp by Vivtek on Wednesday February 29, 2012 @04:03PM (#3649693)
Oh, that's a nice idea. I have to admit that the boxes don't do much for me, but symbols would make it easier to see what's where.
Re:Pretty Lisp by jimbokun on Wednesday February 29, 2012 @08:27PM (#3650562)
When you want to write an essay, do you use something that draws your essay as some complex graphical representation, or do you use something like Word or a text editor, that for the most part shows your essay as just a bunch of boring characters on the screen?

Sure, there may be some fonts and indentation and colors. (Eclipse and VS use those, too.) But the text is the point.

It's the same with code. Code is a means of expression, best treated as text. Every attempt at turning it into something graphical always reduces the expressiveness.

Re:Pretty Lisp by Detrus on Thursday March 01, 2012 @01:42AM (#3651205)
We have the systems we have now because we used the same medium for thousands of years. To create new expressive mediums that take advantage of computers will take careful design and iteration, just as alphabetic text went through various handscripts like cursive, torturous to read German blackletter http://en.wikipedia.org/wiki/Blackletter and settled on http://en.wikipedia.org/wiki/Roman_type

Then we went to san serifs (like here on HN) and then to monospaced code fonts. It's a long line and a lot of work by designers.

Adding to this medium will also take a lot of work. An essay can be more expressive when various ideas in it are turned into visualizations. Writers of long novels use special writer software to keep track of which characters interact with what others, to create family charts, friend charts, event timelines, etc.

These don't replace text, they augment it. And it would be interesting to have a macro view of the book through such tools for readers someday.

Not every attempt reduced the expressiveness of code. Syntax highlighting is graphical. Labview is graphical. Short compile cycles so the programmer can see what he's doing is graphical. Great demo of that here https://vimeo.com/36579366

Just because this particular attempt at pretty lisp leaves much to be desired doesn't mean we should stop attempting. Simple programmer tasks like naming can be improved if we move away from plain text as the medium, more detail here http://news.ycombinator.com/item?id=3633740 and http://news.ycombinator.com/item?id=3651257

Re:Pretty Lisp by jimbokun on Thursday March 01, 2012 @10:51AM (#3652555)
Yes, to be more clear, I should have said all the attempts to replace code with some kind of a graphical representation, ends up reducing expressiveness.

Augmenting the text with graphical representations is a wonderful idea, that IDEs already perform in many ways, with many more yet to be discovered.

Re:Pretty Lisp by zokier on Thursday March 01, 2012 @02:09AM (#3651263)
Except that in LISP, code is not fundamentally textual. It's S-expressions, which are nested lists, ie trees.
Re:Pretty Lisp by el_presidente on Wednesday February 29, 2012 @09:47PM (#3650708)
We switched from graphics to text a couple of thousand years ago and it's helped us a lot. People have been killing the command line for decades, yet anyone who uses a search engine is working with a cli.
Re:Pretty Lisp by pnathan on Wednesday February 29, 2012 @05:03PM (#3649923)
I have written some amount of Lisp - at this point in the 5-10KLoC range, and I don't think this tool is a great editor.

However, it's one of the more useful code/program visualizations I've come across.

Re:Pretty Lisp by jsmcgd on Wednesday February 29, 2012 @03:43PM (#3649591)
Seconded. I made some designs for a graphical IDE like this years ago, but only on paper. I'm very happy to see someone else has done the hard work for me! I hope they'll support other languages too.
Re:Pretty Lisp by spitfire on Wednesday February 29, 2012 @04:09PM (#3649717)
It's funny, more and more I'm moving my work to Mathematica because it works sort of like this already. That, and it's as far along the power curve from python/ruby as python/ruby is from C.
Re:Pretty Lisp by taliesinb on Wednesday February 29, 2012 @06:11PM (#3650206)
One neat thing about working with Mathematica in Eclipse is that successive clicking expands your selection 'outwards' up the syntax tree. It's an quite astoundingly useful feature for refactoring.

I'm sure some LISP editors have this too, but in a m-expression language like Mathematica it seems like magic.

Re:Pretty Lisp by gsg on Wednesday February 29, 2012 @10:14PM (#3650757)
When I was first learning elisp, one of the utilities I wrote was a flood-selection feature that sounds very similar to what you describe. Interestingly, it turned out to be quite useful in C code despite only being aware of string and paren (and brace and bracket) boundaries.
Re:Pretty Lisp by spitfire on Wednesday February 29, 2012 @06:44PM (#3650299)
Are you talking wolfram workbench or eclipse? (I don't have workbench). If eclipse has mms support I'll be trying that out tonight.
Re:Pretty Lisp by taliesinb on Wednesday February 29, 2012 @06:58PM (#3650341)
Ah, my bad. You can install it as an Eclipse plugin, but that seems to require access to an internal server. So guess you're stuck with the Workbench, our branded version of Eclipse, which requires "premier service".

Sorry!

Re:Pretty Lisp by spitfire on Wednesday February 29, 2012 @07:29PM (#3650412)
Yeah. I don't have premier service. (When it says "call for quote" I leave) I'm guessing you work for wolfram?

Is there a demo available somewhere?

Re:Pretty Lisp by rwallace on Wednesday February 29, 2012 @10:27PM (#3650789)
I've heard Mathematica praised before, but not in precisely those terms - I was under the impression it was more a DSL for mathematics. Can you give a few examples of things it can do that put it that far along the power curve relative to Python/Ruby?
Re:Pretty Lisp by taliesinb on Friday March 02, 2012 @01:02AM (#3655558)
Well, Wolfram|Alpha. I switch from computer vision to parsing to machine learning on a daily basis. But I haven't used the workhorse mathematics functions like Solve or Integrate in 3 years.

Perhaps it would be better to call it a 'Domain General Language' for everything.

Re:Pretty Lisp by Arelius on Wednesday February 29, 2012 @04:43PM (#3649842)
What kind of work do you do? Moving the work from what language? Do you not worry about having to pay huge licensing fees to run your code elsewhere?
Re:Pretty Lisp by spitfire on Wednesday February 29, 2012 @06:38PM (#3650279)
Executive brief - Go high end, where the money is. Where results are valued.

Licensing isn't an issue - $3K/year+libraries for development. A runtime player for Mathematica costs $300. You just have to pick your projects carefully - No rails todo apps.

One recent project I worked on was auto segmentation and labelling of MRI images. Auto-segmentation was the easy part. Labelling however took several different approaches before I got something that works reliably.

Re:Pretty Lisp by Arelius on Wednesday February 29, 2012 @09:44PM (#3650700)
This sounds like the kind of work that most people I know would choose matlab for (image segmentation). I personally have never used either for such, but do you have any thoughts on the matter? Is Mathematica getting better at the things matlab used to be best at?
Re:Pretty Lisp by spitfire on Wednesday February 29, 2012 @11:16PM (#3650886)
It sort of comes down to what you're comfortable with. In this case, the strict image analysis parts were more minor compared to the real work. Also, Matlab seems to be stagnating, while Mathematica has been growing by leaps and bounds. Also, matlab doesn't have built in functionality for gui building, afaik.

A lot of my other work is much less suited to matlab. Mathematica is certainly much better for multi-domain work, which matlab barely supports.

Re:Pretty Lisp by taliesinb on Friday March 02, 2012 @01:03AM (#3655564)
I think most people you are know are just ignorant of how much better Mathematica is. It's okay. People like to stick to what they know.
Re:Pretty Lisp by Arelius on Saturday March 03, 2012 @03:06PM (#3660987)
Being more of a software engineer than a mathematician, and having no MatLab experience, and more basic Mathematica experience. That is, in fact, the the impression that I get. But I still see people using MatLab what seems like more often, and have no weight to backup my claim. I suppose I could learn both and do research, but in general, that seems so less important than getting actual work done.

One aspect that seems to be brought up about MatLab often is the community, it's often claimed, especially in the co punter vision world, that if an algorithm exists, it has an available implementation in MatLab source. Which seems significant.

Re:Pretty Lisp by zokier on Thursday March 01, 2012 @02:15AM (#3651280)