jump to navigation

Someone asked me about programming languages February 27, 2017

Posted by PythonGuy in Uncategorized.
trackback
I won’t post the question or the context. I don’t think it’s too important. The response I wrote follows.
It’s hard to describe what it is a programming language is supposed to be.

Imagine you were an engineer in charge of designing a bridge. You want to build a bridge that goes from point A to point B and can carry a certain amount of weight and such.

Now, of the umpteen billion possible bridges you can build, you’re going to settle on one design. When you choose what makes that particular design the “best”, you’re going to factor in things like the cost of materials, the kinds of technology the local construction companies have available to them, what kind of maintenance will be performed, etc…

Programming languages are like bridges. They go from point A (ideas in your head) to point B (actual running code.) When you consider what programming language to use, you are not so interested in whether the programming language can do the job because they all can, as long as they are Turing complete. You’re going to be interested, instead, in things like how much work it takes to make the program, who is available to maintain or extend the code base, and what you will have to do to find and fix bugs that may or may not arise in the future.

Of all the attributes of a programming language, the most important to me, after programming my whole life and spending 17 years being paid to program, is complexity. If your programming language is complex, then I know it’s going to be really hard to write a correct program, very hard to maintain, and it will cost a lot of money to find people smart enough to keep it working.

But a programming language can be too “simple” as well, meaning that there aren’t enough features that I would like to have available. For instance, Lua is a great, simple language, but it is too simple and doesn’t handle some stuff that other languages provide, and I find that very annoying. And the simplest language of all? Machine code. It’s so simple even CPUs can understand it.

It’s all about balance.

When I talk about “Vanilla C” vs. “C/C++”, I am describing a problem I saw arise in the C/C++ community. C itself is a rather simple language, pretty well-defined with only a few weird cases that arise rarely. The subset of C I call “Vanilla C” is plenty to get any job done right the first time. It takes quite a bit of work, and you have to be a bit verbose, but it gets the job done. C/C++ introduce a number of new concepts designed to make my life better, but it just ended up making my job harder. I saw teams write down rules about “Please don’t use feature X” and such. It seemed every new thing brought in by C++ was disfavored, except namespaces, and even then, it would be confusing.

The reason people use C at all nowadays is for speed and simplicity. Well, now that CPUs are not the bottleneck for the vast majority of problems we are challenged with (even video games!) C or any of its cousins are not the solution we are looking for. Besides, we learn in college that oftentimes, the issue is we’re using an O(n^2) solution when a pretty good O(n) solution exists, so no amount of C code in O(n^2) will make that beat Python in O(n) with sufficiently large numbers.

And one more thing: When you write Python, you can have the computer compile it down to the same thing as C, and make it run as fast as C. And with JIT, some algorithms are even faster.

The world has changed a lot since the 90s. It’s time to embrace the new paradigm shift where the programming language can do a lot more work for you, all without creating a very complex system.
Advertisements

Comments»

No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: