Who am I?

dcrocha

I'm a software engineer with 10 years experience in application development, having worked with Web (Perl, PHP, JavaScript, JSP, Servlets, Flash, ASP), Enterprise (Java EE) and Mobile software (Symbian C++, Java ME, Flash Lite, Python). Currently working as Forum Nokia Technology Expert with many exciting technologies.

Check my blog for more articles and fun stuff: http://heapmemory.net

Calendar

« June 2008 »
Mo Tu We Th Fr Sa Su
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            

Which technology should I use? Round 3: Python

dcrocha | 03 June, 2008 18:49

Python

The comic above pretty much sums it up: Python is a refreshing look at the world of programming. Being so easy to learn and use, it has gained lots of attention from the developer community and it's used for several different purposes such as: web development, desktop apps, utilities, scientific computing, scripting language for games and special effects software, flying and of course mobile development. In fact, I am very surprised that it took so long before any mobile platform offered Python as a viable software creation vehicle. 

In our platforms, Python is offered as a runtime option for S60 devices, ranging from 2nd. to 3rd Edition and all their feature packs. That makes it pretty wide reaching platform, since we have some 130 million+ devices in the market for which you can write Python applications.

The core technologies for mobile development have been analyzed here before: C++ is the raw power of Symbian OS available to developers, with its immense API and functionality sets but steep learning curve; Java is easy to learn and use and it's present in more than a billion devices. Its functionality is good but restricted by the Java Community Process since all APIs have to be agreeded upon by participants of each JSR spec.

Python comes in the middle, and that's in my view its main advantage: it is as easy as Java but (almost) as powerful as C++, and not limited by any industry standard processes: you want a Flying API which is not available? Just create an extension and you're good to go. Our good friend and Forum Nokia Champion Pankaj Nathani (a.k.a. croozeus) has in his website a great list of resources for Python development, including how-to's on writing extensions and more: http://croozeus.googlepages.com/py60extensions. Also, if you are the kind of developer who likes to hack around, Python for S60 runtime is open source, so you can spend your days and nights hunting bugs, adding new features and creating your own version of it!

First part of this article: Which technology should I use for development? Round 1: Java
Second part of this article: Which technology should I use for development? Round 2: C++


Technology: Python for S60

Good for:

  • Internet mashups - You can easily mix the Location API with urlib and Google Maps and create a powerful mobile/web hybrid application which can leverage both platforms strengths. For example, take a look at MobyMaps, a geocoding application in just 104 lines of code, or Fupper, pyAmazon, Mobile Google Maps and many others.
  • Productivity applications - Access to the filesystem, contacts database, local connectivity, camera, gallery with incredible simple APIs lets you quickly write applications through which you can interact with your device and other people. MobileGTD, PyS60RemoteControl, PySpy are some examples.
  • Rapid prototyping - This is probably one of the most popular uses of Python for S60, and you should consider it very seriously. It seems that RP is still not very popular, as people usually choose a technology and develop an app with it; if something goes wrong or doesn't work, they will only find it out at the end of the project, when it's too late. I have seen countless cases like this, specially with Java development: "What, I cannot intercept a phone call with Java? But the product is almost ready!". Python helps you tackle this issue in a very elegant and effective way: you have an idea, want to check whether it works or not, just write a PyS60 script to test it. If you're satisfied, just tweak it a bit more and make it your final product, otherwise implement the final version in C++ or Java if you need more power or portability. I cannot stress enough the importance of showing your customer something working from Day One; this is much more effective than showing slides or specification documents.
  • Utilities - If you have a special event or need and you need to cook up a quick solution for a simple problem, use PyS60. To give you an example, I needed some sample apps for a talk I gave back in March. I was able to develop 10 utilities (photo takers, Bluetooth FTP client, video recorder, etc.) in less than a week. 
  • Games - Given Python's powerful API set that can be used in games, such as: Sensor API, Open GL ES access, graphics and image manipulation, it is a good tool for churning out casual games meant to have a short lifecycle. It can compete well with Flash Lite for this purpose; even though its graphics facilities are not as nice, the powerful APIs will help you create the "wow" factor in your mini-games.

Why? 

  • API/functionality availability - The S60-only list of APIs is reasonably extensive, and you can always add new ones by programming extensions using Python/C API. Many times modules can be added from other platforms without modification (for example, Python debugger - pdb).
  • Ease of use - It's by far one of the easiest languages to learn and work with. In a matter of weeks you can be highly productive with it.
  • Community support - There's a lot of Python code written by the open source community out there that can be used in your application.

Bad for:

  • High performance apps - Python's performance is reasonable, but it is slower than C++, Java and Flash. So if you need to develop a scientific application which requires a lot of number crunching, or a video streaming application, this is probably not the best solution.
  • Commercial apps, destinated to operator channels - Please take this one with a grain of salt. Applications for sale at operator channels usually are required to go through Symbian Signed process, and Python apps don't play very well with it. 
  • Portability - Although the core Python language is the same, there are several APIs which are S60-exclusive so they won't work in any other platforms without several modifications.

Why? 

  • Symbian Signed - In theory Python is compatible with the program, but in reality Symbian Signed was designed for C++ applications, so in some situations PyS60 apps may fail the tests so you have either to get a waiver for the failure or use the Express Signed option. For lack of a better option, I put Python on the "bad for" side of this article, but in the real world you may have different options that make it suitable for operator channels.
  • Platform security - Although it's very noble on its purpose (securing users' devices against malware), platform security can be a pain to live with during the development cycle. The whole Symbian Signed environment and platform security API restrictions slow down development time and can increase development costs, because of test fees, certificate purchasing, re-test, etc. This also affects Python for S60 so I left it here from the previous article.
  • Performance - Don't forget Python runs on an interpreter, so it has some performance disavantages when compared to native applications.
  • Tools - As it's a very new platform on S60, its tools are not as mature as other technolgies'. You can use the C++ SDK with the Python plug-in for testing your scripts, Python Shell for running scripts on your device, and py2sis or Ensymble to package them in an installable .sis file. There's still no integration with Carbide, and the emulator runs only on Windows. This is a pretty basic selection when compared to NetBeans or EclipseME for Java, Adobe CS3 for Flash Lite or Carbide.c++ for, hm, C++.

Python brings back the fun of hacking your device the way you want, with just a few lines of code. It's also a powerful tool for fast development of applications and utilities, besides being ideal for rapid prototyping of more complex software. The learning curve is smooth, the API set is big, and the support of open source community gives it a large set of libraries you can use in your application. As it's still in an incipient phase in the mobile software development, you can use it and contribute for its evolution in the next releases, making it a sweet platform for innovation on S60.

If you are interested in learning more, there's a ton of resources on PyS60 in Forum Nokia web site and also in its wiki page. For impatient people who can't wait to try it, I have posted a few months back a complete presentation on how to get started with Python, along with a collection of sample source code; both can be found here

Happy hacking!

<a href="http://technorati.com/claim/ymg32hejh6" rel="me">Technorati Profile</a>


RSSComments

Re: Which technology should I use? Round 3: Python

bogdan.galiceanu | 04/06/2008, 03:24

bogdan.galiceanu

Excellent post. Been looking forward to this one.

Re: Which technology should I use? Round 3: Python

croozeus | 04/06/2008, 04:11

croozeus

Just to add to this...

Forum Nokia just published an eLearning module about Python for S60.
I recommend this to all Python brothers, Here is the link

http://www.forum.nokia.com/info/sw.nokia.com/id/a5da42ca-3cc6-426f-9d98-234523fd9d75/Python_for_the_S60_Platform.html

Best Regards,
Croozeus

Python and games

coultonp | 04/06/2008, 07:53

coultonp

While I would agree with much of your post I wouldn’t agree that Python is a good platform for games and I haven’t seen a good game developed in it despite having access to OpenGLES as the interpreter doesn’t seem to handle the intensity required for long periods. I wouldn’t agree either that it compares well for casual games as at the end of the day they need to be distributed and there are much better casual platforms.

Re: Which technology should I use? Round 3: Python

svdwal | 04/06/2008, 13:41

If an API is not available in Java, no amount of Rapid Prototyping in Python will reveal this problem. This makes Pyton a good RP language for Python and C++, but not for Java.

Re: Which technology should I use? Round 3: Python

dcrocha | 05/06/2008, 01:03

dcrocha

Hi all, thanks for the comments!

@svdwal: Agreed, but I wouldn't exclude Python as and RP language for Java entirely. For example, for prototyping Bluetooth, File system-accessing, network, location apps, it's still very valid (IMHO) since those APIs are easier to use than in Java ME.

@coulton: Good points. About the distribution, Flash Lite in theory is better, but what we're seeing is that fragmentation is getting there as well. By 'casual' I meant "not long running / not complex" games. I was thinking more of promotional games with a very short lifecycle (for Nokia Trends events for example) but this is a case-by-case analysis I think.

planetmobile.us

miohtama | 22/09/2008, 21:05

Hi Daniel,

Is it ok to subscribe your blog to planetmobile.us aggregator?

Re: Which technology should I use? Round 3: Python

brianna102 | 27/09/2008, 09:27

I didn't have much knowledge about "Python". But after reading your post i feel really very exciting to know about it. This post is very interesting.

------------

brianna

[url=http://jobs.gov-auctions.org.com]Job Oppotunities[/url]

You must login to post comments. Login
 
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved