ebooksgratis.com

See also ebooksgratis.com: no banners, no cookies, totally FREE.

CLASSICISTRANIERI HOME PAGE - YOUTUBE CHANNEL
Privacy Policy Cookie Policy Terms and Conditions
Vala (programming language) - Wikipedia, the free encyclopedia

Vala (programming language)

From Wikipedia, the free encyclopedia

Vala
Paradigm structured, imperative, object-oriented
Appeared in 2006
Developer Jürg Billeter, Raffaele Sandrini
Influenced by C, C++, C#, Java

Vala is a new (as of 2006) programming language, targeting the GObject object system. It was developed by Jürg Billeter and Raffaele Sandrini.

It has a syntax based upon C#. However, unlike C#, it has no runtime system (Vala is compiled to C code, which can then be compiled to native code) and so imposes little additional overhead.

The primary advantage of Vala over C++/gtkmm is that Vala is memory-managed (not using garbage collection).

[edit] Code example

The "Hello World" program:

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

The generated C code (header and source file):

#ifndef __SAMPLE_H__
#define __SAMPLE_H__
 
#include <glib.h>
#include <glib-object.h>
 
G_BEGIN_DECLS
 
 
 
 
G_END_DECLS
 
#endif
#include "Sample.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
typedef struct _Sample Sample;
typedef struct _SampleClass SampleClass;
typedef struct _SamplePrivate SamplePrivate;
 
#define TYPE_SAMPLE (sample_get_type ())
#define SAMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SAMPLE, Sample))
#define SAMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SAMPLE, SampleClass))
#define IS_SAMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SAMPLE))
#define IS_SAMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SAMPLE))
#define SAMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SAMPLE, SampleClass))
 
struct _Sample {
        GObject parent_instance;
        SamplePrivate * priv;
};
struct _SampleClass {
        GObjectClass parent_class;
};
enum  {
        SAMPLE_DUMMY_PROPERTY
};
static void sample_run (Sample* self);
static gint sample_main (int args_length1, char** args);
static Sample* sample_new (void);
static gpointer sample_parent_class = NULL;
static GType sample_get_type (void);
 
 
static void sample_run (Sample* self) {
        g_return_if_fail (IS_SAMPLE (self));
        fprintf (stdout, "Hello World\n");
}
 
 
static gint sample_main (int args_length1, char** args) {
        Sample* sample;
        gint _tmp0;
        sample = sample_new ();
        sample_run (sample);
        return (_tmp0 = 0, (sample == NULL ? NULL : (sample = (g_object_unref (sample), NULL))), _tmp0);
}
 
 
int main (int argc, char ** argv) {
        g_type_init ();
        return sample_main (argc, argv);
}
 
 
static Sample* sample_new (void) {
        Sample * self;
        self = g_object_newv (TYPE_SAMPLE, 0, NULL);
        return self;
}
 
 
static void sample_class_init (SampleClass * klass) {
        sample_parent_class = g_type_class_peek_parent (klass);
}
 
 
static void sample_init (Sample * self) {
}
 
 
static GType sample_get_type (void) {
        static GType sample_type_id = 0;
        if (G_UNLIKELY (sample_type_id == 0)) {
                static const GTypeInfo g_define_type_info = { sizeof (SampleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) sample_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Sample), 0, (GInstanceInitFunc) sample_init };
                sample_type_id = g_type_register_static (G_TYPE_OBJECT, "Sample", &g_define_type_info, 0);
        }
        return sample_type_id;
}

[edit] External links


aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -