Lurker News
Bike’s most original feature is the “fluid” text editing. Lots of text editors have animated some interactions (cursor movement, insert newline, etc), but I think Bike is the first designed from the ground up to support fluid editing.

Give it a try, it feels different. (movie on home page if you don't have Mac)
Other Features:
• In text mode Bike works like a normal text editor. In outline mode rows are constrained to outline hierarchy.
• .bike file format is HTML subset, so files are easy to parse and manipulate. Bike also supports .opml and .txt.
• Scriptable via AppleScript. Javascript plugin API also expected in future, though no timing on that.
• Architecture needed to support fluid editing also makes Bike faster/more scalable than most (all?) outliners and many text editors. I test performance using the Moby Dick Workout[^1].
Implementation Notes:
• View is built using CALayers[^2].
• Animations are performed by Core animation and Motion[^3] lib.
• View performance is determined by visible text, not document size.
Model representation is interesting in that it’s just a flat list of rows. Each row has a `level` property, outline structure is determined dynamically. View implementation requires that each row has a unique ID.
I’m using OrderedDictionary from Swift Collections[^4] to store rows. This is Bike’s performance bottleneck for large outlines. Eventually I may change to augmented b+tree and then should be able to work with gigabytes worth of outline. That will be fun, but not sure it’s actually needed. Already probably fast enough for 99% of use cases as is.
Hope you find Bike interesting. I’m happy to answer any questions.
[^1]: https://www.hogbaysoftware.com/posts/moby-dick-workout/
[^2]: https://developer.apple.com/documentation/quartzcore/calayer
[^3]: https://github.com/b3ll/Motion
[^4]: https://github.com/apple/swift-collections

Comments (236) 69 threads

Show all comments

Showing thread 1 of 69

camgunz2 replies#
In particular I love these features:

- "respects your computer's memory and battery"
- "uses open file formats"
- "is scriptable"
Feels like we should also think about these kinds of things when we think about "organic" software. Kudos to the developer for these.

jxy4 replies#
How much memory and battery do all the animation use?
stevenbedrick1 reply#
Probably very little if it is built on top of CoreAnimation, since that set of OS APIs is extremely heavily optimized specifically to enable animation-rich UIs that are light in terms of CPU and battery use.
armadsen1 reply#
Indeed. As far as I know, Core Animation was originally created as part of work on the first version of iOS (née iPhoneOS), where the target device, the original iPhone, was pretty severely memory and CPU constrained.
xattt1 reply#
Here’s part of the ArsTechnica article on Leopard that discussed CoreAnimation:

https://arstechnica.com/gadgets/2007/10/mac-os-x-10-5/8/
Of note:
> [The] advent of Core Animation probably means that we'll have to endure some amount of gratuitously animated software created by "overly enthusiastic" developers. But the same was true during the introduction of styled text and color graphics. Mac developers learn quickly, and Mac users are good at rewarding restraint and punishing excess.

armadsen#
Right, it was introduced publicly as an API in Mac OS X Leopard, but my understanding has always been that it was actually conceived as part of iPhoneOS, then ported to Mac as well. The iPhone shipped a few months before Leopard, though of course UIKit wasn’t made public until the next year when the iPhone SDK was first released.

There’s a similar story around SwiftUI. It was initially created by the Apple Watch team at Apple, then extended to all the other OSes (all this was long before it was made public).

jessegrosjean#
I think the architecture needed to support them means the total package is less than most apps. For example consider scrolling:

In Bike it's fast enough that when you scroll it just updates what you can see on the screen. This means you only pay memory for visible text. For most macOS apps scrolling performance is achieved by pre-rendering before and after the visible scroll area. So you pay for that cache and you also pay for the background processing required by pre-rendering.
Also consider simple things like window resize. In Bike that only effects visible text. If you open a large document in TextEdit you will see that resize is quite slow and processor and memory intensive. (you can test with https://www.hogbaysoftware.com/posts/moby-dick-workout/). And then after that resize there's lots of background processing to refill a bunch of layout caches I guess. On the other hand resize is instant and only does work for visible text in Bike.
I don't think the animations are expensive, but it's hard to test because that work happens in Mac OS window server and I'm not an expert there. If they really are a problem and you are on battery then you can turn off animations in preferences.

sudhirj#
CALayer is part of the OS toolkit, so probably not much. It’s the same system the OS itself uses, so probably a shared lib, and it’s heavily optimised. Similar to animating your web page with only CSS animations. It’s all baked into the existing rendering system already.
jessegrosjean#
If anyone digs in and profiles Bike 1.0 you'll unfortunately find that it is wasting some CPU with a timer. This will be fixed soon and is not related to underlying architecture or animations. It's me coalescing events from user defaults with a Combine API that I didn't fully understand.
b3morales#
Jesse is certainly one of the patron saints of open formats in the Apple world given he invented TaskPaper.