On March 7, 2017, Microsoft released Visual Studio 2017 and with that, support for the seventh version of the C# programming language. C# 7.0 adds support all kinds of new features including Value Tuples, Pattern Matching and Nested Local Functions. With each new version, the language keeps growing with new features. Since it’s conception 16 years ago, features were added for functional programming, parallelism, asynchronous programming and more.
C# of course isn’t the only language that offers a broad range of functionality to developers. Most modern languages used today offer developers a lot of functionality. One could argue that, while these new features provide value, it becomes harder and harder to know, understand and apply the full potential of a programming language. You also often don’t need all functionality. Therefore, one could say the languages are bloated and it might be better to keep a language simple and concise.
The subject of the richness of a language and the effects of it is also covered in George Orwell’s book Nineteen Eighty-Four. In this book, the totalitarian regime created the language Newspeak. It has a very restricted grammar and vocabulary, created to limit the freedom of thought and self-expressiveness. The state keeps removing words and making the language simpler to make it impossible for residents to express unwanted thoughts. For example the word bad doesn’t exists, only ungood.
Back to the real world. Can you imagine how difficult it would be to explain something if you only have a limited grammar and vocabulary to use? If you use a programming language that only have limited possibilities, would it make your code look clearer or would it just be more verbose and ambiguous? Will it make your job easier or harder?
I believe that having a rich set of grammar and vocabulary at your disposal is a good thing. It allows you to express your intentions better to both other developers and to the computer. After all, a programming language is a language like any other one. The more powerful a language is, the better one can express himself in a clear and unambiguous way with all nuances needed. This in turn improves the quality and maintainability of the code.
From time to time, you hear about tools that allow you to create solutions without writing code. I don’t believe in programming/designing in a visual tool without writing code. Drawing some boxes and arrows just isn’t powerful enough to clearly express your intent and create solutions for more complex problems. You’ll end up with something that is a lot harder to understand, maintain and works as expected. The same applies for Test Automation tooling that doesn’t need programming knowledge. Which is nice for very simple scenario’s, but isn’t usable as soon as it becomes more complicated (hint: it will become more complicated).
Of course, constantly adding features to a programming language can add a burden to developers. You might feel that you have keep up and know about everything that a language offers. But nobody forces you to use all features of a language. You only need to care about the ones that are valuable in your situation.
Just like design patterns, features of a programming language are things that you can use if applicable. Using them is not a goal on its own. We as developers sometimes feel tempted use these cool new features as soon as we learn about them, even if they don’t really add value in that situation.
When you do use a feature of the programming language, make sure that both you and everybody working in the same code base thoroughly understand the ins and outs of it. This prevents subtle bugs or unwanted side effects from being introduced to your code. You can use coding guidelines to define when and how use should use a feature. Code reviews can help you to make sure your implementation is understood by others.
I‘m glad that programming languages keep adding new features and borrow ideas from each other in order to evolve. It’s a good thing because it allows developers to better express their solution for a problem and offer solutions for problems that developers face. A programming language is a language can is used to communicate and restricting its functionality restricts the developer. Beware to not use them just because you can, but because they help you to communicate your intent clearer and more concise. Using the valuable parts that a programming language can offer in your situation help improving the quality of your code. +1 for powerful, feature rich programming languages!
This blog was written by Harm Pauw.