Jacob Peddicord

Mono v. Vala: Fight!

| 26 Comments

Ignore the inflammatory title. I frankly don't care to hear more on the drawn-out debate about patents. Nothing has happened for a long time, just more people yelling at each other over who is right.

What I never hear brought up is the C#-like language Vala. For the uninitiated, it's a "self-hosting compiler that translates Vala source code into C source and header files" using GLib/GObject. So you feed it Vala code and it spits out C. Now what is so great about that?

1. No runtimes. When you run an application written with Vala, the OS has no idea. At runtime, Vala code is identical to C. No extra libraries, nothing needed to keep your program running. You could ship a version of your project with just the C code and have no extra build dependencies, though your recipients might question as to why there are a bunch of strangely-named generated variables (_tmp0_, _tmp1_, etc) in there. (Kidding about shipping generated C, see comments.)

2. Nearly infinite extensibility. Since Vala just generates C, the bindings can be derived from C. If you have Vala installed, take a look at /usr/share/vala/vapi/webkit-1.0.vapi. 200 lines! The WebKit bindings are only 200 lines long. And according to the file header, they were automatically generated. What's not to like?

According to the Vala roadmap, we may see 1.0 in time for the GNOME 2.28 release.

So I want to hear your thoughts: Does this compare, from a technical standpoint, to Mono? Will it become a widely-used language? Is it easy to port an application from Mono to Vala, and vice-versa?

26 Comments

As pretty much noone except .NET devs use .NET languages, i don't think it'd be easier than porting to C++ or Java or Pizza or whatever. But I'd really love the people who advocate for a FOSS and easy-to-code-with OO language to care more about Vala, for the sake of less runtimes, less patent risk, and designed for linux instead of ported from something designed for windows.

What keeps me uninterested in Vala is the fact that is is yetanother_ language to learn and to refine, and as I don't see any use for Vala outside of Gnome programming, it seems to be a lot of training for very limited field of work. Also, I'm asking myself "what can I do with Vala that my current C++ and Python skillset can't do"?

So, I'm wondering if there's anything that counters these drawbacks; for example, iterative and easy migration paths for current C/C++ projects; or some killer feature that makes Vala a must-have. Any ideas?

Vala is a great language. I've used it quite a bit and am really happy with it. It makes coding gobject code a pleasure! Once Vala hits the 1.0 and has a stable api I think (hope) adoption will pick up because it could really be beneficial to gnome development.

Vala is inspired by C# with regards to syntax, so once it is stable enough, porting from C# should be less than difficult, and lead to huge benefits in terms of performance.

While Vala was initially closely tied to the GNOME platform, it is currently possible to easily bind non-GLib libraries (curses and SDL come to mind), and a POSIX profile, which doesn't require the GLib runtime, has recently been added to the compiler.

we are in 2009 and we keep using a language that was created in 1972 something must be wrong here.... i dont know if mono or vala is the solution (cause if ppl care about developing a language like vala and developers do bindings in vala, there is a problem) but we need to choose a high level language and start using it...

Number one reason against any language-translation computer languages - optimization.

gus:

I don't see any constructive criticism in your comment. What specifically is wrong with C, and why should people stop using it?

Sirrus:

Obviously, though that rules out Python, Mono, Ruby, Perl, etc. and leaves you with C/C++/ASM. I like C myself, but there is a point where I'd make the tradeoff between a programming speed and runtime speed.

oliver: “what can I do with Vala that my current C++ and Python skillset can’t do” Well, since Vala, C++, and Python are all general purpose languages, the answer is really nothing. What really sets Vala apart from say C++, is that the code is often cleaner and less error prone (unless you've been a C++ for some time and don't make all the mistakes rookies tend to make.) In Vala (AFAIK) you really can't access the hardware directly like C/C++ can, but unless you're doing OS coding, that's not a big deal (though, since Vala converts to C, it might be interesting to see a Vala OS. Some things will obviously have to be written in C/ASM, but still, it should technically be possible.)

gus: Really? So, just because it's stood the test of time it's all of a sudden bad because something shiny and new came around? The reason C has outlasted so many other languages, is simply that it's very good at what it's good at. That being the ability to interface with the hardware on a low level when needed. Should it be used for everything? Probably not, hand writing OOP code in C can be quite ugly, but get something like Vala that shields the programmer from that mess, and you get a pretty good combination. BTW, "we need to choose a high level language and start using it" is about the most asinine statement I've heard in a long time. First because there are plenty of high level languages and second because most all of them get significant use. Why do people have to settle on one language anyways?

Sirrus: You're right, you let Vala generate relatively optimized C, and let GCC do it's job. Really, as long as nothing is totally FUBAR'd in the C that Vala generates, you'll get a decently optimized executable. Still not happy? Fine, write the code that /has/ to be optimized in C, and do a quick (something probably around the 5 line mark) binding to your function, and then you have the hand optimized/compiled C pulled into a Vala project (see why this could be very appealing to people wanting that 5-10% speed over JIT, if even that much in some cases.)

I'm not sure how easy things will be to port from C#. The program will most likely need a substantial rewrite to be honest. Mainly because besides similar syntax, all the libraries (classes, functions, etc) share basically nothing in common. Similar syntax doesn't mean easy portability.

In all honesty, I'd like to eventually see Vala incorporate support for QT. Though it won't be a trivial task, it would be cool. I like C++ quite a bit and all, but again, it'd just be cool :)

Hey, vala is great, but please don't promote hot things in free software by suggesting to ship just the C-code instead of proper source!

".":

That's what I was trying to hint at with "though your recipients might question as to why there are a bunch of strangely-named generated variables" ;)

I love the idea of Vala that the compiler make C source and header files.

This means that your programs can be used by other applications written in C.

I like C# syntax, i don't use mono by patens and for big projects Python can make your code difficult to keep and Java is a lot of slow.

I hope for 1.0 final version to use it.

Actually, I'd say there's nothing wrong with shipping the generated C with the Vala code. That way if they want, they can generate the C themselves. (This is actually how Vala ships since if you don't have Vala to begin with you're left with a chicken or the egg situation.)

Harley:

A multiboot-compliant kernel has already been written in Vala, see http://mail.gnome.org/archives/vala-list/2009-February/msg00032.html.

It's just a conversion of the sample multiboot kernel shipped with GRUB, but shows running a program written in Vala without a underlying OS is indeed possible.

Mono is a runtime. Vala is a language.

Most .NET/Mono developers don't care all that much about C# the language...they care about the benefits of using the runtime.

In your post you seem to think that depending on a runtime is a negative thing (because of disk space or something?). If that's the case, then Mono, Python, Ruby, etc are probably just not for you. I hope the nice syntax of Vala is helpful to you as a developer, and that you are able to be productive without the benefits of a runtime like Mono.

There are also multiple C# based os project:

http://www.gocosmos.org/index.en.aspx http://www.codeplex.com/mosa http://en.wikipedia.org/wiki/SharpOS%28operatingsystem%29

Sandy, Vala is built on top of the GObject framework, so anything implementing GObject can be used by Vala in an extremely userfriendly way. You already have Glib for collections/algorithms, GTK# for GUI, and GStreamer for multimedia. All these are native GObject libraries, and there is many many more..

Vala + GObject you basically get all the advantages of .NET or Java, introspection, garbage collection - but you don't have to execute bytecode, you can do this all natively and with low memory and CPU usage..

Just goes to show you, you can have your cake and eat it too, native performance in a high level, modern language.

Vala seems like an interesting proposition - but I'd like to see more apps using it before I commit too much time to it (I believe Avant Window Navigator is the only big Vala app). It's also not clear to me how portable Vala is outside Linux.

There's also a certain irony that the most fully-featured Vala development environment is Monodevelop - but no more ironic than people using Eclipse for C++, of course.

gus:

Here's your answer: "we are in 2009 and we keep using the English language that was created over 1000 years ago something must be wrong here…. i dont know if Esperanto or Loglan is the solution (cause if academics care about creating a language like Loglan and idealists do translations in Esperanto, there is a problem) but we need to choose a universal level language and start using it…" :-)

There is no reason for Mono and Vala to fight.

Mono's MonoDevelop IDE has strong support for Vala as a language.

We embrace diversity.

Mono and Vala take different approaches to solving a programmer problem. Maybe if you had some specifics to your post someone could answer the actual technical differences.

You can't mention Vala without Genie. Vala is a C#/Java-style language and Genie more closely resembles Python. The languages aren't difficult to learn, but they're kind of a moving target right now.

Join the mailing list and ask questions when you run into trouble. They're very helpful.

Robert: nice. :P

Miguel: Hence "Ignore the inflammatory title." I was just curious as to why Vala is never brought up in conversation even though it is syntactically similar.

Daeng: That's interesting. Will have to check that out.

Gus,

We have been breathing air for several thousand years, but it still works and is the most efficient solution to staying alive.

Mono/.Net is a platform and Glib/Gobject/vala is another very diferent. The idea in my opinion is eliminate the .Net dependency in GNome. Not because is bad programed but because can bring pattents problems to the comunity.
I think also that vala is great to program with it because Gnome is great to program with it but, C object oriented its really difficult and vala makes it easy. Also look to the project gobject-introspection that is the vala companion. Give it a try if you didnt yet because believe me we are talking of the next years programming language.

I was inspired by VALA and I programing with it. It is very simple to learn and easy to use. We all should use VALA because of it's so simple syntax and because it is truly open-source.

VALA is very helpful to me. Easy to use. i like it

Leave a comment





Feed identi.ca Twitter LinkedIn Launchpad OpenID