Developers/Issues/lang-es: Difference between revisions

From OLPC
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
{{Developers}}
{{Developers}}
[[Developers/Stack|Previous]] [[Developers/Projects|Next]]
[[Developers/Stack/lang-es|Previous]] [[Developers/Projects/lang-es|Next]]


Esta página intenta apuntarte a las diferencias mas grandes al programar para una [[Hardware|OLPC-XO]], y programar en una maquina de escritorio tradicional. Las recomendaciones que encontrarás son útiles aun para otros sistemas, pero en la XO, las limitantes de recursos, y disponibilidad de drivers hacen a las cosas "útiles" se conviertan en "criticas".
This page tries to point out the major differences between coding for the [[Hardware|OLPC-XO]], and coding for traditional desktops. Most of the advice here is useful even for other systems, but on the XO, resource limitations and diverse deployment can make "useful" turn "critical".


= Uso de memorias y procesadores =
= Uso de memorias y procesadores =
Line 134: Line 134:




[[Developers/Stack|Previous]] [[Developers/Projects|Next]]
[[Developers/Stack/lang-es|Previous]] [[Developers/Projects/lang-es|Next]]
[[Category:Developers]]
[[Category:Developers]]

Revision as of 02:38, 31 May 2011

Previous Next

Esta página intenta apuntarte a las diferencias mas grandes al programar para una OLPC-XO, y programar en una maquina de escritorio tradicional. Las recomendaciones que encontrarás son útiles aun para otros sistemas, pero en la XO, las limitantes de recursos, y disponibilidad de drivers hacen a las cosas "útiles" se conviertan en "criticas".

Uso de memorias y procesadores

Fundamentally, the OLPC-XO hardware which is our primary target platform has only 1024 MB of storage (Flash), and 256 MB of RAM on a single-core processor. This requires developers to pay much more attention to the memory "footprint" of applications. Developers may need to adjust attitudes and make tough choices to keep the system within this footprint.

While laptops increase in power and size along Moore's Law, the OLPC project will opt for less expensive hardware and wider distribution. The Linux community has become much more sensitive to issues of "bloat", has provided internationalization capabilities for scripts, higher quality rendering and, best of all, a much wider range of applications.

Small is beautiful (and usually faster) for everyone.

Localización

The OLPC project is deploying in a large number of countries, each of which has unique cultures and languages. To be accessible to the children in these countries we have to internationalize and localize our software for each country. Regardless of which Activity stack you are working on, your project will need to be localized into potentially hundreds of languages.

Our base technology choices have been predicated on the ability of the software to achieve the best overall worldwide "user experience". This requirement drove our choice of GTK+ and Pango (with Cairo as the graphical underpinnings) as our primary GUI system. Pango's abilities in complex scripts are currently the most advanced of free software technologies.

Other development toolkits can be used: but they come at a cost in memory and flash footprint, and today, in the ability of software based on them to be localized to many of the scripts we face immediately, which include both Thai and Arabic. Including other toolkits as a standard part of our base system is therefore problematic, and experience on embedded systems show that including multiple toolkits would almost certainly cause the overall experience to suffer.

The quick summary of how to prepare your project for internationalization is to:

  • always remember that you will need to internationalize, so avoid building assumptions of culture into the activity
  • use gettext for all user-facing strings, text, icons and the like
  • use Unicode text for rendering and GUI elements

If you do that as you code, the job of internationalizing won't be finished, but it should be reasonably straightforward and won't require a lot of retrofitting.

See: Localization for extensive documentation on how to Localize your Activity See: Developing Unicode Aware Applications in Python (PDF), 31-slide presentation on how to work with Unicode See: Gettext and it's documentation Tip: You can create a fake translation with lengthy text containing non-ASCII characters. It is common to do this with Cyrillic (Russian) and Greek characters that are shaped similar to English characters. Does the text get rendered? Are any graphical elements too small? East-Asian characters may need extra height, along with some of the double-accented characters used in Eastern Europe. Right-to-left scripts like Arabic should also be considered.

Procesador

Sugar puede correr en todos los equipos, la meta es que corra en OLPC While Sugar can run on almost any computer, the target of the OLPC project is to run on extremely inexpensive machines, and particularly the OLPC-XO. As such, you need to target your projects to the constraints of the hardware. The CPU in the machines is the rough equivalent of a 500MHz Athlon processor from the turn of the century. This includes instruction set and performance.

Eficiencia

Many OLPC-XOs will have to be hand-cranked or will need to last long periods between recharges. Every erg of energy is precious.

Our power-saving approach requires the ability to put the entire machine to sleep when it's not doing anything. If your activity is constantly doing silly things the machine may not be able to go to sleep at all.

Disable your activity's operations as soon as possible (i.e. as soon as you determine that you are not needing to do any more calculation). Avoid GUI operations that are "just for show"; those which don't improve the educational experience. Try only to calculate or render in response to events, don't render 30fps if your data only changes once every 10-20 minutes.

Try not to have your activity running constantly or waking frequently, the laptop is intended to "go to sleep" as quickly and often as possible, and your activity's trivial loop may prevent that sleeping. Use asynchronous interfaces such as "select" or "INotify" rather than "polling" constantly for changes.

See: Dave Jones' paper "Why Userspace Sucks" Note that most of the particular problems identified are already being worked on, we want to avoid making similar mistakes!

Consider rewriting key sections of slow code in your high-level languages in lower-level and more efficient code. Improving the performance of your code by a factor of ten may let the machine go to sleep 3 or 4 times as often.

Modularidad es buena

Breaking out the functionality of your application into separately-loadable plugins or modules can allow for substantial memory and/or storage savings.

For example, GAIM supports just about every IM protocol in existence, but we can only anticipate 3 being common. Leaving off the unneeded plugins saves both memory and flash-storage footprint.

For Python development, 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.

Fugas de memoria

An OLPC-XO only has 256MB of memory.

Normally when programming in high-level garbage-collected languages such as Python, Javascript or Smalltalk you normally do not need to worry about garbage collection. In lower-level language development, including extensions for high-level languages you need to be more on your guard.

It is a good idea to check for memory leaks at least a few times during the development process. Sample the memory size (see Memory leak testing for instructions) 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.

Remember that every leak, however small, counts!

Almacenamiento

An OLPC-XO has 1GB of storage using a JFFS2 compressing, wear-leveling file-system. JFFS2 compression tends to provide about 2:1 compression for text and typical data, with no extra compression on already compressed data.

It is possible to install JFFS2 on a Linux machine should you feel you need particularly precise measurements of your storage usage. This likely isn't practically necessary, try to keep the size down and use the zip-compressed size as an approximate estimate of the JFFS2 storage requirement.

On flash file-systems write performance is generally slow, while random access is actually very good. 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 levelling helps flash longevity, but it has limits, and writing burns power.

Writable file mappings (via the mmap system call) may not be supported.

Pantalla

La OLPC XO tiene doble modo de pantalla, una que tiene una gran resolucion en modo blanco y negro. Cada aplicacion debe ser programada para ser usada en este modo y sus gráficas, muchas de estas son materia de escoger el modo de colores con diferentes luminosidades y altos contrastes.

La resolución efectiva en modo de colores es mas o menos menor que una en escala en grises, aun cuando el frame buffer siempre sera en alta resolución. Si tu aplicación no honra las fuentes y su ajuste al vuelo, o los contores de las fuentes cambian su pixelación, tu aplicacion no será capaz de degradarse elegantemente y requerira de ajustes manuales para ser usado. Por favor ten en cuenta esto y arreglalo.

El hardware de la OLPC-XO soporta la combinación alfa (composición Porter-Duff), así que esperamos eventualmente soportar esto tambien, pero de momento not existe este soporte.

La XO de la OLPC aun no cuenta con hardware 3D. OpenGL se puede usar, pero no esta incluido por defacto (esto inflara el tamaño de tus actividades considerablemente) y no tendrá ningún soporte de hardware. En teoría tu puedes considerar los motores MMX y Enhaced 3DNow! para proveer soporte 3D de forma modulada, pero esto es solo una teoría.

Redes

No debes apoyarte unicamente en una conexión a Internet, aunque sea rápida o estable. La latencia en conexiones satelitales puede ser extremadamente mala, así que mensajes al servidor pueden dejar tu actividad inservibles para los niños en el campo, aunque se vea perfectamente bien en otro lugar.

Las redes inalambricas de la OLPC permite la redificación entre pares, sin conexión a internet. Normalmente esto se implementaría mediante una red mesh o matriz fuera de la escuela, pero una escuela sin conexión a internet trabajaria de una manera similar.

Avahi y Telepathy-provee redes locales descubiertas por las aplicaciones aun cuando no hay una conexión activa a Internet. Intenta hacer tu creatividad usualmente en el vinculo local.

Seguridad

Tu código deberá trabajar dentro del sistema de seguridad OLPC Bitfrost. Aunque el usuario es muy transparente, de la perspectiva del desarrollador Bitforst es una forma intrusiva de asegurar la aplicación. Esto es por diseño. Para trabajar dentro de Bitfrost tu estaras comunmente pensando en las ramificaciones en cuanto a seguridad de lo que estés haciendo.

Considera cuidadosamente si tienes ciertos tipos de operación, si tu vas a necesitar marcar tu actividad con un bit especial de seguridad. Algunos de esos permisos son, por defacto, mutuamente exclusivos. Si necesitas esas funcionalidades mutuamente exclusivas, deberás implementar una actividad firmada, o una autorización explicita pue rl niño que ejecture la aplciación en su laptop.

Se te invita a leer la documentación de OLPC Bitfrost para completamente comprender los principios principales y sus enfoques.

Resumen de restricciones

Las mayores restricciones al trabajar con Bitfrost son:

  • acceso a las redes -- boolean control flag bit, if not set, no network access is possible
    • rate-limited by default
    • filtering restrictions available to protect against corruption (i.e. you can firewall your activity, in a sense)
  • file access -- by default you will have no data-file access without explicit selection by the user
    • store all user data within the Journal
    • unrestricted file access for a file-type -- by default not available if network access is available (to prevent automated uploading of e.g. all of a child's documents to an attacker), if you need both, you need to be signed/explicitly-enabled
    • constrain all file-writing to be only within the ${SUGAR_ACTIVITY_ROOT} (available as an environmental variable passed to your Activity instance)
    • file writes -- rate-limited by default to prevent flash storage exhaustion (if you are planning to stream video to flash storage, you likely need to consider this!)
  • camera/microphone access -- special flag to be allowed to ask for access, 30 minute timed access after which re-request required
  • background sound -- flag, allows for playing sounds when not the foreground activity
  • background CPU -- flag, allows for using more than a small fixed percentage of CPU while not foreground
  • synthetic X events -- flag, allows you to generate synthetic X events (mouse and keyboard, for instance) and send them to other Activities
    • if you are considering tutorials or similar tools that "run" another activity for the user, you need to consider this.

Especificando banderas:

Especificando filtros de red:

Procedimiento de registro de actividades

Previous Next