Re: [Vala] Vala & concerned issues !!



Emad Al-Bloushi wrote:
Peace be upon you all,

I'm new to Vala programming language and I have well experience in Java & PHP programming languages using 
OOP , honestly I'm little bit concerned about list of issues I hope you can help me to reach the right 
direction as listed below :

    1) How can I list installed packages to compile my code "pango , cairo , gtk+-2.0 ..etc" and where are 
they installed (I'm using ubuntu 9.10) ?

Here you can find the installed Vala bindings:

 ls /usr/share/vala/vapi/  (or /usr/local/share/vala/vapi/ if you have installed from source)

In order to use a library you must have the library and its development files installed.
On Ubuntu, for example:

 'libgtk-2.0-0' and 'libgtk-2.0-dev'
 'libclutter-2.0-0' and 'libclutter-2.0-dev'
 ...

    2) I have never developed applications with programming languages that use pointers !! so in Vala where 
to start to understand pointers and to keep my applications safe from memory leaks ?

Use pointer syntax (*, ->, delete) if you want to do manual memory management.
Instead of

 Foo foo = new Foo ();
 foo.method ();
 // object freed automatically

you can alternatively do:

 Foo* foo = new Foo (); // allocate object
 foo->method ();        // access member
 delete foo;            // free object

Use it only if you really want to have full control.

    3) Using pointers in Vala is it a must ?

No, it's best to avoid them. ('void*' can be an exception. For example, a thread
function is expected to have a 'void*' return value, which basically means anything
can be returned. However, I'd just return 'null'.)

    4) Where should I start to know more about using binding libraries ?

Using bindings is easy: just pass '--pkg xyz-1.0' to the compiler.

If you want to create your own bindings there are two options:

 * if it's a GObject based library then you can semi-automatically generate the
   bindings: http://live.gnome.org/Vala/Bindings
 * otherwise you must write the '.vapi' file by hand.
   http://mike.trausch.us/blog/2009/02/18/vala-bindings-for-non-gobject-type-c-libraries/

    5) What version of unicode does Vala support ?  

Strings are UTF-8 encoded.

    6) owned, unowned, and weak modifiers I do not know how can I use them & why ?

The "Memory Management" section of the "Vala for C# Programmers" tutorial explains
some of it:
http://live.gnome.org/Vala/QuickIntroForCSharpProgrammers#head-0d70172d9170f2aad9365e747aceaae818c99697

By the way, I'm working on a similar Vala quick start tutorial for Java programmers
and will put it online within the next days.

finally , I have developed a simple snippet to demonstrate how to use Google AJAX API in Vala but I did not 
use any thread in my code so I'm forced to use "--thread" to run my code perfectly I do not know why ?

I guess libsoup depends on threading support.

Best regards,

Emad Al-Bloushi                                         

Best regards,

Frederik



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]