Basic
Std
Std means GLib
Hello world
print ("hello, world\n");
//If you don't need to allocate memory in the heap then main is not neededUser Input
stdout.printf (@"Your name is : $(stdin.read_line ())");Mathematics
stdout.printf ("Please enter the radius of a circle: ");
double radius = double.parse (stdin.read_line ());
stdout.printf ("Circumference: %g\n", 2 * Math.PI * radius);
stdout.printf ("sin(pi/2) = %g\n", Math.sin (Math.PI / 2));Random Numbers
var rand = Random.int_range (1, 49);Reading and Writing Text File Content
Spawning Processes
Timer
OS Specific
Network
Get Twitter Status
Soup Library
GIO (Vala standart input output library)
Async Server Example
Signals with data (Qt like)
Native Regular Expression Literals
Class
Things u can do with classes:
GObject Constructor Class
Structs
DBus
Server
Client
HTML5 Generate
Compose - Functional templating for Vala.
Gpseq (C# Linq/Java Stream API, Go lang Chanels and Parallelism)
Parallel sorting
Simple Parallel Data Processing
GoLang like channels
simple example
Complex example
Sum using divide and conquer:
GoLang like Managed Blocked Parallelism
If you comment out the blocking block and put only Thread.usleep then the program will run for a time equal to the number of running threads divided by the number of threads of your processor.
With blocking, it is equal to the execution time of a single thread, that is, one second. This is called work stealing. When a thread starts waiting for something, such as a packet from the network, another thread steals its CPU time and starts working until the first thread waits for the event it needs.
Если вы закомментируете blocking блок и оставив только Thread.usleep, то программа будет работать в течение времени, равного числу запущенных потоков, деленному на число потоков вашего процессора.
C blocking оно равно времени выполнения одного потока, то есть одной секунде. Это называется work stealing. Когда поток начинает чего то ожидать, например пакета из сети, другой поток ворует у него процессорное время и начинает работать, пока первый не дождется нужного ему события.
GObject
3 Types of classes
Vala supports three different types of class:
GObject subclasses are any classes derived directly or indirectly from GLib.Object. This is the most powerful type of class, supporting all features described in this page. This means signals, managed properties, interfaces and complex construction methods, plus all features of the simpler class types.
Fundamental GType classes are those either without any superclass or that don't inherit at any level from GLib.Object. These classes support inheritence, interfaces, virtual methods, reference counting, unmanaged properties, and private fields. They are instantiated faster than GObject subclasses but are less powerful - it isn't recommended in general to use this form of class unless there is a specific reason to.
Compact classes, so called because they use less memory per instance, are the least featured of all class types. They are not registered with the GType system and do not support reference counting, virtual methods, or private fields. They do support unmanaged properties. Such classes are very fast to instantiate but not massively useful except when dealing with existing libraries. They are declared using the Compact attribute on the class, See
Memory for Compact classes is allocated by this monster.

Run-Time Type Information
Dynamic Type Casting
Last updated
Was this helpful?