Monthly Archives: May 2014

Why I consider Debian to be one of the best OSes for beginners

As I promised, I’ll tell you why I prefer Debian over other distributions and why I’d advise it as a starting platform for Linux beginners.

I’ve wanted to start using Linux some 4 years ago. I’ve been in a school where informatics teacher was in charge of setting school PCs, including some in public usage. Those were often raided by students who’d put porn pics on a desktop, set pornsites as homepage and do all kinds of other nasty things. Apparently, he wanted to experiment with some kind of public-available PC that’d be resistant to those attacks, so once he put some kind of Linux distribution with full-screen Opera in kiosk mode on one of public PCs. This worked as a charm – it’s hard to change desktop background picture when there’s no desktop or change settings that are unchangeable in kiosk mode. I, just being curious, asked him what the distribution was, and he said it was Debian.

Some time after this, I installed it on one of my PC and started experimenting with it. I broke things a lot, and therefore got to fix them a lot. That’s when I learned the basic principles – like, there are video cards that just do not work in Linux. No matter what the vendor is. Hope this will change, but nowadays it’s not really likely to – there will still be incompatible laptops, for example.

Then I got a not-so-fast Intel board with no possibility to upgrade the GPU/CPU. It really wasn’t anyhow fast for desktop, and I decided to make a server on it. The only suitable place for it was hard to reach and it also had video driver problems under Linux – so I didn’t have any other option than to live without GUI and had to use SSH. It was kind of hard but I eventually got Samba installed – even though I couldn’t have set up passwords properly =) Thank god nobody looked through my files… Or so I think ūüėČ But I had a file server and tried to improve it actively to suit my needs.

The board broke after some time, due to my hands that were kind of unsuitable for any hardware modifications back then. I was left without a server and any experimentation possibility. It was so until my friend called me and explained he needed a 3G router for one 10 day long event, the day after that. We both were kind of broke those days, so there was no possibility to buy/rent a factory one. So, I needed to set up a gateway with a possibility to use USB modem as an uplink – something I never did before, and all this just in one night. I didn’t promise anything but decided to try, and it just appeared that Internet has all sorts of tutorials about almost everything, and Debian configuration seemed to be a well-covered topic. So, my gateway was ready and I even managed to get some sleep. That was impressive for me as it showed just how easy things are.

After the event, I left the gateway working as my own home router and it appeared to work, and was stable enough… Until I messed everything up again =) I had to reinstall things multiple times, but every reinstall was a cleaner one, I understood installation options better and each time the system was more and more stable. It lasted for around two years at a final state, just working (c). I reinstalled it once again, and finally it’s both working and not a mess of services, unused packages and downloaded files.

Now, I have enough knowledge – but it wouldn’t be so if I didn’t experiment with real things =) And reinstalls both saved time to repair and taught me how and what to backup.
Would I have gotten that all experience, using some other distribution?

Probably, no. Debian has everything you’d demand from a Linux distro for both novices and average users, maybe even professionals:

  1. Easy installation (lacking from many distributions).
  2. Clean structure with hardly any fixes needed, which’d have taken a lot of my time when I was a beginner.
  3. Large community – that means tons of tutorials available and being made, and people that are glad to help.Friendly environment – things are mostly as simple as they can be, but no more simple that is necessary
  4. Good package system – it was hardly needed to compile anything during these 3 years, that would sure add some problems,
  5. Being a stable system – unlike Ubuntu, I mean. Even though it’s a derivative from Debian, they seem to like breaking things from release to release. And Debian maintainers seem to be way more mature in this field.
  6. Being both desktop system and server system at the same time – only one button during installation divides those two things. Therefore, you know that you can easily resign from using desktop environment, and it’s somehow encouraging.
  7. Having different release types – you won’t be dealing with unstable software on a server or with outdated software on desktop. An upgrade from one release to another is flawless most of the times.
  8. Old enough to have well-developed philosophy about how things should work.

Some of those pros are good for novices, some – for experts. And if a distribution is suitable for people of many different levels, it means you stay on the same distribution all the time and get used to it. That does save time and effort. And it’s certainly better to be pro at some well-structured distribution than to have entry-level knowledge in many.

So – every of those qualities Debian has is really important for both learning and usage. That is why I’d advise Debian to any novice in Linux – nothing else has this exact set of qualities, and those qualities are just too important to dismiss any of them.

Use assert() carefully!

Please, don’t¬†use Python ¬†assert(statement) for things¬†other than debugging in any more or less significant script.

Python compilers have optimisation modes. Those modes make code run faster by stripping down some¬†things that are not really necessary for the code to function. For example, those are function¬†docstrings – they’re omitted in optimisation mode just for the sake of optimisation.
Python interpreters also have a boolean called __debug__ that is defined by the compiler inside each script executed. It cannot be changed by the script itself. It is set as True all the times except for optimisation modes, where this boolean is False. Why we need this boolean? Just you wait.
Originally, assert was thought as a tool for the debugging. Actually, it still is. How does it work? Well, the original function’s code looks like this:

def assert(expression):
    if __debug__:
        if not expression: raise AssertionError

So, if __debug__ is False, there might be no¬†AssertionError raised where you expect it. Let’s see a small¬†script that the officers of some top secret nuclear attack site use:

#Used mainly for preparing tea 
#Nukes everybody if argument "nukeeverybody" is given
import sys
import nuke
import tea
    assert(sys.argv[1] != "nukeeverybody") 
except AssertionError:
    teacup = tea.Tea(volume="cup")
    our_nuke = nuke.Nuke(target=nuke.targets["everybody"]) #OH MY GOD
    our_nuke.prepare() #WHY THIS
    time.sleep(3) #WE'RE GOING TO DIE
    our_nuke.launch() #At least we used objects where they were really aproppriate

Suppose that somebody made all the technical officers at the rocket silo recompile all their Python interpreters so that by default they use the optimisation mode. Then¬†one of them wants some tea and launches… Assert behaves as if the statement is True, even though it isn’t.¬†So the code passes straight to the “else” block and the code there gets executed…

Until time.sleep(), as “time” isn’t imported ūüėČ Still, nuke is prepared for the launch, who knows,¬†what bad could happen due to that. Also, officers don’t get any tea.

Don’t use assert for things like checking arguments and such. It wasn’t prepared for anything other than testing and debugging and thus may misbehave on other occasions.