Content deleted Content added
→run(): why the main entry point might be placed inside a class body |
→C++: pros and cons list |
||
Line 23:
Can somebody highlight the pros of using Vala, compared to using C++/gtkmm? <small>—Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/82.238.35.175|82.238.35.175]] ([[User talk:82.238.35.175|talk]]) 10:10, 10 February 2008 (UTC)</small><!-- Template:UnsignedIP --> <!--Autosigned by SineBot-->
:Depends largely on your preferences and aims.
<blockquote>Pros:
* Vala generates C code that relies on GLib/GObject for it's object system. Benchmarks show that generated Vala code is generally as fast or faster than hand-coded C++ (see link at bottom of article).
* Vala also makes it extremely easy to use external C libraries: you just have to wrap the header in a Vala API file (called a VAPI), and declare what functions you'll be using. There are already a bunch of VAPIs for GNOME related stuff like libglade and gstreamer.
* Vala also makes it easy to write C libraries -- you can use Vala to write libraries, compile them to C files, then distribute the C files. Vala can even generate a VAPI for the library along with the C files, so that you can use the compiled library from Vala -- i.e., you can use Vala to write a C library that can be used from any application with a C ABI and natively from Vala itself (the tutorial shows an example of this near the bottom).
* Since it is so tightly coupled with Glib/Gobject it obviously make it easier working with libraries that also use GLib/GObject.
* It's syntax is almost identical with C# (even has delegates and signals [think events]). I like this syntax *much* better than C++, personally, but that's subjective.</blockquote>
<blockquote>Cons:
* Vala is relatively young and doesn't have the huge use base and community support that C++ does.
* Vala has very sparse documentation in many places (just the method names with no description, no descriptions of the parameters except their names, &c).
* There is alot of existing C++ code that can be reused, not so much with Vala (although they have a pretty good sized list of examples on the front page).
* The VAPIs are a work in progress (e.g., glib-2.0.vapi doesn't wrap g_chdir [but see below]).</blockquote>
:That's basically it, I think.
:Ps. As an example of how easy it is to wrap C libraries, one can edit glib-2.0.vapi to wrap g_chdir by putting the following code under the DirUtils namespace, then compiling with the switch --vapidir=/path/to/modifier/vapi:
<blockquote><source lang="csharp">
[CCode (cname = "g_chdir")]
public static int chdir (string pathname);
</source></blockquote>
:Which then be used from Vala code:
<blockquote><source lang="csharp">
DirUtils.chdir( "/foo/bar" );
</source></blockquote>
:[[Special:Contributions/24.243.3.27|24.243.3.27]] ([[User talk:24.243.3.27|talk]]) 08:00, 22 September 2008 (UTC)
== Generated code? ==
|