Underscores, camels and insane madness of modern programming styles

So, I went over several articles related to programming style, after I noted that basically every modern project uses some special formatting, which even if I am familiar with, I never liked.

I decided to take programming styles little bit more in a detail from technical perspective and made some interesting conclusions.

In past, when GNU project started, most of programmers followed the so called “ISO” style (which is known as Allman see wikipedia) which I kind of like, even if I could think of better one.

This style uses opening and closing bracket for every function on separate line, for example

void Foo(int Bar)
    printf ("%i", Bar);

Unfortunatelly this style has two disadvantages. I love that allman style put brackets vertically on same position – that makes it just perfectly simple to “parse by eyes” and you never get lost in brackets, unfortunately, GNU does pretty weird indentations, probably because old code was developed in 85×24 terminals, so they really needed to keep it low on width.

Nowadays, most of programmers like to write code using style that makes the code “cute” but awfully hard to read, error prone and ineffective.

It’s not just that K&R put brackets in a way, that you can save one line (like if that was actually needed), but can’t figure out which bracket matches which. But also the letter cases are pretty weird. I discovered this great post: you really should check it out. It perfectly describes pro’s and cons of camelCase over underscore_name and I can tell you, I can see why most of respondents changed their mind after reading the article. Underscores, are clearly better in almost everything, and only argument why camelCase is better was “it is more cute”.

I think this kind of reflects the modern programming trends. Programmers, instead of making effective code, write cute code…

Even if I am not a big fan of Microsoft, I must say that code they use in their examples and Visual Studio has modern and very effective styling which I find extremely easy to read.

They basically use NormalCases and vertically matching brackets for everything, as well as 4 spaces to indent. Which indeed need more space than GNU’s 2 spaces, but make the code easier to read on modern screens with high resolutions. So no matter how people blame Microsoft for everything, this is a style I like and probably going to use in most of my projects, no matter of language. It may not be “cutest” but at least it makes the code easy to read.

Why do I hate python

Some people who know me, might have noticed that I am not really a big fan of python. To prevent myself from repeating the reasons why over and over again, I will try to summarize it here.

How I see python

I can’t really say that I hate python that much as long as it is being used as a scripting language, because that is IMHO what python is. Just like bourne shell can be useful to implement simple scripts, while it’s definitely not a best choice, for example to write some server application (not that it wouldn’t be possible), python is also useful tool when someone needs to write a simple script in order to automate some stuff. It however, isn’t really a best choice for large solutions, which many people use it for these days (such as GUI applications, large projects etc). I will try to explain why bellow:

Interpreted language

Python is an interpreted language, that means it requires interpretor for it to run. That brings several disadvantages:

* It is slow

At least for some tasks it will always be slower than compiled binaries. Even for simplest “hello world” you will need to load a number of libraries and python executable just so that it reads your script from storage, parse it (compile if you like), evaluate and process. That requires a huge number of cpu instructions which will always be overhead.

* It eats a lot of memory

Again, you need to load lot of stuff you wouldn’t need for binary + python comes with Garbage Collector (useful for programmers – they don’t have to deal with memory management) which naturally causes programmers to often write a shitty code (let me explain this: imagine you are writing a code in c++, you allocate memory for some object, then you no longer need it, but even if you don’t intend to, you still hold reference to it somewhere, and you even access it. That will crash your application because when you delete it, this reference will point to invalid memory, so your application crashes right away and you know you have a problem and you fix it, however if you are working with garbage collectors, it will know you are holding a reference, so that it will not delete the memory and your application will just silently leak memory, you will have problem, you will likely not find it out and your application will suck). Also it seems to me that python handles memory pretty poorly because even very simple objects need to consume far more operating memory than they would need in other languages. For example, every single variable in python is an object which needs to contain information about its type, because it’s dynamically typed language, which requires more memory than in any static typed language.

* It brings more dependecies

Every system you want to run the application on, requires the interpretor. While many linux distributions come with python, Microsoft windows and most of UNIX platforms (HP-UX, AIX, Solaris) do not. For all of them, you need to install python.

* It makes it harder to identify your process

Because in fact you never have a process of your own. It will be python’s executable that will run. So tools like killall will just not work.

This all applies to all interpreted language, not just python, that’s why I don’t like any interpreted language to be used for large solutions


Is most ugly syntax I have every seen for a programming language, seriously, even brain-fuck looks better to me. But this is very personal opinion, many people feel opposite about it.

I don’t like that python forces you to use specific indentations, other languages that use brackets give programmers more freedom. They can choose style they like. In python everyone must use same style, like in some totalitarian fashion.

The way how classes are defined is absolutely un-failsafe and probably causes heavy troubles to many programmers.

The syntax itself is full of various restrictions and writing anything in python makes me feel like if I was moving in a mud. I basically have to be careful about every space, bracket and colon because in python it may have some special meaning, different than somewhere else in source.

It’s nothing new

There are many interpreted languages out there, which are IMHO even better and better supported, like perl. I don’t know why people still need something new, when we already have that and it works.

No static typing

Python is strong typed, which takes away the freedom you should have, but dynamically typed which gives you the freedom where you shouldn’t have it, that means you do not declare what types are you working with statically in machine code, but it’s dynamically decided during runtime. While this may seem to be a good thing to some beginner programmers (they can declare variable x and assign any object to it), it’s pain in ass for more experienced ones. So I have this code:

# x didn’t exist so far
x = a + b;

Now tell me what the hell these variables are? I don’t even know from the code if I am declaring x here, or assigning to it. In order to find out answer to what type a and b are, and if x is being created or assigned, I have to browse through possibly huge source. That really makes things hard.

def foo(bar):
# now 400 lines of source code follow

Tell me, what type is “bar” and what type does it return? Hm, maybe I will just have to read these 400 lines of code to figure out…

Handling OOM issues gracefully on linux

I figured out that there is almost no simple way to handle situation when your system is running out of memory. There is a subsystem called OOM killer implemented in the kernel, but that thing is truly dangerous. You probably never want to get your system to point when it is being used, because it might leave the system in unusable state.

For this reason I created a tool that allows everyone who uses linux to handle this kind of situation gracefully, it’s called terminator daemon, and it watches the system and eventually kills specific kinds of processes, which can be easily defined by an administrator.

You can find more about this tool on

Basic idea is, that when your system is running out of memory, this daemon will pick processes that can be “safely” killed without any impact on system and takes them out according to your settings. You can even prevent it from killing certain processes, for example: If you were running mysql server, you probably wouldn’t care about interactive shells being killed, but you would care if mysql was killed.

In such situation you can tell terminatord to never kill mysql, but other “user processes” can be safely killed.

In addition you can even set terminatord to execute some command on every kill, for example it can send you a mail that something wrong is going on with your system.

There are several examples on GitHub, here I copy pasted some of them:

Kill all processes that use more than 400mb of ram, except for user apache and root

# get uid of apache
grep apache /etc/passwd
# let's say apache is user 20, now we test it
terminatord -dvvv --soft 400 --hard 420 --ignore 20 --dry
# if everything is ok
terminatord -d --soft 400 --hard 420 --ignore 20 --kill

Kill random processes in case that system has less than 100mb of free ram, except for root

# test it
terminatord -dvvv --ssoft 100 --shard 60 --quiet --dry

Combine both examples, in this example unlike the previous one, apache processes will not be killed, when system go OOM

# let's say apache is user 20, now we test it
terminatord -dvvv --soft 400 --hard 420 --ignore 20 --shard 60 --ssoft 100 --dry
# if everything is ok
terminatord -d --soft 400 --hard 420 --ignore 20 --kill --shard 60 --ssoft 100

Installing oracle 11i (12c) on debian sid (6.0)

Somehow it happened that I decided to try out oracle on latest linux kernel and debian system.

I horribly failed.

In order to make you not fail, here is a guide what to do in order to install it

1. Install necessary packages

apt-get install build-essential libaio1 gawk ksh libmotif3 alien libtool lsb-rpm make gcc libsc-dev libxp-dev

This is probably not needed:
2. Update /dev/shm

Oracle requires shared pool to be present there, but latest linux is using /run/ to store it – this is dangerous and you should reboot your server once you finish (you only need to do that if /dev/shm points to /run/shm)

sudo rm /dev/shm
sudo mkdir /dev/shm
sudo chmod 1777 /dev/shm 

3. Change the system limits

Write the following options to the /etc/security/limits.confce file:

oracle soft nproc 2047        
oracle hard nproc 16383
oracle soft nofile 1023
oracle hard nofile 65535

Add the following to /etc/pam.d/login to validate parameters /etc/security/limits.conf:

session required /lib/security/        
session required

Make sure you have this in your /etc/sysctl.conf file:

sysctl -p:         
# sysctl -p
kernel.printk = 4 4 1 7
kernel.maps_protect = 1
fs.inotify.max_user_watches = 524288
vm.mmap_min_addr = 65536
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
fs.file-max = 65535
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65535
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144

4. Change some more links

ln -s /usr/bin/awk /bin/awk        
ln -s /usr/bin/rpm /bin/rpm
ln -s /usr/bin/basename /bin/basename
mkdir /etc/rc.d
for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d ; done

5. Create user credentials

addgroup oinstall        
Adding group 'oinstall' (GID 1001) ...
# addgroup dba
Adding group 'dba' (GID 1002) ...
# addgroup nobody
Adding group 'nobody' (GID 1003) ...
# usermod -g nobody nobody
useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle
# passwd oracle        
Password changed.
mkdir /home/oracle 
chown -R oracle:dba /home/oracle

6. Change dash to bash

# if you see this:
ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Mar  2 18:07 /bin/sh -> dash
# do this:
sudo su
cd /bin
rm sh
ln -s bash sh
# These links needs to be created as well to fix problems with makefiles
sudo su
mkdir /usr/lib64
ln -s /lib/x86_64-linux-gnu/ /usr/lib64/
ln -s /usr/lib/x86_64-linux-gnu/libc_nonshared.a /usr/lib64/
ln -s /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a /usr/lib64/
ln -s /usr/lib/x86_64-linux-gnu/ /usr/lib64/

Now you can install oracle using their universal installer. If you don’t have GUI, you need to create a response file. Don’t forget to bypass system checks, because the version of libraries used by debian is too new for oracle

About me

Hi all,

So I decided to start writing some interesting articles occasionally, and this one is my first, so I will introduce myself a bit.

My name is Petr Bena, I am an open source developer and in real life I work as a sysadmin.

I am heavily involved in wikimedia project, where I serve as a “community  developer” (non-paid guy who is helping out with many software projects) and I am also volunteering on many other wikimedia projects.

Beside wikimedia, I am working on Pidgeon – open source irc client which I decided to create because I just couldn’t find a good cross-platform irc client 🙂

If you want to find out more personal information about me, have a look on this wikipedia page:

If you are lazy to click the link, here you have some personal information:

I live in Europe, I like coca-cola and czech beer. I don’t like czech politicians. I have 1 cat and 2 tomcats 🙂 and I like them more than they like me. And the most important thing – I like star wars (who doesn’t? :P)

Thank you for reading my blog