Rants from the Ballmer Peak rss feed

Nim for cross platform software

On the 21st of February of 2014, Sarah Con… er… Seohtracker v4 was released for iOS. A puny little iOS app. And now the app has crossed the bridge and made it to the Mac App Store as Seohtracker for OSX. Why would this be of any relevance? Because both programs are partially implemented in the Nim programming language.

Doge is very impressed

The Nim programming language compiles pythonesque style code into portable C. Might be more portable than Java. And more machine performant at the low level. And more developer performant at the high level! And more lisp macros. And… whatever man. It's just cool, and I believe it is going to allow me to produce real life programs for more platforms with less effort (still working on the less effort part, though).

But Nim is relatively new and unpopular. Despite the website stating "The Nim Compiler can also generate C++ or Objective C for easier interfacing", there's not much proof out there you can take as reference. So I decided to start my own, and that's what Seohtracker is. The internal architecture of Seohtracker splits the interface from the logic. Hence, you have a cross platform logic code which is implemented in pure Nim. Then, somewhere in the middle is floating a thin Nim to Obj-C convenience layer which exposes the Nim logic, and finally you have the iOS and OSX clients which are consumers of this API.

Why not write everything in Nim? That's something I've heard a lot. The most important practical reason is I'm a simple guy doing this on his own, and I can't compare to well paid and full of people firms doing the wrapping of all the little details. But also because each platform has a different user interface which requires separate design. For instance, the iOS version of Seohtracker is split in multiple view controllers, each reigning its own screen, while the OSX version is pretty much contained in a single root view controller for the main window. Or how about help? The mobile version includes little breadcrumbs of information in certain screens, while the mac version simply lets you go to the index and browse whatever your heart desires.

And this is just the beginning! A planned iPad specific user interface already requires a different approach from the iPhone version. But what about Android? And what about Linux? Yes, you can implement a GTK2 version for Linux/Windows too (plus there already are bindings for this toolkit). If you try to cram every platform under the same language and graphical toolkit, you are likely to piss off people on each platform, as the result won't be a 100% full citizen compared to the rest of the operating system, just that strange bloke with the weird hair, who hopefully gets the job done, or else… And if you don't use the same graphical toolkit for every platform, well, your bang for the buck for using Nim is very reduced, especially because there are only a few low level bindings.

Show me the money!

In the spirit of releasing some statistics like other projects do, here are some results of running SLOCCount on the iOS, OSX, and logic modules as tagged for the v4 release:

Lines of code in Objective-C 1886 (68.71%) 1107 (73.85%)
Lines of code in Nim 792 (29.85%) 324 (21.61%) 832 (100%)
Lines of code in sh 67 (2.44%) 68 (4.54%
Total physical source lines of code (sloc) 2,745 1,499 832
Development Effort Estimate, Person-Years (Person-Months)
(Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05))
0.58 (6.93) 0.31 (3.67) 0.16 (1.28)
Schedule Estimate, Years (Months)
(Basic COCOMO model, Months = 2.5 * (person-months**0.38))
0.43 (5.22) 0.34 (4.10) 0.27 (3.24)
Estimated Average Number of Developers (Effort/Schedule) 1.33 0.90 0.61
Total Estimated Cost to Develop (average salary = $56,286/year, overhead = 2.40). $ 78,003 $ 41,327 $ 22,273
Grand total $ 141,603
SLOCCount, Copyright (C) 2001-2004 David A. Wheeler
SLOCCount is Open Source Software/Free Software, licensed under the GNU GPL.
SLOCCount comes with ABSOLUTELY NO WARRANTY, and you are welcome to redistribute it under certain conditions as specified by the GNU GPL license; see the documentation for details.
Please credit this data as "generated using David A. Wheeler's 'SLOCCount'."
Total Estimated Cost to Develop (average salary = $90,060/year, overhead = 2.40). $ 124,808 $ 66,125 $ 35,637
Grand total $ 226,570
Updated salary wages by random internet US centric post.

In any case, you should ignore the statistics for lines of code, they are pretty much useless for experiments like this which don't fall into the normal development category.

It's 16:27 past deadline

How about if we measure time? Fortunately I did track all the hours I put into this project so far. Unfortunately, until v4 all the previous iPhone releases had both Objective-C and Nim hours lumped, while after v4 most Nim hours will go to the logic module. At least we can get more realistic cost estimates. Let's consider a full US work year in neoliberal hours, which clocks at 2088 hours per year. Using this metric we get that the default average software developer earns 26.96 $/h, while the corrected averaged programmer earns 43.13 $/h (still lower than what I've seen reported on various iOS forums, but let it be).

State iOS OSX Logic
v1 44.33
v2 22.08
v1+v2 66.41
v3 9.17
v1+v2+v3 75.58
v4 26.08 56.92 3.75
v1+v2+v3+v4 102.16

Total hours for the combined project: 162.33.

Estimated costs: 162.33 * 26.96 = 4376.41$

Or the more realistic average: 162.33 * 41.13 = 6676.63$


The good about using Nim

The bad about using Nim

Bomi asks you to calm down

Unfortunately, Nim is not a girl, not yet a woman:

Maybe you have noticed a pattern here? Lack of developer power, since all of these issues are fixable. A one man language has little to do against projects sponsored by multimillion companies. And multimillion companies lack the taste to fund a language like Nim, so this looks troubling. If you are working on a tight schedule I don't recommend using Nim (unless you overestimate like SLOCCount, hah!). If you like tinkering with cool stuff and don't mind getting dirty, go ahead.

You don't need Nim to write software for iOS and OSX

True. The astute reader will realize that both platforms use Objective-C, a quite ancient crap language (what else can you expect from C?) which only recently (thanks to the iPhone) has been cardiopulmonarily resuscitated with GCD and ARC (don't you love to throw acronyms around to look like you know stuff?) so that programmers from other platforms willing to start writing software for Apple devices manage to get past the yuck factor.

But in the previous paragraphs I've already outlined the possibilities: the Nim logic code is already cross platform, you can grab the compiler and run the test suite on Windows, Mac, Linux and whatever else you are able to run Nim. Don't worry, the clients for other platforms will come. Just no guarantees on a delivery date, being a programmer means you have to master weaseling out of committing to a deadline. So whenever it's done.

This is my first little step. Hopefully it will turn into a long walk and you will be able to witness true cross platform-ness. Who knows, maybe Nim will even start to be relevant to Wikipedia? In your dreams…

Nim (programming language). From Wikipedia, the free encyclopedia.

This page has been deleted. The deletion and move log for the page are provided below for reference.

  • 23:57, 28 October 2013 ErrantX (talk | contribs) deleted page Nimrod (programming language) (G4: Recreation of a page that was deleted per a deletion discussion: See for context: https://news.ycombinator.com/item?id=6627318)
  • 16:55, 28 August 2013 Postdlf (talk | contribs) deleted page Nimrod (programming language) (Wikipedia:Articles for deletion/Nimrod (programming language) (2nd nomination))
  • 00:02, 18 May 2010 Cirt (talk | contribs) deleted page Nimrod (programming language) (Wikipedia:Articles for deletion/Nimrod (programming language))

See the article index or browse articles by tags: programming , nim , nimrod , seohtracker , elhaso , objc .
Published on: 10/03/2014 21:17. Last update: 02/08/2015 15:01. rss feed
Copyright 2016 by Grzegorz Adam Hankiewicz.
Generated with ipsum genera. Look at the source code.