Posts

Packing executables

One of the biggest challenges with embedding platforms is the limitation related to file sizes. Here is the hint how to make executables smaller - strip them and pack them: strip is a tool from GNU binutils , it discards symbols. Usually the platform toolchain has one. upx is an excellent executable packer. Can be downloaded as binary or sources from the UPX sf.net site . As an example, I'll show you the packing of Python 2.6.7 binary: $ ls -s --block-size=KB python 6493kB python $ strip -s python $ ls -s --block-size=KB python 1696kB python $ upx --best python                        Ultimate Packer for eXecutables                           Copyright (C) 1996 - 2010 UPX 3.05        Markus Oberhumer, Laszlo Molnar & John Reiser   Apr 27th 2010         File size         Rati...

Compiling Python: Modules/Setup

A little hint for Python developers who use it for embedded or unconventional platforms (like Cray supercomputers if you're lucky): it can be compiled and used without any dynamic libraries. I've got the problem with stripped libc.so - some Python shared object (like _socket.so ) try to use it, but can't find anything because it's stripped. The only choice I had is using Python without these shared objects. Fortunately, Python support it out of the box. After configuring it, you can use Modules/Setup file to set up which modules have to be compiled within the Python binary: The build process works like this:  1. Build all modules that are declared as static in Modules/Setup,     combine them into libpythonxy.a, combine that into python.  2. Build all modules that are listed as shared in Modules/Setup.  3. Invoke setup.py. That builds all modules that     a) are not builtin, and     b) are not listed in Modules/Setup, and   ...

Embedding Python

Just want to share some useful links about embedding Python to your C-based application: the main article:  Embedding Python in Another Application additional article that shows peculiarities of multithreading, sockets and shared memory: Embedding Python in C/C++ ( Part1 , Part2 ) Cython (or Pyrex ) can be used to reduce handwritten code for Python interoperability: A quick Cython introduction If you have doubts about Python size, there are some minimal implementations: see Embedded Python article. Let me quote tinypy : tinypy is a minimalist implementation of python in 64k of code ... What more could you possibly want?? a pony? However, I highly recommend to use classic CPython implementation (basically because it has a huge number of contributors and supporters, and has an excellent documentation). It can be stripped up to 1-2 megabytes depending of your requirements.

Introduction to ReviewBoard

Image
Review Board is a powerful web-based code review tool that offers developers an easy way to handle code reviews. It scales well from small projects to large companies and offers a variety of tools to take much of the stress and time out of the code review process. Review Board is written in the Python programming language and makes use of the Django web framework. Installation   Install auxiliary packages if needed and all its dependencies: $ sudo apt-get install python-setuptools $ sudo apt-get install python-svn $ sudo apt-get install python-subversion $ sudo apt-get install apache2 $ sudo apt-get install libapache2-mod-python $ sudo apt-get install git Clone the ReviewBoard package and install it: $ git clone git://github.com/reviewboard/reviewboard.git $ cd reviewboard $ sudo python setup.py develop Also install post-review tool: $ sudo easy_install -U RBTools Set up the required site for the ReviewBoard (for Apache/SQLite backend, otherwise - see Cr...

Your Language Sucks (and about PHP again)

I've found a good wiki-article about programming languages faults and want to share a link:  http://wiki.theory.org/YourLanguageSucks . The "winner" is PHP as usual, but Python is also noticed (as well as Ruby :) ). I agree with almost everything there, but in my own eyes Python is still the best choice for programming. Nevertheless, I also want to point out some other recent links related to PHP (I really shouldn't but just can't help doing it): PHP Sucks PHP Must Die What are the horrors of PHP? What factors during the development of PHP contributed to it being such a poorly designed language? And a quote from the interview with Rasmus Lerdorf  (the creator of PHP): I don't know how to stop it, there was never any intent to write a programming language [...] I have absolutely no idea how to write a programming language, I just kept adding the next logical step on the way.

Facebook and PHP

There is a common mistake about "If everybody use it, so I also have to use it - millions of people can't be wrong". Apparently, they can, and huge codebase, support and knowledge mean nothing, otherwise we would still use Fortran, Cobol, Basic and other almost died monsters. Also there is an another common mistake about "If big corporation use it, I also have to use it". It's very doubtful, almost always decision are made in hurry and/or by wrong people and/or without serious consideration. And after some period of time, it's difficult to nullify previous decision because it would require huge efforts. Good example - Facebook. Let me quote the presentation  HipHop for PHP Tech Tasting : PHP is problematic for Facebook: High CPU usage High memory usage Reuse of PHP logic in other systems Extensions are hard to write for most PHP developers But huge codebase, strange affection towards PHP (in what universe "loose typing and universal ar...

Python vs JS vs PHP for embedded systems

UPDATE (07/18/17): The original article was written in 2011 and pretty much outdated, I've updated the numbers and conclusions. I've got a question about which programming language is preferable for the website development for embedded systems (with limited resources). Here is my small investigation in a table form. Please note that the question was about only these 3 programming languages - there are better candidates for the embedded systems now (for example, Rust). The Memory and Performance overhead numbers are based on the n-body benchmark and calculated as relatives to "C gcc #4" measurements. Python 3 Node.js PHP Memory Overhead x7.62 x29.04 x8.53 Type System Strong Typing Weak Typing Weak Typing Vulnerabilities 220 1411 5626 Performance Overhead x78.31 x2.82 x30.12 Documentation Excellent Excellent Average C Bindings Excellent Average Poor Code Readability With PEP8 it can be almost perfect ESLint enforces very good style PEAR Coding Stan...