The Typographic Programming Language
joshondesign.com
joshondesign.com
A few notes:
We convert () into a box for viewing, but de-convert it back to () when the line is selected for editing.
Unicode (and non-uncide special characters) is used as a rendering for ascii based operators. So >= is rendered as "≥"; however, for editing to work, we add a dot at the end so the character count remains the same, so its actually "≥∙", if you delete the dot, you are basically deleting the ascii "=" so the character becomes ">".
I thought about colors and graphics, but they create huge real estate issues, and they aren't widely applicable. Also, people get what "red" is while the literal color red is quite ambiguous.
Rather than find a new symbol for multiplication, it probably makes more sense to render the single x variable differently (as well as other single variable identifiers like i and j). I haven't implemented this yet, but its on my list.
If you look at the videos, you'll see that static and run-time errors are rendered underneath the tokens they are related to. The idea is to keep the feedback as close to the code as possible.
If it's more than syntax highlighting, then how do you make the "quoted" text? What keypress to you use to start and end the markup that signifies quotes? Maybe the quote key ;-)?
I think one big part of all of this is speed of execution: both maximum speed, but also the learning curve. And I'm not at all sure that we can do better than typing text. Hell we've been trying to get rid of the keyboard for years, and yet nothing is faster than a VIM ninja
I could imagine a source file format where the nodes have different types for different literals. There would be much less parsing problem than parsing plain text, of course it would need a special editor.
Also, there must be a better example than quotes and strings for this "visual" representation to make sense. There is nothing hard about either reading or typing them. It's not even a particularly nerdy concept; readers and writers everywhere know how to handle quotes.
Quotes are already visual by the way. They simply aren't color-based. Which probably makes colorblind readers glad.
And unless those node types are "green round-rectangle", then I posit that it's still syntax highlighting, since the editor is deciding how to display "string node".
5 ↤ "hello"
Now you could argue that the editor might detect that and not allow it, but if your abstract syntax tree data structure can support it, then you will be handed it at some point and so you should detect it.But more importantly, the abstract tree itself has to be stored. Whatever the format (binary or otherwise), that has to be checked, too (unless you want buffer overflows or code execution exploits in your compiler/editor).
All in all, it sounds like the same stuff compilers already have to deal with, so I don't think it wouldn't be a win there.
How would you store that highlighting to disk?
In seriousness, I think this kind of extreme highlighting could be an important step in making programming more accessible. There are only so many characters like ,;:.()[]{}<> available to use in code, and often most of them indicate completely different things in different places.
Done the right way, and combined with live evaluation á la Bret Victor or the Swift playground, I think this has the potential to be the next paradigm of accessible programming, after Excel.
http://www.wolfram.com/language/fast-introduction-for-progra...
What seems to have caught on instead is editors that use syntax highlighting/formatting to show ascii source code in not-pure-ascii ways. It would be interesting to take this further.
{ C: r => 2 * π * r }
There's a link inside to their paper on Language Boxes, which formalize the whole idea. It uses an incremental parser where nodes of the syntax tree can be opaque "boxes" which could contain any other nested AST, as the languages are parsed separately. It does a nice job of tackling the syntax composition problems, of which the proposals seem like a special case.
As Tratt points out though, the ideas are not particularly novel - they've been around for decades, but are usually met with resistance as they break existing workflows or programmer expectations. The design philosophy behind Eco, their prototype editor for language boxes, is that it should look and behave almost exactly like a traditional text editor. It does support highlighting of inner languages when they're selected, but the highlighting is usually not visible. I'm pretty sure we could turn them always on and get the kind of appearance this post is looking for.
As far as the concatenation thing surely that's solvable by a grammar that interprets a single line list of expressions as an implicit concatenation. It doesn't seem like something that requires a particularly smart compiler - or a new IDE. Maybe I'm overlooking something inherently hard about the problem though.
For example, it you would type a string, and wouldn't need to worry about whether it is represented as multi-line string or not or how to properly escape newlines and special characters. Your editor would know that you are typing a string and do the appropriate thing.
That said, many advanced IDEs do have very sophisticated syntax parsers which can do many of these things already. Light Table and Lisps evolve this even further. I would imagine that a language designed with this use case in mind would enable even tighter integration with the development environment though.
M. Klerer and J. May, A user oriented programming language, The Computer Journal (1965) 8 (2): 103-109. doi:10.1093/comjnl/8.2.103 http://comjnl.oxfordjournals.org/content/8/2/103.abstract
Not particularly hard to implement a code viewer for the specific examples and the parser is one of the less complicated parts of a compiler, i suppose. Instead of quotes as delimiters you get e.g. xml tags, that the editor generates.
I've also posted a follow up to my blog, this time focusing on fonts.
You might want to check out this LTU thread:
http://lambda-the-ultimate.org/node/4733
You can find much old work on code typography linked there, like
https://www.youtube.com/watch?v=mG0lyGekGDs
http://www.othmanismail.com/classes/GPH352/ReadingArticles/D...
http://books.google.ca/books/about/Human_factors_and_typogra...
I'm kind of disappointed (but not surprised) that you didn't try a proportional font for code...it is my mission in life to banish fixed-width fonts from the earth.
edit: more extensive example: http://imgur.com/a/grrzl (from http://stephane.ducasse.free.fr/Teaching/CoursAnnecy/0506-Ma... )
- Encode the program in a data format like JSON or XML. Ideally, this should be readable (though verbose) on its own.
- Create an IDE that renders the JSON/XML using the typographical stylistic flourishes, and that possibly allows the definition of new styled "blocks". This could even be done with CSS.
Creating a language that is sufficiently connected to its IDE that it can define new syntax highlighting, autocompletion, etc. in the code itself would go a long way toward making something like this practical. DrRacket (http://racket-lang.org/) sort of does this already; it even has image literals!
Also, what's the big deal with removing quotes? I didn't know they were hard to read or understand. Are we removing them from books as well?
I'd welcome a nice rendering of mathematical formulas, sure. But that's merely presentation.
Basically, if you want an editor that displays code with colors and boxes instead of delimiters, that's fine; writing one would be a practical project. It is neither necessary nor desirable to attempt to design a new language, write a new compiler, version control system and half a dozen other ancillary tools at the same time as part of the same project.
Incremental text input is a different problem. If you only have to deal with a batch renderer, then no change is needed; if you have an interactive IDE, you might want to complete the closing " so feedback remains sane.
It would make more sense is with a custom keyboard perhaps, like apl.
Re. encoding data like images at the program level; this is not suitable for general purpose languages (IMHO) because it forces an implementation on the programmer. It's fine for relatively narrow-purpose languages like Mathematica.
I could imagine an IDE where it still serializes/deserializes to normal text, but you edit it in a mode like this.
Remember that when APL was created these things were not set in stone and what seems wrong to you in retrospect made perfectly good sense at the time (and in fact still makes perfectly good sense today, it's just that the world has moved on from APL to languages that are more verbose and/or that do not require symbols like these).
Math is another such language, and there is no keyboard suitable for entering mathematical expressions so we use software like LaTeX instead.
At least with the APL keyboard the link between input and display was very direct, with LaTeX much less so.
What?
http://pcmonk.wordpress.com/2014/03/19/phlisped-an-experimen...
"hello world"
"hello, #{name}!" # interpolation
%{hello world}
%{hello, #{name}!} # interpolation
%{hello, "#{name}"} # interpolation with quotes
%|hello, "#{name}"| # you can use other kinds of surrounding "brackets" if you don't like curly onesMore amazingly, want to combine TeX, lisp, a markdown like language, and python/whatever in a single document? Try org-mode.[3][4]
[1] http://ergoemacs.org/emacs/i/emacs_xah_css_mode_2014-04-22.p...
[2] http://www.nongnu.org/geiser/geiser_3.html#Seeing-is-believi...
so far TEXT files (ASCII, utf-8, utf-16, etc.) have made most sense for source code, when comes to huge group of people (100+).