Live data from Hacker News

Ask HN: What's the best library for making cross-platform UIs?

news.ycombinator.com

201–210 of 230 posts

Re: Ask HN: What's the best library for making cross-platform UIs?

#201
post #198

Earlier quoted context omitted.

I don't understand how anyone can assume that antialiasing is missing in Tk, it's simply wrong and has been there for many years for font drawing. On Linux, it must be compiled against fontconfig/xft (default, if the headers can be found). On OSX and Windows, it uses the native font renderer. The only point on OSX high dpi displays: you need to set a property that the application supports high dpi (in a .plist file),…

Thanks so much for this! I know very little about Tk. Besides antialiasing on a canvas, does antialiasing also work in text in labels, buttons, etc? Can I get in Tk all the fonts I can get in a Mac? Is Helvetica there? Why can't I find on the web screenshots of Tk apps running on Mac OS X? Is the only way to get Tk to look good on a Mac using Tile http://tktable.sourceforge.net/tile/screenshots/macosx.html ? From wha…

The link [5] in my top-level comment plus http://www.tkdocs.com/tutorial/fonts.html should answer your questions. The former has screenshots of Tk on macOS and discusses how to make it look good there. There is a screenshot of a commercial Mac application built with Tk at http://www.codebykevin.com/portauthority.html.

Tile was integrated into Tk with version 8.5 (2007). The Tile button, label, etc. are now built in.

Re: Ask HN: What's the best library for making cross-platform UIs?

#202

For a file manager I'm developing [1], this question recently boiled down to Electron vs (Py)Qt. I chose (Py)Qt because Electron's startup speed is too slow. [1]: https://fman.io

How are you handling licensing? Are you using the commercial version of PyQt? I've been thinking of distributing some apps I've built but I don't want to make them GPL (I don't mind using MIT or BSD though).

There's PySize https://wiki.qt.io/PySide but it probably needs work

Re: Ask HN: What's the best library for making cross-platform UIs?

#203
post #200

Earlier quoted context omitted.

I agree across the board with your assessment. It is a shame that OP does not want to go HTML/CSS engine, because over the years, I have found that to be the easiest to update, the most reliable across platforms, and (most importantly) the easiest to support for multiple users. I have tried (and used in production) most of the UI tookits mentioned here. WxWindows (later WxWidgets), Tk, and FLTK are getting long in th…

Why is Tk getting long in the tooth? This comment believes Tk is as good as wkWindows and QT https://news.ycombinator.com/item?id=12380456

Tk and WxWidgets are not in the same league as QT.

Tk is limited, specifically, to being a gui toolkit, and even though the most recent versions look like native widgets, they are limited and the online support (from groups, etc) is limited. All the connecting libraries feel like you are back in the 90's programming again.

WxWidgets is to QT, as Linux is to Mac OS X -- one is cobbled together from amateurs with varying quality of components, and the other is built by professionals and held to professional rigor. The API (and output, in my opinion) is amateurish and dated in comparison. It lacks the polish and ecosystem that the professionally-supported QT has.

If you are making a full-fledged application (as opposed to a user tool or back-end interface) and are hell-bent on using a windowing toolkit (over say an HTML/CSS engine), then QT is currently the only correct answer. There are others around, but they all fall short of QT.

On a side note, Tcl (by the same original author as Tk) is a wildly under-appreciated scripting language.

Re: Ask HN: What's the best library for making cross-platform UIs?

#204
post #196

Earlier quoted context omitted.

Different platform, different requirements. If a language run-time or virtual machine promises, "you can write code once and run it anywhere," then they're not telling you the whole story. There's no such thing as, "cross platform." It's just a vague term that is commonly interpreted as, "major OS platforms," or, "most popular mobile platforms," etc. Requirements are both technical and non-technical. If we just focus…

> I have yet to see any kind of language or run-time that lets you have it both ways. If there were such a language I wouldn't be asking this question on HN. I have yet to see a clear answer why there is no such kind of language or run-time. > the same code written for the DSL is not likely going to run well or even be considered for use by your other target platforms. Why? Can be you more specific with an example?

> I have yet to see a clear answer why there is no such kind of language or run-time.

... I'm having trouble not being glib in my response. I want to say, because computers. But let's be a little hand-wavey for a moment.

As programmers we sometimes put too much faith in our poorly-thought-out abstractions. We think, "why is there not a library/runtime/VM that abstracts away all of these painful, tedious details? Surely someone must've invented a GUI library that runs on all platforms, perfectly." We look for ways to avoid the difficulty of thinking too hard about it. We just want to write an application and not think about operating systems, hardware architectures, memory allocation, etc, etc.

Well there are systems that do remove some of the effort in writing such applications. They will manage memory for you, abstract away the differences in various operating systems, and they might even provide a common library for writing a GUI that works across all of the platforms that the VM/runtime supports... this is a great tool to have.

However it has a cost. It has it's own memory model. It makes assumptions about what GUI interfaces are. It targets the common denominator between operating systems. It is, by necessity, quite complex on the inside... so as long as you can sit comfortably in the box and write programs that the system expects you to write you can safely ignore the hairy details of allocating memory, making system calls, managing resources, etc.

But if your application requirements pull you out of that comfort zone be prepared to have to deal with garbage collection algorithms and mapping your application's data to the runtime's model. That has a cost.

For some applications that cost isn't worth it or even feasible. How much battery power are you willing to consume? How many updates to the simulation can you make per second? How fast do you have to stream that data of the disk to this other component?

These languages and runtimes that claim to be "cross platform" are really just selling you a subset of functionality on a subset of platforms that you may or may not care about. It's never what you intuitively assume it to mean, "write once, run everywhere."

> Why? Can be you more specific with an example?

I wrote a 6502 assembler in Common Lisp many moons ago. With it I was able to write applications for that processor in a high-level language with all of the Common Lisp tools I was used to. However that DSL was restricted to that platform backend.

Had I a requirement to target another platform, say x86_64, I would have to write another backend for my high-level DSL and introduce plumbing to my build tools to produce the executable code for either platform. Great! Cross platform code!

Well... not really. I still had to write two different backends. And I can't really exploit the unique features of either. I can only really make use of the common denominator between both or else emulate features of one in the other at the expense of making one platform less performant/useful than another.

There's no such thing as "cross platform." It's just a marketing buzz-word. There are hardware platforms. There are operating systems. These are the things we program.

Abstractions are great but they're not free and they don't free you from thinking. It's an easy mistake to make because it comes so naturally to us humans -- we hate doing things that are difficult. But there's nothing natural about programming. It's hard.

Re: Ask HN: What's the best library for making cross-platform UIs?

#205
post #200

Earlier quoted context omitted.

Why is Tk getting long in the tooth? This comment believes Tk is as good as wkWindows and QT https://news.ycombinator.com/item?id=12380456

Tk and WxWidgets are not in the same league as QT. Tk is limited, specifically, to being a gui toolkit, and even though the most recent versions look like native widgets, they are limited and the online support (from groups, etc) is limited. All the connecting libraries feel like you are back in the 90's programming again. WxWidgets is to QT, as Linux is to Mac OS X -- one is cobbled together from amateurs with varyi…

Thanks for sharing this knowledge.

What can Tk not do, specifically? This thread believes Tk is as good as QT https://news.ycombinator.com/item?id=12380456

Re: Ask HN: What's the best library for making cross-platform UIs?

#206
post #198

Earlier quoted context omitted.

Thanks so much for this! I know very little about Tk. Besides antialiasing on a canvas, does antialiasing also work in text in labels, buttons, etc? Can I get in Tk all the fonts I can get in a Mac? Is Helvetica there? Why can't I find on the web screenshots of Tk apps running on Mac OS X? Is the only way to get Tk to look good on a Mac using Tile http://tktable.sourceforge.net/tile/screenshots/macosx.html ? From wha…

The link [5] in my top-level comment plus http://www.tkdocs.com/tutorial/fonts.html should answer your questions. The former has screenshots of Tk on macOS and discusses how to make it look good there. There is a screenshot of a commercial Mac application built with Tk at http://www.codebykevin.com/portauthority.html . Tile was integrated into Tk with version 8.5 (2007). The Tile button, label, etc. are now built in.

This comment says Tk is limited https://news.ycombinator.com/item?id=12381978 You and the GP say it's not.

Is there anything Tk can't do?

Also a question on fonts. Does Tk make it possible to use webfonts I see on websites?

Re: Ask HN: What's the best library for making cross-platform UIs?

#207
A few other people have mentioned JavaScript and HTML but in my experience HTML and CSS support varies wildly between platforms and as applications become larger it is difficult to tune the performance of your running application. Also the implementation of the base code for HTML tags and what CSS properties can do are inaccessible to JavaScript making many task much harder than they would be in other environments where you can simply extend or introspect the internals.

But if you want something to run everywhere including web browsers, JavaScript is the only realistic option. So we make do. My current approach is to rely on HTML/CSS and React/React Native for the easy stuff and everything else is rendered in the Canvas tag with lots of JavaScript to bend the platforms into doing what you want.

In the past I have taken similar approaches by using things like Ejecta but the android support for this is lacking and now that WKWebView has addressed many of its issues, using standard WebViews within native containers is fast enough on mobile.

On desktop, Electron, NW or the other things like this can fulfill the same setup.

People will complain about performance which was a really big issues a few years ago but today the difference isn't large enough that it can't be worked around and most of the fear is in people heads. Most environments have web workers, and webgl, and JavaScript that has a JIT, and many new things like Web Assembly and SIMD should be available in the coming years making these platforms even more viable.

Re: Ask HN: What's the best library for making cross-platform UIs?

#208
post #202

Earlier quoted context omitted.

How are you handling licensing? Are you using the commercial version of PyQt? I've been thinking of distributing some apps I've built but I don't want to make them GPL (I don't mind using MIT or BSD though).

There's PySize https://wiki.qt.io/PySide but it probably needs work

PySide doesn't work with Qt5 yet.

Re: Ask HN: What's the best library for making cross-platform UIs?

#209
post #199
post #163

Earlier quoted context omitted.

Before you start to roll your own consider that there have been many attempts to do this already and they have all failed to varying degrees. The reason for this is that it's much harder to get right than it seems. QT is what I've used when a client is determined to go down this path, but if a web app doesn't make sense the best option is almost always to spend extra time making sure that most of your code is portabl…

> it's much harder to get right than it seems I'm not disputing this but I've yet to see a clear explanation why it's harder to get right than it seems. I want to understand, precisely, what makes this hard.

It's not necessarily hard but it is a ton of work and requires a lot of low level knowledge of the underlying window system. You need to have a very good understanding of the layer beneath you (xlib, Wayland, win32) and how fonts are rendered on the various systems you want to support. There's also various tradeoffs you need to make. Do you go with custom drawn widgets or use native ones? Native offers a shortcut if you have a greater understanding of the lower system API. Custom drawn requires possibly less knowledge of the various widget API but more knowledge of the underlying window drawing API. Getting basic buttons and labels drawn is not hard. The harder parts are menus, text entry, scroll bars and scrolling. None of the current toolkits were cross platform from initial release. Almost all started with Xlib and then years later were ported to Windows. Some still haven't made the port to OSX (except to rely on x11). It's a lot of work and maybe that's what makes it hard.

Re: Ask HN: What's the best library for making cross-platform UIs?

#210

Just getting started on Electron myself. Used by Atom, Slack, Visual Studio... It's worth a look ;) Electron - Build Cross-Platform Desktop Apps With HTML, JS, CSS http://electron.atom.io/

Electron only works for desktop applications and probably needs a js-framework to work good. I think that React + Electron looks like a nice combo and then you can use React Native to create Android and iPhone apps also, probably sharing a lot of code between all versions.

At the moment the pairing seems to be Electron + Cordova for non-React JS frameworks; with those two you can share 100% HTML at least if you have a responsive CSS design.

Also, now that React Native is extending into the Desktop space more directly (with Linux, Mac, and Windows UWP variants), for React you may not need Electron at all.

Post reply on HN