Scrolling with pleasure

Mouse with a smileIn this article I explain what it takes to implementing high-quality smooth / high-precision scrolling on modern computers and why some systems have it while others don’t. Most of the insights came from my work on implementing “true smooth scrolling” in IntelliJ IDEA.

The article complements my previous article “Typing with pleasure”, just like scrolling naturally complements typing in the day-to-day activity of most computer users. Nowadays, some interfaces are based solely on scrolling! Because scrolling is so ubiquitous, any improvement in its functioning automatically improves the user experience and can boost our productivity big time.

The topic of scrolling seems to fascinate a surprising amount of people — computer forums are filled with questions like “Why does Mac OS X trackpad moves so much better than Windows?” or “Why no smooth scrolling on Linux?” . Despite the pry, the answers usually come down to something like “Mac OS uses magic, just deal with it”, which only makes the issue even more mysterious. However, as the third Clarke’s law says “Any sufficiently advanced technology is indistinguishable from magic” — so no actual magic is required — the proper technology is all that is needed.

Although the article contains a great deal of technical details, I hope that it will be interesting not only to computer programmers, but also to people who wonder how scrolling works under the hood, why we have what we have and how we can make the scrolling better.

Contents

All the code examples are available as a GitHub repository.
Continue reading

Typing with pleasure

Keyboard with a smileIn this article I examine human- and machine aspects of typing latency (“typing lag”) and present experimental data on latency of popular text / code editors. The article is inspired by my work on implementing “zero-latency typing” in IntelliJ IDEA.

Latency recently became a hot topic in computer world — now we have low-latency keyboards, 144 Hz monitors, special technologies to reduce latency (like FreeSync or G-Sync), dedicated communities and whatnot… Sure, a part of the buzz is marketing, however the truth is that low latency became both feasible and desirable.

Apparently, gamers are the first who gain form those advancements. In some areas, like virtual reality latency turned out to be a crucial factor, where even a single millisecond matters. But what about programmers? Do we need “typing with pleasure” to “develop with pleasure”? Let’s find out.

The article is also (independently) translated into Russian.

See also: Scrolling with pleasure.

Contents:

  1. Human side
    1.1. Feedback
    1.2. Motor skill
    1.3. Internal model
    1.4. Multisensory integration
    1.5. Effects
  2. Machine side
    2.1. Input latency
    2.2. Processing latency
    2.3. Output latency
    2.4. Total latency
  3. Editor benchmarks
    3.1. Configuration
    3.2. Methodology
    3.3. Windows
    3.4. Linux
    3.5. VirtualBox
  4. Summary
  5. Links
    Continue reading

Typometer

Technical drawing of keyboard keysTypometer is a tool to measure and analyze visual latency of text / code editors.

Editor latency is delay between an input event and a corresponding screen update, in particular case – delay between keystroke and character appearance. While there are many kinds of delays (caret movement, line editing, etc.), typing latency is a major predictor of editor usability.

Check my article Typing with pleasure to learn more about editor latency and its effects on typing performance.

Project source code is available as a GitHub repository.

Download: typometer-1.0.1-bin.zip (0.5 MB)

Java 8 or latter is required to run the program. You can download Java from the official site.
Continue reading

Low-latency painting in AWT and Swing

00:00:00In this article I enumerate reasons why typical approach to painting in AWT / Swing can result in substantial visual lags, provide examples that demonstrate the problem and propose methods to significantly reduce the drawing latency.

Despite the focus on Java platform, the key ideas can be extended to most modern operation systems and GUI frameworks.

Contents:

  1. Problem statement
  2. Typical implementation
  3. Asynchronous painting
    3.1. Queue delay
    3.2. Request skip
    3.3. Region extension
    3.4. Component reordering
  4. Synchronous painting
    4.1. Component opacity
    4.2. Buffering overhead
    4.3. Showing delay
    4.4. Buffer reuse
  5. Active rendering
    5.1. Incremental painting
    5.2. Pipeline flush
  6. Summary

All key points are accompanied by short, shelf contained, compilable examples that clearly demonstrate the theoretical concepts in practice. The code is also accessible as a GitHub repository.
Continue reading

Install IntelliJ IDEA on Raspberry Pi

Raspberry Pi and IntelliJThis article shows how to install IntelliJ IDEA on Raspberry Pi. The instructions are also applicable for other IDEA-based IDEs like PyCharm, RubyMine, PhpStorm, WebStorm, CLion, etc.

At first, the idea of installing a full-fledged, contemporary IDE on Raspberry Pi may seem unrealizable. Raspberry Pi boards are incredibly small, so it’s hard to believe that those devices are apt for such a task. Nevertheless, in reality, Rasperry Pi can do much, much more than blinking a LED.

After trying out Scala on Raspberry Pi for some time, I configured my Rasperry Pi to run IDEA & Scala plugin for the recent ScalaDays conference. While it was initially intended to be just a “proof of concept”, it turned out that we were able to open the Scala plugin project itself (which is pretty large, and includes all IDEA CE sources) and to comfortably use this setup for most feature demonstrations. Obviously, it’s unreasonable to expect desktop-like performance from such a device, however I happen to successfully use a similar environment on EEE PC which was hardly faster.

The instructions rely on the following keystones that make the undertaking possible (and even practical):

  • Raspberry Pi 2 Model B, which offers a 900MHz quad-core CPU and 1GB of RAM (this one is for the “practical” part, yet you may try to use Rasperry Pi 1 as well).
  • Oracle JDK 8 for ARM (with HardFP, JIT and server VM), which provides >10X performance boost (comparing to Zero VM from OpenJDK).

  • Small, but essential modifications that enable IntelliJ IDEA to run on ARM systems, like Raspberry Pi (you may use the same techniques for other ARM-based microcomputers).

Update: we’ve fixed the incompatibilities, so IDEA 15 (or later) should be able to run on ARM architecture (including RaspberryPi) out-of-the-box.

Contents:

  1. Installing Java
  2. Installing IDEA
  3. Tweaking Raspberry Pi
  4. Tweaking IDEA

Some of the commands will require root privileges, so either login as root user or use sudo to start an interactive shell via sudo -i.
Continue reading