Tuesday, February 9, 2016

Six Weeks with Vala

Update: https://blog.darkoverlordofdata.com/2016/12/vala-revisited.html

One concept discussed in functional progamming is 'Reasonablness', which focuses alot on how side effects make it hard to predict what your code is actually doing. In case you're not familiar, here is a great post on the topic http://fsharpforfunandprofit.com/posts/is-your-language-unreasonable/

One thing I like about that post is that the author points out that by their nature, we cannot expect much of this 'reasonableness' from your typical oop language. But I think Vala fares worse on than most.

Part of it is the ecosystem - it's hard to reasom without information. Documentation is sparse, conflicting, or just missing. Granted that all technology products have this issue to some degree, but it's particularily bad in the case of Vala. I can't get the Gnome toolset working because I'm not using a gnome desktop. If this were Microsoft or Oracle, we'd call it vendor lockin. I'll give Gnome the benefit of doubt and chalk it up to tunnel-vision or not-invented-here-syndrome. But the result is that I am using Atom and command line make, and scratching my head alot while I seach the web for clues.

But that can be fixed. The real issue I belive is the dependancy on GObject. Remember, GObject was created to compete with Microsoft COM. COM was the object system that backed VB6. It was also the cause of much of VB6 unreasonable behavior. DotNET was created to replace COM. Microsoft wanted a 'pure' object system that would met the requirements of any language. Vala follows the VB6 model of shoe horning the langage to fit the existing object system. And this leaks through the abstracton and results in arbitrary constraints on the language. I continually get compilation errors - things like interfaces and properties sometimes don't compile until I base the class on GObject, resulting in other side effects, requiring more than one ground up redesign. And I still find myself surprised by the results, and not in a good way.

So, what was I actually able to accomplish in those six weeks of vala? First, I discovered Genie, Vala's whitespaces language. This is a great alternative to Vala's curly braces, and I credit it with speeding up the process. It seems to be designed to provide intelligent defaults, and the overall effect is much less typing, and an easy to read grammer. It is missing a couple of features present in Vala - namely lambda's and multidimemsional arrays - though I can declare them in Vala and then comsume them from Geanie. I will miss Geanie.

So, after six weeks, I have a prototype shmup game using SLD2 and Bosco.ECS (My ecs inspred by Entitas). It's a little dissapointing. Performance is not better than Unity. And with Unity, 6 weeks later I had a full game enviromment, with menu, scores, leaderboard, running on Windows, Linux and Android. I still can't get a Vala game to compile on or for Windows 7. Nor have I yet addressed sound or a UI. In case you're interested in Vala, my project is https://github.com/darkoverlordofdata/shmupwarz-vala

I really like Vala and wanted it to work, but its mostly frustrating. And I found that I Genie, the 'other' language compiled by valac, is vastly underrated. Genie could be the next big thing, if Gnome lets it. But I'm moving on to something more fruitful.


5 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. I think you misunderstood some things about Vala and GObject. First, GObject wasn't created to compete with COM (that was Bonobo, the corba-based component system originally used by gnome). GObject is just a library to have object-oriented capabilities under C language, nothing more, nothing less. It wasn't mean to be a component system.

    Second, I don't understand what do you mean about the Gnome ecosystem... I create programs with Vala and they work great under other environments. Remember that GTK isn't specific for Gnome.

    About your problem with interfaces and so on... The documentation explains the difference between a class that doesn't inherit from Object and one that does. The reason to have both, instead of inheriting by default from Object, is that the former are more lightweight, but, of course, they lack a lot of capabilities.

    Finally, there's a reason for modelling the language around GObject: Vala was created to simplify creating GObject code. Doing it in C is extremely boring and hard, and previous tools weren't as useful as Vala.

    Of course it's your decision and your opinion, and I respect both. Just wanted to comment those points.

    ReplyDelete
    Replies
    1. Thanks for clearing up my confusion. That is really the main issue - trying to navigate the Gnome-verse. It is very opaque if you come to it from outside.

      Delete
  3. I think as swift is open source, and adopted by Canonical. it's a good challenger as next multi platform language.
    https://github.com/apple/swift

    ReplyDelete
  4. The title of Six Weeks with Vala seems fascinating! Is it a work of contemporary fiction or historical fiction. A fantastic genre for delving into many eras is historical fiction. Don't forget to correctly credit your sources if you're writing an academic article on the subject. When constructing your bibliography, an oscola citation generator can come in handy.

    ReplyDelete