Live data from Hacker News

Libui: GUI library in C

github.com

71–80 of 186 posts

Re: Libui: GUI library in C

#71
post #40
post #29

Earlier quoted context omitted.

Umm, Gtk?

Correct me if I'm wrong, but GTK isn't really native on anything but Gnome. Instead apps are just skinned to (mostly) look like each platform.

Yes. GTK on Windows is borderline useless unless you pour significant effort into optimizing your program for it; and under OSX no amount of effort will make it feel anywhere close to native.

Re: Libui: GUI library in C

#72

Earlier quoted context omitted.

Performance?

The FFI reasonings are OK, I understand them. I didn't think in those terms originally. (Thought I asked about writing a C app not a C library...) But speed and C are othogonal nowadays (at least if productivity is in the picture). It is so much simpler to write correct programs leveraging multicore environments an/or asynchronity in other environments, that it is not productive to chose C for speed. (In terms of dev…

> Thought I asked about writing a C app not a C library...

libui is mainly intended for FFI use with Go.

Writing GUI apps in C is a pain in the ass, yes.

Re: Libui: GUI library in C

#73

This is a very good approach for the current times! As far as I understand from the source code, libui is a thin C wrapper that makes calls to each platform native ui framework. For instance, to create a window on OSX it calls the corresponding Cocoa function, for Linux the corresponding GTK function, etc. So, unlike Qt and GTK which are heavy cross-platform libraries because they can "draw" their own widgets themsel…

> [...] GTK is perfectly fine for Linux. This is great news, so now it is the best time to make thin wrappers around these stable things so that we can all go make useful software..

Hoping not to start any kind of framework quarrel, but my understanding was that quite many applications (such as Wireshark, Subsurface, and OpenShot) are moving from GTK to Qt very much due to Qt being more stable. Or is the main reason cross-platform compatibility?

Re: Libui: GUI library in C

#75
post #24

This is so funny. Yesterday there was another discussion on how C needs to be replaced due to security/corectness concerns (the K&R topic), today people are fascinated by a UI(!!!) library built in it. And they actually consider using this library.

C is simply the Correct Tool For the Job when writing cross-platform (native) UI's. It's simple, it's callable from almost any other language, and all OS GUI API's are already in C. There has been a lot of negativity/arguments against C here lately, which in my opinion has been very exaggerated. Seriously, how often do you guys write GUI apps that _also need to be secure_? An application isn't secure just because you…

Security should be evaluated based on requirements and usage. It makes no sense to say that UI (or any kind of) apps don't need to be secure, since a lot of them have high security requirements and ALL of them should at least have basic safety in place.

Re: Libui: GUI library in C

#76

This is a very good approach for the current times! As far as I understand from the source code, libui is a thin C wrapper that makes calls to each platform native ui framework. For instance, to create a window on OSX it calls the corresponding Cocoa function, for Linux the corresponding GTK function, etc. So, unlike Qt and GTK which are heavy cross-platform libraries because they can "draw" their own widgets themsel…

It's not a new approach, though. SWT (for the JVM) and wxWidgets (C++, with bindings for more than a dozen languages) have been following it for years.

The main difference is the License which is much more liberal in this case. Also binding C++ code requires wrapping the code trough a C interface which is really a pain; especially when considering the the underlying OS APIs have a C root.

Re: Libui: GUI library in C

#77
post #71
post #40

Earlier quoted context omitted.

Correct me if I'm wrong, but GTK isn't really native on anything but Gnome. Instead apps are just skinned to (mostly) look like each platform.

Yes. GTK on Windows is borderline useless unless you pour significant effort into optimizing your program for it; and under OSX no amount of effort will make it feel anywhere close to native.

I wonder how Deluge looks/feels on Windows or OS X. I've heard only good things about its native looks, but haven't ever used it on anything but Linux.

Re: Libui: GUI library in C

#78

Earlier quoted context omitted.

C is simply the Correct Tool For the Job when writing cross-platform (native) UI's. It's simple, it's callable from almost any other language, and all OS GUI API's are already in C. There has been a lot of negativity/arguments against C here lately, which in my opinion has been very exaggerated. Seriously, how often do you guys write GUI apps that _also need to be secure_? An application isn't secure just because you…

Any app i write needs to be secure as much as reasonably possible. If you communicate over a Network with not fully trusted remote endpoints, and handle text you have a fair chance of remote code execution in C. A git front end. A text editor. Anything written in C has a fair chance to making a mistake. Your very basic attitude is an example to the problem the industry is having! We will always make mistakes, no matt…

I'm not really sure I agree with communicating over the network in your GUI anyway. A git frontend shouldn't handle the connections, this is what libgit is for. Which would probably use curl or similar internally. Both of those are written in C, and are also reasonably secure as far as I know.

I stand by my point. Simply "not using C" isn't magically going to make your application so much more secure.

Re: Libui: GUI library in C

#79

Earlier quoted context omitted.

We would have to probably ditch the content creation applications we have right now too. I mean, Electron and web based apps are nice for stuff like a weather widget, simple music player or a gallery application, but I don't see it being used for 3D editing applications, audio editing applications and similar uses. There aren't even any good UI frameworks for doing html desktop like looking applications, most are des…

> 3D editing applications You can do 3D editing on the web, at least in a fairly basic way. http://threejs.org/editor/

https://clara.io/

Re: Libui: GUI library in C

#80
post #38

Earlier quoted context omitted.

This is not the same approach. Wxwidget is C++ which makes binding to other languages cumbersome. The same applies also to TK which is binded trough an embedded TCL interpreter.

Also TK doesn't offer native looks. Wx tries, though I'm not sure how good taking into account all platforms.

Since version 8.5 Tk ships with themed widgets that by default try to look native on Windows and OS X by leveraging the respective platforms' native GUI toolkits for drawing.

For the details see https://tcl.wiki/14796.

Post reply on HN