The Vala Programming Language
vala.dev
vala.dev
I have been involved with Vala in it’s early day and some hardcore GObject/C users never quite liked the C code that Vala generated although it was perfectly valid and exposed a very clean C header to interface with it.
I think that Vala is a really great tool for building applications that make use of Glib/GObject. For example Gtk applications, but also GStreamer and DBus applications.
If you aren't developing a DAW, a browser, or some other performance critical GUI app, you're moving to Electron and other layout engine solutions. And who should blame you, people don't want to fiddle with GTK_Window_Context_Handler* gtk_wdw_ctx_hdlr_ptr = Init_GTK_Window_Context_Handler(Window_Context* w_ctx); just to make a damn app.
Even if Vala drops in to save us all from noodling with Window Context Rocket Ship Handlers, layout engines are more portable solutions. The decline of WPF and Winforms is proof of this.
wpf is still heavily used in industry so that isnt very convincing to me
a) being able to deploy same codebase on web and desktop
b) reusing the vast selection of libraries for web
c) tapping the large amount of trained developers.
Sciter fails on a) and b), because it doesn't support even such a basic and widely used feature as CSS flex (they have something similar, but incompatible).
Even c) is very debatable.
Binary sizes are currently around ~12mb which isn't as good as Sciter but is quite a bit better than Electron.
Desktop UI and Web UI models are so different that in reality you cannot use the same codebase on 100% in both targets.
Web UI uses traditional Web's "endless tape" model where only width is known. This does not really work on desktop where width and height are finite. See this Sciter based app https://notes.sciter.com/ as an example.
> reusing the vast selection of libraries for web
If you do need this then you can use Sciter's WebView that is a <frame> backed by system browser:
https://sciter.com/wp-content/uploads/2022/04/sciter-webview...
> If you do need this then you can use Sciter's WebView that is a <frame> backed by system browser:
iframes are very constrained in what you can do, if you’re targeting the web from the start you get the full power of using those libraries beyond the bounds of a single frame.
I develop an Electron app and the CSS is 100% same on both web and desktop. It's not a "web page", it's an app, which doesn't use the "endless tape" model.
> If you do need this then you can use Sciter's WebView that is a <frame> backed by system browser:
At that point it seems easier to just use something like Tauri which uses the system browser for all rendering.
> In almost 10 years, Sciter UI engine has become the secret weapon of success for some of the most prominent antivirus products on the market: Norton Antivirus and Internet Security, Comodo Internet Security, ESET Antivirus, BitDefender Antivirus, and others. The use of HTML/CSS has allowed their UI to stay in touch with modern GUI trends throughout all these years, and will continue to well into the future.
Made me laugh a bit, I usually find antivirus softwares out of touch with good design and really impractical due to that.
That’s why I mention performance critical
> wpf is still heavily used in industry
But is anything new being made with wpf? Because that’s why I left that area.
windows shop still reach for it heavily in "boring" industry in my experience.
there is a difference between performance critical and sloppy of course. most people default to heavy crap cuz its good enough, or a good fit sometimes, i get that
and this is coming from someone who had to use wpf for software where it ended up too slow in all rendering paths despite MS "trust us bro" and had to render using directx directly. not super uncommon but we were paying the price early (.net fw 3, fuzy wpf text, vibrating layouts, the good days)
No, that‘s very common. I‘m peripherally involved in such a greenfield project, too. And my employer is (very) slowly switching existing WinForms applications to WPF. It‘s the new thing.
(I know that there are a handful newer MS GUI frameworks, but for us it‘s new)
they are both too new
Couldn’t be happier.
Look around, it’s a bloated, buggy world. Calendar apps aren’t being carefully engineered by European computer scientists.
>Electron apps tend to be poorly designed
How so, are you saying because they use Electron they’re inherently poorly designed?
I’m not the original commenter, but Electron apps are regularly poorly designed and lacking quality. I won’t say it’s inherent to Electron, but it’s largely due to the fact that the standard controls offered by browser engines are incredibly rudimentary. They are still catered primarily to forms and simple interactivity in a document.
Rich interactivity requires you build your own or find some third-party package, whereas at this point most desktop UI toolkits have 20-30 years of development and refinement behind them.
Panels and panes are resizable and collapsible; you can have multiple free-floating, smoothly resizing windows; collections/tables will efficiently reuse cells to avoid tanking performance on long or infinitely scrolling lists.
All of this stuff is possible with Electron I’m sure, but the platform doesn’t offer it for the taking, so most don’t bother. And when they do, it’s less refined than what we had in desktop apps in 2005.
Do people care? Evidently not. I do though.
It's a constant chase not worth any developers time.
They backtracked a bit on that but they'll still replace GTK4 with GTK5 at some point, probably deprecating context menus or whatever else this time. Clowns.
I haven't used qml a lot but I wonder if gtk has an equivalent to that too. What am I missing about gtk here? Like, where does GTK beat qt?
Secondly would be the license, while they're both LGPL these days, that wasn't always the case, and the current Qt company is highly hostile to open source.
I would like to know the honest answer to that question, actually.
And Java Swing was there from the beginning, still perfectly usable, and is widely used in industrial applications.
But I was unable to find information about how to set up my repo and build process with GTK vendored into the project. All tutorials said that I should just install GTK libraries with my system package manager, but that was not a satisfactory answer for me.
After some hours fiddling around stackoverflow, adding flags to my GCC invocation and being unable to solve the problem, I just gave up.
Flutter Desktop seems like a compelling alternative to GTK these days.
Sad news for ya, flutter just wraps GDK (from GTK) on Linux. It also, last time I checked, was limited to a single application window.
Another thing I would like to avoid is the philosophy of "the application binary doesn't come with its dependencies bundled, the user should install them using the system package manager". Unfortunately, many frameworks have this philosophy but, apparently, Flutter doesn't.
How about input events? How about vsync synchronization? How about monitor information? How about clipboard? How about drag'n'drop?
GDK does an awful lot of lifting for Just here.
In general, Qt acknowledges the differences between desktop styles and tries to match them, while Gtk doesn't seem to care about any style or interaction model other than its own.
Qt is old, and cool.
Now that Ardour has switched are there still any DAWs using GTK?
From https://ardour.org/whatsnew.html# :
> From a project-level perspective, perhaps the most important change is that we have moved the source code of our GUI toolkit (GTK v2) into the Ardour source tree.
A lot of the color fiddling etc. that web apps due is due to
1.) Graphic designers having no other way to go, now that print is dead
2.) Corporate Identity (which is of lower priority than platform identity)
3.) Selling stuff (not needed as much with desktop apps)
And since most folks end up supporting the web as a first class platform you have to BYOD there anyway. Nobody is out there making a JS framework to emulate WinForms.
Not everything has to or can be be cross-platform, not everything has to be web-visible. And I'd argue that serving the same view to everyone is quite often a bad idea. (Heck, in the web-case, it's not even just the view)
Reason being that the Rust bindings are fairly ergonomic regarding the GTK OO system, plus Rust has a great ecosystem.
Relm4 in special is pretty great
https://relm4.org/book/stable/
edit: here is some earlier blog post from 2016 https://blogs.gnome.org/despinosa/2016/11/01/rust-and-vala/ but I think there were others since then
I wanted my app to work well on desktop Linux and my pinephone running postmarketos and phosh.
Vala fit the bill nicely. I enjoyed it much more than python and the performance is great. I wanted something that was performant and minimized battery usage since I’d be using it on my pine phone.
Genie = 24 repos:
https://github.com/search?q=language%3AGenie%20&type=reposit...
Vala = 3.1K repos:
https://github.com/search?q=language%3AVala+&type=repositori...
Writing software for GNOME.
https://en.wikipedia.org/wiki/Vala_(programming_language)
https://en.wikipedia.org/wiki/GObject
KDE is based on Qt GUI library, and Qt is C++.
GNOME is based on GTK GUI library, and they wrote their own object system (GObject) on top of C. Then they wrote Vala, which updates plain C to be more like C# or Java, so it's easier to work with GObject than by using plain C.
I also liked the itemwise comparison with Java: https://wiki.gnome.org/Projects/Vala/ValaForJavaProgrammers
Defining a new language "just" for the GTK library will likely be responsible for it not taking off that much, even if - as is the case here - the language looks neat. The fact that it compiles to C, which is universally available, and the fact that it is not associated with corporate interests (unlike Microsoft C#/.net and Oracle Java/JVM) could be interesting, but perhaps decoupling things from GTK could have been wiser to get more reach?
I mostly develop software libraries nowadays, and the only GUIs are Webguis to interact with REST services, but for those folks that make the Linux desktop a better place, this seems a good way to be more productive than in C.
Speaking of which, the Linux desktop needs a re-think: someone should start and re-develop all apps in a much more clean and homogeneous way so that it is obvious what is done how. The existing bag of tools from different decades, inclusive apps from xfig, xlock, xv over LibreOffice/KWrite to gedit/kedit are just an inconsistent mess; even MS-DOS apps managed (at some point) to stick to standard text menus, from EDIT to TurboPascal.
https://www.theregister.com/2024/01/24/rise_and_fall_of_cua/
I have no doubt that the Java world has excellent tech behind the AOT support but the footprint is simply not comparable when you can't even construct a java.lang.String without bringing in the entire JapaneseChronology.
That said, it only really shines for the "gtk based linux desktop" usecase, for everything else the situation flips around, as you now need to bring your own GTK. Occasionally still worth it embedded, but not much else.
But the GNU/Linux camp was rather hesitant to adopt .Net for fear of Microsoft suing people over patent issues. At least that is my memory of it. People wrote replacements for those apps Tomboy -> gNote, F-Spot -> Shotwell, Banshee -> ???, using Vala.
Now that Microsoft has made .Net open source, the lawsuit threat seems to be gone (at least for the foreseeable future), but I think the ship has sailed.
Pretty much everyone reverted back to Rhythmbox, which to this day still feels less polished somehow.
There is also now an option to statically link native libraries into NativeAOT binaries in .NET, and to statically link NAOT-compiled .NET libraries into existing C/C++/Rust binaries.
I wonder, does Vala have a stable ABI, or native compatibility with other higher-level languages like C++ or ObjC? These are other difficult challenges which Swift attempts to tackle (and depending on who you ask, with varying levels of success).
In any case this is an interesting language. Thanks for sharing
It's almost a clone of C#; it's tightly coupled with the GObject system instead of .Net.
Even if you compile MSIL to native, you’re compiling to the GC’s ABI, which is definitely very different from what Vala and Swift do.
Practically speaking, you cannot call .NET methods directly unless they are annotated with [UnmanagedCallersOnly] which is necessary to ensure GC is in consistent state, module initializers have ran, etc. This is a concern for NativeAOT libraries as you don't have to explicitly call their entrypoint before calling them AFAIK.
This, however, is true for most languages that are not C. This is also a constraint for both Swift, which has its own reference counting and ABI (Library Evolution ABI) and likely Vala assuming it is reference counted.
The runtime vs runtime-less arguments are not exactly helpful given the context - there are """runtime"""-heavy interpreted languages like Python, Elixir or JS, there is Java which assumes JVM, but is already lower level, and then there's .NET, which under the hood looks a lot like a strange flavour of C++ when you e.g. inspect the AOT binaries with Ghidra.
Fun fact, native profilers work with NAOT applications transparently on all platforms. You can hit "sample" in activity monitor on macOS and it will show you fully symbolicated trace if symbols are available. Just recently, I used Samply to perform multi-threaded profiling and it worked just as well as it would for something written in Rust, if not better.
That’s an enormous difference in ABI.
I don't think what you say on .NET correlates with reality - you are not supposed to pass managed objects across FFI (you just can't, it won't let you unless you do unsafe cast shenanigans) - the correct way is to either marshal the data or use blittable representation (plain structs can be passed as is, either by reference or value, same goes for arrays/pointers of primitives). On the rare occasion where unmanaged code needs to keep a GC object alive, it is passed via special GCHandle but that's an exception not the rule.
Swift has its own high level representation for such objects which are very much not FFI compatible. ARC in Swift is a feature that requires compiler involvement to work correctly, and its structs are not FFI compatible unless they are "trivial". Swift also has its own more advanced Swift Library Evolution ABI, which is strictly not C ABI you expect out of your regular library and has its own calling convention and semantics.
Overall, there seem to be strange misconceptions about how these languages work so it would be best to check with the documentation first:
.NET P/Invoke (FFI):
- https://learn.microsoft.com/en-us/dotnet/standard/native-int...
- https://learn.microsoft.com/en-us/dotnet/core/deploying/nati...
Swift non-C ABI:
- https://github.com/apple/swift/blob/main/docs/LibraryEvoluti...
- https://www.swift.org/blog/library-evolution/
Swift ARC:
- https://docs.swift.org/swift-book/documentation/the-swift-pr...
- https://github.com/apple/swift/blob/main/docs/ARCOptimizatio...
(I don't actually know if any other other platform, besides Swift itself, implements Swift ABI support, but .NET is going to have it in .NET 9 - likely the first non-Swift platform to do so)
I have lost all love for the platform, but I still have to hand it to Microsoft: no FFI has come anywhere close to .Net in the 25-odd years of its existence.
> How would C track references for heap-allocated data originating from (A)RC-based language?
Intentionally designed FF interfaces do not at all. C either delegates allocation to the host language, or the host language needs to let C know when it's done with things. I think Lua is an example of the former (it has been a while), the Vulkano crate is a living example of the latter.
On the other hand, GCHandles[0] are rare and only ever needed when you have complex object lifetime where, for example, the object reference needs to be passed back from unmanaged and object needs to survive in the meantime. The unmanaged code cannot interact with an object itself because it is not representable and would have arbitrary layout.
Today, there is support for multiple calling conventions and ways to interact with FFI. [UnmanagedCallersOnly] exports with NativeAOT-compiled libraries are C exports in the same way they are for the dynamic (or static) libraries compiled with GCC. Various flavours of function pointers have existed for a long time, yes. The most recent one allows to cast pointers directly to the desired unmanaged function signature within unsafe code, or create one given mentioned UnmanagedCallersOnly annotation on a C# method.
[0] https://learn.microsoft.com/en-us/dotnet/api/system.runtime.... note specific use case, it's not the bread and butter regular marshaling and pinning are
And Vala’s is exactly what GObject code was already doing.
There is no free lunch in software engineering, only difficulties with accepting reality.
[0] https://clang.llvm.org/docs/AutomaticReferenceCounting.html
Objective-C's refcounting is exposed to C via CFRetain/CFRelease. Long before there was ARC (the thing you cite), the bulk of the NexTSTEP and then Apple frameworks were written with Objective-C code manually doing [obj retain]/[obj release] and C code manually doing CFRetain(obj)/CFRelease(obj). There was some doc somewhere telling you the protocol.
Later, ARC came around to automate it for Objective-C code that opted in. ARC carefully mimicked the semantics of the protocol in that doc.
And then later, Swift came along and mimicked the semantics of ARC.
There is a free lunch for languages that use reference counting. That free lunch doesn't exist for GC'd languages, which introduce a semantics that is different from the ones that C code already uses.
Sorry to burst your bubble.
The GC<->legacy-C interoperability problem is unavoidable. I’ve been around the block on that problem as someone who writes GCs for a living. It always devolves to some sort of ugliness.
Anyway, the fact that Vala uses GObject RC semantics is a point in favor of Vala. Folks who go that route, as Swift also did, should just be honest with themselves about the tradeoff: simpler interop, worse throughput.
Cool stuff.
edit: Actually I meant to say Unity’s IL2CPP, which transpiles IR to C++. Burst is a different tool with similar goals—it compiles IR straight down to native via LLVM.
- Automatic or semi-automatic memory management
- Threadpool and, optionally, async abstraction implementation
- APIs to introspect type system properties / reflection
Swift very much has all these. And so does .NET.
As for Unity, it has diverged and lags behind "vanilla" .NET in features, language versions and performance significantly, so the experience of using it won't translate to what is expected to be "normal" C#/.NET of today.
I checked it ten years ago-ish, I think it transpiles into C (with GObject). Still no runtime though.
There's a great documentation website that has everything located in one place also, which makes development a breeze: https://valadoc.org/
https://wiki.gnome.org/Projects/Vala/
"Vala - Compiler Using the GObject Type System"
Vala Programming Language - https://news.ycombinator.com/item?id=32113825 - July 2022 (93 comments)
Vala Programming Language - https://news.ycombinator.com/item?id=28905761 - Oct 2021 (1 comment)
Vala Programming Langauge - https://news.ycombinator.com/item?id=26019680 - Feb 2021 (1 comment)
In the end, I think it lost due to the network effect.
Well it is massively easier to integrate C and C++ libraries in Vala compared to C# or Java - P/Invoke is bearable, but JNI is a pain to use and very hard to get right.
In 2009 I wrote a lib to auto-generate Ruby bindings for Vala code. It gave a very pleasant API to create native extensions for Ruby, if you were happy using glib.
EDIT: might be getting confused with ubuntu
Like the desktop app store, the Ubuntu installer is now written in Flutter.
[1] https://vlang.io
At this point I feel something is definitely up. How many V* languages are there floating around out there.
Although on the other hand, we have C, C++, C#, and objective C (etc). So maybe this is just something that happened every once and a while through otherwise unsuspicious causes.
How popular is it within the GNOME community?
What are its advantages over more popular garbage-collected programming languages like GoLang?
The gitg git gui is written in vala. I've used it for several years because it allows easy staging of individual lines, as well as reverting them.
I have been looking for this functionality for literally years at this point. Thank you! I will be trying this.
It does indeed have the same functionality as gitg for staging and reverting individual lines. It does have several UI niggles. For example when selecting it does not do so on a line by line basis, but instead character by character. But the operations are line by line, (or hunk). You also can't right click on file names and choose stage, revert, or delete.
While git add -p is in theory doing something similar, it is a lot more painful to use, and you are still working a hunk at a time instead of just scrolling through changes.
I often use this functionality when I've made a number of changes during development and everything is now coherent, especially on a multi-language project. It is then easy to go in and discard lines that were added to debug, and stage lines across multiple commits so they are logically grouped.
So the biggest difference from C# or Java is that there is no VM. It is mostly syntactic sugar over C and GObject.
At least, this was the case last I paid attention 15 years ago.
Ha! Ain't that the truth :-)
It touches on a big problem for new language development in that there are barriers to entry at getting workable in a new language, but employers don't want to use them unless they can hire for them, and they can't hire for them unless people use them, but people don't use them because they can't get hire'd to use them, rinse and repeat.
I actually first heard of Vala just a few days ago when I was looking at a C#-related PR[1] for highlight.js:
> This fails the tests as the Vala default.txt is recognized now as C#. However, Vala is very close in syntax to C#, and the default.txt also seems to be valid C# so not sure what to do about this.
https://wiki.gnome.org/Projects/Vala/ValaForJavaProgrammers
Imagine going to a link called docs and finding the first 2 links are about what you ask for :D
Maybe I'm alone, but my immediate thought when seeing a new language, with fairly familiar syntax, was "why is this different than Java". And if that's my first thought, it probably makes sense to answer that question immediately rather than talk about vague things like Productivity and Open-Source.
Any reason in particular to use vala over qt?
Downvoting coz doesn't have enuf grey matter to realize dat one can read about Vale outside of HN, and den search hn.algolia.com for vale language and find some hits, and share that info in HN.
an apps list is here
else you have : Pamac-manager is on vala Gnome-Boxes gnome-calculator
:look: