Welcome to Principles of Software Engineering, where I, Jon Crain, self-taught programmer and ex-Facebook employee write about Software Engineering.
After you choose the correct programming paradigm for your project, your next step is to pick a language. We'll talk about considering domain, popularity, and organizational inertia.
The first thing to consider when picking a language is your domain. As I discussed in the paradigm article, if you can't tolerate arbitrary delays in processing, you cannot pick a language with garbage collection. Most object oriented languages like Java, Javascript, and Python fall under this category. As an example if you're designing medical equipment or a radar system, you need a language with manual memory management so you can control exactly how and when your code executes. This typically meshes with the imperative programming paradigm.
In this case, I would typically choose C++. It's the most popular language with manual memory management, it supports object oriented programming if you desire or need it, it has a massive community, and there are a lot of professional developers familiar with it.
You could also consider a low-level language like C or Rust. I would normally choose C++ over C in general, as C++ is backwards compatible with C whereas some of the constructs in C++ don't exist in C. Rust is a newer language that is becoming popular for low-level, especially concurrent programming. Concurrent programming is a particularly difficult domain, as it's not easily predictable how code is executed coming from a sequential world. Having a good concurrency model in the language you use is essential, and both C++ and Rust have good options available to minimize bugs.
If you're not in a life-critical domain, which is true of most industries, going with a garbage collected language is probably a worthwhile trade-off. While there may sometimes be small pauses in execution, it simplifies the job the programmer has to do and prevents an entire class of memory allocation and freeing bugs which comes with manual memory management.
After you've decided whether you want manual or automatic memory management, the next most important factor is popularity. This may sound strange to choose over other technical factors, but in the real business world, being able to hire developers familiar with your language will reduce bugs and time to train new programmers. What is important about a language is not just the constructs of the language itself, but the ecosystem of the language. Most of the heavy lifting in your software, if you have competent engineers, comes from libraries. As a rule the more popular a language is the more high quality libraries are available.
Java is one of the most popular programming languages for a reason. It's battle tested, scalable, has excellent debugging tools, and portable. It comes with a small overhead of running on a virtual machine, but with just in time compilation the overhead is quite small. The benefit of running on a virtual machine is portability, which few other languages offer. It has an extensive ecosystem, and strong concurrency models for high performance. The only drawback is the one I mentioned above, garbage collection, and performance when compared to low level language. These drawbacks are irrelevant to most applications.
C# is very comparable to Java, and a recently fashionable choice. I would probably make the decision between the two based on how many engineers I had familiar with each.
Python is a popular programming language, especially for machine learning and data science. It has massive ecosystems in those areas, think PyTorch or TensorFlow. Even if you want your ML to run faster, you typically code in Python and then your framework executes low level functions in C, so you get the nice (in my opinion) syntax of Python with the performance of C. Compared to Java at a technical level it has less boilerplate, which can be nice for quickly iterating on ideas.
Javascript is actually the most used language, given its dominance of web development. It's the only really popular language supported in all modern browsers so it's not even a choice to use it if you want to do web development. It definitely has some quirks, so I wouldn't probably use it outside of the context of web development.
Golang is a newer language gaining some popularity. I would generally recommend against using it, unless it solves a compelling technical problem another language cannot, as it still doesn't have the developed ecosystem of the above languages.
PHP, Ruby, Perl and Scala all fall into this category of not recommended for large projects as well, I wouldn't pick them without a very good justification. These languages all have their proponents and some advantages, but as I said when the rubber meets the road, you need to be able to hire quality engineers which are hard enough to find as it is, and get them ramped up when you need to scale your business. You can make these languages work, or any language that's Turing complete work, but I think you're adding unnecessary friction.
I would also consider inertia, that is, what does your company already use? Every language you add to your company decreases standardization, decreasing engineer mobility between projects, and making devops and operability more difficult. If you're considering adding a project in a new language, you need to make sure the benefits of that language justify adding that complexity to your engineering organization.
Hopefully this article gave you some things to think about when choosing a programming language.
Enjoyed this article? Tip me on gofundme.
© 2023 Jon Crain. All Rights Reserved.