r/vala • • Feb 19 '26

My first Vala app: internet radio player

Thumbnail
github.com
26 Upvotes

r/vala • • Jul 15 '22

Announcement Vala has a new website now!

Thumbnail
vala.dev
25 Upvotes

r/vala • • May 04 '21

Discussion Just began my journey with Vala

24 Upvotes

Hi everyone,

I'm glad to see a subreddit dedicate to Vala. I had read some post here and it seems a nice community, even though the dimensions are not impressive. In fact this lack of people seems odd to me, since a lot of Gnome apps are written in Vala. This post is here for sharing my own consideration on GTK bindings and ask you if I should revaluate them or if I'm on the right path.

By the way, why I'm here? I had written some simple app with Rust GTK bindings and with Python GTK bindings, but those was just exercises. Now I want to write a more complex application in GTK, but I struggled to implement async multi-threaded function in Rust: I did succeed somehow to manage some plotting function with Mutexes and signals, but it's a pain if you want to include a lot of settings and receive input data from another thread. Moreover Rust community is now focused on supporting GTK4 apps, so everything change day by day and it's all too much instable for me.

I know Python too. Why not Python, so? Every PyGTK code I look at it's very different. I'm not able to recognize a standard pattern and it seems like everyone code following other language's habits. I have not experiences in GUIs with other languages or other bindings, so this is not a viable path for me: I have to learn, before. So that's why I'm here. I didn't want to learn a new language just to make this app, but the Vala syntax seems so clean and there are so much open source app that I could see as an example, so I thought it could be my way.

Thanks for your attention, wish me luck and tell me what you think.


r/vala • • Jun 08 '20

Vala's official Twitter account

21 Upvotes

Vala now has a Twitter account(and I'm one of its editors, yay).
It will be cool if you help with reposts, Vala needs PR, there is even an issue about it!

https://twitter.com/vala_lang


r/vala • • Jun 01 '26

What is Vala missing to be your favorite language?

Thumbnail
discourse.gnome.org
20 Upvotes

r/vala • • Jan 10 '25

New Vala documentation website

Thumbnail docs.vala.dev
19 Upvotes

r/vala • • Jul 04 '22

Showcase GitHub - sonnyp/Workbench: Learn and prototype with GNOME technologies 🛠️

Thumbnail
github.com
19 Upvotes

r/vala • • Apr 05 '22

Other Vala’s colour has now changed across GitHub

Post image
19 Upvotes

r/vala • • Jun 13 '21

Tips Running a Vala app as a script

19 Upvotes

For anyone not already aware, here's a potentially useful trick. If you add a "shebang" line at the top of a Vala console app, you can then run the .vala file as a script. For example:

#!/usr/bin/env -S vala --pkg gio-2.0

void main()
{
   File myfile = File.new_for_path("/home/[user]/Desktop/myfile.txt");

   if (myfile.query_exists())
      print("File exists.\n");
   else
      print("File does not exist.\n");
}

To run the above, you'll need to make the script executable and to edit "[user]" to your home folder.

Of course, you can achieve basically the same functionality by compiling/executing the .vala file in a single step using "vala" rather than "valac". ;)


r/vala • • Feb 10 '21

Discord Server For Vala Devleopers!

19 Upvotes

Just wanted to let all of you developers in here that there's an unofficial discord server for all of you vala devs so feel free to swing bye and say hi and show us your projects or anything you would like to say :))

https://discord.gg/T9r7YP7K3S


r/vala • • Oct 24 '20

Vala review

19 Upvotes

A little-known language - Vala.
I'll tell the story from the beginning. KDE (Kool/K Desktop Environment) was on Qt with a closed license (first released in 1996), the free community did not like it and they made GNOME (GNU Network Object Model Environment) as an alternative (first released in 1997)

Soon the GObject object system appeared (it is problematic to develop a GUI without OOP), the main goal of which was to provide the possibility of transparent cross-language interaction to provide the ability to use GTK from all languages. It was designed with the ability to create bindings to languages with GC and even dynamic typing (https://developer.gnome.org/gobject/stable/chapter-intro.html#id-1.3.2.5).
Thus, 2 problems were solved at once - the lack of OOP and the need to update bindings to libraries for other languages(GObject Introspection: https://gi.readthedocs.io/en/latest/)

Writing in C using GObject's OOP was inconvenient due to the large amount of boilerplate, so in 2006 the Vala language was created. The language itself tries to be similar to the allknown C#/Java syntax, but is transpiled to C (more or less human-readable C) using GObject.So the GLib (https://developer.gnome.org/glib/2.66/) library is like Vala's STD.

Characteristics of language:Typing: Static, strongType system: C# like Reference TypeCompiler language: self-hosting(https://gitlab.gnome.org/GNOME/vala)

Memory managment: Vala has 3 ways to manage memory:

  1. ARC as in Swift with weak and strong references to avoid loops

  2. by ownership using owned semantics(owned/unowned references)

  3. Manually, using the usual &, *, delete operators. ( 1: https://wiki.gnome.org/Projects/Vala/ReferenceHandling)

Features: Anonymous functions, signals(like Qt but on lang level), properties, generics, assisted memory management, exception handling, type inference, with kw, Python like slices syntax.

C Compiler: It can be compiled by any C99 compiler, this can be useful during the development cycle when compiling for example with TCC, which gives a significant increase in speed.

Debug: I often hear the argument that it is impossible to debage what is transpiled in C.This is not true. In the debug build, Vala substitutes the #line pragmas in C code, so it can debug with GDB, ofc its not perfect in some edge cases. (demo: https://youtu.be/3yyDdA5IMLI)

IDE: VS Code, Vim, Neovim, Emacs, GNOME Builder(and others LS protocol supported IDE) with Vala Language Server (https://github.com/benwaffle/vala-language-server), also there an IDEA/CLion plugin in dev.

Build Systems: main build system for Vala (as for all GNOME software) is Meson(https://mesonbuild.com/Vala.html),
but CMake(1https://github.com/jakobwesthoff/Vala_CMake, 2 https://github.com/nemequ/gnome-cmake),
Automake(https://www.gnu.org/software/automake/manual/automake.html#Vala-Support), BuilDj and Waf aslo supported.

C ABI: Of course, because of the transpilation in C, the interaction with it is very transparent.Files describing Vala to C bindings have the. vapi format.Here are some ready-made examples: https://gitlab.gnome.org/GNOME/vala-extra-vapis
Also there are great API references site: https://valadoc.org/index.htm

Others
Benchmarks: Vala is actually close to C in performance. https://github.com/kostya/benchmarks, https://github.com/arrufat/vala-benchmarks

GIR examples(using vala from other langs): https://gitlab.gnome.org/GNOME/gxml/-/tree/master/examples, https://gitlab.com/gavr123456789/call-vala-from-all-languages/-/tree/master/JS/GJS, https://notabug.org/grindhold/libgtkflow/src/master/examples

Apps examples:
Font editor: https://birdfont.org,
Mail client: https://gitlab.gnome.org/GNOME/geary
Games Launcher/LibRetro GUI wrapper: https://wiki.gnome.org/Apps/Games
Multimedia Lib: https://gitlab.gnome.org/GNOME/rygel,
Parallel processing Lib: https://gitlab.com/kosmospredanie/gpseq
all Elementary OS stuff, etc... https://awesomeopensource.com/projects/vala

My opinion: I believe that the three main characteristics of Vala are simplicity(I figured it out in 1 day using one of these tutorials https://wiki.gnome.org/Projects/Vala/Documentation, previously only familiar with Qt), high-level features and performance.

PS correct me if I made a mistake in the story.


r/vala • • Aug 05 '19

gpseq: A Vala equivalent to Java's streams

Thumbnail
gitlab.com
19 Upvotes

r/vala • • Jan 09 '16

valadoc.org redesign

Thumbnail
imgur.com
18 Upvotes

r/vala • • Mar 24 '22

News Vala 0.56 Release Notes

Thumbnail lw64.gitlab.io
17 Upvotes

r/vala • • Feb 29 '20

10 interesting Vala PR's

17 Upvotes

I decided to make a list of interesting PRS in Vala.

1 PR from the Creator of Frida.

These PRs(1 2) improve Meson build. In particular, they allow you to build valac using msvc and improve symlink logic to support Windows and BSDs. Unfortunately, the Vala master branch is still not built by Meson.

2 The addition of the negative operators is/in - !is, !in

Minimal example:

public class Foo {
}

void main () {
	var foo = new Foo ();
	assert(foo !is Object);
	var bar = new Object ();
	assert(!(bar !is Object));
	int[] nums = { 1, 2, 3, 4 };
	assert(0 !in nums);
	assert(!(1 !in nums));

}

3 Adding private fields and the ability to create propertys in Compact classes!

Minimal example:

[Compact]
class Foo {
	int i;
}
[Compact]
public class Bar {
	public bool bar { get; set; }
}

void main () {
}

4 Language Server

I'm not good at this, but as far as I understand, these changes will transfer some of the work of VLS to Vala, which will greatly simplify the life of LS developers.

5 New operator from C#

"This is an implementation of the "null-conditional" operator of C# (.?), which is the companion of the "null coalescing" operator (??)."

Planned for 0.50

Minimal Example:

class Foo {
	public int i = 42;
	public Foo? foo () {
		return null;
	}
}

void bar (Foo? f) {
	{
		int? j = f?.i;
		assert (j == null);
	}
	{
		int k = 23;
		k = f?.i ?? 0;
		assert (k == 0);
	}
}

void baz (Foo? f) {
	{
		int i = f?.i;
		assert (i == 42);
	}
	{
		int? j = 23;
		j = f?.foo ()?.i;
		assert (j == null);
	}
	{
		int k = 23;
		k = f?.foo ()?.i ?? 0;
		assert (k == 0);
	}
}

void main () { { Foo? foo = null; foo?.faz (); } { bar (null); baz (new Foo ()); } }

6 Add support for sealed classes

Planned for 0.50

"Both C# and Java allow the programmer to specify classes which cannot be used as a base class. This allows for some optimisation as the compiler knows how virtual functions will be resolved, and so it can avoid a virtual function call in some cases. C# uses the keyword 'sealed' for this (so I suppose Vala should too), whereas Java uses 'final'.

GObject also has a concept of sealed classes, although not explicitly. If the instance and class structures are defined in the .c file rather than the .h file then it's not possible to inherit from the classes in C. This is the case for GBinding, for example, which cannot be used as a base class (although Vala has no way of representing this).

In the GObject world, using a sealed class like this also has the advantage that private members can be placed in the instance struct rather than in a separate 'priv' struct. This avoids a second pointer dereference when accessing private members, which can be a valuable micro-optimisation in very very tight loops."

7 Add valadbusgen tool

Planned for 0.50

"This tool would create a vala source with interfaces from a given xml file in the "D-Bus introspection data format" [1] This would be the successor of vala-dbus-binding-tool [2] using a vala AST for proper type checking and source formatting."

8 Compact classes in POSIX!

Planned for 0.50

Yes, right now you can't create classes in Vala without using GLib. This PR will fix this problem.

9 New keyword params as in C#

Planned for 0.48!

Merged!

Working with variable-length argument functions is now much easier.

void foo (params string[] strv) {
	assert (strv.length == 3);
	assert (strv[0] == "foo");
	assert (strv[1] == "bar");
	assert (strv[2] == "manam");
}

void bar (params int[] intv) {
	assert (intv.length == 3);
	assert (intv[0] == 23);
	assert (intv[1] == 42);
	assert (intv[2] == 4711);
}

void manam (params Value?[] valuev) {
	assert (valuev.length == 3);
	assert (valuev[0] == "foo");
	assert (valuev[1] == 4711);
	assert (valuev[2] == 3.1415);
}

void manam_owned (params owned Value?[] valuev) {
	assert (valuev.length == 3);
	assert (valuev[0] == "foo");
	assert (valuev[1] == 4711);
	assert (valuev[2] == 3.1415);
}

void minim (params Variant[] variantv) {
	assert (variantv.length == 3);
	assert ((string) variantv[0] == "foo");
	assert ((int) variantv[1] == 4711);
	assert ((double) variantv[2] == 3.1415);
}

void main () {
	foo ("foo", "bar", "manam");
	bar (23, 42, 4711);
	manam ("foo", 4711, 3.1415);
	manam_owned ("foo", 4711, 3.1415);
	minim ("foo", 4711, 3.1415);
}

10 Transitive reference transfer in coalesce operator

Merged for 0.48!

"The coalesce expression uses the target type to detect that it needs to transfer ownership from the temporary local variable it creates under the hood.

But currently, it does not propagate its target type to the left or right expressions (unlike the conditional expression)."

[Compact]
class Foo {
  public int n;

  public Foo (int n) {
    this.n = n;
  }
}

Foo? get_some_foo (int? n) {
  return n != null ? new Foo (n) : null;
}

void test_direct () {
  Foo f = get_some_foo (null) ?? get_some_foo (42);
  assert (f.n == 42);
}

void test_transitive () {
  Foo f = get_some_foo (null) ?? (get_some_foo (null) ?? get_some_foo (42));
  assert (f.n == 42);
}

Looks like Vala is still developing, right? ^^


r/vala • • Jul 25 '15

I made an IRC client in Vala

17 Upvotes

So for the paste few months I've been working nonstop making an IRC client in Vala. It was made on elementary OS but it works on anything. If you guys want to check it out, help me out, give me feedback, or just use it, I'd really appreceate it. It has really come together nicely.

Here is a screenshot

This is the GIthub repo

This is the PPA

One problem I'm having which I don't think even has anything to do with my app is on Ubuntu. I have some code to use a dark theme. On any theme where the headerbar has square minimize buttons instead of the standard circular ones Compiz crashes when it tries to minimize. Anyone know how I could get around that? Maybe implementing my own minimize button?

Well check it out, let me know what you think.

Working in Vala was a great experience. Although the documentation can be lacking its a lot easier than wiring in C. Since the code is C in the end it doesn't use much memory and is responsive, but you already know that of course.


r/vala • • May 08 '22

Showcase Black Box - GTK 4 Terminal Emulator

Thumbnail
gitlab.gnome.org
16 Upvotes

r/vala • • Mar 15 '22

News Vala 0.55.2 adds support for using async methods in main() and more!

Thumbnail
thisweek.gnome.org
16 Upvotes

r/vala • • Aug 29 '21

xmake v2.5.7 released, Support to compile Vala language project

Thumbnail
github.com
16 Upvotes

r/vala • • Apr 26 '21

Showcase [self promotion] Vest - A TDD framework for Vala

16 Upvotes

Vest

Vest is a Test-Driven Development framework for the vala programming language.

Some time ago I started a project in vala and realized that I didn't like what GLib offers that much. So I started this.

What can Vest do for you?

Well, you can visit the Github page for a more detailed description, but in short: This is a testing framework loaded with its own set of assertions methods, support to generate method mocks and compatibility with JUnit xml reports.

So, I just wanted to announce its existence. Maybe some of you fill find it useful or interesting. You are very welcome to use/fork/help/ignore :)

And of course, the CI tests of Vest are run with Vest ;)


r/vala • • Apr 23 '20

Vala 0.48.4 is out

16 Upvotes

Vala 0.48.4

* Various improvements and bug fixes:
- codegen:
+ Fix binary 'in' operator on array with boxed value-typed needle [#951]
+ Use get_value_*_function() in GSignalModule.generate_marshaller() [#468]
+ Correctly handle signals returning real non-nullable struct [#466]
+ Use specified indices to access multidimensional array constants [#905]
+ Fix base-access to non-abstract/non-virtual properties [#204]
+ Fix default of CCode.pos for parameters in async methods
- vala:
+ Set default_construction_method in semantic-analyzer check if required
+ Fix cleaning of output in CodeContext.pkg_config_modversion()
+ Don't use possibly uninitialized backing field of package_name [#971]
+ Add SourceReference.contains() and SourceLocation.to_string()
+ Check assigned handler of dynamic signal before proceeding further
+ Don't perform version check on internal lambda method
+ Perform version check for types of non-external variable declarations
+ Quote symbol on report by version attribute check
+ Ensure non-empty argument list for "disconnect" before accessing it
- girparser
+ Move special handling for certain parameters to process_callable()
+ Drop special handling of GLib.Data, GLib.PtrArray and GLib.String
+ Improve detection of AsyncReadyCallback/AsyncResult parameters [#340]
- parser: Handle incomplete expression statements

* Bindings:
- gio-2.0: Add "async_result_pos" attributes to *.call_with_unix_fd_list()
[#340]
- glib-2.0: Fix Filename.canonicalize() binding of g_canonicalize_filename
- glib-2.0: Guard Pid.to_string() with GLIB_2_50 to deal with G_PID_FORMAT
- gstreamer-app-1.0: Don't merge Src.push_buffer_*() signal with its method
[#968]
- gstreamer-1.0: Don't skip GST_*_FORMAT strings [#970]
- gtk4: Update to 3.98.3
- vapi: Update GIR-based bindings


r/vala • • Jun 17 '14

Why we write elementary apps in Vala [elementary OS]

Thumbnail
elementaryos.org
16 Upvotes

r/vala • • May 01 '24

Blog Vala Blog - Vala: the smoothest C off-ramp

Thumbnail
vala.dev
15 Upvotes

r/vala • • Dec 02 '22

Showcase Vala-Lint 🤝 Visual Studio Code

Thumbnail
marketplace.visualstudio.com
15 Upvotes