ڤالا

Vala
ParadigmMulti-paradigm: imperative, structured, object-oriented
DeveloperJürg Billeter, Raffaele Sandrini
First appeared2006; 18 years ago (2006
الإصدار المستقر
0.32.0[1] / 21 مارس 2016; منذ 8 سنين (2016-03-21
Typing disciplinestatic, strong
OSCross-platform all supported by GLib, but distributed as source code only.
LicenseLGPL 2.1+
Filename extensions.vala, .vapi
Websitewiki.gnome.org/Projects/Vala
Influenced by
C, C++, C#, D, Java

ڤالا Vala هي لغة برمجة كائنية التوجه مع self-hosting compiler that generates C code and uses the GObject system (that "can be seen as an alternative to C-derived languages such as C++ and Objective-C").

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

مثال للكود

A simple "Hello, World!" vala program (see also GTK+ hello world)

void main () {
    print ("Hello World\n");
}

A more complex version, showing some of Vala's object-oriented features:

class Sample : Object {
    void greeting () {
        stdout.printf ("Hello World\n");
    }
    
    static void main (string[] args) {
        var sample = new Sample ();
        sample.greeting ();
    }
}

An example using GTK+ to create a GUI "Hello, World!" program:

using Gtk;

int main (string[] args) {
    Gtk.init (ref args);
    
    var window = new Window ();
    window.title = "Hello, World!";
    window.border_width = 10;
    window.window_position = WindowPosition.CENTER;
    window.set_default_size (350, 70);
    window.destroy.connect (Gtk.main_quit);
    
    var label = new Label ("Hello, World!");
    
    window.add (label);
    window.show_all ();
    
    Gtk.main ();
    return 0;
}

The last example needs an extra parameter to compile on GNOME3 platforms:

valac --pkg gtk+-3.0 hellogtk.vala

This is the converted C code:

/* hellogtk.c generated by valac 0.28.0, the Vala compiler
 * generated from hellogtk.vala, do not modify */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>

#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

gint _vala_main (gchar** args, int args_length1);
static void _gtk_main_quit_gtk_widget_destroy (GtkWidget* _sender, gpointer self);

static void _gtk_main_quit_gtk_widget_destroy (GtkWidget* _sender, gpointer self) {
	gtk_main_quit ();
}

gint _vala_main (gchar** args, int args_length1) {
	gint result = 0;
	GtkWindow* window = NULL;
	GtkWindow* _tmp0_ = NULL;
	GtkLabel* label = NULL;
	GtkLabel* _tmp1_ = NULL;
	gtk_init (&args_length1, &args);
	_tmp0_ = (GtkWindow*) gtk_window_new (GTK_WINDOW_TOPLEVEL);
	g_object_ref_sink (_tmp0_);
	window = _tmp0_;
	gtk_window_set_title (window, "Hello, World!");
	gtk_container_set_border_width ((GtkContainer*) window, (guint) 10);
	g_object_set (window, "window-position", GTK_WIN_POS_CENTER, NULL);
	gtk_window_set_default_size (window, 350, 70);
	g_signal_connect ((GtkWidget*) window, "destroy", (GCallback) _gtk_main_quit_gtk_widget_destroy, NULL);
	_tmp1_ = (GtkLabel*) gtk_label_new ("Hello, World!");
	g_object_ref_sink (_tmp1_);
	label = _tmp1_;
	gtk_container_add ((GtkContainer*) window, (GtkWidget*) label);
	gtk_widget_show_all ((GtkWidget*) window);
	gtk_main ();
	result = 0;
	_g_object_unref0 (label);
	_g_object_unref0 (window);
	return result;
}

int main (int argc, char ** argv) {
#if !GLIB_CHECK_VERSION (2,35,0)
	g_type_init ();
#endif
	return _vala_main (argv, argc);
}


IDE support

There are various projects in various states of stability in order to provide IDE support for Vala:

انظر أيضاً

  • Genie, a programming language for the Vala compiler with a syntax closer to Python
  • Shotwell, an image organiser written in Vala
  • Ease, a presentation program written in Vala
  • elementary OS, a Linux distribution with a desktop environment programmed mostly in Vala

الهامش

  1. ^ "Vala Releases". 8 April 2016.
  2. ^ "Vala specific section,Vala Documentation".
  3. ^ "Source code of Val(a)IDE".
  4. ^ Valable
  5. ^ https://github.com/Valama/valama

وصلات خارجية

هناك كتاب ، Vala Programming، في معرفة الكتب.


Comparison with other languages

قالب:GNOME