Coffee Space


Language Rant

Preview Image

Previously I discussed an idea I had regarding implementing a new programming language. I have been thinking about that article more, and whether there is really anything to be added in that space.

This morning I am in a little bit of a ranting mood after having programmed in Python till 2am last night, and have decided to express some ideas on here. These items are by no means exhaustive and there could be a part two in the near future.


In Python, scoping is achieved like so:

0001 def func() :
0002   if something == summin :
0003     do_stuff()
0004   return # This is good practice in Python IMO

In C++, you might have something like so:

0005 void func(){
0006   if(something == summin){
0007     doStuff();
0008   }
0009   return;
0010 }

Both do essentially the same job, but one is robust against random new line characters (Unix’s \n vs Windows’ \n\r), one is robust again space vs tab , one can be split over multiple lines without potentially changing the execution entirely - and so on.

Until any of these things become standard, writing a programming language that entirely depends on these things is asking for trouble.


In Python you can have a variable that changes type during execution, like so:

0011 variable = 67 # 67 int
0012 variable = str(variable) + ".9" # 67.9 string
0013 variable = float(variable) + 1.1 # 69 float

Whilst the example is contrived, getting an unknown type from some function far away from the code you are currently operating on is not. I’m sure some Python guru reading this will say “well yes, but you can just do X…”. The point is that it’s not standard.

Having everything un-typed was supposed to make things “easy”, but as you can see, whilst easing the ability of variable declaration and assignment, you lose a lot of conceptual structure. You can quite easily get bitten by some random variable not being of the correct type.

In something like C++, such errors would be caught at compile time:

0014 int variable = 67; // 67
0015 variable = std::to_string(variable) + ".9"; // Compile error

You have to make quite an effort to mix types. And as for easy of declaration, newer versions of C++ allow for stuff such as:

0016 auto variable = 67;

That’s all for now folks… Until the next rant.