GUI development is broken
charlesetc.com
charlesetc.com
Use the text widget in tcl/tk. It can display graphics and is powerful enough to build an old HTML 4.01 editor.
> I wanted to draw a horizontal line between the name of the file and its contents.
Use the text widget in tcl/tk. You can hard-code a base64 encoded gif/jpeg of a horizontal line, store it in memory, and display it wherever you need a horizontal line.
> I wanted to be able to open new instances/windows of this text editor quickly to fit into my workflow.
Use the text widget in tcl/tk. Tk's design is the old-school multiple-toplevel-window paradigm which is perfect for this use case.
> And I wanted low-level control of how the text was rendered (fonts, syntax highlighting, and the ability to add vim keybindings.)
Use the text widget in tcl/tk. It allows you to tag particular parts of the text which you can later manipulate. But it is way more lightweight than the DOM.
> I wanted this to be easy.
Then use the text widget in tcl/tk.
https://github.com/ocornut/imgui
Checkout the screenshot threads https://github.com/ocornut/imgui/issues/1607
Especially desktop apps like this look interesting: https://github.com/ocornut/imgui/issues/1607#issuecomment-37...
And it's small enough to work well with WebAssembly: https://floooh.github.io/sokol-html5/wasm/imgui-emsc.html
With that said, nobody cares about GObject Introspection in OCaml. So unless you want to maintain that, you're stuck with an ancient wrapper library for GTK2, which is pretty sad. I definitely would avoid it.
If we're going to discard GTK for a reason that isn't "I probably picked the wrong language", I'd add that it's challenging to target non-"Linux" platforms with it, but then your best option for that is Qt, and if you pick Qt you probably aren't using OCaml…
So I can see where he's coming from, at least for OCaml, but, uh, JSON?
Qt has a long history of bindings coming and going to the point where I wouldn't trust any of them to last unless they come from the qt team themselves. Couple this with c++ making binary compatibility much harder (https://community.kde.org/Policies/Binary_Compatibility_Issu...) and you've got a recipe for frustration.
I was hoping this would be a call for a higher order of expression which could be interpreted by lower order frameworks, but alas. I think the author is confusing the technology with the tools. The tools for building interfaces haven’t changed a whole lot in the last decade.
He glances over that part...
Also, not sure why he is fixed on JSON. There are plenty of GUI libraries that use XML, why doesn't he use one of those (and therefore not use OCaml).
Misleading, clickbait title and low quality, narrow content. It's a shame.
i understand reinventing wheels is both fun and educational and grants a deeper understanding of wheels in general, but the way that statement reads is... over confident. the idea that any nontrival standard tool for software developers can be written in an afternoon, presumably from sratch, starting cold, not even done with preliminary researche (as evidenced by the rest of the article), is just silly.
>I wanted this to be easy.
has the author ever programmed anything at all these things are never "easy" just "easier than once thought", which is rare, and "inexplicably more difficult and obtuse, and motivation enough that time is better spent on other projects" or somewhere in between.
It's kind of funny, because one of the first things I wrote with Delphi when I first got my hands on it was a text editor. :-)
We use the XE7 version of the IDE, which is excruciatingly slow on a laptop with an i7 7700HQ processor, fast nVME SSD, and 32GB RAM. Oh, the IDE is 32 bit so it runs out of memory. The IDE also crashes a lot (I have never heard of a stable release of any version of Delphi). Our codebase still compiles on Delphi 7 (from 2002) because it is a better developer experience than thier modern versions...
Trying to find good components was easy in 2002, but it can be impossible now. All the good component developers moved on to more profitable targets. You can't find good open source components because no developer can afford the annual costs to get new versions of the compiler and compile components.
These days, we write Python that generates SQL in order to generate HTML, then write Javascript to talk HTTP to the Python and then generate HTML that gets interpreted into the screen by CSS...and there is no way a tool can present the result of that in a coherent manner (let alone autocomplete it!).
(I get an up-close view of this because I cofounded Anvil - https://anvil.works - which does the complete opposite of this at every level. All in Python, one framework, all autocompleted - basically a modern Delphi for the web.)
Because everything the author was complaining about was solved in Delphi in mid-nineties.
Heck, if he were to write for Windows, he could still use Delphi and get what they want!
For that matter, VS.NET platform would be a pretty good tool for that job too (no surprise given that the head of the project was heading the development of Delphi before jumping ship to MS).
He he, I did the same.
>Because everything the author was complaining about was solved in Delphi in mid-nineties.
Related:
Delphi – why won't it die? (2013) (stevepeacocke.blogspot.com)
https://news.ycombinator.com/item?id=7613543
I had commented a few times in that thread.
1) the trend towards greater and greater complexity and more features as time goes by and as version numbers increase.
2) the cost, of course.
Edit: Also, as others point out in this thread, some versions of it were reportedly moderately to quite buggy.
And as someone else said in this thread, Lazarus is an option.
Beating a dead horse and outing myself to anyone that knows me!
I do not understand the article at all. We created our own GUI development using Dear IMGUI. It is probably the simplest GUI in the world. For text we use our own rasterizer library.
But it comes at a price: It just continuously draws the screen, 60 times per second, which makes the battery of laptops last very little.
Now our software uses a fork of Dear Imgui that does not update the screen but just when necessary.
Before Dear Imgui, we tried Qt, GTK, Web, Win32. Making your own widgets with hardware accelerated fonts that you control is extremely complicated in those GUIs.
I think you missed the target on dismissing the first option... i.e there’s a reason html/css/js is the most popular - as in popularity is a good objective median.
To get to the point, use electron with jsonSchema and a form builder of choice (I suggest Vue) but React and Angular could suffice depending on how much functionality your text editor needs.
Point is, your “answer” is pretty much reinventing jsonSchema in Python.
Any particular reasoning for this?
Vue gives you the binding, flow and components - whilst maintaining a closer relevance to what can be considered “familiar”... and subsequently a good introduction for someone who rejects web at first, yet introduces how a Text Editor can actually he built in a day using the principles shared by all modern web frameworks.
Or something like that... :)
out({command: "new_text_box", border: "grey", content: "hi there!"})
looks a lot like
<div style="background: grey">hi there!<div>
The browser is complicated, because its an abstraction that runs in almost every modern environment. Once WASM gets document bindings, writing web code will become language agnostics.
Also how are you going to bind interactions with the UI? I see a global event listener, but that would become unmanageable.
Every time I make a change in my QML based photo editor I marvel at how easy the toolkit has made it.
This started to be really noticeable for me in the linux world, where QT is already common, but more and more UIs are converted to QML from QtWidgets.
The difference is staggering for me. QML GUIs are also often styled by the authors, which very often break or replace the system theme, something I hate.
As far as slow, no way. Instant startup, instant everything, no memory leaks. I've left my editor running for multiple weeks straight with no issues.
Usability bugs? Yes, there's basically one: scrolling. I've hacked together my own momentum scrolling system but I'm not happy with it. At least it's better than scrolling in KDE Plasma native applications, though.
darktable on the other hand has basically one dark theme only which also shows stupid UI mistakes as black-overscroll-on-black-background in all lists and fixed font size. If there is ONE setting you have to keep, is the FONT SIZE in the system theme!
You're excluding many more issues from here. Click on a scollbar and drag outside: very often the scrollbar doesn't release when the mouse button is depressed, though styling and custom events play a role. QML is not immune to a lot of quirks in highdpi, most of which are completely absent in QtWidgets. In detail, font rendering (hinting) in QML in GL contextes is basically broken.
The whole UI is perceptibly laggier as a whole. I'm a programmer myself. As a programmer I feel ambivalent, but as an user, I hate it.
do while .t.
@ 22, 1 clear to 22, 78
@ 22, 26 say 'Ready to Print ? <Y/N> ' get cPType pict '!' ;
valid ( cPType = 'Y' .or. cPType = 'N' .or. cPType= 'H')
read
if cPType = 'N'
exit
elseif cPType = 'H'
jAlert( ';Help on Print Formats - Press : ;;' + ;
' Y for normal bill without leaving no blank lines;' + ;
' N for aborting bill print ;' + ;
';' + ;
' L for Large bill covering an A4 size paper'
)
loop
endif
invoice_print( cPType )
exit
enddo
This piece of code executes linearly, there are no events to listen for and so no callbacks. There are only keyboard events that occur at specific times in the program's execution. No mouse events that'd have generated events that you'll need an asynchronous model of the program to deal with. And this screen is fixed size - 24 lines and 80 columns; it has 16 colors: red, green, blue, yellow, and the rest. The window doesn't resize nor the screen size ever change.Modern GUI however has events and has to work on devices with all sorts of resolutions, and they support mouse and asynchronous execution. The program model is vastly more complex, and although the good old days were really really nice, they would probably never be back.
https://stackoverflow.com/questions/166231/tcl-tk-examples
(also, the author hasn't reviewed any of the Windows approaches to this; drawing up a quick GUI in Visual Studio and C# is pretty easy)
https://github.com/sircmpwn/chopsui
I plan on finishing up the boring parts in the next few weeks, then the exciting stuff begins.
I am more enthusiastic about the future of GUI development than ever before. ;-)
But you only want those basics for, like, a minute or two. Or to show a couple buttons and nothing else. Then you realize how incredibly restricting that is, and how impossible it is to make something nice and not just functional, and you discover the problem is bigger than you thought it was.
Shoes gets pretty close perhaps? http://shoesrb.com/ But even a tiny glance will show it's vastly more complicated than the proposed API here, because the proposed API is so inadequate you can't even say "put X near Y".
A rather disingenuous omission by the author.
Javascript isn't either.
Both of them have a glut of good cross-platform gui options.
With mono, C# and winforms work pretty well cross-platform too.
Famous last words :P
I think it's a good scenario: it seems that in most cases available libraries don't expose a C API at all.
I had thoughts similar to the article's conclusion, and even a prototype of a similar GUI (stdin/stdout, s-expressions), but then decided that a subset of HTML (or XUL, as mentioned in another comment, though not sure how reusable libxul is, and it seems pretty close to a full web browser with its scripts and events) would be fine, though didn't get to trying it out. Currently GTK seems usable to me, even if imperfect.
If C is too hard maybe you want c#: http://www.mono-project.com/docs/gui/gtksharp/hello-world/
Here it is in Tcl:
pack [button .b -text "Hello world" -command {echo "Hello, world!"; exit}]
Now you know what I mean when I said Tcl/Tk was "the fastest" way to get a GUI up. Especially when you consider that wish also functions as a REPL at which you can test your ideas right away with no compile step.And this is where we are. A huge number of today developers, maybe even majority, are so accustomed to web programming that it's the first thing that comes to their minds.
Nuklear looks promising if you don't care about "native look and feel". In this age of "web swallowing the world", I don't think I care about native look and feel. Then again, maybe the native look and feel on windows and linux just sucks. All of the gorgeous, yet still fast apps are for the Mac and iOS ecosystems and it isn't because their tooling or native GUI APIs are so much better than everybody else's.
1. Terminal emulators have too many LOC (how many LOC does cairo, Xlib, Chrome, or GTK have?)
2. Oh noes, you have to check for control codes in your text. (do you want to use a text editor that doesn't?)
That's interesting. If you decided to use Lazarus instead, you'd have the project finished sooner that you wrote the blog post.
The clickbait title is plain wrong: GUI development can be easy and fun, depending on what toolset you choose.
Lazarus doesn't have a simple small framework, if anything it is much bigger than Gtk, but it is very simple to start with and you can ignore most of it. If you want to see how it is to use it, recently i recorded a video making a simple game with it under Linux [4] (there are a few comments in a text editor in the first 6-7 minutes but after that i do not have any sort of comments). If you want something with more GUI controls (the game really uses just a painting control), i also have an older video making a tilemap editor [5].
Now to make a disclaimer: IMO both Lazarus and Free Pascal (the language used by Lazarus) are a bit messy and i'm not presenting them as examples of the perfect development environment. However Lazarus is both very powerful and very simple to use, to the point that i consider it by far the best and easiest way to create GUI desktop applications (the only closest alternative is old versions of Delphi before it became a bloated mess - but even if the new versions weren't bloated, i'd still not recommend them because of their ridiculous price, the fact that VCL only supports Windows and above all the DRM they have - i remember reading complaints from users that they had to use cracks so that they can use their highly expensive software in their own laptop, which is absurd IMO). It has warts but they are well worth it.
My biggest issue with Lazarus is that it seems that the Gtk3 backend is going to become the default one on Linux in the future and as a user i dislike everything about Gtk3 (and Qt5 but to a lesser extent).
[1] http://www.lazarus-ide.org/
[2] https://i.imgur.com/tCd64Wh.png
[3] http://runtimeterror.com/rep/lil