in ,

Autocomplete as an interface, Hacker News

Many computer systems offerautocomplete: the ability to guess what you’re about to type based on the first few letters you’ve typed. For instance, if you open up IPython and create a string variable, you can do this:

In [7]: s=’foo’ In [8]: s.splitlines s.startswith s.strip s.swapcase

I’m used to thinking of autocomplete as a convenience tool that saves you a few keystrokes, but it’s much more than that. Good autocompletion has become a driving factor in which tools I choose. If I were writing a sophisticated user interface today — say, a programming language or a complex application — autocompletion is one of the primary constraints I would design it around. It’s that important.

Tons of folks (including me) swear by zsh as a huge improvement over bash. But most of us barely use the actual features that are exclusive to zsh (RPROMPT? Advanced globbing? “Improved array handling”?) Instead, for most people the killer feature of zsh is thatit doesn ‘t re-output the prompt when you autocomplete. Compare…


test% cd fofoo1 / foo2 / foo3 / fop /


test $ cd fofoo1 / foo2 / foo3 / fop / test $ cd fo

In zsh, the cursor stays on the first line, whereas in bash, the cursor moves to the third line. (bash also requires you to hittwice — the first time you press it, you get a bell sound but no completions. Gee, thanks, bash!)

That one extra line is the single biggest reason why bash users leave. Because it means that bash barfs out a different set of completions every time you tab (twice):

test $ cd fofoo1 / foo / foo / foo 13 / foo2 / foo3 / fop / test $ cd foofoo1 / foo / foo / foo 13 / foo2 / foo3 / test $ cd foo1foo1 / foo / foo / foo 13 / test $ cd foo1

Once your directories start having more than 10 files in them, you’ll end up with an unreadable mess in your terminal history. Zsh, by contrast, will delete your previous completion lists when it makes a new one, avoiding the mess entirely. It’s a dramatically more pleasant experience when you autocomplete shell commands a hundred times a day.

I can point to exactly one tool that has approximately doubled my programming speed, and that’s the IPython notebook (as an alternative to coding into a file and running it).

Part of this is because I can immediately see the results of my computations. But a larger part is because IPython autocompletion is hands-down the best way of learning about Python.(1) ******************** (1) ****************

Say I want to manipulate a string in Python. I could open up a new tab, google “Python string api”, remember whether I need Python 2 or Python 3, scroll through theirbadly organized page on strings, realize that the first Python 3 result for “python string api”doesn’t actually describe the methods onstr, search “python string methods” instead, realize I wanted the “built-in types”docs, scroll wildly through theirlong, spaced-out list of methods Until I found one I wanted, context-switch back to my code, and repeat.

(I swear I wasn’t trying to pick a particularly convoluted example and this isactually what happenedwhen I looked for the string documentation while I was making this post)

Or I could take my string object that already exists in my notebook, type (s.and see whether any useful-looking methods appeared. Nice!

And that’s just with strings, which have relatively well-written documentation. Good luck navigating something less well-supported likePyQTwith the written documentation! I hope you enjoy constantly translating from C to Python.

(As a side note, this is a big advantage of the ()instead of Julia-style (bar (foo) for method calls. In Python you can typefoo.and get a list offoo. I'm not sure an equivalent operation exists in Julia, and it would be tough to design one that's as easy to use.)

I spend most of my waking hours in a state of mild annoyance at Xcode. But it’s a great case study of autocompletion enabling fundamental interaction shifts.

Objective-C reallyneedsautocomplete in a way that many languages ​​don’t, because in Objective-C all arguments are keyword arguments. (Mostly.) Your method calls will look something like(2)

(I’ve left it to hang off the side of the page for effect.)

On the one hand, the method names can get pretty heinous. I’m glad that somebody else is invoking


so I don’t have to.3The API writers could certainly use a lesson in concision. And the fact that Apple’s methods were designed for autocomplete means that the language is practically unusable in environments without it, which in practice means substantial lock-in to Apple’s proprietary dev tools since no one else invests as much.

On another few hands:

Blitting is a complex operation that needs to go really fast! If you want to blit something quickly you actually do need an eight-parameter method.

    The reason we don’t usually need named parameters is that (a) there’s usually an obvious convention for the order that the parameters go in, so the programmer can guess the order; (b) if you mess up the order, the type system will usually catch your mistake. If you have eight integer parameters, both of these break down.

So why is auto-completion so great?

First of all, the keyboard is a much higher-bandwidth interface than pointing and clicking. If you type words per minute you’re typing 4 characters per second, for bits of entropy per second. To match that precision with a mouse would require you to be able to identify and navigate to any thumbnail-sized part of your screen in a third of a second. (********************************************** (6)Maybe barely doable if you’re very dextrous.

The problem with most keyboard-based interfaces is that, even if the input is high-bandwidth, the output isn’t. For instance, my text editor appears on a screen with 3.5 million pixels (100 megabits of entropy if we’re being generous), but it’s barely using any of that to display novel information —Every time I press a key, I can predict almost exactly what my file will look like afterwards. I’m giving the computer a lot of information, but I’m not getting very much back.

Here’s why the high-bandwidth visual interface is important: The common thread in between the autocompletion in zsh, IPython, Xcode and OS X help is that itmakes it easy to find hidden things.

As computers get more complex, the number of objects they have to deal with — files, functions, menu items, or anything else — explodes. The easiest way to tame the complexity is to hide these objects away until you, the user, call them out by name. But the computer is dumb, so you have to get the nameexactly right. You have to pick exactly the right menu sequence, or type out the method signature precisely, without any feedback process — it’s like shooting a bullseye in the dark. Autocomplete turns on the lights.


****************************** Read More (**********************************

What do you think?

Leave a Reply

Your email address will not be published.

GIPHY App Key not set. Please check settings

Dow Smashes Record as Animal Spirits Seize the U.S. Stock Market, Crypto Coins News

Dow Smashes Record as Animal Spirits Seize the U.S. Stock Market, Crypto Coins News

Back pain is a massive problem which is badly treated, Hacker News

Back pain is a massive problem which is badly treated, Hacker News