My Personal Programming Language Recommendation Shift over Time

I am developing software for 20+ years now. In the early days, I developed software in Assembler, Basic, Fortran, Pascal and C. Meanwhile my focus gradually shifted over time.

It is a very personal view, with my own language recommendations I gave over time. Languages I never recommend are missing in this article, even I actively use them in software development – like C#.

Personally, I always distinguished between script languages and compiled languages, until languages with bytecode compilers got popular.

Also, the performance of computers led to this shift. There was no way around Assembler for the Commodore 64 until the end of its era. With more power, languages like C and Perl got popular and later even Java worked reasonably well on most systems.

If you ask me today, which programming language you should learn, I will recommend you one of the ones on the right side in the diagram. In the case you already know one, I will recommend you to look at one of its successors on the right.

My recommendation always depends on the usage of the language. Developing a desktop application is a whole different task than adding some animations and interactions to a website.

The illustration above shows my recommendations for different kind of uses. If you are a complete beginner, look at how many arrows pointing to a language, if you decide which one to learn. My advice – learn Python. If you own a Mac, learn Swift. After mastering these languages, have a look at C++, Go or Rust.

In the following sections, I will add some personal thoughts about the previously mentioned programming languages.

Please note: some of the code examples are very bad examples! They illustrate the weaknesses or disadvantages of the discussed programming languages.

Assembler

Assembler has still its uses, but the scope where and when to use it got very narrow. The lack of portability is the main problem for productive use. So I write assembler code to solve optimisation problems – like timing sensitive code for microcontrollers.

Basic, Fortran, Cobol, Pascal, etc.

The time of these languages is definitely over. If you are interested in the history of programming languages, you should definitely look into these. Especially study, what is missing in these languages. Look at (missing) features like recursive calls, scopes or function parameters.

10 print spc(rnd(1)*38) "*"
20 goto 10

C

Avoid C at any cost. There are better alternatives, like C++, Go or Rust. There are situations, where you are forced to use C, like if you work on an operating system kernel or writing drivers for one.

C allows you to write very low-level code, which is great if you have to. If you are not careful or lack the required experience, you will write unsafe code. It will lead to problems with buffers and add security holes to your code.

If you read about some security hole, just have a look at the programming language which was used. You will see, C leads this statistic by far, followed by PHP and Java.

#include <stdio.h> int main(int argc, const char * argv[]) { char *buffer; strcpy(buffer, "Boom!"); // Ops... return 0;
}

Perl

Perl was never a great script language, but a mighty one. It is the reason, why it is still used on many servers to automate tasks. With a few cryptic lines, complicated operations are made possible – like magic.

Python is a very good successor of Perl. It not only replaces Perl, but it can also replace languages like PHP for web application development. Python’s powerful and extensive libraries have a solution for almost every task.

#!/usr/bin/perl -w use strict; while (<>) { # Easy to understand? ... s/<(.+?)>/[$1]/gi; print $_;
}

PHP

PHP was a language especially designed for hypertext processing. Usually, it is embedded into HTML code and executed by the web server while delivering the page to the browser. It started as a simple C like language, but over time, more and more features were added to it.

The way, how the language is used allows quick and simple results – but makes it very difficult to maintain large code bases in a secure and structured way.

Today, a large percentage (more than 25%) of all web sites using WordPress as its content management system – which is written in PHP. This is also the reason why PHP in the top three of languages causing security holes.

Instead of PHP, better switch to Python and a different approach to develop web applications. There are wonderful frameworks, like Flask or Django which may be a great alternative to WordPress in many situations.

<?php
$id = $_GET['id'];
$db = new mysql('localhost', 'xxx', 'xxx', 'important_data');
$sql = "SELECT username FROM users WHERE id = $id"; // Ops...
if ($result = $db->query($sql)) { while($obj = $result->fetch_object()){ print($obj->username); }
} elseif ($db->error) { print($db->error);
}
?>

Java

Java is still widely used, especially in enterprise environments. The language was created to solve problems of C and C++ and many other languages, removing platform dependencies and low-level code. It also introduced new problems with the byte code compiler and garbage collector.

Meanwhile most of the problems are solved, still, the use of the language is declining – the alternatives are way better.

Writing platform independent desktop applications can be done using C++ with the Qt library with fewer lines of code. Server applications using Python or Go.

The dream of real platform independent applications, using one single code base was dropped with the introduction of smartphones. Modern applications need to follow the design principles of the operating system to increase its usability.

Shared code is put into a server backend or in a library and a very thin application is developed for each operating system individually.

public class AtLeastOneClass { public static void main(String[] args) { System.out.println("Hello!"); }
}

Objective-C

Objective-C was never a nice language, but the concepts and ideas behind this mix of Smalltalk and C are great. With Swift there is a great successor of Objective-C which is a modern and well-designed language.

If you plan to develop applications for macOS or iOS, Swift is the best choice to learn. Also Apple provides an extensive documentation and learning materials for this language.

#import <Foundation/Foundation.h> @interface Foo : NSObject
- (int)changeColorToRed:(float)red green:(float)green blue:(float)blue;
@end @implementation Foo
- (int)changeColorToRed:(float)red green:(float)green blue:(float)blue;
{ // implementation return 0;
}
@end int main(int argc, const char * argv[]) { @autoreleasepool { Foo *foo = [[Foo alloc] init]; [foo changeColorToRed:0.1 green:0.2 blue:0.5]; } return 0;
}

C#, VBA and other Microsoft Languages

Avoid these languages at any cost. There are situations where you have no choice and have to use them. I recommend to limit your exposure to these situations.

JavaScript

If you create interactive web content or animations in web sites, there is no way around JavaScript. It is also an excellent language for automation tasks, where you like to embed a small script environment into a larger application to make the configuration even more flexible.

It is extensively used in web development and most of the interactive features in today’s webpages weren’t possible without it. Still, the language has many weaknesses which makes writing secure and reliable code very challenging.

As a beginner, you should start with another scripting language like Python. While it has its uses, the scope of JavaScript is too narrow.

<!DOCTYPE HTML>
<html>
<body> <script> alert('Hello world ;-)'); </script>
</body>
</html>

Python

Python is today’s scripting language of choice. It has a unique syntax which forces the programmer to write well-formatted code. It also comes with an extensive standard library, which can solve most of the problems with a few lines of code.

Modules and classes let you structure even large projects in a clear way and make maintenance a breeze. A subset of the language, as MicroPython can also be used to program microcontrollers.

It is a beautiful scripting language to learn if you like to learn software development.

The language is also a very good choice for server automation and web application backends. You can write very well behaving and secure applications easily.

def fib(n): a, b = 0, 1 while a < n: print(a, end=' ') a, b = b, a+b print()

Swift

If you develop applications for the Apple ecosystem, Swift is the language of choice. It is a modern language, which prevents many programming mistakes by design. It is simple and clear, but provides powerful constructs for advanced developers.

It is a perfect language to learn as a beginner, because of its clear structure and ease to use. The only limitation is the platform, but if you learned Swift, a transition to other languages should be easy. There is also really good and interactive learning material from Apple.

As a professional, you will like the elegant syntax of the language and the powerful constructs. There is still the strong influence from Smalltalk which lets you extend existing interfaces without touching the original libraries. Application development using Swift and Xcode is simple and fast.

import Foundation let numbers = [1,2,3]
for n in numbers.reversed() { print(n)
} func factorial(n: Int) -> Int { if n <= 1 { return n } return n * factorial(n: n - 1)
} let number = 4
print("(number)! is equal to (factorial(n: number))")

C++

C++ is the working horse language, which covers everything from low-level to high-level programming. It is a perfect choice for experienced software developers.

Recent developments with C++11 and C++17 added many great new language features, which really transformed how you use the language today. Version C++20 will add even more helpful features to the language.

With the great power of C++ comes great responsibility. It is definitely no beginner language. You can easily misuse the language, writing horrible unstructured code. The best examples of bad code are exhibited in embedded software development.

namespace lr { enum class Type { Simple, Complex,
} class Wonder {
public: Wonder() = default; bool operator==(const Wonder &other) { return _type == other._type; } bool operator!=(const Wonder &other) { return !operator==(other); }
public: Type type() const { return _type; } void setType(Type type) { _type = type; }
private: Type _type;
}; } int main(int argc, const char * argv[]) { auto wonder = new lr::Wonder(); wonder->setType(lr::Type::Simple); auto fn = [=]{ wonder->setType(lr::Type::Complex); }; fn(); delete wonder; return 0;
}

Go

The Go language was specially created to write performant and concurrent code for server environments. If you like to use the full power of a server and like to write secure and reliable code, the Go language is a very good choice.

As a beginner, you better start with Python for server applications. As soon as you understand multithreading and all its problems, the transition to Go will be pretty simple.

package main import "fmt" func sum(s []int, c chan int) { sum := 0 for _, v := range s { sum += v } c <- sum // send sum to c
} func main() { s := []int{7, 2, 8, -9, 4, 0} c := make(chan int) go sum(s[:len(s)/2], c) go sum(s[len(s)/2:], c) x, y := <-c, <-c // receive from c fmt.Println(x, y, x+y)
}

Rust

Rust is a language created for very reliable and safe software, with a focus on memory safety. It is the perfect successor for C and in some cases even of C++.

If you need to write low-level code, close to the hardware but like to write it in a safe and structured way, Rust is the perfect language for it. Also similar to Go, it is a great language to make full use of a server CPU.

use std::thread;
use std::sync::mpsc; fn main() { let (tx, rx) = mpsc::channel(); thread::spawn(move || { let val = String::from("hi"); tx.send(val).unwrap(); }); let received = rx.recv().unwrap(); println!("Got: {}", received);
}

Summary

If you starting a new project or like to learn to develop software, I recommend one or a combination of these languages:

  • C++
  • Python
  • Swift
  • Go
  • Rust
  • (JavaScript)

This list is a very personal recommendation, based on my personal experience. You may have a completely different opinion – but if you have – you probably are experienced enough to make your own choices.

If you have questions, miss some information or have any feedback, feel free to add a comment below.

Source: MakerFeed.net

Leave a Comment