Live data from Hacker News

Building a hackable editor in the browser

bjenik.com

61–70 of 74 posts

Re: Building a hackable editor in the browser

#61
post #6

...how about moving things out of the browser? It's cramped as it is. And then people wonder why their browser is so slow... "it's just displaying documents!"

For that we’ll need an adequate cross-platform (-ish) way of doing UI. I’m not a fan of React Native, but it seems to be the technology we’re looking for, though it doesn’t seem to be as ready for the desktop yet. An all-native solution on top of a powerful modern language (rust?) would be ideal, but that doesn’t seem to be the direction things are moving. We’ll probably end up with Flutter/Native.

What about libui?

Re: Building a hackable editor in the browser

#62
post #50

Earlier quoted context omitted.

That's what native used to be, but nowadays it's "not electron". Qt or wxWidget apps are considered native as well.

> That's what native used to be, but nowadays it's "not electron". This makes me sad. Coherent UI is a very important point to users IMO. Users can assume that some special feature from App X will also work on App Y. (It also allows OS/GTK/Qt devs to enhance UX without application modification.) For example, in macOS Cocoa, textboxes have universal readline-esque keybindings (and is configurable globally) which, as a…

> macOS Sierra added tabs to Cocoa apps, and applications could get the feature without additional modification. (I’m not sure if it’s absolutely none or if recompiling was needed, but I think it’s the former.)

Tab support was added without linking against the new SDK: apps would get it "for free" when running on macOS Sierra.

Re: Building a hackable editor in the browser

#63

Earlier quoted context omitted.

> That's what native used to be, but nowadays it's "not electron". This makes me sad. Coherent UI is a very important point to users IMO. Users can assume that some special feature from App X will also work on App Y. (It also allows OS/GTK/Qt devs to enhance UX without application modification.) For example, in macOS Cocoa, textboxes have universal readline-esque keybindings (and is configurable globally) which, as a…

> macOS Sierra added tabs to Cocoa apps, and applications could get the feature without additional modification. (I’m not sure if it’s absolutely none or if recompiling was needed, but I think it’s the former.) Tab support was added without linking against the new SDK: apps would get it "for free" when running on macOS Sierra.

> Tab support was added without linking against the new SDK: apps would get it "for free" when running on macOS Sierra.

Yeah, right. I remember being very happy as some of my not-worried-about-mac applications (it's a word processor that uses a special format only used in our country) had tabbing enabled. :-)

Re: Building a hackable editor in the browser

#64
post #47

Earlier quoted context omitted.

For that we’ll need an adequate cross-platform (-ish) way of doing UI. I’m not a fan of React Native, but it seems to be the technology we’re looking for, though it doesn’t seem to be as ready for the desktop yet. An all-native solution on top of a powerful modern language (rust?) would be ideal, but that doesn’t seem to be the direction things are moving. We’ll probably end up with Flutter/Native.

Yes that would be awesome! Unfortunately the providers of the OS'es we use don't bother with this. What would the world be like if you could run anything anywhere and most importantly: how would you decide that you prefer a mac to a windows-machine? I think web technologies are a bridge that many like to use because of the sad state of things in the UI domain.

Microsoft maintains it's own fork of react-native that allows this. https://github.com/Microsoft/react-native-windows

There's more experimental forks for macos and qt.

Re: Building a hackable editor in the browser

#65
post #51

Earlier quoted context omitted.

> The way I see it is that a new toolkit like GTK or Qt is required in the target language. The way i See it is that a new toolkit like GTK or Qt is required in C so that it can interface with any language as to avoid unnecessary duplication between languages (it is much easier to convince people switch toolkit than switch programming languages), ensure no language-specific indirect dependencies (especially if it is…

> and perhaps hopefully become a "standard" API people can target on Linux without having to carry 29892482923TB of libraries for a trivial app since you cannot rely on anything outside of X11 being there so, uh, what would you depend on ? at the bare minimum you would need, for a gui toolkit : - dependencies to X11 (xcb) and wayland (and cocoa and win32) - dependencies to xkb, etc.. for keyboard handling - dependenc…

Of everything that list all you really need is the X libraries and you do not need to carry (meaning distribute) those since they are part of the every single desktop environment and have a stable ABI. The rest aren't strictly necessary, but i think Cairo has a stable ABI. I'm not sure if it is available everywhere though. OpenGL (and Vulkan) can be provided via dynamic linking, though only via an API that doesn't guarantee its existence (it doesn't exist in all X11 desktops - AFAIK Raspberry Pi doesn't support them).

In any case, the dependencies i mean here are dependencies for the applications that target your API, not the dependencies your API has. You can make your API use whatever library you want to -e.g.- load PNG, JPG or whatever, but that can be hidden from the user of the API (ie. their binary will link against libyourapi.so.1 for yapi_load_image and what that specific version of libyourapi.so.1 uses to load the requested image is an implementation detail).

Note that this is in the context of making that API a standard people can target, not a reusable library (and its own dependencies) people carry with their binaries. Basically the equivalent of how you do not need to give USER32.DLL on Windows to your users because you can pretty much expect that it will be there.

Nowadays the only equivalent on Linux is the X libraries, anything else is either not guaranteed to be there now, or not guaranteed to be there in ~5 years because thanks to CADT people cannot stick with an API and feel the need to break everyone's programs to feel useful.

Re: Building a hackable editor in the browser

#66
post #48

Earlier quoted context omitted.

fyi, I'm on Linux. Here's a list: ranger, urxvt, sxiv, w3m, xev, vim, feh and qutebrowser.

vim is slow to start? Have you checked the SMART stats on your drive lately?

No, read the conversation again. I've listed stuff that loads faster than zero point two seconds.

Re: Building a hackable editor in the browser

#67
post #23

Earlier quoted context omitted.

If you think you browser is fast, you'd be blown away by any decent application. Too bad all apps are now electron.

> If you think you browser is fast, you'd be blown away by any decent application. In data centers, loading data from networked server, where it's in memory, can be used over loading data from a disk, because disk is comparatively slow. A web app can load JavaScript assembler, which isn't much slower than a desktop app written in C. Bigger - and slower - parts of the web app can be loaded after the app starts interac…

> In data centers, loading data from networked server, where it's in memory, can be used over loading data from a disk, because disk is comparatively slow.

RDMA has no relevance to this discussion.

> A web app can load JavaScript assembler, which isn't much slower than a desktop app written in C.

This is incredibly wrong. An Electron app goes through many stages before code is executing with acceptable performance:

1. A full web browser loads.

2. JavaScript is loaded and parsed.

3. JavaScript runs interpreted, which is very slow. It is only here that the "application" starts.

4. After a while, the JIT may decide to compile some code. This is very resource intensive.

5. After compilation, you finally have some parts that have decent performance. However...

6. Gaurds fail (i.e. bad assumptions), and the code is deoptimized, running at slow speed again. JIT compilations may be tried again later with new assumptions, and if you're lucky, they might hold.

At #5, you have code that is as fast as it gets. It is nowhere near as fast as native code (any benchmarks you think of are synthetic and designed to show JavaScript as fast—it doesn't take a lot to shake out the issues).

For a native application, however, the process looks like this:

1. The application starts, and it runs.

Done. There is no parsing, interpreting, optimization. This single step is orders of magnitude faster than just #1 of the life of an Electron app.

> Bigger - and slower - parts of the web app can be loaded after the app starts interacting. So - at least in principle - no sizeable speed difference, which would blow somebody away.

We are talking a speed difference in orders of magnitude here. An electron application is not even done preparing Electron before a good native application is done loading.

And it's all fine and dandy that you can load heavy things later, but for a good native application has nothing to load later. It's done.

A fun comparison:

1. Slack cold-start on my machine: ~3 seconds before anything shows up, ~5 seconds until a main window with a loading indicator is visible, ~10 seconds till fully loaded and usable.

2. Telegram-desktop cold start on my machine: ~1 second till fully loaded and usable.

And telegram-desktop is a very slow native application! A speedy application starts in 250ms or less, and never waits after that.

> Advantage of web app is cross platform uniformity.

And the disadvantage is that they are are huge, resource intensive and pathetically slow.

We have very functional cross-platform toolkits, like Qt that telegram is based on.

Re: Building a hackable editor in the browser

#68
post #7

Earlier quoted context omitted.

My browser is not slow, for me starting and using a lot of desktop apps feels slower than browser apps to be honest.

Your slow desktop app is an electron app

No, my fast app (VSCode) is an electron app. Steam is slow, Photoshop is slow, SourceTree is slow.

Re: Building a hackable editor in the browser

#70
post #23

Earlier quoted context omitted.

If you think you browser is fast, you'd be blown away by any decent application. Too bad all apps are now electron.

> If you think you browser is fast, you'd be blown away by any decent application. In data centers, loading data from networked server, where it's in memory, can be used over loading data from a disk, because disk is comparatively slow. A web app can load JavaScript assembler, which isn't much slower than a desktop app written in C. Bigger - and slower - parts of the web app can be loaded after the app starts interac…

> Advantage of web app is cross platform uniformity. Write once, run everywhere.

In theory -- yes. But in practice, it is write once, debug anywhere. Remember a certain electron app consuming 100% CPU for a blinking cursor on a certain platform?

Post reply on HN