Archive for July, 2010

Reference: Passing functions as parameters in C

Sunday, July 18th, 2010
#include <stdio.h>
//Example to show how to pass 
//functions as parameters in C.                                               

//simple function that returns the sum of two ints                                                                                              
int sum(int i, int j) {
  return i+j;
}

//simple function that prints a char*                                                                                                           
void printSomething(char* something) {
  printf("%sn",something);
}

//function that takes                                                                                                                           
// 2 ints                                                                                                                                       
// 1 char*                                                                                                                                      
// one function that returns an int and takes two ints                                                                                          
// one function that takes a char* returns nothing                                                                                              
void functionThatTakesOtherFunctions(int a,
                int b,
                char* name,
                int (functionA) (int,int),
                void (functionB) (char*)) {
  printf("Function A: %dn",functionA(a,b));
  functionB(name);
}

int main(void) {
  //we pass the first two functions as parameters                                                                                               
  functionThatTakesOtherFunctions(3,4,
                                  "John Doe",
                                  sum,
                                  printSomething);
  return 0;
}

This worked fine on my gcc compiler (MacOSX 10.5), no need to even use * or & operators when defining the parameters or when passing the functions as parameters.

On “Inception” and Programming

Sunday, July 18th, 2010

After watching Inception I think I have an easy way to explain what complex object oriented programming can be like.

Next time someone asks “What is Programming like?” I’ll say something along these lines:

“Did you watch that movie “Inception”? Programming is similar, you build your own worlds, with your own rules (and worlds that can only exist in the abstract, sometimes very hard to explain in words), but now imagine that instead of dreaming in 4 levels (dreams inside dreams) you could be dreaming in about 12 levels down, but not only that, you could be having several dreams at once (each with several levels down), and most of the times some of these dreams have to share things with one another in order to make sense or they break.

So Programming is like Inception, but Deeper, In Parallel and Synchronized.”

Photo by Smif

Reviewing the Nokia N900, User and Developer opinions.

Wednesday, July 7th, 2010


Playing with it from the User Perspective
- Virtual keyboard is deactivated by default, not good if you have one hand busy, however I can see why it’s this way (the virtual keyboard sucks). When it comes out it covers the entire screen, and the experience with it is not there yet in comparison to the virtual keyboards of the iPhone or Android.

- Physical Keyboard feels great.

- Not sold on the stylus, I think I might loose it. However it comes in handy when clicking on tiny links.

- Web browsing experience is clumsy if you try to use your fingers and you’re used to Android or iPhone where dragging occurs on a light touch. With the N900 you have to Tap harder to begin to drag, probably like that intentionally. I must admit I find myself making mistakes on the Droid maybe because it’s too sensitive.

- Using forms on the browser is inconvenient. There’s no way to move from form field to form field except using the stylus. Keyboard arrows won’t work to switch focus between form fields, and the lack of virtual keyboard (when you’re using the real one) implies that you won’t have a “Next” button to move through the form (or at least I couldn’t figure out a field hopping mechanism).

- Zooming in and out on a web page will be extremely unintuitive. Thanks to patents on multitouch gestures you’ll have to either double tap, or do a ridiculous tap+hold and twirl clockwise zoom in (in a controlled way), or tap+hold and twirl counter-clockwise to zoom out… wtf.
Nokia has to put up a fight on this, natural multi-touch gestures are a must on today’s smartphones.

- I still don’t know how to select, copy and paste text from a website. Very hard to quote text and twitter it.

- Default timeout for screen auto lock is way too short.

- It has a stand on the back, which as a developer I appreciate. It’s a pain to debug apps on the nexus one, you always kind of need to pick it up or create some sort of desktop apparatus to have the phone facing you while you test hands free.

Multimedia
- Video and audio playback were perfect. Droid and Nexus One have nothing to envy, so it’s not a selling point. Watch the 3 phones playing the same video.

- Navigation is convenient with top left corner control. It took me a few seconds to figure it out being used to Android’s back and Home Button and of the one physical button on the iPhone.

- The Media player comes with pre-installed internet radio streaming app. On Android I had to download one from the Market.

- Didn’t have to install Flickr photo uploading app, already comes with OS.

- OVI Store experience frustrated me. Should be an app, not a web page. I got asked for an HTTPS certificate while trying to install a Twitter plugin, it was basically the same exception you get on a web browser. The regular user would get lost adding the certificate and the security exception. Then after that I got asked to signup for the OVI store, and I gave up. Installing apps should be a breeze. Setting up your OVI Store account should be done as part of the phone setup process on an App.

The more I use the phone the more I think, Nokia’s hardware is hot, but they’re wasting their time with competing on software. Nokia running Android would kill everybody else, let’s hope it will happen sooner than I think, they just need to test with one cool device and feel the market.

Unboxing Pictures
[flickr-gallery mode="photoset" photoset="72157623986709513"]

Playing with it as a Software Developer
- No SDK for Mac environment, or at least not a very accessible or official version of it. The only solution seemed to be installing the SDK on a Virtualized Linux (e.g. VirtualBox).

- Maemo SDK not compatible with Ubuntu 10.4 64bit, it seems it’s only 32bit.

The project page confirms this:
“The development environment for Maemo running on the desktop is called Maemo SDK. You can only install Maemo SDK on a Linux operating system. Maemo SDK currently supports the following Linux distributions: Debian, Ubuntu”

Tried installing Scratchbox on my Mac with no luck.

- It was a little surprising to see the Nokia documentation for developers talking about GTK+ in all their examples and not Qt, given the acquisition of Trolltech by Nokia in 2008. However you go to the Qt page and it says that it’s the defacto SDK for Maemo devices.

In the end I decided to install it on a 32bit Ubuntu VirtualBox image on my Mac and deal with the performance hit, I couldn’t just return the phone without compiling something, otherwise I’d be speaking out of my ass right?

Hello World in GTK

Hello World in Qt4, exactly the same code I would’ve used for a desktop Qt4 app.

compilation is the same thing as if developing a regular Qt4 app on linux

/scratchbox/login
fakeroot apt-get install libqt4-dev

create your helloworld.cpp… then make your project

qmake -project
qmake
make
run-standalone.sh ./qt_helloworld

If you’re used to Linux development with GTK or Qt4 you will feel right at home, and you probably know right off what’s the most comfortable set of tools to code. If you’re not, it seems like Nokia has left the whole thing way too much on the hands of the Maemo community.

Documentation seems a little all over the place, unfinished Wikis, not very welcoming for non-linux developers, I’m talking about companies that come from actually making money on iPhone OS or Android, looking to port their apps to Maemo. The first impression won’t be the best and you’ll think that things aren’t as well prepared as for iPhone with X-Code or Android with the Eclipse extension which let’s you deploy a signed installer in just a few clicks.

It seems that Nokia is relying way too much on the Linux community for all of this, I’m not sure if this is going to get very far with mobile shops, specially after seeing how many hurdles a user has to go through sometimes to get an app from the OVI market (in comparison to iPhone or Android’s markets simple purchasing processes).

SDK experience Screenshots
[flickr-gallery mode="photoset" photoset="72157624248900230"]

Conclusions

First of all thanks to Nokia for sending the N900. My final conclusions which are mostly thinking from the consumer perspective might not be one you’ll like much (you=Nokia), but you probably need to hear this (I’m guessing this is why you sent the device in the first place).

In my case after being a faithful Nokia consumer I felt dissapointed with the software side when I chose the N95 over the iPhone, newer Nokia phones came, but the same shitty platform was running on them, I thought Maemo would change that but now I know it’s nowhere near what smartphone users today expect. Then Android came along to truly compete with the iPhone.

Now as an Android user when the time comes for me to upgrade my phone I’ll be looking for another Android device.

Let’s imagine what’s going to happen when my Droid is too old, by that time there will be even more Android phones to choose from also a richer Application ecosystem, if I were the kind of person that installs paid apps I’d probably like to keep my “investment” for my next phone, however even if there’s a myriad of Android phones out there, the only brands I’ll consider are Motorola, HTC, LG and SonyEricsson, I’m not too fond of any of them so I’ll have to research what each of the phones they’ll be offering will suit my needs.

An Android based Nokia smartphone would certainly make my decision a lot easier. As of now you’re entirely out of the picture, there’s no way I’m switching to Maemo, and Moblin is way too new to tell if it’s going anywhere.

Nokia, Stop playing outside the garden, don’t get cocky with your current numbers and admit you’re slowly decaying, if you don’t do something about it once Android is on every cheap phone you’re gonna die. Android could use some Nokia.

Follow the geek.




  • Categories

  • May 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • October 2012
  • September 2012
  • July 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • June 2010
  • May 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • October 2009
  • September 2009
  • July 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • December 2007
  • November 2007
  • October 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007
  • February 2007
  • January 2007
  • December 2006
  • November 2006
  • October 2006
  • September 2006
  • August 2006
  • July 2006
  • June 2006
  • May 2006
  • April 2006
  • March 2006
  • February 2006
  • January 2006
  • December 2005
  • November 2005
  • October 2005
  • September 2005
  • August 2005
  • July 2005
  • June 2005
  • May 2005
  • April 2005
  • March 2005
  • February 2005
  • January 2005
  • December 2004
  • November 2004
  • October 2004