Blog

Thoughs on Swift

So that’s it, Apple introduced its new programming language: Swift. Here are some thoughts after reading the publicly available documentation:

  • Of course it’s based on the Objective-C runtime, so it can access Cocoa APIs, but interestingly it goes beyond that with interesting struct semantics.

  • It makes me think of Rust a lot. It definitly isn’t Rust (no move semantics, no borrowed references), but there’s many similarities in the syntax.

  • There’s no pointer type at all. Use arrays, dictionaries and objects if you need to put things on the heap.

  • Done with null pointers: non-nullable is the default and “optional” can be added to the type with “?”. That’s something I’ve gone to great lenghts to mimick using C++, with limitted success. I’m quite happy to see a language with that built-in.

  • Generics. That was overdue in Cocoa.

  • No exceptions. Not completly surprising as Cocoa use exceptions only for logic errors in the program. It thus makes some sense to get rid of all the exception handling logic boilerplate the compiler has to insert everywhere for ARC.

  • I wonder if a new error handling pattern will emerge based on those enums to replace the current NSError pointer to autoreleased pointer used all over the place by Cocoa.

  • Apple says it’s designed for safety. It’s important to note that the design of Swift doesn’t protect prevent memory corruption that could happen due to multi-threaded code at all however. I find it striking that there’s no mention of threads or concurrency at all in the language documentation. Maybe they’ll just outlaw threads, but that’d be surprising.

  • Beside this multithreaded hole, the rest of the language seems to be safe from memory corruption bugs.

  • There’s no way to temporarily escape the safeties (like Rust’s unsafe block), so any unsafe thing you may want to do will have to be in C or Objective-C.

  • Will this be open-source?

I’ll definitly give it a try. I’ll probably use it from now on to write most Cocoa stuff.

I’m a little disapointed because when they wrote “designed for safety” I was hoping the safety would cover threads, like in Rust, but that’s not the case. But that’s not something that’ll to prevent me from using it, we’ll just have be careful when playing with threads, as always.


Counterparts Lite

For a few years I’ve been working on an application to facilitate the translation of Mac and iOS apps to various languages and locales. My main problem has always been establishing the perfect workflow for the developers and the translators. I haven’t yet figured it all out, unfortunately.

But one part of this bigger project is already quite good in my opinion, and I think I’d be a shame not to let anyone use it. So today I’m releasing this part as a smaller separate app.

Have a look at Counterparts Lite, the string table editor.

It’s not meant only for translators: Counterparts Lite is a full editor for string tables. It lets you add, reorder, and erase entries in the string table. It also permits comments anywhere and has plenty of keyboard shortcuts so you can keep your hands on the keyboard. Counterparts Lite can open binary (compiled) string tables too.

For translators there’s a side-by-side view where you choose a reference file. The edited file will then follow the same structure as the reference. Translating becomes a job of filling the holes. If there is only a few holes they’re easy to find using the filter control at the top.

Counterparts Lite is available for $6.99 on the michelf.ca Store or on the Mac App Store.

P.S.: If you’re interested in translating this app, let me know.


Black Light 2.0, Gamma Control 4.0

The last major update of Gamma Control was 8 years ago, and Black Light never had a big update. That’s because I’ve always thought these apps to be pretty much feature complete. I could have said the same about Black Light, which never had a version 2.0 in even more time.

Yet, over the years, there were two recurring feature requests that applied to both of these apps:

  1. Having the ability to remove the dock icon and show an icon in the menu bar.

  2. Having a hot key to activate and deactivate the effect from Black Light or Gamma Control from anywhere.

I think those make a worthy bump in version number, and I’m happy to announce today the release of Black Light 2.0 and Gamma Control 4.0.

In addition to the above features, Black Light 2.0 includes a fix for a rare issue with the color filter that appeared on Mavericks. More details on the Black Light web page.

As for Gamma Control 4.0, the layout layout has changed slightly to make room so I could add a global luminance slider for the white and black points. More details on the Gamma Control web page.

Gamma Control and Black Light are available for $6.99 each. You can buy it on the michelf.ca Store or on the Mac App Store. This is also a free upgrade for anyone who purchased the previous version.

Visit each application’s web page for more details:


Sim Daltonism and Retina displays

With the advent of Retina displays, it became necessary for me to update the code capturing pixels on the screen in order for my color blindness simulator app to work correctly. I had code that was supposed to manage with hi-resolution before, but OS X changed the way it was negotiating resolution with applications before shipping Retina displays, leaving the old way to be never used at all. So the things I did in 2007 to future-proof the app didn’t work at all and had to be redone.

It’s actually a good thing the older APIs managing user interface scaling depending on the screen resolution were never used. I’m realizing now that they were full of shortcomings. For instance, even at integral scale factors, there was nothing to deal with having two screens with different scaling, even less for windows moving from one screen to the other and changing scale factor. So I’m quite happy Apple changed things.

But now I have to release an update. This new update is available as a free app on the Mac App Store. Enjoy!



  • © 2003–2024 Michel Fortin.