Hacker News new | past | comments | ask | show | jobs | submit login
So you want to write a GUI framework (2021) (cmyr.net)
195 points by eatonphil on June 23, 2023 | hide | past | favorite | 113 comments



I think the 3 absolute demons that will eventually seek to destroy you in any homebrewn GUI framework will eventually be:

- Rendering and dealing with text in all of its extreme permutation. Styling. Localization. Character sets. Etc.

- Modern accessibility standards. There are countless annoying yet de facto UX patterns that are just nightmarish to check off the list from scratch. Inputs/forms/etc. Even worse than accessibility, because you can decide to forgo that completely if you really wanted. The sheer volume of UX use cases and edge cases involved in even seemingly basic input components is also an exercise in rote dread. You've got input validation, error states, just so many ergonomics to deal with.

- Fluid layouts and scaffolding. This is where modern HTML/CSS finally starts to shine because making flexible layouts is actually quite painless. But it's a motherfucker to roll your own approach.


I had no idea how deep the text rabbit hole goes until a couple of years ago when I got the bright idea to make my own UI rendering engine. Quickly realized that I was waaaay out of my depth, and I now have a profound appreciation for all the existing stuff we take for granted.


With a background in linguistics and a descent understanding of Unicode, I thought I had something of a grip on the complexities of text. But then I read Text rendering hates you[0] and realized I had no idea how hard rendering text really is. The most striking example for me is the Arabic example where allh (Allah) is styled with different colours on each of the four characters, because this particular character sequence is a mandatory ligature if memory serves, and how do you figure out the colour changes when you're layout out a single glyph from the font?

0: https://faultlore.com/blah/text-hates-you/


Ha, yep this article was actually one of the things I was thinking of when I made the comment. I remember reading it and thinking "...maybe I don't want to do this after all".


Love the pun/typo of descent there. Trying to learn about Unicode does feel like you are descending into the trenches of meaning. In ways you probably don't want to.


I wish more people on HN would be this adventurous and this humble about their adventures.


My career in tech has been one humbling experience after another. I don't know how anyone spends more than a few years in this industry and still feels intelligent.


For me, the top of these is accessibility. Obviously people can write code they like for fun and free, but governments are increasingly, and in my opinion rightly, saying that if you want to sell a product it must be accessible if that is reasonable.

People like Apple, Microsoft and browsers put lots of effort into this if you use their existing frameworks right.


It's been bugging me for years, but I don't really enjoy modern HTML/CSS for fluid layouts when it comes to forms.

To do really nice form layouts in a desktop application, alignment and sizing of labels across the entire form becomes really important to me. Products like Developer Express that have a dedicated form layout work so well for this. And some of the swing layout managers I've used (I can't recall the name, too long ago) make complicated form layouts much more sane than grid, flex and other css layouts.


I will say this about HTML+CSS: it's not the best layout system I've ever used, but it's certainly the best one I've used that runs on all the platforms I care about.

That might change with .NET MAUI, though. I'm not too deep into it yet, and it is significantly different enough from HTML+CSS to be a challenge to learn, but what I havelearned so far keeps making me question "why did the CSS version of this have to be so hard?"


Maui would be interesting, if it had Linux support.


and ready for prime time!


I'll mention two others I find very hard.

The compositor. Dealing with ancient Win32 API, with his semi intelligent windows where seemingly every window feature is in weird undocumented ways coupled. Also, the race condition when rendering, just resize any window and see it jiggle. We seem to have collectively given up on fixing it.

Text Input. While not terrible difficult, so many features. From drag and drop, copy / paste, page up / down, CTRL up down left right, Home / End, wrapping. Text is by far the most complex GUI.


It's not the whole story but part of what makes accessibility hard is toolkits not being designed with it in mind from the beginning. That's how you end up with things like accessibility "modes" that are really just skin deep themes instead of proper modes.

Good accessibility capabilities requires flexibility to be at the core of the UI toolkit. You basically can't make assumptions anywhere.


But you can't forgo accessibility. Anyone who would make software with your framework would be in violation of several laws.

EDIT: I see that there are people down voting several comments in this thread in support of accessibility. I wonder what disagreement that you have? Surely it can't be "not a large enough market". There are more legally blind people in the world than Firefox users, yet web developers will happily test compatibility with that dying browser and eschew screen reader testing.


15+ years ago, I worked for an Australian university. We had a project to migrate to a new student email system – we were going from Novell NIMS (hosted on NetWare) to Sun/iPlanet/JES Messaging (on Solaris).

We asked our disability services office to review the webmail's accessibility. The manager of that office was a blind woman, who was both a staff member and a student, so she had her own personal student account. She told us she couldn't use Sun's webmail, it wouldn't work at all with her screen reader. We complained to Sun, their response was "we know, wait for the next major version".

What did we do? We offered her a shell account on a Solaris box with Pine, and told her that we'd offer the same to any vision-impaired students or staff members who requested it. And she was happy with that solution.

IANAL a lawyer, but from my understanding of disability discrimination law (which is different in different countries anyway), you are legally obliged to offer "reasonable accomodations" – which doesn't have to necessarily be by making the application accessible, it could be offering access to an alternative application instead.

Also, you are only obliged to provide accessibility if a disabled user asks for it, which assumes you have a user with a relevant disability – if your application is sufficiently niche, that might never happen. Suppose you build an internal GUI for SREs to use. Do you need to make that accessible for the vision impaired? Well, are any of your SREs vision impaired? If the answer is "no", then legally you don't. Maybe one day you'll employ a vision impaired SRE – at which point, then you will be obliged to make it work for them. But, maybe you never will, in which case you'll never have that legal obligation.


> Well, are any of your SREs vision impaired? If the answer is "no", then legally you don't. Maybe one day you'll employ a vision impaired SRE – at which point, then you will be obliged to make it work for them. But, maybe you never will, in which case you'll never have that legal obligation.

I don't completely disagree with you, I think accessibility is often a spectrum, and it's good to be thinking in terms of what your specific accessibility needs are, rather than just going for a scattergun approach.

That said, I have some problems with this example.

Firstly, a lot of features end up in the "accessibility" bin that are more broadly useful (the "cut curb effect"). Your SREs might be fully sighted and mobile, but they will probably still appreciate being able to drive the software fully by keyboard. And even from a development perspective, I've found having correct aria roles etc can often be useful for end-to-end testing because it allows you to be more semantic with the tests ("click on the thing with a button role with the text 'submit'" rather than "click on the element with the ID '...'").

Secondly, we often see accessibility in terms of the extreme cases ("you are blind, you have unlocked the accessibility treatment now"), but accessibility is more broad than that. If you're working late at night in a dark room, or trying to do something on a small laptop screen, or you were out climbing and now your wrists ache, you might still appreciate accessibility features - zooming, keyboard navigation, accessible themes etc. Getting this stuff right helps everyone.

Finally, retrofitting accessibility is often a nightmare to actually implement, because (a) it's hard to notice what's not working unless you go through everything with a fine-toothed comb, and (b) if you don't have at least some accessibility plans to start with, you might have dug yourself into a corner that you can't get out of. For example, if your gui framework has no accessibility support, and someone blind starts in a month's time, what are you going to do? Rewrite the whole application for them?


Yes, accessibility is all that too. But those things are what the vendors usually do not want to do. As in, actively, because that gives agency to the user, and would defeat whatever abusive business trickery they built the software to inflict on people in the first place.

We talk about accessibility in terms of extremes, because those extremes are where we have legal support that companies can't ignore. The vendors don't want to cut the curb, they want to replace it with a fence and a toll gate. Talking about wheelchairs and strollers lets us prevent the fences, and the toll gates. If they figure they'll skip the curb too, every user wins, but this won't happen without prioritizing wheelchairs, and won't happen if we emphasize regular people too much.

Or, in short, accessibility is the only weapon we have to fight dark patterns and maybe get some ergonomics for everyone.


Not a lawyer, but if this was true, wouldn't a bunch of developers and companies be facing fines? Especially smaller open-source stuff. And larger companies as well (for instance, Reddit's mobile app is infamously inaccessible).


Yes, they would. We're all only getting away with it because nobody has complained. It's a massive risk that companies are running. I don't know how Reddit has skirted it for so long, but there have been several high profile cases in recent years.


Reddit can be used on a website (which is how I've always used it, old.reddit.com even better) and I assume it's "accessible" on the browser. As another commenter said, as long as disabled users have options for using your application, there's no ground for litigation.


The time isn’t right. They haven’t IPO’d yet. Should file the lawsuit at the end of the second day post-IPO.


> I see that there are people down voting several comments in this thread in support of accessibility. I wonder what disagreement that you have?

Didn't downvote but I want to share a couple thoughts I've had about accessibility:

- I assume that browser/electron accessibility is not really optimal for users. It's sort-of free if you're building web/browser stuff, which is nice because it's available by default, but I can imagine most applications could be tailored for accessibility and be much more productive and enjoyable for end-users. For instance a "blind mode" for a text editor would probably be a lot different than what you get out of the box from a screen reader + VS Code. (I would love to get feedback on this from someone using a screen reader or accessibility features.)

- I worry you're providing a bit of a moat if you regulate/require accessible software, since for most applications that equates to using a native GUI toolkit or browser-based solution.


AIUI that law only apply to businesses who make their employees use the software without accommodating their disablities, and customers that are required to use inaccessible platforms (e.g. only permitting refunds through a website and not in person/by mail, but the website isn't accessible). It doesn't actually require all programmers to exclusively ship their apps with frameworks with accessibility features.

(IANAL)


What are those laws?



I'm not used to reading law in English, so this is all a bit hard for me to parse, but I'm having trouble finding the section that prescribes the addition of accessibility features to all software written for any purpose.

Say I am a British person who decides to make a some common piece of software, like a spreadsheet, and offer it for download on the internet. Am I required by law to make it accessible? And if, for instance, the provision of accessibility features would require thousands of hours of redevelopment, does that fall under "reasonable adjustments"?

I understand that the moment my software becomes required for someone's job, for instance, there might be a problem, but a few posts up it was implied that making software without accessibility features was in itself illegal in some way, and that just sounds doesn't sound right to me.


(Not a lawyer)

Section 20: https://www.legislation.gov.uk/ukpga/2010/15/section/20

That does not call out in its table any reference to software. I can't see anything in it which would effect a binding to software products. Section 22 refers to regulations being able to define what are "auxiliary aids", so in theory an SI may have done so.

Scanning the whole Act, the closest thing I can spot is Schedule 25: https://www.legislation.gov.uk/ukpga/2010/15/schedule/25, however even that defines it as “any service normally provided for remuneration, [...]". Note that is for an online Service, not a Good (which software would generally be). I've also not found what references it.

So that may cover a web site, but only if it was a paid for thing (e.g. online newspaper sites accessed via subscription). I wonder if and how it applies to the likes of Amazon, where the site itself is not paid for, but goods available through it are.

So unless someone can find specific references, I see no reason to believe there is such a statutory requirement in existence for software, certainly not for free software.


The EQA says that your website must provide reasonable access as any other user would have. It focuses on equality of usage, not specification of how software or supporting software should meet it (a la WCAG)

You said

>Anyone who would make software with your framework would be in violation of several laws.

Which just isn't true as there are ways you can comply with EQA without every underpinning library being accessibility-compliant.


Rule of thumb: a UI toolkit is equivalent to a game engine like Unity.

Approach it like that and you have a slight fighting chance because you know what you are getting into.


> UI toolkit is equivalent to a game engine like Unity

Funny that you mention Unity because they first had an immediate mode UI that was very difficult to work with, then they got a more flexible UI but decided to go the HTML way of having separate documents for elements and styles, making the whole design process way more complex.


Unity in recent years has a tendency to overengineer things and have little regard for ease of use for some features.

The new input system is powerful and flexible but is slower to learn and makes lots of things that used to be easy much harder.

Same for the new UI Toolkit and several other recent additions. I think it's a company culture thing - nobody internal is rooting for casual devs or noobs.

The problem is - everyone is a noob on something. You might be an incredibly experienced Unity dev who rarely touches input or UI. You want to quickly implement something and you're going to feel the pain.

"Make the easy things easy, and the hard things possible."


For me it was the text issues that dulled my desire to keep working it. I was updating a Nim based immediate mode GUI called Fidget (https://github.com/treeform/fidget) and fixed a number of issues. It was fun getting 9-patch rectangles with corners working, etc.

I even implemented a fair subset of CSS grid:

    parseGridTemplateRows gt, ["row1-start"] 25'pp \
        ["row1-end"] 100'ux \
        ["third-line"] auto ["last-line"]
( https://github.com/elcritch/cssgrid )

However, text input is hard and tedious! Then you ideally would need to handle the different keybindings for each OS. You also loose any plugins the OS'es provide. Not to mention the lack of accessibility.

I recall reading that browsers shim out to native OS text fields and wonder how that's done. It really seems like the best approach for small GUI libraries to enabled first class text input.


> Fluid layouts and scaffolding.

Short of doing a whole CSS rule engine (best) you can also implement a Flutter-like layout system. It is described well by Flutter documentation and is quite flexible.


For the text rendering part, is there no off-the-shelf library that provides that functionality?


There might be a few, but the complexity of the task reduces the number of options (the most popular choice is probably FreeType+HarfBuzz). But even then there's the problem that FreeType's text rendering might look slightly different than the underlying system's text renderer (so your application stands out like a sore thumb), and text rendering also affects UI layout (just take right-to-left languages for instance) - so it's often not an isolated drop-in solution.

Ideally the underlying system would offer a low level text rendering API that's independent from the system's UI framework and can be combined with your own rendering efficiently (haven't used it, so don't know how good it actually is, but for instance on Windows there's DirectWrite). The problem with this approach is that not all platforms provide such a modular text renderer (for instance web browsers), and you need different code paths on different platforms (maybe even still have to integrate FreeType because one of the target platforms doesn't expose a text rendering API).


I believe Harfbuzz is used almost universally by every major application from Chrome to Firefox.


Harfbuzz only provides 'text shaping' (very important for UNICODE support, especially for languages like Arabic), but the actual text rendering needs to be done elsewhere.


Their rendering engines choose the OS native one. They have abstractions over that. For example they'll use DirectWrite on Windows. Implementing a partial GUI toolkit is just another thing in the list of extremely hard problems in browser engine development.


Long ago, as the silicon on the planet was still cooling, a friend of mine did exactly this. And single handedly.

What he essentially did was he cracked open “Inside Mac” and ported it to a C library that ran on the PC.

He did the bulk of it too. Memory manager, Resource manager, QuickDraw, Window manager, Event manager, Font manager.

They changed it up, they didn’t copy the window gadgets and such, scrollbars worked (and looked) different.

But the task was to port a native Macintosh application to the PC, pre-Windows, and keep it portable. It was not a one way trip. The company maintained both versions.

Got the bulk of it done in less than a year. Obviously this was early Macintosh. B&W, bitmap fonts (though the application generated PostScript for printing).

Yup, they don’t call them The Old Days for nothing.


Everything that was simple 20 years ago is now 100x more complicated. Part of the reasons made programming interesting for me long time ago was that fact that one person could tackle a rather complex job all by himself.

You could write a GUI, a game, a text processor, a compiler and even an OS as a one person team. Now you can't and some of the most complicate aspects of software engineering is how to interface your work with the work of others, how to understand what others have done, to have a high level global view of the whole software application and tools your company works on while having a very low level view of the part of the software you are working on.


You can still do that. You just dont look at all the fancy pancy overengineered frameworks/platforms. I run a solo business in which i need to do backend, frontend, db, networking, low level hardware, graphics, monetization and more. I cannot be a specialist, but its still doable to understand all elements of various layers in software/hardware development. Again. Dont look at the hype stuff. Usually the people who are good at the hype stuff are super specialists in that specific thing. Not my thing at least.


>You could write a GUI, a game, a text processor, a compiler and even an OS as a one person team.

Yup.

And I had read earlier that Niklaus Wirth created a computer and many of the layers above, with just a small team. (I guess there must be other such examples from the early days of computing.) Don't have the reference. May be related to his work on Lilith, Ceres, Oberon, etc.

https://en.m.wikipedia.org/wiki/Niklaus_Wirth

Also see Wirth's Law:

https://en.m.wikipedia.org/wiki/Wirth%27s_law

The derived / related laws mentioned there are also interesting.


As Wirth's work fan, his creations were great for their time.

I am old enough to have used Native Oberon back when it was still a novelty, and compare Modula-2 to Object Pascal compilers.

Nowadays they feel out of place, both in OS capabilities, as well as the languages used to develop them.


Wow, cool.


There are people still doing this. Example: Serenity OS

https://github.com/SerenityOS/serenity


"some of the most complicate aspects of software engineering is how to interface your work with the work of others"

And where exactly is the difference, when you write a OS, where you have to interface with the low level hardware and the choices of those engeneers?

Apart from that, what is stopping you? Just pick a simple plattform and start. But yes, the result will be probably hard to sell, unless you find the right niche.

Alternativly, you can join SerenetyOS, which started exactly as just a one man project and came quite far alone. And now they are getting momentum (100000$ donation to build a browser).

https://serenityos.org/


Kinda why I like embedded development for my hobby. Can still understand all or most of the stack and tinker with it.


That is why I went into it as a career, although I’ve pivoted away from it recently due to how the industry treats embedded engineers. Embedded let me relive the early days of programming where almost nothing is kept from you and understanding the system you are working with in a deep way is entirely possible without overstretching yourself. And of course it’s really satisfying to be able to work with a complex electronics schematic as part of your everyday development environment. The issue with it as a career are many unfortunately, such as being forced to used atrocious tooling at times (IAR, looking at you), less remote positions available, and the salary offers can be a joke compared to what you are expected to know. As a hobby though it’s very rewarding.


I completely disagree. I am writing an OS in TypeScript. The GUI portion was complete with 15 days.

In JavaScript land people are scared shitless to write original software or learn the basic foundations of their common platforms. So yeah, that would make 10000000x more challenging. But that is a psychology and preparation problem, not a technology problem.


Interesting, what is the approach to kernel / managed language layers?


The application does not touch the metal. It executes as an application doing the top half of what the lower operating system does. The reason for the redundant pseudo-OS is that it operates the same across multiple devices irrespective of the metal and lower level OS. That means it provides a seamless connected experience between Windows, Linux, and OSX (I still need to test certificate installation in OSX) with end-to-end encryption for things like file system, sub-processes, media processing, file execution, and so forth.


I see thanks, I was curious if was a kind of SELF like experience, with bare metal set of primitives, with possible JIT/GC infrastructure, and then the rest managed.


>Everything that was simple 20 years ago is now 100x more complicated

No, it's really not. Let's take just UI animations for example. I can create a fade-in transition with a custom timing function movement in 3 lines of CSS today. To do the same thing natively 20 years ago involved writing hundreds of lines of custom OpenGL code. I get that there's a lot of fatigue from framework churn, but the layers of abstraction are orders of magnitude higher today, to the point that most UI work has become an afterthought.


> You could write a GUI, a game, a text processor, a compiler and even an OS as a one person team.

You still can and many still do, but we expect a lot more from our tools in 2023 than we did in 1983.


You totally can, but it won't match users modern expectations.


Everything that was simple 20 years ago is now 100x more complicated. Part of the reasons made programming interesting for me long time ago was that fact that one person could tackle a rather complex job all by himself.

You could write a GUI, a game, a text processor, a compiler and even an OS as a one person team.


You could still do all these things before the summer is out.

Compiler design is no harder today than 20 years ago.

Any text processor you would have created single-handedly 20 years ago is similarly doable.

Simple, performant GUIs are easy if you restrict yourself to a single platform. Windows 11 still runs win32 apps, Ubuntu/GTK is also straightforward.

For an OS, consider targeting a well-documented microcontroller. Some variants are approaching a similar amount of compute and RAM as 25-year-old PC hardware but have Ethernet ports and/or LCD displays.

And if you just want to build a game to say you did, you could build just about anything in the browser using vector graphics primitives reminiscent of DOS.


> Compiler design is no harder today than 20 years ago

Depends on how much one takes interactive compilers on environments like Energize C++, Visual Age for C++, Strongtalk, Dylan,Oberon,Cedar... into consideration.

While similar to modern compiler based IDEs, their language servers, compiling while typing, static analysis while typing,...,weren't as feature rich.


Heh. I did a partial port of Resource Manager so I could load up Macintosh Fonts on an Amiga. Aspect ratio was fun as the Mac had square pixels.


What was the application? So interesting.


The HLH Orion [1] had a GUI that was a copy of the Macintosh one, it kept the appearance as well as the API.

[1] https://en.wikipedia.org/wiki/HLH_Orion


QuickTime for Windows contained pretty much exactly this: a port of all the required Classic Mac APIs.

QT wasn’t just a video player but also an interactive environment, so this was a lot of API surface.


For a recent project (http://keymux.com/) I chose Yue (https://libyue.com/), a cross-platform native widget GUI toolkit for C++, JavaScript/Node.js, and Lua. I've only used the Lua interface and macOS backend, but it has worked quite well, despite the very steep learning curve. This was also my first desktop GUI app, so I had to learn many implicit concepts that weren't obvious from the otherwise extensive documentation.

Yue was the only option that 1) supported macOS, 2) supported Lua, 3) was sufficiently comprehensive to build a non-toy GUI app, 4) and that I could integrate into my (static) build. I couldn't even get the wxWidgets Lua interfaces to compile, and Qt and FLTK wrappers had similar stories, whereas reverse-engineering the baroque Yue build (based on Google's internal build systems) was relatively simple. The first candidate I tried was libui, but it had some crashing bugs that didn't inspire confidence, the widget set was bare, and most importantly development had ceased. Yue had some sharp edges, but I was able to work around them whilst patiently waiting for patches and fixes upstream.

Immediate mode interfaces were a non-starter for me. For a non-trivial set of otherwise typical controls and window management you have to implement too much yourself, plus being non-native they not only felt wrong (which admittedly is somewhat subjective; the younger crowd seems to think non-native, immediate mode interfaces look more state-of-the-art), but lacked other interfaces for proper desktop integration, like theme change signaling (i.e. notification that a user switch between light and dark modes in the macOS system settings panel).

All in all I would highly recommend Yue.


>All in all I would highly recommend Yue

>despite the very steep learning curve.

?

I used your quotes out of context, I know, because those phrases are in different parts of your comment, and I did it because I could, ahem, reuse your words, and it looked cool to do so, but the question is genuine:

Why do you recommend it despite the very steep learning curve? Because of support for Lua? macOS?


I meant that the steep learning curve related to the intrinsic complexity of dealing with desktop GUI frameworks, which I lacked experience with previously: terminology, layout and flow caveats (e.g. with embedded scroll panels, limitations on autosizing and reflow in the absence of explicit dimensions), etc. The Yue author clearly has extensive GUI SDK experience, and while comprehensive, like many open source projects the Yue documentation assumes some minimal understanding of the concepts and inevitable limitations.

The only possibly unnecessary complexity with Yue is the build framework, but that sort of thing can be quite subjective and a function of various requirements (personal, third-party libraries--it uses Facebook's Yoga for automagic layout and reflow) and familiarity. Excepting libui (which is basically defunct), all the frameworks I investigated had terribly complex builds, so it's pretty much par for the course. Notably, Yue releases prebuilt binaries with every release. I couldn't make use of those because I wanted a fully static, fat application binary (x86-64 + arm64), and also I needed a convenient, local Yue build for writing and testing patches.


Thanks for the answer.


These bullet points are exactly what I did in Sciter (https://sciter.com)

- Windowing

-- Tabs

-- Menus

-- Painting

-- Animation

-- Text

-The compositor

-Handling input

-- Pointer input

-- Keyboard input

- Accessibility

- Internationalization and localization

- Cross-platform APIs

- The web view

- Native look and feel

On top of that DOM and CSS implementations to achieve declarative UI. And JS as a languuage behind UI - declarative in some sense way of defining UI behavior.


What about the ability to have platform specific code? Like serial/USB communication.

Right now I'm using libgdx so I can have a cross platform UI and then specific code for USB communication for each platform.

Sciter would be great if I could use it.


You can extend Sciter by native components. As purely functional (native classes and methods in JS) as visual (custom UI components).


Okay, so I can get access to platform specific APIs?

When you say "Native compontents" it still sounds very UI focused :P


This is all a very neat summary, but I'll go out on a limb and say that for most of us, the first-order approximation should be "don't. Just don't".

Been there. Done/sort of doing that. Have impressive collection of scars. There are no t-shirts to be had.

This document only barely scratches the surface of the work necessary. If this is your calling, by all means, but expect to sink a good chunk of your life into it. Things are glossed over in a paragraph that mean years of work. (My favorite is the internationalization section, closing with "But don’t worry: there’s a standard. All you need to do is implement it." - All you need to do, indeed :)

To be clear: Colin knows it's years of work. He's been working on a number of excellent projects in the space (xi-editor, druid, ...). But I really feel this deserves a warning sticker, lest you accidentally spend a decade or two of your life on it.


Well, it is definitely not a suicide mission. At least in my Sciter I've implemented all those by myself in reasonable time frame - first version was made in 9 months.

But "yes", you need some prior experience, in order to come up with flexible architecture that will allow to expand it further without major redesigns.

First version had DOM/CSS and used just GDI. GPU support (Direct2D, OpenGL|Metal|Vulkan via Skia) was added later with API staying the same.


Eh, re-inventing wheels is fun. I learned a lot making my own games from scratch with no engine. I'll make a bad one-user GUI kit some day too.


Working on Godot Engine, in a team adjacent to things like Unicode fonts (with left to right languages etc.) and multiple windows support was watching an uphill struggle for Godot Engine 4.0.

I have no idea how other team succeed at it either.

<edit>

Recognize every item on this list. EVEN THE WEBVIEW ONE https://github.com/godotengine/godot-proposals/issues/960

Unicode variables names https://github.com/godotengine/godot-proposals/issues/916


If you're interested in what it takes to render bidirectional text with complex scripts and line breaking, I had the experience of implementing that (in immediate mode too) and wrote about it here:

https://hasen.substack.com/p/imgui-text


Thankyou. I am starting an experimental desktop application myself and currently at library selection phase. This is going to help few decisions.


Discussed at the time:

So you want to write a GUI framework - https://news.ycombinator.com/item?id=28127492 - Aug 2021 (173 comments)


My one gripe with this article is that it doesn't really explain why a wrapper over native toolkits is untenable. There haven't been many attempts of this idea, of which wxWidgets and libui are a couple. Yes, it exposes its own complexity, but I would rather start with a GUI that's portable/accessible, and then worry about its look-and-feel.


I think the problem is that nobody wants to do a lot of work to make something that will be basically just good enough for hobby projects. There's no money in it, and side projects "for personal fulfillment" tend to avoid the kind of clerical work that compatibility with several different APIs requires: lots of reading, lots of boilerplate (on the framework end), lots of testing, not much freewheeling design and speculation. Hell, IUP (which supports Windows and Gtk) has gone decades without finding someone outside Brazil to maintain a Cocoa port. It's either professional-grade — very complex and needing a corporate backer — or it's not, and a GUI cross-platform compatibility layer is in the uncanny valley. Maybe someone will figure out how to fund it?


It really bugs me that native toolkits, and even cross-platform kits like GTK+ or Qt, seem to reject testability.

They want you to open a window and build a widget inside the window. The APIs for rendering to a byte buffer and injecting bogus input events seem kinda weak. If I make my own toolkit, I'll focus on that first. I don't want such a huge part of the app to be an untestable I/O leaf.


In the case of Qt, this is simply untrue. Google "qt gui unit tests" and you will find plenty of content -- from Qt and blog posts with Real World cookbooks and stories.

And, Win32 has a whole separate subsystem for unit testing UIs. Read more here: Win32 -> "UI Automation Test Library"

Man, there is so much damn misinformation about Qt on HN. It is tiring. I don't understand the source of this misinformation. Part of it probably stems from their various licensing mishaps over the years that seeded a bunch of FUD. It's a ridiculously good cross-platform UI library. KDE would not exist without it! I don't work for them, but I have used the toolkit for years. Nothing beats it. Yes, it is huge, but it does everything you could ever need.


I used Qt4 for a few years and never found an easy way to run a widget outside the context of a window.

Maybe I didn't check the docs closely, maybe it's better in Qt6. I stopped working on GUIs a while back.

Fwiw HTML and xaml were just as bad for that.


It is unbelievable what people complain about with GUI toolkits. Nothing short of "does not do my homework" seems to be the limit of complaints. Let's get this straight: You want to paint a widget without a normal window border. This is not normal. It would be difficult even using native UI APIs.

Also, Qt4 was last released in 2011. That was nearly 12 years ago. Maybe... try again?

Also, you can Google: qt widget without window border

Plenty of hits.


Part of the problem is that it's hard to build native toolkit wrappers in a way that's "sexy". Cocoa, Win32, GTK, etc are boring old retain mode UIs using boring old patterns which lends to their wrappers being written the same way. Trying to write a React-style wrapper for example is not going to be fun because you're fighting the very nature of what's under the hood.


I mean... no, it's not that bad. Working around retained-mode UI patterns in declarative UI is a fairly well explored problem.

The real issue, in my opinion - as someone who's worked in a litany of UI systems and built my own UI frameworks and libraries: it's a lot of frankly boring as shit work that everyone gets into and then drops like a rock once the dopamine rush of implementing basic widgets wears off.

(Then you add on that the number of people who know the big three (Cocoa/Win-whatever-they-use-now/GTK-or-QT) really well is a much smaller pool)


Funnily enough, the web browser DOM is also an old boring retained mode pattern. Hence all the vdom diffing madness React does…


> Since GPUs are good at drawing 3D scenes, and since 3D scenes seem “more complicated” than 2D scenes, it may feel like a natural conclusion that GPUs should handle 2D trivially. They do not.

While not trivial, nanovg shows that it can be done reasonably well. At least well enough for a GUI. Thankfully a GUI doesn't need a very advanced 2D rendering engine (see Dear Imgui or egui). Vector art apps can write their own engines.


Unfortunately I know all too well. And it's only a small part of my project (rpgplayground.com).

I wanted to have a GUI inside the game itself (so you can edit games while you play), but that means I had to develop my own GUI. I created simple game GUI's before, so I thought this wasn't a big of a deal. Oh boy was I wrong. A couple of buttons and textfields is very different from a full widget toolkit.

And then another thing: I originally developed RPG Playground in ActionScript3, so I latched on to the native textfield they provide. In fact, most GUI toolkits you see are able to make use of some native textfield functionality.

So after Flash was killed, I ported my product to Haxe. And then realized that I can't really latch on to any native textfield functionality. Yeah, you guessed it, I had to write my own textfield code: word wrapping, mouse handling, ... . That was another project in itself.


I think the flutter (and to some extend QT) path is the future of x-platform GUI framework. Lift the complete GUI framework and rendering outside of the OS and implemement everything in the app as a library. A lot of the complexity mentioned is just the result of the inability of the big platform (android,ios,windows) to agree on a coherent set of api. The core reason the web worked so well as a target is that it's a well defined single uniformed API any body can target.

The obvious downside is the lost of "native feel". But i think this has been overblown. Probably a reaction to horrible look for 2000/2010 java/jwt applications. But the web doesn't have a native feel, but still can look great everywhere.


I am not sure why this strange fixation on tabs as an important ui element exists. In most cases such as within a browser tabs are horrible to navigate. In my opinion they only make sense if you have a fixed number of diffferent "submenus" that you want to show. The tabs will always be named the same (for the different categories) and they will stay at the same place.

Using dynamic content for tab is just only barely useful and still persists in many browser and applications (such as postgres or obisidan). What happens is that you will open a large number of things in this will completely clutter your tabview. A list which is filterable will always be better to navigate than some tabs with dynamic content.


Only one paragraph for l10n and i18n? A GUI framework written only by people speaking English is 99% most definitely going to get font display wrong ( https://heistak.github.io/your-code-displays-japanese-wrong/ ) and will have a plethora of locale-specific behavior bugs ( https://heistak.github.io/your-code-displays-japanese-wrong/... ).


My wish: framework developers give up on cross-platform. Write a framework tightly integrated with macOS or Windows or whatever OS you love. Once you do that, many of the concerns the author described become much easier to tackle.

The article specifically mentions Rust which does have Mac and Windows bindings. That’s necessary, but not sufficient. Where is the macOS or Windows Rust framework that makes writing fast, safe, beautiful apps in Rust the best and easiest choice?

Surely a developer with modern tools and knowledge can do better than Microsoft did in 1992 with C++ and MFC.


As I'm looking through the Skia APIs I have the dumb question: why doesn't Skia have its own wrappers for input method editors (at least on Windows and macOS)? Or maybe it does and I'm missing it.

Implementing these APIs for Windows and macOS seem super arcane. It's hard to find docs on implementing them. I guess there must be a good reason there are not cross-platform libraries that abstract IME specifically.


I can’t answer from rust perspective, but just my opinion. GUI frameworks in general seem like an atrocity, you have QT and that seems like it besides proper native development and targeting 1 platform.

Java still seems like the only language with cross platform GUI and swing/awt are on the way out with javaFX being “abandoned”? (Probably not the right term but it never was made main stream). You got to Python, etc and it’s an absolute mess. C/c++ have a few but cross platform still seems tough.

Don’t even get me started on the mess of electron.


What's interesting to me is that there are a handful of languages that include gui frameworks: tcl with tk, erlang binds wxwidgets, and racket has its own thing built on gtk.

It's curious what these languages have in common too: as languages almost nothing. But they're all venerable, proven & respected in their domains if not beloved, and relatively unpopular.

I don't know how to interpret that. Maybe it's just a coincidence. Or stdlib gui frameworks are just out of style and it's survivorship from the old ones. But then python is from around the same time, why doesn't it?


tkinter is the Python one!


Ruby has a Tk-based one too, but I don't remember the name, since I used it only a little, years ago, though I did some non-GUI Ruby and Rails web work.



No, I think it had a bundled one like Python's Tkinter, which was a wrapper over Tcl's Tk.

Edit: this is it, Ruby Tk.

https://ruby-doc.com/docs/ProgrammingRuby/html/ext_tk.html


You haven’t heard of Flutter?


Exactly... looks like most people don't know that Flutter uses Skia... and it's a real multi-platform framework (Windows, MacOS, Linux, Android, iOS, even Web), whether you like it or not.


IME handling must be implemented at OS level.

IME is not Skia's responsibility.


    IME handling must be implemented at OS level.
Really? X11 has a wide variety of IMEs. That's user space, not "OS level" (kernel?).

A different view: It might be possible to write an IME for X11 using Skia. :)


OS level includes the core system libraries in the userspace. Of course you can argue no such thing exist in Linux. It is the odd one among all OSes, both major and minor, in not providing any stable and well-defined system layer.

The lack of unified standards in X11 and especially in Wayland/libinput is a huge source of problems in accessiblity and user experience of traditional Linux environments.

Each of those IMEs (ibus, fctx,...) are a major pain to setup and configure correctly. They often don't look "native" to the toolkit of the desktop.


SDL2, which is an abstraction intended for games (gives you a window, sets up OpenGL and handles input events, but leaves the drawing to you), has a very simple text input API that can handle IMEs: https://wiki.libsdl.org/SDL2/SDL_StartTextInput + https://wiki.libsdl.org/SDL2/SDL_SetTextInputRect. But the trade-off is that you can't write a text editor with this. It just lets the user type text using the OS's text field or similar and the app is not in control while they do so.


Skia only does rendering, not input, right?


Presumably to keep the focus of the library small.


I wasn't under the impression Skia had a focus on being particularly small. (Though I have no clue. I'm just getting into this stuff.)


Check out nanovg and all the alternatives.



Oh wow, I haven't thought about Jidesoft in YEARS. I used it back in the early 2000 to add some much nicer data grids, toolbars and other things to our mining software package.

Those were the days!


place i was at used it for an options trading platform in 2006




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: