Sorry for the somewhat noob question, but how do you pick a library for making a GUI for your apps? My background is in physics, so most of my programming is perfectly find with a CLI that outputs a graph as a ps file or some csv. I am looking to learn about making some neat little GUIs. I was thinking it would be a good idea to try and build my GUI out of the browser so that my app can be as portable as possible, but does this mean it has to be in Javascript or can the backend be done in anything else?

I am not really sure what I am asking, but wanted to get a feel for how people approach front ends.

Thanks :)

5 points

The UI platform with the largest install base of all is the web. Nearly all computer users can use your GUI if you develop it for the web, it’s almost the definition of the universal open standard for GUIs.

Browsers can only execute JavaScript or WebAssembly, so you need to write it in JavaScript or in something that compiles to these things, e.g. TypeScript (but there are also ways to compile other languages to JS or WASM).

permalink
report
reply
7 points
*

I (probably unreasonably) despise using web front-ends for desktop applications.

GTK is OK. QT is very feature rich, but that adds complexity. Both can be cross-compiled to most systems and shipped with all the required libraries pretty easily.

I haven’t used it in a long while, but I remember liking Java Swing for some reason. Java should be “write once, run anywhere.” But, cross-compiling isn’t usually too hard, so not sure how much that matters. There’s more modern frameworks for JVM-based languages now, but I haven’t tried them.

I’ve noticed Gradio is popular in the ML community (web-tech based, and mostly used for quick demos/prototypes).

Edit: For web applications, I prefer Angular’s more traditional architecture over React’s hook architecture.

permalink
report
reply
7 points

I’m a web dev with a wife who is a researcher, and on the side I’ve built a few tools for her work. Web apps are great because cross-platform distribution and compatibility are non-issues. If you don’t need a database or server-side logic, a client-side only application is basically free to host given that it’s ultimately just a pile of static files. You can use localstorage for persistence, and because there’s no server logic you have a lot fewer security implications to worry about.

JavaScript gets a bad rap, but if you pair it with typescript and decent tooling it’s really not bad. HTML and CSS are an incredibly powerful engine for building UI, which is only getting better.

permalink
report
reply
7 points

What language are your apps written in? Generally the best options are:

  1. Qt (C++) or PyQt (Python wrapper if you hate yourself). Old school desktop GUI. Works extremely well though.
  2. Web based, then you can pick from a gazillion frameworks, most popular is React. You generally have a Typescript based frontend and a backend in whatever language you want. The downside is you have to deal with the frontend/backend communication which can be a pain.

There’s also Flutter which is pretty nice, but again you have to use Dart for the GUI so if the rest of your app is in another language you’ll have some friction.

But yeah, I would say the language you want to write your “business logic” in is the biggest factor to choosing. Also if you care about exposing your app over the web.

permalink
report
reply
1 point

I’m a bit if a python guy but I’m split between java and up and coming rust for employment purposes.

permalink
report
parent
reply
2 points

For rust I use iced, as it meets all my needs and is a delight to work in. I don’t think it’s good for making graphs though. For graphs I heard that people like matplotlib (in python), which you can also use inside PyQt apps. I’ve tried using matplotlib and did not enjoy the experience at all, but I don’t know of any alternatives.

permalink
report
parent
reply
1 point

For Python PyQt is the obvious choice. For Rust there isn’t really a mature option yet. Egui is decent, but it’s immediate mode which isn’t to everyone’s taste. Dioxus is pretty popular too but I haven’t used it.

No idea for Java. Is Swing still the standard?

permalink
report
parent
reply
17 points
*

If you do want to go the web route, I’d highly recommend avoiding SPAs and going with https://htmx.org/ instead. Much simpler, less code, entirely driven by your backend, while still giving you the ability to make nice interactive applications.

As a bonus, since you presumably have been working with Python anyway, the author of htmx has a whole book online walking you through building an app using htmx and Flask, a web framework for Python: https://hypermedia.systems/book/contents/

permalink
report
reply
1 point

Whoa I’ve heard of tkinter but I’ll look into htmx too!

permalink
report
parent
reply

Programming

!programming@programming.dev

Create post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



Community stats

  • 3.6K

    Monthly active users

  • 1.7K

    Posts

  • 28K

    Comments