Wednesday, January 05, 2005

Bricks and Programming Languages



Let us compare the choice of a programming language required to construct a software product, to that of bricks required to construct a building.

A high-level programming language is like a set of bricks that are of larger size than ordinary bricks. So, by using a high-level programming language you can construct a software faster, than you can with a low-level programming language. That's because, the amount of bricks you need to construct a building, is conceptually equivalent to the amount of lines of code you need to write, to build a software product.

But by using bricks that are of small size you have more control and can build quite intricate designs using them. Now, you can do the same thing using blocks that are of larger size, but you will need to have blocks that are specifically meant to get that kind of intricate looking design.

Similarly, a high-level programming language needs to provide language constructs that allow you to implement behavior that you would have to otherwise put sufficient effort into to implement using a low-level programming language (Pause and recall implementing a while loop in assembly).

I find the analogy between programming languages and bricks interesting because as computers become faster (in accordance with Moore's Law), new programming languages would continue to be invented which are more closer, than those that preceeded them, to how humans need to be communicated the solution, than how machines need to be.

Consider automatic garbage collection, which is a great productivity booster for example. All the recent programming languages, like C# and Java for instance, support automatic garbage collection, while none of the older programming languages did. Thus, these languages can be considered to be at a higher level than some of the older programming languages, like C/C++, which do not provide an automatic garbage collection facility.

The skill and effort saved by choosing a high-level programming language can be better utililized to build more beautiful software.

2 comments:

Abhimanyu said...

Nice observation. But, I wonder what made you think on those lines.

Sid said...

The analogy between architecting software and architecting buildings is an old one. I first came across the analogy in Grady Booch's foreword to the classic book on design patterns by the gang of four in which he referred to Christopher Alexander idea of a pattern language for architecting buildings and cities.

Oh no... maybe I first came across the analogy in one of Stallman's essays where he said that a program would grow like a city... old parts would get broken and new constructed...

I liked the analogy so much that lately I even changed the name of my blog from "#define _TechBlog_" to "City of Code".