332 points · by westoncb · 13y ago · 91 comments
Someone get this man a job, even if it has nothing to do with this code.
"My studies at these times were very fruitfull and I think now that mathematics has a chance at contending with coding, and I have finally seen some glimpses of mathematical structures that should be called beautiful."
Could be an alternative path there.
Game controllers are not better. Excerpt from wikipedia: "RSI is also used as an umbrella term for non-specific illnesses popularly referred to as Blackberry thumb, iPod finger, gamer's thumb"
Personally, I have never needed code folding (I prefer to have my own map of the code in my head, and anything that obscures that map just gets in the way), or Sublime Text's minimap, nor have I ever needed the symbol sidebar that is found in some IDEs (Eclipse, Netbeans). What I really want is more efficient editing.
For example, text editors like Sublime have zero language-sensitive refactoring support. I can't rename (variables, methods etc.) or extract methods, for example. Even some really simple operations like "select entire current nesting level" are unavailable. I remember using Eclipse 7 years ago and really liking the intelligence of the incremental compiler backend, even though I hated Java; it seems that with backends such as Clang, those tools can once again be applied outside big, annoying IDEs like Eclipse and Xcode.
Not sure if this particular approach is useful except to a small niche, but it looks pretty slick. Good luck with the effort!
On the other hand, I have colleagues who can't program without having pen and paper around -- people use whatever tools they like based on how their mind works.
The context-sensitivity is handled by having a list of expansion/contraction functions to try in sequence, so your region grows outwards by different units. Or you can specify a specific expansion function (like, er/mark-outside-python-string) upfront.
As an example, the expand function list I have for a python buffer open is:
(er/mark-word
er/mark-symbol
er/mark-symbol-with-prefix
er/mark-next-accessor
er/mark-method-call
er/mark-inside-pairs
er/mark-outside-pairs
er/mark-comment
er/mark-inside-python-string
er/mark-outside-python-string
er/mark-python-statement
er/mark-python-block
er/mark-python-block-and-decorator
er/mark-outer-python-block)
[1] https://github.com/magnars/expand-region.el or from ELPASublime also has "Expand Selection to Scope", except it doesn't really work that well: First invocation it chooses the current symbol, on 2nd the current brace block except the braces, on 3rd the braces themselves, and so on.
And it also has "Expand Selection to Indentation", but I don't see use for it in cases where you want to manipulate blocks of code, since it nearly always doesn't select what you want.
What I'd like is a command, let's call it "Expand Selection to Statement or Block", that:
* On 1st invocation, selects the current line.
int foo(int bar) {
bar = mogrify(bar);
if (bar > 0) {
slartibartfast = 42;
[[baz = bar + 1;]] # <-- [[ selection ]]
print_report();
}
return bar;
}
* On 2nd invocation, expands to the current contiguous set of lines, bounded by either empty lines or language-specific block (usually braces, or in Ruby's case, "if/while/..." until "end"), but not including the boundary: int foo(int bar) {
bar = mogrify(bar);
if (bar > 0) {
slartibartfast = 42;
[[baz = bar + 1;
print_report();]]
}
return bar;
}
* On 3rd invocation, expands to the current contents of the block, excluding braces and excluding the lines containing the braces. int foo(int bar) {
bar = mogrify(bar);
if (bar > 0) {
[[slartibartfast = 42;
baz = bar + 1;
print_report();]]
}
return bar;
}
* On 4rd invocation, expands to the enveloping statement that uses the block: int foo(int bar) {
bar = mogrify(bar);
[[if (bar > 0) {
slartibartfast = 42;
baz = bar + 1;
print_report();
}]]
return bar;
}
* On 5th invocation, it would continue to step 2, ie., looking for more lines that are contiguous with the current selection: int foo(int bar) {
bar = mogrify(bar);
[[if (bar > 0) {
slartibartfast = 42;
baz = bar + 1;
print_report();
}
return bar;]]
}
* And so on. Eventually it will get to the entire function declaration.Combined with a "wrap selection in braces"-type command (that indented the selection, wrapped it in braces, and placed the caret at the beginning so you could start typing something like "if (...) {") you would have a fairly powerful block-manipulating shortcut.
It would probably be quite trivial to write such a plugin. I might try my hand at this. Not sure how much language sensitivity it would need, might be doable without anything at all.
Talking of contiguous lines. I like macros of the following form for quickly hopping around vertically in a file:
// .sublime-macro
[
{"command": "move", "args": {"by": "stops", "empty_line": true, "forward": false}}
]
// .sublime-macro
[
{"command": "move", "args": {"by": "stops", "empty_line": true, "forward": false, "extend": true}}
]
// .sublime-keymap
{ "keys": ["ctrl+up"], "command": "run_macro_file", "args": {"file": "Packages/User/HopUp.sublime-macro"} }
{ "keys": ["ctrl+shift+up"], "command": "run_macro_file", "args": {"file": "Packages/User/HopUpSelect.sublime-macro"} }, vi{
v%For anyone else looking for exactly this, here's a great vim extension that gives you "indent" objects: http://www.vim.org/scripts/script.php?script_id=3037
Moving code around is not a difficult problem to solve. Drag to highlight, grab it and move it somewhere else. You've done that elegantly.
But writing massive amounts of code on a device without a traditional keyboard is awful and that's the difficult problem to solve. Until that's solved I don't think anyone can claim to have made real progress enabling development on keyboardless devices.
PD: Apple please don't sue me for the patent and copyright violation this may contain; I have no money and this image is just a non-profit parody so it is covered by "fair use" under US trademark law.
"What's not There (Yet): Text generation: with sufficiently structured text, the Tiled Text engine will narrow down the possibilities of what can be inserted at any given point so that the user can select textual constructs from a grid of options, rather than inserting everything one character at a time (this won't work for natural languages; it's for apps like shells and code editors, and perhaps some more exotic things). The engine for doing this is at ~(70% - 80%), but it has not been attached to the UI yet ..."
It'll be there soon!
I've come across occasional research projects in 'structural editors' which only allow semantically correct input (and, depending on the size of the input alphabet, can function through almost 100% autocomplete menu input)
Anastasia[1] is one that I know of, and this Modeless Structure Editing by Sufrin et al.[2] looks interesting.
The main issue I can see, apart from the effort involved, is how to deal with incomplete documents, since almost by creation or editing process will have interim invalid structures. Emacs paredit can be pretty infuriating if you don't use its specialised operations and try to edit your code in a way that malforms the structure.
I'm not sure how it would scale though, perhaps in a collapse/expand fashion similar to the current 'focus' mechanism, or some sort of level-of-detail aware zoom that progressively replaces chunks with higher level representations.
The author also notes on the main subtextual.org site about issues of mutable state, but it's definitely an interesting take on language design, and may (hopefully) not share the same death-by-layout-complexity fate most visual languages eventually suffer.
But the key complaint with these EMRs is that you need to type to use them, which is awkward and breaks the flow of conversation with a patient. Eye contact is important during patient interviews. Therefore, most doctors use paper and type them into the EMR later (waste of time).
A lot of people (and companies like drchrono) think that the way forward is to use tablets like the iPad mini or the Galaxy Tab, which balance the intrusiveness of the computer form factor against the ability to enter data. A pain point of tablet EMRs is text entry--but like I said, a lot of notes that doctors write have predefined structures, like code.
I think there is potentially a lot of money in elegantly solving this UI problem with a new interface like Tiled Text.
[1]: http://emacs-versor.sourceforge.net/
[2]: http://www.cb1.com/~john/computing/emacs/emacs-gamepad.html
The program looks awesome, but i believe it would be more productive to have this features on a regular IDE where you can actually use the keyboard... All the movement between nodes looks terrific.
But anyway...
He developed carpal tunnel or some other wrist aliment, and can't type for any real amount of time on a keyboard, apparently using an xbox controller is easier but really he wants to move to using the kinect.
I'm working on a non-plaintext programming language that just needs a structural editor like this. I'll drop you a line.
For example, in the video it was predetermined exactly what was going to be moving and where it was going to go to. From my observations, these sorts of large scale changes are rarely handled so easily. Context helps people map things cleanly, and the contextual change of zooming in and out forces you to constantly rebuild that map. It's an issue I've seen over and over again with any zoom-oriented interface.
Regardless, this is cool work. We need new and interesting interfaces for code - I'm hoping to show some fun things myself at the Live Programming Workshop [1] at ICSE[2].
[1]: http://liveprogramming.github.com/2013/ [2]: http://2013.icse-conferences.org/
Hadn't heard of those workshops -- will take a look.
I did stick around though and the video does look very nice, but I would recommend a more inviting first impression (I realize this is a library for developers, but still).
No one would ever call vim or emacs "slick", yet they own the market among the most expert users. That is not a coincidence.
The recently revamped PSN Store on PS3 has what I thought was quite a usable implementation of text entry. When searching the store, you select characters one at a time from a (vertical) strip, but that dynamic strip only contains characters for which there will continue to be search results after it's appended to your string. The current search results are shown as a live preview, so you need enter just enough to filter out the noise.
> ... I wrote Tiled Text to get around a mouse/keyboard injury I have ...
So this is not necessarily intended for everyone.
I've had an interesting experience using swype on nexus 7. I find my concept of spelling itself is changing'where creating a word is more about the shape than specific correct spelling. Using swype effectively still requires knowledge of how words are spelled and layed out on the QWERTY keyboard. But I see it pointing towards gestural text creation.
I actually like Vim Touch with Hacker Keyboard on my Nexus 7.
We will eventually see some growth in demand for text editing on tablets and phones. With some further research and innovation, you may be able to turn this into a tool (possibly commercial) that is useful for a larger audience.
Thanks for the comment -- reassuring to hear someone else envisioning that path.
I wonder if we'll have that at some point.
Often time I wish I can write some code on my phone but gave up after a while due to the painful editing process. It looks like it can help a lot. Looking forward to further development.