Swift

Of late I’ve been turning to (finally) learning the Swift language developed by Apple, notably for their iOS platform.

The Swift language is now on version 3.0, and by now should have settled down, ironed out all it’s kinks, and generally matured.

Wrong-o.

I’m not a ‘hater’ – I have written software in some many different platforms, languages and IDE’s that I’ve honestly lost count. I don’t mind learning something new, or adapting to changes. It’s a requirement for a professional software engineer.

But so far, Swift 3.0 ain’t mature. Far from it in fact. Now, to be fair, I do like it – mostly. The syntax is a lot cleaner than Objective-C, and yes it does seem to be easy to pick up, especially knowing how iOS frameworks and components already work, and being able to mix .swift with .m/.mm is awesome, as is being able to mix .c and .cpp.

But, there’s a but.

This ‘cleaner’ syntax rapidly turns into a mess of optionals (?) and down-casting (!), and means a double-meaning to established ‘c’ like operators.

if(!weekDays[eventDay! -1])
{
   // do stuff
}
var dictionaryYearWeekDayEvents = Dictionary<Int, Dictionary<Int, Dictionary<Int, [Event]>>>

I mean, wtf? I smell C++ Templates… and this is the structure I want, but now with Swift Dictionaries I am forced to specify the entire object structure before I can use it. NSDictionaries in Objective-C allow me to do it ‘whenever’. Ok, a double-edged sword I agree. Swift is better in the regard that it has tighter constraints on typing objects which is definitely a win. This is a programming paradigm I have to adjust to in my own head.

I also don’t quite get the concept of ‘optionals’;

var someObject: ObjectType?

Ok, so this means ‘someObject’ may not actually exist, i.e. will be nil. So then why does Swift throw an exception if the optional is nil when I try to use it in my own code which allows it to be optional?

Now granted, I am no Swift expert, of course! I’m just starting, but the above are examples of what the language let’s you do. It’s no better than C giving you the rope to hang yourself and C++ tying the noose for you and providing the stool.

Swift’s language spec and syntax makes it incredibly easy to get yourself into a nasty place, very quickly indeed. Not quite what they had in mind with the name ‘Swift’ I’ll warrant. I foresee a lot of domain expert knowledge being consumed by engineers being needed to clean up a lot of messy code in the future, now that enterprise applications seem to finally be taking off on the iOS platform, and all the new gig’s are ‘Swift’ based.

They also changed the majority of the API stack for Swift 3.0, compared to previous versions. This is badand strongly hints at a major and fundamental underlying flaw in the original language spec. This may have been something I’d expect to happen say in Swift 2.0, but not afterwards. The language should have been firmly locked down beyond 2.0

This has led to a lot of confusion on the internet with many ‘How do I do X in Swift’ examples being made instantly worthless (ok, the price of change I guess) but also with now examples given in Swift 1.0, Swift 2.0 and Swift 3.0. Worse, often the examples in Swift 3.0 no longer work –not because the authors are idiots, but because the example has been made redundant by even more changes since it was written.

Try figuring out how to sort a Dictionary by it’s key values. I dare you. I’ve given up. I just pull the keys out into an array, sort that, and then pull the dictionary items out in the sorted array order. It’s just less painful.

And then there’s Apple’s own documentation. Woefully poor for Objective-C but liveable. However, for Swift 3.0 it’s dire and nearly inadequate, often with contradictory examples, or no examples at all (ne. Sorting a Dictionary by key).

If all the above applied to Swift 1.0, I’d forgive, and put-up-and-shut-up. But for all this to be said at Swift 3.0, that’s just plain rude Apple, and shame on you for making the developers lives harder. Let’s not forget just who it was that actually made your mobile platform the place to be all those years ago…

Little Men become Big Men, or Empower Them

That probably sounds a little trite, but the context here is ‘games developers’ and indies vs the rest of the world.

I read this Games Industry article with interest…

It’s not that ‘mobile has become hostile’ to indies. The problem is getting any market-space to get sales traction for the indie game developer. Now the big boys are in, it’s impossible. And now Apple have provided ‘ad space for sale’ it’s made it 100x worse, as the big boys just buy all the ad space. Purdy dumb move IMHO. Great for cash generation though!

It’s not the first time this has happened and it won’t be the last. Indies create the platform, because they are typically the first to embrace a new technology ‘because it’s cool’ or because it’s cheap/easy, etc.

iPhone was a desolate wasteland for games – Apple totally misunderstood their product for this genre, and took years to catch up. But by the time they did, the platform had been well established as a gaming hot spot by ‘the little men’, and it then attracted the attention of the big boys, who then dominated the top 20 from there on in. Only the really rare ‘stand out’ indie games made any headway. Nowadays you have to be the top 1% to get any revenue of note.

It doesn’t always work that way though – the GamePark 32 (which was awesome btw!) disappeared. The Raspberry Pi is doing well – but not stupendously so as it truly deserves – though again it’s a slightly different market niche.

So for the wannabe indie, there are two things to watch out for;

  • Hot new platform which none of the big boys support or care about (yet)
  • Big name behind the platform, or one who doesn’t understand the potential so hasn’t yet attracted the big boys

Get those two right, and get in early… and you never know…

Hmm… VR headsets anyone?

Visit the awesomeness ofDominium!