Development issues: Difference between revisions

From OLPC
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:
* Will the laptops and/or an emulator be available to developers interested in direct contibutions to OLPC?
* Will the laptops and/or an emulator be available to developers interested in direct contibutions to OLPC?
* memory footprint of applications
* memory footprint of applications
:It must be as small as you can make it. These are memory-constrained devices. Don't import modules at the top. Instead, import them just where they are needed in the code and then unload the module. This will require some work with ihooks and imp to support unload() but for now, just use a dummy function in your code. If possible, implement optional components as a separate Python module and delete the .pyc file when a user chooses not to use that option. Remove objects when they are no longer needed using del.
* memory leaks
* memory leaks
: You need to measure the memory usage repeatedly while thoroughly exercising your program. Sample the memory size every minute and graph it. If there is a slowly increasing size, then you have a leak. A normal program will increase rapidly at the beginning and then remain perfectly flat or shrink and grow repeatedly.
* required flash footprint of the application; if it is big, there may not be space. However, JFFS2 does data compression, so don't presume that the size of a file in a conventional file system corresponds to the actual amount of flash used. As a *rule of thumb*, expect a factor of 2 compression for text and typical data, expect no compression on already compressed content, but take actual measurements to understand what your actual flash usage will be.
* required flash footprint of the application; if it is big, there may not be space. However, JFFS2 does data compression, so don't presume that the size of a file in a conventional file system corresponds to the actual amount of flash used. As a *rule of thumb*, expect a factor of 2 compression for text and typical data, expect no compression on already compressed content, but take actual measurements to understand what your actual flash usage will be.
: If you test on a Unix system you can install JFFS2 and test directly. Since JFFS2 does block compression you can affect the amount of compression by reorganizing your code.
* your application should be engineered and packaged to make it easy to strip unneeded functionality. For example, GAIM supports just about every IM protocol in existance, but we can only anticipate 3 being common. So the fact it uses plugins that we can choose to not package saves greatly on its footprint, whereas if everything were built in, both the memory and flash footprint would be much larger.
* your application should be engineered and packaged to make it easy to strip unneeded functionality. For example, GAIM supports just about every IM protocol in existance, but we can only anticipate 3 being common. So the fact it uses plugins that we can choose to not package saves greatly on its footprint, whereas if everything were built in, both the memory and flash footprint would be much larger.
* ability to operate applications when running in black/white mode
* ability to operate applications when running in black/white mode
:Judicious use of contrasting colors will mean that your program automatically works in B&W mode.
* the 640x480 effective resolution in color mode: some applications will find this hard, even though the frame buffer will always be in high resolution. If your application does not honor the font resolution change-on-the-fly mechanisms, or hardwires fonts by pixel size, your application won't be able to switch modes gracefully and may require manual intervention to be usable. Please fix.
* the 640x480 effective resolution in color mode: some applications will find this hard, even though the frame buffer will always be in high resolution. If your application does not honor the font resolution change-on-the-fly mechanisms, or hardwires fonts by pixel size, your application won't be able to switch modes gracefully and may require manual intervention to be usable. Please fix.
* the hardware does support alpha blending (Porter-Duff compositing), so we expect to eventually support this well
* the hardware does support alpha blending (Porter-Duff compositing), so we expect to eventually support this well
* no 3D hardware: we don't have shaded triangles or a geometry pipe; so any OpenGL used will be based on Mesa, and without hardware, will be very slow
* no 3D hardware: we don't have shaded triangles or a geometry pipe; so any OpenGL used will be based on Mesa, and without hardware, will be very slow
:Ideally, don't use OpenGL at all except for specialty applications which absolutely must and which can accept the slow rendering. For instance a design program could use OpenGL to provide a rendered view because most of the time the user will not be using OpenGL.
* choice of libraries and required applications: you may not have the dependencies you might need, or those dependencies might come at too high a memory cost. We will inventory what you can "count on" in the basic system as it becomes clear.
* choice of libraries and required applications: you may not have the dependencies you might need, or those dependencies might come at too high a memory cost. We will inventory what you can "count on" in the basic system as it becomes clear.
: In the meantime, make sure you know your application's dependencies. Run it with "python -v" to get a list of all modules imported.
* graphical activity that does not turn itself off quickly; we want to save power
* graphical activity that does not turn itself off quickly; we want to save power
:This means avoid cute animated GIFs that do not add value to the educational experience. Your users will have to exert themselves physically to provide the electricity to run your application. Respect them and their effort.
* CPU performance: the system is slow relative to current desktops, though fast relative to desktops at the turn of the millenium.
* CPU performance: the system is slow relative to current desktops, though fast relative to desktops at the turn of the millenium.
* power consumption: if your application is CPU bound for long periods, or routinely requires itself to be run (can't be suspended well), this isn't good
* power consumption: if your application is CPU bound for long periods, or routinely requires itself to be run (can't be suspended well), this isn't good
Line 21: Line 28:
* presuming that you can contact a server for service will often not be possible. Design applications to be peer-to-peer, or to self elect servers in a local cloud of people working together. We can presume at least some technology like mDNS (e.g. Avahi) is available for discovery.
* presuming that you can contact a server for service will often not be possible. Design applications to be peer-to-peer, or to self elect servers in a local cloud of people working together. We can presume at least some technology like mDNS (e.g. Avahi) is available for discovery.
* applications should be localizable. Do not embedd any user readable text in your code.
* applications should be localizable. Do not embedd any user readable text in your code.
: Start by reading these 31 slides about how to use Unicode in Python: http://downloads.egenix.com/python/LSM2005-Developing-Unicode-aware-applications-in-Python.pdf
: Next, read the documentation for the Python gettext module. Become familiar with GTK+ and Pango features for I18N and L10N.
: Try writing a sample application with menus and dialogs following the guidelines. Then find a friend who knows a foreign language. Ask them to translate your strings and then test the application with the translated strings. Sit beside them and watch how your program works. Are any graphical elements too small?



This page is a stub. Please expand on it.
This page is a stub. Please expand on it.

Revision as of 09:54, 1 June 2006

Here are a few of the most obvious development issues/questions/comments:

  • What language should be used to develop applications?
The answer is here OLPC Python Environment
  • Will the laptops and/or an emulator be available to developers interested in direct contibutions to OLPC?
  • memory footprint of applications
It must be as small as you can make it. These are memory-constrained devices. Don't import modules at the top. Instead, import them just where they are needed in the code and then unload the module. This will require some work with ihooks and imp to support unload() but for now, just use a dummy function in your code. If possible, implement optional components as a separate Python module and delete the .pyc file when a user chooses not to use that option. Remove objects when they are no longer needed using del.
  • memory leaks
You need to measure the memory usage repeatedly while thoroughly exercising your program. Sample the memory size every minute and graph it. If there is a slowly increasing size, then you have a leak. A normal program will increase rapidly at the beginning and then remain perfectly flat or shrink and grow repeatedly.
  • required flash footprint of the application; if it is big, there may not be space. However, JFFS2 does data compression, so don't presume that the size of a file in a conventional file system corresponds to the actual amount of flash used. As a *rule of thumb*, expect a factor of 2 compression for text and typical data, expect no compression on already compressed content, but take actual measurements to understand what your actual flash usage will be.
If you test on a Unix system you can install JFFS2 and test directly. Since JFFS2 does block compression you can affect the amount of compression by reorganizing your code.
  • your application should be engineered and packaged to make it easy to strip unneeded functionality. For example, GAIM supports just about every IM protocol in existance, but we can only anticipate 3 being common. So the fact it uses plugins that we can choose to not package saves greatly on its footprint, whereas if everything were built in, both the memory and flash footprint would be much larger.
  • ability to operate applications when running in black/white mode
Judicious use of contrasting colors will mean that your program automatically works in B&W mode.
  • the 640x480 effective resolution in color mode: some applications will find this hard, even though the frame buffer will always be in high resolution. If your application does not honor the font resolution change-on-the-fly mechanisms, or hardwires fonts by pixel size, your application won't be able to switch modes gracefully and may require manual intervention to be usable. Please fix.
  • the hardware does support alpha blending (Porter-Duff compositing), so we expect to eventually support this well
  • no 3D hardware: we don't have shaded triangles or a geometry pipe; so any OpenGL used will be based on Mesa, and without hardware, will be very slow
Ideally, don't use OpenGL at all except for specialty applications which absolutely must and which can accept the slow rendering. For instance a design program could use OpenGL to provide a rendered view because most of the time the user will not be using OpenGL.
  • choice of libraries and required applications: you may not have the dependencies you might need, or those dependencies might come at too high a memory cost. We will inventory what you can "count on" in the basic system as it becomes clear.
In the meantime, make sure you know your application's dependencies. Run it with "python -v" to get a list of all modules imported.
  • graphical activity that does not turn itself off quickly; we want to save power
This means avoid cute animated GIFs that do not add value to the educational experience. Your users will have to exert themselves physically to provide the electricity to run your application. Respect them and their effort.
  • CPU performance: the system is slow relative to current desktops, though fast relative to desktops at the turn of the millenium.
  • power consumption: if your application is CPU bound for long periods, or routinely requires itself to be run (can't be suspended well), this isn't good
  • while we are a great fan of interpreted languages, key CPU bound kernels had better be in compiled code, or your performance and power consumption will be poor
  • your slow code has a direct impact on power consumption, and its usability. Applications that run CPU bound will be very, very unpopular on battery powered machines that may be powered by children having to run a generator.
  • the file system is a flash file system, so its write performance is slow, while random access is actually very good. The performance is glacial if the file system is low on space and has to continually erase freed blocks before writing (jffs2 attempts to do this in the background, but if it can't....). Programs that continually write to the file system without need are anti-social; wear leveling helps flash longevity, but it certainly doesn't help, and burns power.
  • looping waiting for events eats power; don't do it. Poll and select with timeouts are your friends. Don't gratuitously wake up at frequent intervals just to test if something has happened; design your hardware and software to be completely idle between events they have to respond to.
  • presuming that you can contact a server for service will often not be possible. Design applications to be peer-to-peer, or to self elect servers in a local cloud of people working together. We can presume at least some technology like mDNS (e.g. Avahi) is available for discovery.
  • applications should be localizable. Do not embedd any user readable text in your code.
Start by reading these 31 slides about how to use Unicode in Python: http://downloads.egenix.com/python/LSM2005-Developing-Unicode-aware-applications-in-Python.pdf
Next, read the documentation for the Python gettext module. Become familiar with GTK+ and Pango features for I18N and L10N.
Try writing a sample application with menus and dialogs following the guidelines. Then find a friend who knows a foreign language. Ask them to translate your strings and then test the application with the translated strings. Sit beside them and watch how your program works. Are any graphical elements too small?


This page is a stub. Please expand on it.