Showing posts with label symbian. Show all posts
Showing posts with label symbian. Show all posts

Sunday, June 20, 2010

Nokia, the next Geoworks?

Summary: Nokia gave a profit warning, because their high-end phones do not sell well. This post compares the problems of Symbian, Nokia's high-end phone OS, to Steve Yegge's analysis of why Geoworks went bankrupt.



What Geoworks?

Geoworks was a software company which wrote a windowing system and applications in assembler. In the end, it went bankrupt in the end of nineties. When Steve Yegge wrote about the benefits of high-level languages, he used Geoworks as an example how using low-level languages takes a toll on business.

His argument is that low-level languages make optimization impossible and implementing features slow. After the system reaches a critical point in complexity, usability starts to suffer. User see sluggishness, bugs and lack of features.


...But it's because we wrote fifteen million lines of 8086 assembly language. We had really good tools, world class tools: trust me, you need 'em. But at some point, man...

The problem is, picture an ant walking across your garage floor, trying to make a straight line of it. It ain't gonna make a straight line. And you know this because you have perspective. You can see the ant walking around, going hee hee hee, look at him locally optimize for that rock, and now he's going off this way, right?

This is what we were, when we were writing this giant assembly-language system. Because what happened was, Microsoft eventually released a platform for mobile devices that was much faster than ours. OK? And I started going in with my debugger, going, what? What is up with this? This rendering is just really slow, it's like sluggish, you know. And I went in and found out that some title bar was getting rendered 140 times every time you refreshed the screen. It wasn't just the title bar. Everything was getting called multiple times.

Because we couldn't see how the system worked anymore!


Which is higher-level language, C or C++?

One benchmark of language level is how many lines of code are needed to implement a feature. In high-level languages, the compiler does more work. The programmer has to write less code. This means that implementation is faster. There are also less bugs, since the lines of code which were not needed don't contain bugs, and because debugging is easier in small haystack.

C language is infamous for being low-level. Therefore it's paradoxical that Symbian Open C is a advertised as a productivity tool. But sadly it really is a productivity tool compared to Symbian C++.

The examples below demonstrate why. The snippets below read a configuration variable from a file. The scenario is that we want to run automatic system tests on a communication protocol and to automate the selection of an access point. It is stored in format "accesspoint=Winsock". The important thing here is the length of the listing, not the exact content.



// Read a configuation variable with 35 lines of code.
_LIT8(KAccessPointId, "accesspoint=");
TBool ReadAccessPointNameL(const TDesC& aFileName, TDes& aResult)
{
RFs fs; // File session
RFile file; // File handle
TBool apNameFound = EFalse;

// Connect to file server
User::LeaveIfError(fs.Connect());
CleanupClosePushL(fs);

// Open file for reading
if (file.Open(fs, aFileName, EFileWrite) == KErrNone)
{
CleanupClosePushL(file);
// Read the file to memory (we can't use line-by-line
// reading with TTextFile, since it can't handle 8-bit text)
TInt size = 0;
User::LeaveIfError(file.Size(size);
HBufC8* content = HBufC8::NewLC(size);
User::LeaveIfError(file.Read(content->Des());

// Find the start and end of the access point name.
TInt start = content.Find(KAccessPointId());
if (start > KErrNotFound)
{
start = start + KAccessPointId.Length();
TInt end = start;

// Find the next newline.
do {
end++
} while(end < content.Length() &&
(*content)[end] != '\r' &&
(*content)[end] != '\n');
}

// Save the result.
aResult.Copy(content.Mid(start, end - start));
apNameFound = ETrue;
}

CleanupStack::PopAndDestroy(content);
CleanupStack::PopAndDestroy(&file);
}

CleanupStack::PopAndDestroy(&fs);
return apNameFound;
}



The same in C:



// Read a configuation variable with 20 lines of code.
const char* access_point_id = "accesspoint=";
char* read_access_point_name(const char* file_name)
{
char* result = NULL;
// Open file for reading.
FILE* file = fopen(file_name, "r");
if (file) {
char line[200];

// Read line by line and search for access point variable.
while(!result && fgets(file, line, 200)) {
if (strstr(line, access_point_id) == line) {

// Remove newline.
int len = strlen(line);
while (line[len - 1] == '\r' || line[len - 1] == '\n') {
line[len--] = 0;
}

// Get the value of the variable.
reuslt = strdup(line + strlen(access_point_id);
}
}
fclose(file);
}
return result;
}



Symbian C++ was written before people really knew how to do object-oriented programing. They completely botched all the APIs. The horrible descriptors were designed to counter memory overflows, which C functions don't check. Nowadays they just clutter the code. Symbian takes pride in being a microkernel OS, so they require the programmer to connect to servers to start sessions. This adds further lines. The exception handling with cleanup stacks vomits more useless lines. And if you think this is ugly, you haven't seen anything, like the use of active objects in the socket interface.

One C++ selling point is the syntax for classes. Well, Symbian has a 68-page coding convetions which gives very explicit rules how to name classes and which functions they should at least have. This nitpicking makes classes heavy structures, and decimates any advantage from syntactic sugar. Virtual functions are the only part of C++ which wasn't assaulted. Even templates were banned as too error-prone.

So Posix C really is a higher-level language. Just for comparison, here is the same in Ruby.



# Read a configuration variable in 9 lines of code.
def readAccessPointName(fileName)
file = File.open(fileName, "r")
file.each_line do |line|
if (line =~ /accesspoint=(.*)/)
# The (.*) in regular expression caught
# the access point name to $1.
return $1.chomp
end
end
raise 'No access point name in file ' + fileName
end



So it is unsurprising that App store contains 225000 appplicaitons while Ovi store contains just thousands.


GeoWorks attempted to get third party developers but was unable to get much support due to expense of the developer kit — which ran $1,000 just for the manuals — and the difficult programming environment, which required a second PC networked via serial port in order to run the debugger. (source)


But it's the user experience that counts...

Symbian phones are famous for having equal features but lower usability than iPhone. To demonstrate how difficult programming is visible in usability, I'll tell you about usging the file browser to read log files. The plain text viewer has several defects. If you open a large log, it announces out of memory error and shuts down. It underlines randomly some content which it thinks might be a link. It can't choose a small font to show lots of content, so you only see a few lines at a time. Luckily, there has been some progress in plain text viewer. Earlier, it used to crash with medium-sized files. Now it either shows it or announces error.

The way I see it, these defects reflect the difficulty of the programming platform. Usually programmers have some professional pride, which makes them fix errors and usability defects with time. What could be stopping it? We can only speculate.
  • Customizing the UI component which shows text would require too much work, since platform doesn't support dynamic loading and presentation.
  • Low level language necessitates big project sizes. This dilutes responsibility so that no one is responsible for the plain text viewer in the "buck stops here" sense.
  • There is a culture of fixing only showstopper bugs and leaving others there, since there isn't time to fix all bugs, as fixing a single bug is slow.

This way, we get "multimedia computers" which can't display plain text.

It doesn't have to be this way

Nokia does fine in low-end phones, which use the closed Series40 OS. Also the Maemo/Meego platform is promising, however the phone in N900 is still fresh software, creating issues in sound quality and usability. They haven't had time to finalize the phone. In compatibility with major desktop operating systems, Maemo's Linux kernel runs circles around Symbian. This will show up in usability sooner or later. You can always strip down the user interface to produce a simpler phone which is easier to use, but you can't put the solid Linux infrastructure to a Symbian phone.

In the long run, I'm optimistic about Nokia's future. Once they finalize the phone on Maemo and scrap the Symbian platform, they'll be fine. If you want to capitalize on this, the right time to buy Nokia shares is just before they start selling their next Meego phone. However, make sure that the press agrees that Meego has good phone, battery life and usability - if they botch them on Meego, they won't recover. However, I'm not putting my money where my mouth is, because I have enough economic Nokia risk in my life already.

Monday, April 09, 2007

What's Wrong With Symbian

In short: Crippled C++. C++ is already quite a low-level language. Symbian has plenty of coding conventions and classes, which make this even worse. There is cleanup stack to prevent memory leaks; leave mechanism to simulate exceptions; and RArrays and RPointerArrays to simulate std::vector. Finally, there are active objects to simulate threads or message passing or callbacks or whatever, I'm still not quite sure despite using them for years.

Nowadays Symbian phones have as much memory as late 486s or early Pentiums, although the memory is slower. So is it really worth it to save miniscule amounts of memory and make programming harder?

The era of mobile Java isn't here yet. I mean, the era when the operating system consists of Java VM, device APIs, and some core high-performance units like phone calls, video codecs, OpenGL, etc. Java is still too slow. Therefore, C++ is still a necessary evil.

In addition to crippled C++, also APIs are less-than-perfect. Java developers who have used entity beans or Hibernate may feel schadenfreude from this fact: Symbian has an internal database in every device, but you can only access it with SQL. No object/relation mapping tools for you. In general, there aren't any helper APIs which wrap the functionality to an easier form. 2.5 years ago when I last programmed Symbian, the APIs also has stupid bugs, but I hope that is fixed now.

Friday, April 06, 2007

The Glass of Success is Half Full

As planned, I applied for J2EE jobs using Finnish annotator (FA) as a merit. FA was implemented with embarrassingly low technologiy: HttpServeltResponse.GetPrintWriter().println() produced most of the web pages. I got to 3 job interviews based on it.

After one interviewer told me that they used JSP and servlets to implement web services in 2001, in no uncertain terms, I realized my J2EE experience was inadequate and that I would rather be an experienced Symbian programmer (despite the shittiness of Symbian, which is worth anoter post) than a J2EE trainee. After that, I applied for Symbian jobs and got one from a mid-sized Symbian subcontractor. I'm not going to tell the name of the company, since I have no idea how it differs from other mid-sized Symbian subcontractors, and because they have their own marketing department to take care of their external image, thank you veeery much for your suggestion of advertising by blogging but no thank you.

The Symbian job I got pays 600e/month more than what I got at Nokia. I started 1.4. I still haven't been assigned to any project, but anyway I'll get more pay than ever before for carrying less responsibility than at the last months of Nokia.

If I had really wanted to get a J2EE job, I could have applied at J2EE Professional Trainee Program at Tapiola. But I thought that it was too easy, since from the 4 technologies they list (JSP, XML, EJB, WSAD) I already know JSP and XML and have read a book about EJB, so that only WSAD (whatever it is) would be totally new. Also, applying to the program would be dishonest, since my interest in J2EE is not about becoming a Tapiola man, but about developing the FA.

By the way, "professional trainee" is an oxymoron. Who wants to be an oxymoron?

My initial plan with Finnish Annotator was to collect a 5000 word Finnish vocabulary by September. This would have required me to write English definitions for about 24 words a day. Now that I actually work, I have noticed that I have no energy to write word definitions after work. So 5000 words is utopistic. I'll have to either overcome procrastination or find out just how many words I have patience to write before contacting a Finnish teacher and sugggesting co-operation.

The glass of success if half full or empty in the sense that I failed to get a J2EE job but succeeded in getting a job that pays more than anything I have done before.

What to do with the money when I've accustomed to a student budget? There are practically only 3 ways to spend it in a way that actually increases my standard of living:

  • Get a mortgage instead of paying rent; this would mean that in the future, if I want, I can loan money and use the apartment as a guarantee.

  • Travel to foreign countries. Among my peers this is a popular hobby which I haven't done much.

  • Buy sex, an option I should try since I'm never going to get any with my current levels of nerdiness and muscularity without paying for it.