Developers/Stack: Difference between revisions
(Begin writing real introductions.) |
(Finish the primary reshuffling/restructuring) |
||
Line 2: | Line 2: | ||
There are a number of approaches (software stacks) to develop software for the OLPC environment. The stack you choose will strongly influence what type of [[Developers/Setup|setup]] you need and what your actual development process will look like. |
There are a number of approaches (software stacks) to develop software for the OLPC environment. The stack you choose will strongly influence what type of [[Developers/Setup|setup]] you need and what your actual development process will look like. |
||
= Basic Platform = |
|||
The normal OLPC Operating stack looks approximately like this: |
|||
* [[Hardware]] -- normally an OLPC-XO, but could be another Linux machine that happens to have Sugar installed |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
** [[Telepathy]] -- inter-machine RPC and presence engine |
|||
⚫ | |||
* [[Software components]] |
|||
= Activity Development Stacks = |
|||
This section attempts to describe the major Activity development stacks available in the OLPC Sugar environment. |
This section attempts to describe the major Activity development stacks available in the OLPC Sugar environment. |
||
= EToys = |
== EToys == |
||
[[EToys]] is a Smalltalk development environment running on the Squeak virtual machine. Smalltalk is an "old" teaching language, that is, it has been in use for decades, and as a result has a huge body of components and pre-built content and resources that can be used to create new activities. |
[[EToys]] is a Smalltalk development environment running on the Squeak virtual machine. Smalltalk is an "old" teaching language, that is, it has been in use for decades, and as a result has a huge body of components and pre-built content and resources that can be used to create new activities. |
||
Line 11: | Line 26: | ||
The EToys environment is easily scripted via GUI interactions, and components have access to the all of the special hardware features on the laptop. You can often create fascinating projects and useful demonstrations with just a few mouse clicks and bit of simple logic. |
The EToys environment is easily scripted via GUI interactions, and components have access to the all of the special hardware features on the laptop. You can often create fascinating projects and useful demonstrations with just a few mouse clicks and bit of simple logic. |
||
See ??? to start using EToys to develop for the OLPC. |
|||
⚫ | |||
⚫ | |||
Sugar includes a Mozilla-Firefox-derived (Gecko) [[Web|Web Browser]] Activity. This browser includes HTML, XHTML, Javascript and SVG support. You can set up simple web-servers on a laptop using Python, or children may access an application hosted on a public web server (but keep in mind that children often have very poor connectivity). |
Sugar includes a Mozilla-Firefox-derived (Gecko) [[Web|Web Browser]] Activity. This browser includes HTML, XHTML, Javascript and SVG support. You can set up simple web-servers on a laptop using Python, or children may access an application hosted on a public web server (but keep in mind that children often have very poor connectivity). |
||
Line 17: | Line 34: | ||
You can develop for this platform with no particular hardware or setup, and can test using regular Firefox during initial stages. It is easy to port work from elsewhere into this stack, and easy to export your work for use outside of the OLPC project. The environment is, however, rather constrained, without access to most of the special hardware or software components on the laptop. |
You can develop for this platform with no particular hardware or setup, and can test using regular Firefox during initial stages. It is easy to port work from elsewhere into this stack, and easy to export your work for use outside of the OLPC project. The environment is, however, rather constrained, without access to most of the special hardware or software components on the laptop. |
||
== Browser Component == |
=== Browser Component === |
||
The built-in Browser is actually just a thin wrapper around the Gecko control. You can use the Gecko control yourself and create web-browser derived activities, either using XUL or Python/PyGTK to instantiate the browser. This gives your Activity access to system services and hardware, at the cost of considerably more complexity. |
The built-in Browser is actually just a thin wrapper around the Gecko control. You can use the Gecko control yourself and create web-browser derived activities, either using XUL or Python/PyGTK to instantiate the browser. This gives your Activity access to system services and hardware, at the cost of considerably more complexity. |
||
See ??? to start using XULRunner/Web Control to develop for the OLPC. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
Python and GTK based activities are the "standard" way to write software for the OLPC. Using Python and PyGTK is strongly encouraged so that the "View Source" button will normally show the same language whereever the user invokes it. The use of the same language throughout also means that code can often be factored out of one project to be shared with another. |
|||
On the Sugar platform, PyGTK has access to the following major support libraries: |
|||
⚫ | |||
* Cairo -- high performance postscript-like library for drawing vector graphics, with the RSVG SVG-rendering library |
* Cairo -- high performance postscript-like library for drawing vector graphics, with the RSVG SVG-rendering library |
||
* Pango -- flexible text layout system capable of dealing with complex internationalization issues |
* Pango -- flexible text layout system capable of dealing with complex internationalization issues |
||
* |
* [[D-BUS]] -- inter-process communications |
||
* Telepathy -- inter-machine |
* Telepathy -- inter-machine RPC and presence management with network traversal and discovery logic (activities are encouraged to use Tubes where practical) |
||
⚫ | |||
⚫ | |||
* NumPy -- high performance numeric analysis and array-handling |
* NumPy -- high performance numeric analysis and array-handling |
||
⚫ | |||
⚫ | |||
* IPython -- enhanced interactive Python interpreter with syntax highlighting, command-completion and the like |
|||
* Xapian -- full-text text-search engine |
|||
⚫ | |||
GTK Controls: |
|||
in addition to the Python standard library. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
* [[Evince]] Control -- PDF and EBook-reading control |
|||
* [[#OLPCGames|Pygame]] -- game development engine based on SDL (see OLPCGames), not exactly a control, but close... |
|||
in addition to the Python standard library, which includes rather a lot of built-in functionality. One key inclusion is the SQLite database engine, which provides a basic single-user SQL database which can be used by activities for storage. |
|||
⚫ | |||
Activities can use compiled Python extensions which are installed into their Activity directory. This can be used to provide access to the core of not-normally-Python activities you are porting. See [[#Low Level]] for more on this. |
|||
Official description of the [[Software components]] on the laptop (XXX maybe merge this into that page, we want links to further information about each library, though?) |
|||
You may also consider rewriting areas that profiling say are problems in your activity as C extensions. This can save both processor load and memory depending on the nature of the extension. Keep in mind, though, that premature optimization is generally not a good idea; code first, optimize later. |
|||
Development Languages: |
|||
See [[Sugar Activity Tutorial]] to develop in Python (with PyGTK) for the OLPC. |
|||
* Python is strongly encouraged, to have a single language "under the hood" when the curious child looks inside |
|||
** C/C++ should be used where Python performance is unacceptable, but try to keep it to a minimum, preferably as standard well-encapsulated and documented components |
|||
* Smalltalk-speaking developers may wish to work within the eToys environment |
|||
* Javascript can be used in web-based applications (Gecko or Opera engine Javascript implementation) |
|||
⚫ | |||
GUI Environments: |
|||
[[Pygame]] is a high-level wrapper around the C [[SDL]] library, which provides low-level support for developing games. Pygame allows you to easily create raster (pixel-based) graphics for games with reasonable performance thanks to SDL. |
|||
* PyGTK or the PyGTK-derived [[OLPC Python Environment| Sugar]] system should be used for most "Window, Icon, Mouse, Pointer" type GUIs. Note, however, as of 2007-04-21 that the Sugar "graphics" package is in Flux. |
|||
* [[Pygame]] SDL-based 2D game environment can be used for "Canvas" graphics using "Sprites". |
|||
* (Mozilla) XULRunner can be used to develop Gecko-based activities |
|||
* [[EToys]] |
|||
[[OLPCGames]] is a Python package which allows you to create Sugar Activities using Pygame with access to the special features of the laptop. |
|||
Operating Stack: |
|||
See [[Game development HOWTO]] to start using Python, Pygame and OLPCGames to develop for the OLPC. |
|||
* [[Hardware]] |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
Libraries/modules/services of note: |
|||
Sugar includes the Gnash engine by default, and the Adobe Flash playing engine can be installed. At the moment we do not have a Flash authoring tool that can be distributed on the laptops, however. If you have Flash-based content, it may be possible to simply run it on Gnash on Sugar. |
|||
⚫ | |||
* Telepathy (Glib, Salut, Gabble) -- collaboration/communications engine with "Tubes" (cross-machine RPC over DBus) and various network traversal and discovery logic, activities are encouraged to use Tubes where ever practical |
|||
⚫ | |||
* Abiword -- collaborative text editor/word processor usable as a GTK widget that can be embedded in other activities |
|||
* [[SQLite]] -- lightweight relational database |
|||
* XULRunner (with Python DOM-capable bindings) -- Gecko 1.9 (Firefox 3.x) engine |
|||
⚫ | |||
⚫ | |||
== Low Level == |
|||
Common libraries not available: |
|||
Being a regular Fedora 7 Linux machine, the OLPC-XO can run regular Linux i586 executables. However, integration with the Sugar shell is currently a non-trivial exercise. It is often easier to wrap your C/C++/Assembly/Whatever activity in a Python wrapper than to attempt to implement the entire [[Low-level Activity API]] yourself. |
|||
⚫ | |||
⚫ | |||
* If you are unsure whether something is supported, ask, or load up an emulated machine and check for the presence of the library |
|||
See also [[Developers/Setup#Emulation for Compilation/Experiments|Emulation for Compilation]] for a tip on how to compile using emulation |
|||
Testing/working: |
|||
= Common Libraries Not Available = |
|||
* Announce your project on the [http://lists.laptop.org/listinfo/devel OLPC devel list] so that people know what you are working on and duplication of effort is reduced |
|||
* Add your project to the [[Software projects]] page |
|||
While the Sugar environment is rich, it cannot include every possible library or extension and still fit in 200MB. The following extremely common libraries are '''not''' available by default: |
|||
* Test your application in an official image (or a physical laptop) before publishing broadly |
|||
* To conserve memory or improve performance, consider replacing problematic areas in your Python code with C. For example, a [http://dev.laptop.org/ticket/1303 rewrite of the hardware manager service] in C saved 1.8 megabytes of private dirty memory. On a machine with only 256 megabytes of RAM and no swap space, efficient use of memory can make the difference between a usable system and a system made unreliable by out-of-memory failures. |
|||
⚫ | |||
* Distribute your source code under the GPL, LGPL or MIT license. |
|||
⚫ | |||
* When ready to test with real users add your activity to the [[Activities]] page to allow for easy download and installation |
|||
* Qt/KDE |
|||
* Gnome |
|||
[[Developers/Setup|Previous |
[[Developers/Setup|Previous]] [[Developers/Projects|Next]] |
Revision as of 21:08, 14 December 2007
There are a number of approaches (software stacks) to develop software for the OLPC environment. The stack you choose will strongly influence what type of setup you need and what your actual development process will look like.
Basic Platform
The normal OLPC Operating stack looks approximately like this:
- Hardware -- normally an OLPC-XO, but could be another Linux machine that happens to have Sugar installed
- Firmware -- the XO uses Open Firmware
- Fedora Core 7 based Operating System
- Bitfrost -- Security System
- D-BUS Services -- various platform-specific services (most XO-specific hardware/operations are exposed via D-BUS)
- Telepathy -- inter-machine RPC and presence engine
- Sugar -- GUI Shell (desktop)
- Software components
Activity Development Stacks
This section attempts to describe the major Activity development stacks available in the OLPC Sugar environment.
EToys
EToys is a Smalltalk development environment running on the Squeak virtual machine. Smalltalk is an "old" teaching language, that is, it has been in use for decades, and as a result has a huge body of components and pre-built content and resources that can be used to create new activities.
The EToys environment is easily scripted via GUI interactions, and components have access to the all of the special hardware features on the laptop. You can often create fascinating projects and useful demonstrations with just a few mouse clicks and bit of simple logic.
See ??? to start using EToys to develop for the OLPC.
Browser
Sugar includes a Mozilla-Firefox-derived (Gecko) Web Browser Activity. This browser includes HTML, XHTML, Javascript and SVG support. You can set up simple web-servers on a laptop using Python, or children may access an application hosted on a public web server (but keep in mind that children often have very poor connectivity).
You can develop for this platform with no particular hardware or setup, and can test using regular Firefox during initial stages. It is easy to port work from elsewhere into this stack, and easy to export your work for use outside of the OLPC project. The environment is, however, rather constrained, without access to most of the special hardware or software components on the laptop.
Browser Component
The built-in Browser is actually just a thin wrapper around the Gecko control. You can use the Gecko control yourself and create web-browser derived activities, either using XUL or Python/PyGTK to instantiate the browser. This gives your Activity access to system services and hardware, at the cost of considerably more complexity.
See ??? to start using XULRunner/Web Control to develop for the OLPC.
Python/PyGTK
Python and GTK based activities are the "standard" way to write software for the OLPC. Using Python and PyGTK is strongly encouraged so that the "View Source" button will normally show the same language whereever the user invokes it. The use of the same language throughout also means that code can often be factored out of one project to be shared with another.
The support for writing activities provided by the core Sugar system (which is itself largely written in Python) is almost always exposed first through Python libraries. On the Sugar platform, PyGTK has access to the following major libraries:
- Cairo -- high performance postscript-like library for drawing vector graphics, with the RSVG SVG-rendering library
- Pango -- flexible text layout system capable of dealing with complex internationalization issues
- D-BUS -- inter-process communications
- Telepathy -- inter-machine RPC and presence management with network traversal and discovery logic (activities are encouraged to use Tubes where practical)
- NumPy -- high performance numeric analysis and array-handling
- CSound -- acoustically modelled sound-synthesis engine (seen in the TamTam activity)
- GStreamer -- general purpose media streaming platform, used for accessing the video camera and playing media
- IPython -- enhanced interactive Python interpreter with syntax highlighting, command-completion and the like
- Xapian -- full-text text-search engine
- Avahi -- discovery and advertising mechanism for mesh-hosted services
GTK Controls:
- Web Browser Control -- Gecko 1.9 web browser as a simple embeddable control with Python DOM access
- AbiWord/AbiCollab Control -- AbiWord word processor as an embeddable control with the ability to collaboratively edit with another user
- Evince Control -- PDF and EBook-reading control
- Pygame -- game development engine based on SDL (see OLPCGames), not exactly a control, but close...
in addition to the Python standard library, which includes rather a lot of built-in functionality. One key inclusion is the SQLite database engine, which provides a basic single-user SQL database which can be used by activities for storage.
Activities can use compiled Python extensions which are installed into their Activity directory. This can be used to provide access to the core of not-normally-Python activities you are porting. See #Low Level for more on this.
You may also consider rewriting areas that profiling say are problems in your activity as C extensions. This can save both processor load and memory depending on the nature of the extension. Keep in mind, though, that premature optimization is generally not a good idea; code first, optimize later.
See Sugar Activity Tutorial to develop in Python (with PyGTK) for the OLPC.
OLPCGames
Pygame is a high-level wrapper around the C SDL library, which provides low-level support for developing games. Pygame allows you to easily create raster (pixel-based) graphics for games with reasonable performance thanks to SDL.
OLPCGames is a Python package which allows you to create Sugar Activities using Pygame with access to the special features of the laptop.
See Game development HOWTO to start using Python, Pygame and OLPCGames to develop for the OLPC.
Flash
Sugar includes the Gnash engine by default, and the Adobe Flash playing engine can be installed. At the moment we do not have a Flash authoring tool that can be distributed on the laptops, however. If you have Flash-based content, it may be possible to simply run it on Gnash on Sugar.
Low Level
Being a regular Fedora 7 Linux machine, the OLPC-XO can run regular Linux i586 executables. However, integration with the Sugar shell is currently a non-trivial exercise. It is often easier to wrap your C/C++/Assembly/Whatever activity in a Python wrapper than to attempt to implement the entire Low-level Activity API yourself.
See also Emulation for Compilation for a tip on how to compile using emulation
Common Libraries Not Available
While the Sugar environment is rich, it cannot include every possible library or extension and still fit in 200MB. The following extremely common libraries are not available by default:
- OpenGL/MESA
- Server-based relational databases (MySQL, PostgreSQL)
- Qt/KDE
- Gnome