10 ms·
Puny GUI – A tiny cross platform GUI Kit in Janet
- liuliu 6y agoSeems to be based on iup that supports both Windows and Linux? http://webserver2.tecgraf.puc-rio.br/iup/ http://webserver2.tecgraf.puc-rio.br/iup/ The new crop of immediate mode cross platform GUI libraries are more interesting (such as nuklear and Dear Imgui). I also did some experimentation with these libs a few days ago: https://liuliu.me/eyes/write-cross-platform-gui-in-swift-like-it-is-1998/ https://liuliu.me/eyes/write-cross-platform-gui-in-swift-lik...
- mwcampbell 6y ago> The new crop of immediate mode cross platform GUI libraries are more interesting (such as nuklear and Dear Imgui). They're also completely inaccessible to blind people (using screen readers) and probably some people with other disabilities as well. IUP is at least partially based on platform controls. I'll take usable over interesting.
- flohofwoe 6y agoThis wouldn't be a problem if the underlying operating system APIs wouldn't treat accessibility as an opaque "feature" baked into their UI frameworks. There should/could be open accessibility APIs in each OS which sit between (e.g.) screenreader software and custom UI frameworks.
- mwcampbell 6y agoSome platforms do have APIs like that. For example, on Windows, UI Automation is not tied to any particular UI framework; the UIA tree just needs to be associated with an HWND (Win32 window handle). But implementing these APIs is a lot of work. And I imagine it would be especially challenging for an immediate-mode toolkit, because an API like UI Automation is based on a retained tree of objects that the screen reader or other assistive technology can query on demand. So I figure applications are more likely to be accessible if I warn developers away from such toolkits altogether.
- andrewnc 6y agoI love new programming languages, I'll have to give Janet a go and see how I like it
- postalrat 6y agoAny language that has really impressed or surprised you?
- pierrec 6y ago"The solution (hint: there wasn't one until now)..." That's quite the bold statement. I actually thought of IUP/Lua when I saw this line, and it turns out you precisely used IUP for the UI portion of your framework! Except you didn't use the Lua binding, instead you created a Janet binding. Using something like luastatic[1], with whatever Lua libraries you want (including IUP), you can get something pretty similar to this system, except of course you'd be using Lua instead of Janet. Janet is really interesting and that alone justifies this framework very well. [1]: https://github.com/ers35/luastatic https://github.com/ers35/luastatic
- ahungry 6y agoYea, sometimes when I get to rambling I can be a little bit overly opinionated/bold in some statements. Python tktinkter is also in a similar vein - what I am putting out is more of an aggregation of other's hard work (cross platform packaging?) more so than anything I've directly innovated. However, even in the python sample, I couldn't find anything that was just "Download, Unzip, Modify" to start creating (all seem to have cumbersome install steps or hoops to jump through - I basically wanted something that was 0 configuration/installation, for fast iteration and development).
- macmac 6y agoSpeaking of aggregation, what motivated the license choice? It appears that only one dependency (Mongooos is GPL), and the choice of GPL will seriously inhibit any adoption of a toolkit like this.
- ahungry 6y agoI may replace mongoose and change license when done to MIT (pending completion of work on my own much smaller server implementation)
- zem 6y agothere are nice chicken scheme bindings for iup as well. http://wiki.call-cc.org/eggref/5/iup http://wiki.call-cc.org/eggref/5/iup
- crispinb 6y agoHowever, the elephant in the room (which I also like to ignore as a Clojure enthusiast) is that the start up time of a Java based GUI app is too slow (this is exacerbated even moreso when Clojure is involved) I'm expecting a GraalVM rejoinder from someone. For anyone who's used GraalVM (particularly with Clojure) - what are the downsides and limitations?
- ahungry 6y agoThis is a really cool usage of it: https://github.com/borkdude/babashka https://github.com/borkdude/babashka, but last I had checked, it didn't have any GUI integration, and installing the GraalVM to begin with is a very heavyweight install.
- crispinb 6y agoYes I've installed babashka. It really is a cool project. Must look into GraalVM at some point, but, as someone new to Clojure, I'm wary of spending too much time on tooling yet. I've found in the past I can tinker so much with such things that it interferes with getting fluent with more fundamental stuff. I'd be interested to see if either now or in the future Clojure + JavaFX in GraalVM would be feasible. Edit: I don't quite get the install size issue - I thought native image was an entirely standalone executable?
- ahungry 6y agoThe GraalVM system/tooling itself, for generating native code from JVM was a big download/install - the generated binaries, I can't speak to too much.
- pjmlp 6y agoJava has had AOT compilers since 2000, they just haven't been free beer for the most part, hence why FOSS keeps ignoring them. Ironically they have to thank Oracle for doing something that Sun was religiously against, having an AOT compiler as part of the free beer Java layer.
- brabel 6y ago
- ashkankiani 6y agoWith opengl, libuv, and libcurl, and Dear Imgui, I can write a C program resulting in a binary that's about 400kB unstripped, to put 5MB in perspective. And for a simple program like what you wrote, I don't even bother trying to free the memory myself sometimes, I just let the OS free it when I exit. With that design choice in mind, the end code is like <1000 lines, and a decent bit is reused snippets. In the end, this feels like a an appraisal of IUP and Janet more than a demo of anything new. If that's the case, then familiarity with your stack is more important for this kind of productivity than anything else, so trying something new is less appealing to me. But I was curious about Janet, so seeing some examples was nice.
- ahungry 6y agoDear imgui looks very cool (I had missed that one), and like nuklear, a strong candidate for very customized look and feel - but I think it glosses over things much like nuklear does, by showing what seems to be small/simple samples, and prefixing it with a statement such as "after it's set up" (and it doesn't bother to show the other 1000 lines said setup required). But you are spot-on that this is more showcasing the joining of various other things out there, rather than anything innovative (although I do plan to add more and extend the existing convenience wrappers, such as wrapping the IUP calls in a hiccup-like DSL using Janet macros).
- exDM69 6y agoThose "1000 lines of boilerplate" is why imgui and nuklear are so popular. If you're on a commonly used platform, say SDL and OpenGl, you can just copy all or most of it. But the magic here is that imgui and nuklear will integrate into any engine or rendering api you can imagine. To simplify a little, you pass these libraries the events from the windowing system and it gives you a list of triangles back. Then you feed the triangles to the GPU and you're done. All the logic (and nothing but the logic) is done by the GUI library. This is why dear imgui is perhaps the most popular GUI library in the world. It's used in a lot of game development tools, etc. If anyone is interested in the topic, I am writing a lightweight flexbox-based retained mode GUI layout rendering library that integrates like imgui/nuklear. Give me a shout if you want to know more.
- _emacsomancer_ 6y agoWhat about macOS? So far Racket seems like the easiest solution for a lisp with easy cross-platform GUI support (Linux, Mac, Windows). It would be nice to have more easy choices, but also nice if all 3 major platforms were supported.
- brabel 6y agoRacket is so nice, but try to create a GUI with it and see how heavy the resulting app is... I wrote a simple one just to play around with it, but was really disappointed by how slow and heavy it was.. it took over 250MB of RAM to show a shape on the screen.
- DagAgren 6y agoIn reality, if you want to actually make a serious, usable and comfortable GUI, there is no cross-platform solution. There are many attempts, but none will let you create a GUI that actually fulfils all those requirements. If you are making something serious, you will have to implement at least the GUI layer separately for all platforms.
- yellowapple 6y ago> In reality, if you want to actually make a serious, usable and comfortable GUI, there is no cross-platform solution Qt? Tk? I've used both cross-platform and both work great for desktop operating systems (and unlike in the olden days, Tk's themed widgets actually look reasonably native now). Qt's only downside is the licensing and the sheer size of it, and Tk's only downside (for my use cases) is the lack of an embeddable browser widget; in both cases these are issues regardless of platform. The actual cross-platform issues, from what I've seen, are more to do with the non-GUI pieces. For example, Windows and macOS/Linux printing are wildly different from one another, and all three operating systems have wildly different strategies for packaging and distributing applications (especially when writing the program in a scripting language like Python or Ruby or what have you instead of something precompiled like C++ or Rust; with Linux this is trivial, and with macOS this is less trivial but manageable, but with Windows this is a royal pain in the ass). On another note, I'm currently looking into Avalonia and .NET Core as another potential option in this space; from preliminary testing, .NET Core looks like it mostly addresses the issues I've encountered (it certainly makes it easy to cross-compile for Windows/Mac/Linux, and I'm hoping it'll eventually subsume Xamarin or portions thereof to enable easy Android and iOS builds, too), so whether or not this becomes my go-to hinges on whether or not Avalonia itself is ready for primetime (and while simple examples seem to be promising, as are more complex examples like the Avalonia version of ILSpy, I'm still actively investigating).
- FraKtus 6y agoI disagree with the author, it's really easy to test the examples of Nuklear. I made applications with Nuklear that runs on Android, iOS, macOS, Windows and share the same main C code. For me, it's a dream come true if you create a cross-platform application that needs a simple GUI. Dear ImGui is also fantastic and more complete than Nuklear. What I like a lot with Nukear and Dear Imgui is that you have a GUI that is GPU accelerated and so can be updated at 60 FPS without burning resources.
- DagAgren 6y agoYou're still going to be updating at 60 FPS which will absolutely murder your battery on a mobile device. These are meant for use in games that already do this. They are not suitable for building regular apps.
- maeln 6y agoThey are perfectly suitable for regular app. You don't need to update them at 60fps, you have the entire control of the rendering state, so you could decide to update the gui whenever it is needed and not at a constant fps.
- FraKtus 6y agoYou can update when you want and only on changes if it works better for your case.
- ducktective 6y agoI think Nuklear had an option for dynamic update rate. Not sure though
- flohofwoe 6y agoThe common solution is to only update rendering when input happens, and otherwise sleep. That's fairly common for ImGui applications outside games (in games it doesn't make sense of course, since those usually render each frame anyway).
- amelius 6y ago
- CharlesMerriam2 6y agoHow about English? This is just programed as: > Puppy is an app OK, you run 'Puppy'. It doesn't do anything. > RandomHost is 'https://dog.ceo/api/breeds/image/random' https://dog.ceo/api/breeds/image/random' OK, 'RandomHost' is a constant, looks like a URL > Get an image from RandomHost OK, I think you meant Set Message to Read RandomHost retreiving UUENCODE. > No. Get an image using json Not the previous thing. I think you meant Set Message to Read RandomHost retrieving JSON, field Message. > Get Image at Message OK. I think you meant Read the URL Message and retrieve an image file > Show the Image OK. Displaying the Image on the screen > Add Repeat Button OK. Displaying a button named 'Repeat' > App is While on Repeat, do the Display. OK. App is set. Do display, Wait for Repeat button, Loop > Puppy? Puppy is an application: Repeat RandomHost = 'https://dog.ceo/api/breeds/image/random' Message = fetch(RandomHost, JSON)."message" anImage = fetch(Message, DATA).ensure(IMAGE_TYPE) Display.reset(Items [ Image: An Image, Button: Repeat text "Repeat" ]) ClientSideWait Repeat.onPress Forever > Problems? Your app can run. You have eight error conditions to discuss. Use 'Talk about errors' to decide how to handle them. Right now, the answer is 'ignore first, or just explode'. >Push Pushing transcript to GitLab.... Building App.... Pushing Build to GitLab. > Move button above image.
- deleted 6y ago[deleted]
- asimjalis 6y agoNeat. Are there screenshots?
- vidugavia 6y agoCool. I fell in love with Janet during last advent of code, so I'll definitely give it a try
- csb6 6y agoFor anyone needing a simple and fast cross-platform toolkit for C++, FLTK is really good. It is easy to build and statically link only the parts you need, and the API/widget selection is pretty good. It looks a little old school/non/native, but it has been useful for me.
- Rochus 6y agoFLTK is just very spartan compared to e.g. Qt; from my point of view it is only useful for very simple GUIs; I hardly have any applications anymore that do not need item views or rich text.
- MaxBarraclough 6y agoIf you want a halfway house, there's the FOX Toolkit. http://fox-toolkit.org/ http://fox-toolkit.org/ It's not so active these days, admittedly.
- Rochus 6y agoWell, there is also Tcl/Tk and some others, but they are all at most half as powerful as Qt. An interesting alternative could be Flutter; however, you have to write (at least) the GUI in Dart, which is not everyone's cup of tea.
- MaxBarraclough 6y agoTCL is interpreted, so presumably it's not as lightweight as FLTK and FOX. I don't imagine Flutter is nearly as lightweight either.
- Rochus 6y agoTk is just a shared library accessible by any compiled language; there are many C/C++ cross-platform applications using it; it was actually also the first GUI toolkit used by Python; it's true that it includes Tcl which is a scripting language, but that doesn't matter much. It's nearly as lightweight as FLTK and Fox toolkit. Applications AOT compiled with the Flutter SKD are surprisingly lean (i.e. compared to Node/Electron) and not much larger than Qt applications.
- bmn__ 6y agoSubtracting all the delusional fluff about small sizes, this article is about a Janet binding to Gtk3. ldd app.bin|rg -o '/usr/lib[^ ]+'|xargs stat -L -c %s|perl -lne'$s += $_; END {print $s}' 38120904
- mwcampbell 6y agoActually it's about a Janet binding to IUP. The key difference is that on Windows, IUP uses native controls, whereas GTK does not.
- overgard 6y agoGUI frameworks are big because they do a lot. These minimalist things usually only work until you reach the limits of what they can do and then you have to rewrite in something like Qt anyway, or sacrifice what your users want in a GUI for your own code aesthetics.
- mwcampbell 6y agoWell said. And remember, it's not just what your users want, but what some of them need, e.g. accessibility. Enough said about that. :)
- davidcuddeback 6y agoIt’s be helpful to have some concrete examples of where one might run into limits with the minimalist frameworks and why a larger framework is required to overcome those limits.
- mwcampbell 6y agoTwo words: internationalization and accessibility.
- rootlocus 6y agoTables, tree views, popup menus, floating / docking windows, flexible layouts, file dialogs, animations.
- ahungry 6y agoIUP, which this wraps, does have most (all?) Of those
- overgard 6y agofile open/save dialogs, i18n, drag and drop, image formats, web views, any sort of accessibility, themability that actually fits into native platforms, sometimes the ability to open new windows, many common controls that we just take for granted now that you have to implement yourself, sometimes limited amount of events you can reasonably handle based on the design of the api (IM gui's for instance). I wouldn't say never use an minimalist framework. It can be handy for embedded debugging tools or for toy projects. But I wouldn't use one of these things for an application that I thought might have a few thousand users and some sort of life span.
- coleifer 6y agoTcl/Tk dabs on your gui frameworks from the unreachable pinnacle of the heavens.
- 9214 6y agoInteresting pitch for Janet. Here [1] is a quick rewrite in Red language, which lives up to the author's requirements: 10 LOC, native support for all 3 major platforms, can be shipped as a single binary, and all that's required is a 1MB toolchain. [1] https://gist.github.com/9214/dfa15d37342065dbf368eae35abcdc37 https://gist.github.com/9214/dfa15d37342065dbf368eae35abcdc3...