Archive for the ‘coding’ Category

The religion of programming

Tuesday, November 13th, 2007

I had to look up religion on webster to check exactly what it means.

Main Entry:
re·li·gion Listen to the pronunciation of religion
Pronunciation:
\ri-?li-j?n\
Function:
noun
Etymology:
Middle English religioun, from Anglo-French religiun, Latin religion-, religio supernatural constraint, sanction, religious practice, perhaps from religare to restrain, tie back — more at rely
Date:
13th century

1 a: the state of a religious <a nun in her 20th year of religion> b (1): the service and worship of God or the supernatural (2): commitment or devotion to religious faith or observance2: a personal set or institutionalized system of religious attitudes, beliefs, and practices3archaic : scrupulous conformity : conscientiousness4: a cause, principle, or system of beliefs held to with ardor and faith

re·li·gion·less adjective

 

 

Probably a better definition would be a set of irrational beliefs which have absolutely no scientific /  logical basis. But then again webster could not have a definition like that since it would piss off too many people.

 

Religion in the programming world raises its ugly head time and time again, mainly in the threads to show why language X is better then language Y.

 

Ussually the reasons given are rather comical. Well more people use language X. Yah well 100 years ago most people rode arround in horse drawn buggies, does that mean that a buggy is better then a motor car ?

 

Or language X is very easy to learn. You can learn it in 24 hours. It has a simple syntax. Yepper that is a good reason to use language X. Shit how come  Mario Gabriele Andretti  do not drive a tricycle. It is much easier to learn how to drive a tricycle then it is operate a racing car.

 

It is best that you know many languages. Each language is better for certain tasks. PHP is good for web programming, but IMHO lacks when it comes to the properties that perl and python have when it comes to general purpose tasks.

 

Looking at quirky languages like lisp or scheme can teach you a lot. You learn a whole different perspective of doing things. One of the most narrow minded attitudes people have is if they can not see an immediate use for the knowledge, they consider it a total waste of time. It has been said that you should learn one new language a year. It is like an investment often you will not use this knowledge for many years but the investment will payoff 10 fold easy.

 

People often tell me, how much computers have changed in the last ____ years. The truth of the matter is that they have changed very little. Most of our so called modern programming languages have thier roots from fortran and lisp which are over 50 years old. The only thing that has changed is that computers are smaller and faster. The truth of the matter is that men like Bool, Turing, Babbage envisioned a machine that could crank out massive amounts of calculations, and most importantly could be programmed to solve the task at hand. All of us have them temptation to buy a book on programming since it is “new”, “modern” talks about the new language ______ . The truth of the matter is most algorithms where developed over 30 years ago.

 

We all have the natural tendency to think that what ever tools we are using are the best. I try to keep and open mind, but often my own prejudice sets me back. Just remember when you look at the merits of certain languages it is not a religion. The only hell you will experience is one of your own creation :)

The need for faith, (the mental state of programming)

Thursday, October 25th, 2007

A long time ago I was talking to a right wing christian. He was explaining to me about his religion etc. He told me I should read the bible etc. I told him I had read the bible many times. Some where in the conversation he found out I was a programmer. He then made the statement. “You would not understand about faith/miracles, computers are logical”.

I then tried to explain that computers are anything but logical, in order to be a good programmer you have to have a lot of faith. The simplest computer is nothing more then a toggle switch, it contains 2 states, off/on , 0/1 etc. If you attach a clock to that switch you have a computer. A very simple computer. You line up 32 of those switches you can store your telephone number. But when you have millions of these switches it becomes extremely complex.

With something like a Fibonacci series it is not possible for me to calculate the next number in the series unless I know the previous number. So unless I know the previous 99 states I can not determine the 100th state. The same principles can be used to create pseudo random generators etc.

Your PC probably has components from over 1000 manufactures. Its operating system has millions of lines of code, that has been written by 100s of people. The applications well …. . And somehow all of this functions and works together 99.9% of the time. As a programmer you will use API constantly to communicate to the OS, other apps etc. It is like a black box. I give it stuff and magically it will give me what I want back. I do not know the inner workings of this black box, just this is what happens. And the right wing christian accused me of not having any faith, or believing in miracles. It is a miracle computers even operate :)

There are very few books on actually how to program. Most of the books are just abbreviation of some programming languages specification manual, ussualy full of poorly written code examples. And then some drivel about how to use function XXXXX, often with incorrect information. Again here we can draw lessons from the bible :). In the story of jesus and the centurion, because the centurion is important man initially he sends one of his servants to go talk to jesus. But then the centurion knows that these servants will probably fuck it up. So he decides he better go talk to jesus himself, find out what the true story is :). And so the same in coding, even the API sometimes lies, always if in doubt look at the source code if possible. The source never lies :)

As king solomon said, there is nothing new under the sun. And so the same hold true today. All ideas are just old ideas recast with new wrappers. People used to ask me at parties what I do for a living. Being the prankster that I am I would reply I am a magician. And then I would tell them (i stole this from some book i read a long time ago, and forget which one).

I create objects at will, I make them appear and disappear :).

I have been accused of never leaving concrete examples, and so I shall :)

A good example is the internet.

On the simplest levels it is nothing besides a bunch of electrical pulses going allong a wire (0/1).

But on a hardware level for sake of organization these pulses are put into “packets”.

But these packets do not really exist, they are just something router/hardway guys invented.

But for the programmer these packets are a pain in the ass, and hard to work with, it is much better for them to view the packets as a “stream”. As in the internet is like a water pipe, and when i turn on the tap (socket) data flows out, and when i turn if off the data stops.

And so you may ask, which way is the best to envision the internet. Should it be views as a stream or packets. (Like the arguements is light a wave or a particle :) ).

And light, the answer depends on what you are doing.

If you are designing an application that does not do real time, (example an irc type chat proggie, email etc) then the stream answer is the correct one.

But lets say you are doing a real time app. (example VOIP) when fractions of a second make a difference, and you have to deal with the latency of the packet. Then you need to use the packet analogy.

When i had to do voip work, i would picture then internet in my head as a road, along the road where vehicals, like cars, trucks, buses etc. And all of these vehicals where going to all sorts of different places. Sometimes there where accidents (net work collisions) bus runs into a car :). At the intersection of these roads are like policemen (routers), these policemen send the cars to the proper place. But sometimes the policemen are taking nappy time :).

When i had to make like none real time apps i picture the net as an oil refinery with like thousands of pipes. Big pipes, little pipes. And connecting the pipes are all sorts of valves etc. Or sometimes a rivers (depending how I feel).

Each application you make you make different type of picture in your head, depending on what you need to do.

Well i guess looking at it, my concrete example was not so concrete after all :).