Archive

Archive for December, 2011

Case-insensitive identifiers

23.12.2011 Leave a comment

Recently I came across Jeff Atwood’s article about the idea of case-insensitive identifiers. I think this is an interesting idea, here’s why.

Why have case-sensitive identifiers at all? Function names, variable names, object member names. Having two variables in your program which overlap in any scope, whose names differ only by case is generally a bad idea. To somebody who tries to read and understand the program, they are indistinguishable, most likely they are a programming error or a remainder from an older version of the code. It would probably be a good idea for statically typed languages to forbid two variables of the same name differing only by case.

Let’s take dynamically typed languages, such as Python or JavaScript. One of their advantages over statically typed languages is that they allow faster development cycle, because there is less text needed to write a program so source code is more concise.  More concise source code is statistically easier to read and review and therefore maintain. However the disadvantage of dynamically typed languages is that the variables references are not checked during compile time, but resolved in run time. Hence it is easy for bugs to hide in Python or JS programs – the kind of bugs that can only be detected in run time in very specific situations.

Let’s consider the following function in Python:

class Vector:
    def __init__(self, x, y):
        self.x = x
        self.y = y
def AddVectors(v1, v2):
    return Vector(v1.x+v2.x, v1.y+v2.y)

Most of the time there won’t be a problem with it, but sometimes the caller may pass malformed input (e.g. input read from a wrong file) and the function will raise an exception. That’s the drawback of dynamically typed languages.

But in some code path the programmer may just make a mistake:

class Empty:
    pass
v1 = Empty()
v1.X = 1
v1.Y = 2
v2 = AddVectors(v1, v1)

This program will obviously fail with an exception. It is a programming error, but does it have to be?

I argue that no, it should not really be a programming error. This kind of bug may be very annoying if it occurs in a rarely traversed path, and causes rare, unnecessary crashes for the end user.

Because using two variables differing only by case should be avoided as it leads to confusion and therefore bugs, it would actually be useful if identifiers in dynamically typed languages were case-insensitive.

This problem does not directly apply to statically typed languages, because all variable references are resolved during compile time, so the programmer has the opportunity to catch all spelling errors before the program is executed for the first time. It would still not hurt if the compiler (say for C++ or Java) did not allow two variables differing only by case – this would lead to cleaner and better code.

Categories: Computing

Are we alone?

12.12.2011 Leave a comment

Once in a while a theory pops up that questions whether Earth is special for whatever reason. After all we know that our planet is just a speck in the vast depths of the Universe, but as of today we have no proof that life ever existed anywhere beyond Earth.

Is there life anywhere else in the Universe?

Elements which are basic building blocks for the life as we know it are abundant in the Universe. Water is everywhere, we have evidence that it’s on the Moon, on Mars and various other planets and satellites in our system, not mentioning comets. It’s essentially trivial to create membranes of which living cells are composed by taking a bunch of chemical compounds and shocking them with electric current. Give these processes billions of years and mono-cellular organisms will likely evolve.

Mars may have harbored life in the past. Certainly it had liquid water an may still occasionally have it. In a matter of decades we may find out whether it did have life indeed.

Europa (Jovian moon) is thought to have liquid ocean underneath the icy surface. One day we may find out whether there is anything living in it or not.

So out of 12-15 bodies in our Solar system (planets and satellites) there are three or four which have or might have harbored life.

During the recent few years we learned that at least half of stars harbor massive planets. And this is just through observation under certain conditions – the axis of the planetary system of the observed star must meet conditions for us to notice the movement of the star. We can’t notice smaller planets yet. So it’s safe to assume that most stars have complex planetary systems like ours.

Our Galaxy contains 200-400 billion stars. That means that there are probably a trillion planets or satellites. 10% of those may have conditions for mono-cellular life.

So definitely life exists beyond Earth and it’s abundant in our own Galaxy. In addition to that, we estimate that the observable Universe contains 100 billion galaxies (10^11) and the total size of the Universe is not known (may be one or two orders of magnitude bigger). The odds for extraterrestial life existence are quite high!

Do extraterrestial civilizations exist?

We estimate that a star like ours lives for 10 billion years. It took 5 billion years for our Civilization to appear on our planet. Multi cellular organisms had 1-1.5 billion years only, before our planet may not have had conditions necessary for them – we are not really sure, because most of the surface of our planet was recycled due to plate tectonics.

Should a terminal event not occur 65 million years ago, maybe dinosaurs would eventually evolve a civilization? Well, life on our planet had at least two chances to evolve a civilization.

If life is so abundant in our Galaxy, that there may be 10 billion of planets or satellites on which life may have abound, and many of these bodies may have had billions of years to evolve a civilization, then it becomes quite clear that there may be plenty of planets that will produce a civilization in their life time. How many bodies exactly? Millions? Billions? We can’t estimate right now due to lack of statistical data… but they must be abundant.

After a civilization leaves their planet, life will remain on it and continue evolving. So potentially a single planet may produce more than one civilization.

If extraterrestial civilizations are so abundant, why haven’t they contacted us yet?

This question is also known as the Fermi paradox.

It took 5 billion years for us to appear on Earth. We started putting together something that could have been called an early civilization only a mere few thousands years ago. The real transformation started about 200 years ago and it speeds up ever since, exponentially. The means of communication 200 years ago are today considered primitive. The means of communication used today will also be considered primitive in a few tens of hundreds of years. So the aliens may not even know how to contact us, that’s how fast our technology is changing.

Besides, we may not be interesting to be contacted at all! We are as interesting to contact for them as fish are for us. I’m not saying we are edible to them. We have nothing to offer for them, just like we have nothing to offer for humans 100 years from now. We are not that much different from any other creature that lives on this planet after all, we haven’t really managed to produce intelligent beings able to sustain cosmic conditions and explore the Galaxy. Plus we cause a lot of suffering to ourselves like other mindless animals. Our systems, corporations, governments, politicians, are resource driven (money).

Given how rapidly our technology changes today, in a few tens or hundreds of years we may change significantly. Maybe then we will be worth to be contacted, or maybe we will find out their existence and be willing and able to contact them ourselves.

Categories: Universe