Can Vala be used without GObject?
Asked Answered
Q

3

16

I'm new to Vala. I'm not familiar with GObject. As I understand it, GObject was spun off from the GLib project from GNOME. Correct me if I'm wrong.

I do like the syntax and implementation of Vala very much, yet it is not in my intentions to write desktop applications for GNOME.

I also know (think I know) that Vala does not have a standard library other than GObject itself.

So my question is: Can Vala be used without GObject and if it can, is it usable (are there optimal and maintained base libraries for common things like type conversions, math, string manipulation, buffers, etc... available)?

Quinsy answered 3/3, 2012 at 21:26 Comment(1)
The GObject framework is not bound to gnome desktop environments. You can use the GObject libraries on almost any form of linux and even on windows.Snuffle
C
11

There is some other Vala profiles like Dova and Posix.

Culpepper answered 3/3, 2012 at 21:36 Comment(1)
Note that you can't have classes in the Posix profile (or at least only [Compact] ones)Mylesmylitta
N
8

TLDR: I recommend using Vala with GLib/GObject, because it was designed on top of them.

While there may be alternative profiles for valac they are either unfinished or deprecated.

The whole point of Vala is to reduce the amount of boilerplate required to write GLib and Gtk+ applications in C.

It also adds some nice other improvements over C, like string and array being simple data types instead of error prone pointers.

It mostly wraps all the concepts present in GObject like:

  • classes
  • properties
  • inheritance
  • delegates
  • async methods
  • reference counting (which is manual in C + GObject, and automatic aka ARC in Vala)
  • type safety of objects
  • generics
  • probably much more ...

All of these concepts can be implemented without using GObject/GLib/Gio, but that would mean to basically rewrite GObject/GLib/Gio which doesn't make much sense.

If you don't want to write GUI applications GLib can be used to write console applications as well, using GIO or GTK+ is optional in Vala, applications work on a headless server as well.

I think that there is even some effort in Qt to eventually switch to the GLib main loop, which would make interoperability of Qt and GLib much easier.

A good example of a framework that uses GLib is GStreamer which is used across different desktop environments as well.

In summary:

  • GLib is a basic cross platform application framework
  • GObject is the object system used by the GLib ecosystem
  • GIO is an I/O abstraction (network, filesystem, etc.) based on GLib + GObject
  • GTK+ is a graphic UI toolkit based on GLib + GObject + GIO + others
  • GNOME is a desktop environment based on all the "G" technologies
  • Vala is a high level programming language designed to reduce the boiler plate neded to use the "G" libraries from the C language.

GTK+ originally came from GIMP and was since split into the different "G" libraries that are the basis for GNOME today.

Vala also has very powerful binding mechanisms to make it easy to write so called "VAPI" files for any kind of C library out there.

With the correct VAPI bindings you don't have to worry about manual memory management, pointers, zero termination of strings and arrays and some other tedious things that make writing correct C code so difficult.

Nevins answered 22/9, 2016 at 10:53 Comment(0)
U
4

Here is another profile that you can use Aroop. (Note it is still under heavy development). What I hope is it is good if you need high performance. Please check the features here.

Unfortunate answered 9/8, 2012 at 12:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.