Most of the code I write professionally is PHP, a chronically insane and awkward language. It could be objectively the worst language in general use today, and yet in terms of development speed, approachability, and practicality, it’s an undeniable success. When I’m working on personal projects I barely ever choose PHP: usually I go with Ruby or C, and a few years ago I became very enamored with C# until I found out about Ruby.

Lately, there’s been a groundswell of support for a new language called Vala. It’s a lot like C# but has cleaner syntax and doesn’t depend on the Mono runtime environment. But we’ll get to Vala in a minute.

The problem with C#

The odd one out in this list is C#, because the more time I spend on it the more it feels like a dead end. There are licensing issues. Microsoft may (or may not) have the legal authority to stop other people from writing or using their own C# compilers and runtimes, and although they recently open sourced part of .NET consensus has yet to form regarding the impact or sincerity of the maneuver. And in any case, .NET’s crossplatform UI libraries are a joke. Managing Mono versions is a nightmare, except nightmares you eventually wake up from. C# is cute, but it’s not hot. And it needs to be hot in order to place favorably on the hot/crazy scale.

6a0120a85dcdae970b01538e3ee72e970b-800wi

C# is at the center of the red circle. SQL is hovering above that hipster dude’s shoulder. PHP is, relative to this picture, buried deep in the Earth’s core.

So I was excited to read about Vala, a new programming language with syntax broadly similar to C#. It’s easy to read and not too verbose, and it compiles to C so writing portable1, efficient code is pretty straightforward. Another benefit of being built on C: it is capable of interfacing with a number of widget toolkits, C libs, and so on.

There’s only one problem: Vala uses GLib for its native type system, and GLib is licensed under LGPL.

Open Source Software

Let’s backtrack a minute to talk about Open Source licenses, because they’re great. Ultra great. My professional life would not exist without it, because picking things apart to see how they work and installing server software without needing to pay for it let me become a programmer in the first place. And there aren’t really any good reasons for using proprietary languages or development tools if a credible open source alternative exists – and it frequently does.

But with that said, open source licenses get a little sticky when it comes to compilers. The problem is thorny enough that GCC2 has a specific exception in its license which explicitly permits distributing software compiled with GCC under any license. This is a good thing, because it means developing with GCC does not encumber your product. Contributing to GCC improves the quality of the software you generate with it. Everybody wins.

The GNU Lesser General Public License (LGPL)

In plain English, the LGPL stipulates that you can link LGPL software with closed-source software – the only catch is that you must dynamically link them so your customers can compile their own copy of the LGPL-licensed libs if they want. If that doesn’t make much sense, think of it this way.

mas250_engine_large

Overwrought car metaphor

Imagine some plans for a car engine, which anyone can get and use free of charge. The only catch: any time you want to sell a car using that engine without making the plans for the whole car available, you have to make sure the customer can replace the engine themselves. That means the driveshaft, hoses, and mounts must all have simple, user-reachable connections and you aren’t allowed to weld any of the joints shut, or use weird Torx screws, or lock the hood release lever with a key.

This is a big win for everybody, because:

  • You don’t have to spend R&D time designing a car engine
  • Your customer can swap the engine himself if it breaks or he needs more horsepower later
  • The public can make more informed purchase decisions by examining the plans for the engine
  • Other car manufacturers can use those plans to build better, compatible engines, and provide 100% compatible upgrades to the motor.

You’d think this would make the LGPL a no-brainer, but there’s a big catch: anytime you’re selling software in a way the user can’t alter the source, you violate the LGPL license.

The Apple App Store

Unfortunately, LGPL libraries can only be used when your customers are allowed to recompile the software. Otherwise, they wouldn’t be able to swap out the library on their own. This prohibits you from publishing to a number of marketplaces, where strong DRM and trust-based controls are in play. The big one on the list is Apple’s platform, where a user can’t even install software unless:

  1. It’s approved by Apple and added to the App Store, or
  2. The user has a developer account and syncs the untrusted code to the iPhone manually.

That might seem fine – who else but a developer would want to recompile their libraries? – but unfortunately it’s kind of a big deal.

The problem is, not everyone can swap out the car’s engine anymore. You’re saying they can, but now anyone who wants to drop in a sweet V8 with chromed fuel lines has to sign an agreement with an unrelated dealer downtown and shell out a hundred bucks for the privilege. This is a fundamentally different situation, as are most distinctions between free and not free.

Bottom line is, once you include LGPL libraries in your application, you aren’t really free either. While Apple is obviously to blame for the policy which bars LGPL, the license remains a poor choice for mainstream use.

How does this relate to Vala?

Vala’s compiler is licensed under the LGPL, but its output is explicitly not according to one Juerg Billeter of the Vala list:

We do not restrict the license of the
generated code in any way. In general, it
has the same copyright as the source code
used as input to valac.

HTH,
Juerg

This, once again, would appear very cut-and-dry. The only problem is, Juerg isn’t really saying that your binary isn’t LGPL – he’s saying that the generated code is free. Which is true, albeit in a completely useless way: it can’t be compiled into a binary without linking GLib, a LGPL component, which every Vala executable is linked to at compile-time – a problem completely unrelated to the license of the generated code.

Though Mr. Billeter is clearly trying to act altruistically, I do wonder how he came to make such a bizarre statement, which at best is misleading and uninformed. Remember the whole thing about Mono and the Microsoft Community Promise, when open source nerds were kicking and screaming because Micro$oft was claiming to embrace open source but actually not? This is actually worse, because:

  • Mr. Billeter does not have the authority to make any kind of guarantees on the behalf of the GLib project
  • Technically, he’s not even claiming that the compiled application can be licensed arbitrarily – he’s talking about the generated code, which still has to be linked with GLib
  • Unlike Microsoft’s promise which is contentious enough despite having been written by actual lawyers, this is an informal statement on an email list, the legal bearing of which would be doubtful even if it was made from a position of authority.

This is probably contentious. A lot of people have sunk countless hours into Vala. Unfortunately, it’s hard to imagine how Vala’s licensing situation could be suitable for general use. Even in the hypothetical, It is likely that no one has the legal authority to change GLib’s license or offer alternative licensing for Vala compiled applications3.

The bottom line is, you can’t write Vala code and expect to distribute it in an app marketplace, on desktop or mobile. And the real tragedy here is this: with .NET’s entry into open source, we could quickly find ourselves in a world where Microsoft’s modern crossplatform language is a safer choice for the discriminating Linux coder than a homegrown gnome.org project.

  1. meaning you can port it easily, not that it runs everywhere without adjustment  (back)
  2. The GNU Compiler Collection, which compiles C, C++, and a bunch of other languages  (back)
  3. This could be a post all its own, but the short version is: in order to do this, everyone who contributed code would need to be tracked down to give permission.  (back)

I wonder if it’s wise to run a commercial showcasing just how much a pain in the ass Visa Checkout is. You just know the guys1 who made this were nudging themselves and guffawing, and then they went out for Starbucks and charged it to Apple Pay without even looking at their phones.

  1. I use “guys” gender neutrally, don’t you?  (back)

In order to put sprites behind me, I need to standardize time as the game sees it. Measuring it by milliseconds works, but makes synchronization difficult. There are also a bunch of gotchas in measuring time, like time zones, and friggin’ leap seconds, and what happens if someone’s playing when Daylight Savings Time kicks in?

Someone ought to think about that, I guess. In this case nothing happens, because we don’t care about what second it is so much as when the second it is now changes.
(more…)

Presented without comment:1

Thursday Morning’s Record

August 9, 1928

Bumble Bee Attacks — A little bee caused an automobile to upset. George Crudden, advertising manager for Beck Bros., while driving along the Lancaster-Lititz highway, discovered a bee in his auto.

He batted at the bee with a newspaper, but the insect dodged out of the way. The bee got on his nerves and when he saw it dart for his eye he ducked his head. There was a crash when the auto hit the guard fence, breaking two posts and turned over on the side.

Mr. Crudden was imprisoned in the auto, his arm being pinned fast outside the window. An audience soon gathered. Someone suggested breaking the window to get him out, but Mr. Crudden, apparently cool, called out to them to wait.

With his free arm he opened the handle of the door and he was pulled out. Mr. Crudden has driven an auto for a number of years and he’s come through some “close ones” by keeping his nerve, but in the future he avers, when a bee or any other annoying insect enters his car, he will use safety-first measures and stop immediately.

 

  1. Source: http://lancasteronline.com/article/local/225595_1978–Elmer-Bobst-dies-at-age-93.html  (back)

budgetvm1

Over the course of my consultancy and hobbies, I find it eminently useful to have a number of servers available for development, project space, file storage, and plain old web hosting. Most of the time, these needs aren’t major – so rather than plunking down $2,000 for a rack-mount server, I rent a number of small VPS1 systems as needed.

The majority of those are with BudgetVM, a company I was sort of impressed with until recently. Their prices are low, their website mostly works, and disk access is good. So naturally, when it came time to move development of a project off of my workstation, I spun up a new instance. CentOS, let’s match the deployment environment. Log in, install Apache, install Git. Almost ready for a coffee break. Git clone is running, the source is downloading. Fantastic! I punch out. I return ten minutes later, cup in hand. I notice Git is stuck at 95% – that’s odd, the codebase isn’t that big – but before I can dwell on it too much, I get an email.

Enzu Inc. <support@enzu.com> Winfield Trail, Thank you for contacting us. This is an automated response confirming the receipt of your ticket. Our team will get back to you as soon as possible. When replying, please make sure that the ticket ID is kept in the subject so that we can track your replies.

Ticket ID: API-642-39013 Subject: virt2.sudowned.com – 172.246.84.242
NullRoute Notification Department: Notifications Type: Issue Status: Pending Reply Priority: Normal Regards, The Support Team

This is pretty baffling. Thank you for contacting us? I did no such thing. NullRoute2 notification? That sounds ominous as hell. Oh, and it’s always classy to use my entire name in a form email. I log in and read the ticket:

Posted on: 2013-12-31 22:43:02
Dear Winfield Trail,
Our NOC has detected a network scan (or network attack) either originating or destined to an IP address under your responsibility. Please take the necessary actions to avoid this in future. Any feedback would be appreciated.

The IP Address: 172.246.84.242 has been nullrouted the nullroute will be lifted at 2013-12-31 22:58:16 * Note if there are further event’s it will be NullRouted again for a longer duration. *

Device: virt2.sudowned.com – Netflow Logs
+ 172.246.84.242/32 incoming: 177048780 bits/s Logged: 2013-12-31 19:27:22 Expires: 2014-01-01 07:27:22
+ 172.246.84.242/32 incoming: 177048780 bits/s Logged: 2013-12-31 19:27:23 Expires: 2014-01-01 19:27:23
+ 172.246.84.242/32 incoming: 164580556 bits/s Logged: 2013-12-31 22:43:11 Expires: 2013-12-31 22:48:11
+ 172.246.84.242/32 incoming: 164580556 bits/s Logged: 2013-12-31 22:43:16 Expires: 2013-12-31 22:58:16
This is an automated message generated during the Null route process. Continued attacks will also be nullrouted and may generate additional messages.

This is ridiculous for several reasons. The machine isn’t compromised – I know because it’s brand new, there isn’t any code running on it that didn’t come packed with it or off an official CentOS distro. But I read the first paragraph again:  “…detected a network scan (or network attack) either originating or destined to an IP address under your responsibility.” What? So they NullRoute machines that are on the receiving end of a network scan? Are they insane? What security best practices state that automatically causing DoS attacks to succeed is a winning strategy? I don’t know what to make of it, so I bang off a reply:

Winfield Trail
Posted on: 2013-12-31 22:47:33
Your detection is either inaccurate or the issue is baked into your CentOS 6.4 x64 image. I created this VM less than three hours ago and literally all I’ve done with it is:

-Installed apache httpd + php5 (not configured, still offline), installed git
-Created user, added to wheel
-Disabled root login
-Initiated git clone operation (did not complete)

But hey, the server’s back up. Maybe it’s just a fluke, right? I log in, run git clone again. This time it’s almost instantaneous. Git stops at 50%, my email goes off. Another email, another identical ticket. This time the block is 24 hours. What? Seriously, what. This would be funny if it was happening to someone else.  I post another reply, which is definitely testier than it should have been:

Winfield Trail
Posted on: 2013-12-31 23:12:55
I tried once again to perform a simple git pull, and once again your system has disabled my VPS. Get it back online and disable this ridiculous filter or I’ll take my business elsewhere.

Well, it’s been 40 hours since then and there’s only been one change – they closed my ticket. No response, no feedback. This is about on par with getting the silent treatment while asking the waiter why there’s a log of used soil bobbing placidly in the tomato bisque.

Actually, I take that back: they sent me two surveys asking how they did with my support tickets. Unbelievable. Needless to say, I’m already in the process of moving my operation to someone who hasn’t ever disabled my server and disappeared for days.

The paint chips must be delicious in BudgetVM’s offices.

  1. Virtual Private Server  (back)
  2. Null routing a device kills its network connection. It’s more complicated than that, but it’s also very boring.  (back)

Things I like

  1. Sort of consistent UI
  2. Very nice icon dock
  3. Has a notification tray, kind of
  4. Doesn’t have a Desktop folder, so my wallpaper isn’t encrusted with nonsense that should be in my home directory anyway
  5. It’s not Unity, KDE, or Gnome 3

Things I don’t

  1. File manager crashes frequently
  2. Window contents are inexplicably slow to update. Sometimes they won’t update at all.
  3. Text editor is incredibly laggy
  4. Some tasks, like favoriting a location in the file manager, are nonobvious
  5. Single-click opens files and directories in File Manager, does not open either in the File Browser
  6. The included Music application is awful. Seriously, I could write an entire post about it.

Edit: I actually need to rant about Music. See, it thinks it’s iTunes – which is dire enough, really, but let’s not go there tonight. It’s got the same sidebar-driven UI:

musicfail

But most of them are superfluous and don’t do anything: clicking on one reports No Songs, and asks the user a bunch of impenetrable nonsense about, uh, editing song rules. Seriously, look:

wat

What are rules? Why doesn’t it have rules already? Why would you give me a sidebar option to list music I’ve never listened to if the player doesn’t know how to do that? Why is this even a feature?

But let’s look at that first screenshot for a second longer. See how I’m almost through the song, and my queue is empty?

Thing is, it’s not. A new song played immediately after that one. Two more have come and gone since I started typing. But still, the queue is empty. Where is this music coming from? If I close the problem, will the queue – which doesn’t exist – empty too? Why did this happen when I pressed the “play” button on my keyboard instead of my Spotify track resuming, and why did the Music application even start in the first place? Actually, let’s get even more basic – why do my MP3s occasionally open in Music, even though Audacious is set to handle MP3s?

Maybe the target user is Mac enthusiasts who wish things just didn’t work so dang much of the time.

Android users, here’s the deal. This is the sales chart of Superbrothers: Sword & Sworcery, one of the best games I’ve played on a mobile device to date:

SS_infographic_small

Source: http://www.swordandsworcery.com/

You will notice that 33% is iOS, and a vanishingly-small 5% is Android. This is because, by and large, Android users do not spend money on software. That isn’t necessarily a piracy issue1: they’re just very used to downloading free stuff.

This isn’t even a port issue2: despite the fact that supporting all Android devices is hard, the Android copy of the game was actually more enjoyable than the iOS version I bought when I went back to iPhone (for unrelated reasons.) Device rotation worked more seamlessly, multitask behavior was more favorable. 3

Obviously, iOS did have an eight-month lead over the Android release, but that doesn’t account for the numbers; indeed, profitable games on Android are still so unusual that it’s newsworthy when it happens.

  1. Frequently piracy is blamed for Android’s persistently-low sales records. The accuracy of this interpretation is up for debate; the sales records themselves, however, are not.  (back)
  2. Where sales of a ported game falter because of issues not present in the original version  (back)
  3. No huge problem on iOS, but fit and finish were definitely lacking.  (back)

I wrote a long and rambling post here about refresh rate, resolution, and animation speed. After nearly a thousand words, I’d worked out all my problems and realized almost none of it was worth talking about. Deleting it was a wrench, but not as much as reading it would have been.

So instead, here’s the conclusions I drew and why, along with a small digression on sprites.

(more…)

I’ve been working with GLib a fair amount lately for my indie game project. Generally speaking, if you’re doing anything nontrivial in C you’ll be using libraries to provide non-primitive datatypes like hashmaps (think PHP’s arrays) and lists, because while they aren’t particularly complicated problems to solve, there’s no reason to solve them every time you set out to write a program.

This time, I’m using GLib. This is mostly for convenience, because some of the other libraries I’m linking use GLib’s datatypes internally. It’d be kind of dumb to have two or three incompatible list types floating around, after all. For the most part, GLib has made life easy because it’s easy to pick up, because there’s so much code available for study.

One non-obvious problem, though, is iterating through a list of structs. Google was next to useless, with every example broken or irrelevant. The answer’s deceptively simple: you just cast the gList’s data member to the desired type:

int search_foo(STRUCT_FOO *foo) {
  int result;
  GList *search;
  for (
    search = g_list_first(foo->bar); 
    search != NULL; 
    search = g_list_next(search)
  ){
    return ((STRUCT_FOO *) search->data)->value;
  }
}

This is just a simple example, and a pretty simple problem, but it took me an embarrassingly long time to figure out. The cast is mandatory because the compiler doesn’t remember, or care, anything about the target of the pointer you store inside the linked list.

This can also be an insidious source of bugs: if you mistakenly cast the struct as the wrong type, the compiler won’t complain; it may even appear to work correctly, if the data you try to access is simple, like an integer or boolean value.

Notice: The sixsixfive mirror was down for a month or so due to a documentation issue with the TLD authority. Apparently they wanted my actual documentation and not, in fact, some random numbers and letters. I’ve straightened this out and the domain should resolve by some time on November 26th.

More than a decade ago, I started reading a blog called sixsixfive. It wasn’t called a blog, maybe because it was before “blog” was a word. What a sweet, sweet time that was. Anyway.

The author, one Jeffrey S. Power, wrote a list of six hundred and sixty-five different and (quite possibly) interesting things. And that’s pretty accurate, because sometimes he wrote about his life and sometimes he wrote about what would happen if someone undertook the makings of a golem without really understanding the particulars of the process. Sixsixfive was whimsical, light, dark, happy, sad – whatever was going on that day, I guess. To whatever extent these things ever are, online or otherwise, it felt real.

There’s a reason I’m using the past tense: the site is gone. I’m sad about it.

(more…)