DEV Community 👩‍💻👨‍💻

Donald Sebastian Leung
Donald Sebastian Leung

Posted on

An overview of programming languages (opinion)

As a Web Developer coming out of a coding bootcamp who later decided to major in Computer Science (and am currently in my second year of study), I have worked with many different programming languages over the years, ranging from beginner-friendly scripting languages such as JavaScript and Python to industry-standard C++/Java to niche functional languages such as Haskell and most recently, Prolog which is based on first-order logic. This post aims to introduce some of the languages I've learned or worked with in general terms from my perspective, including my perceived difficulty of their learning curve and how easy/hard it would be to master them.

JavaScript

Initial learning curve: Easy
Barrier to mastery: High

Being a very permissive programming language with little to no boilerplate code required, JavaScript is a go-to language for many beginners. To the untrained programmer, its dynamic, weak type system and implicit conversions seem to make perfect sense, such as the complete absence of distinction between integral values and floating-point values (after all, numbers are just numbers - why should 1 be any different from 1.0?) or the implicit conversions between numbers and numerical strings seen so often in both directions, e.g. 3 - "2" is 1 and "The number is: " + 42 is just "The number is: 42". Its prototype-based object model is also very simple and intuitive at first glance and offers a lot of freedom - you can practice classical inheritance with it or mix-and-match, adding properties and methods to objects on the fly as well as relating different objects in ways perhaps not available through plain classical OOP. However, mastering JavaScript is another question entirely. First of all, its dynamic, weak type system means that almost all errors are delegated to runtime so a valid JavaScript program can always go wrong at any moment. Secondly, the vast amounts of implicit coercion means that even seasoned JavaScript programmers could be surprised by seemingly nonsensical behavior, e.g. "" == false and false == " " but "" != " " (namely, JavaScript's loose equality operator == is non-transitive (and non-reflexive on NaN!), meaning it doesn't accurately describe an equivalence relation). Finally, the concept of prototypal inheritance is inherently difficult to master precisely because it offers so much freedom - the exact reason why ES6 and later versions were "forced" to introduce Java-like class syntactical sugar to hide the monster that is prototypal OOP beneath it (and cause even more confusion regarding Java/JavaScript as a result :p).

Python

Initial learning curve: Easy
Barrier to mastery: Medium(?)

Python is short, concise and readable in many ways, be it in terms of function definition (using the def keyword which is shorter than function, for example) or list comprehensions ([x ** 3 in range(1000)] describes an ordered list of cubic numbers from 0^3 inclusive to 1000^3 exclusive). Furthermore, Python is "batteries included". Want to list all possible permutations of a list? Use a library. Want to map, filter a reduce a list in a cool, functional style? Use a library. Want to analyze the grades of thousands of students in your university and predict their future GPAs using sophisticated machine learning techniques? Use a library! Python is also fairly permissive in terms of overloading operators and such for your own classes. Probably the only thing that makes Python difficult to master is the sheer number of built-in libraries that it contains - chances are there is some library that you've never touched upon even after working with Python for a year or two.

C

Initial learning curve: Difficult
Barrier to mastery: Easy

If you've only used (very) high-level languages so far in your programming career, get ready to have your mind bent with C. In this programming language, many of your favourite built-ins simply do not exist. Want to concatenate two strings? Sorry, there's no built-in + operator for strings - consider using the library function strcat instead (which does in-place concatenation) or roll your own. Want to find the length of an array? Sorry, there's no such built-in property/method on an array - you'll have to keep track of array length yourself. Want to append an element to an existing array like in Python (list.append(elem)) or JavaScript (arr.push(elem))? You'll have to reallocate the memory yourself if necessary and make sure that you don't go out of bounds. And being a low-level language (at least compared to, say, JavaScript/Python or even C#/Java), be prepared to debug a whole host of cryptic errors you'd never even dream of encountering in other languages - dangling pointers, out-of-bounds array indexing, memory leaks ... Even worse, you don't know which error is which most of the time - many different types of errors (such as dangling pointer and out-of-bounds array indexing) all appear as segfaults. Even the whole concept of pointers themselves which is fundamental to the C programming language will probably take you a good while to grasp. The good thing about C is it's blazingly fast - you'd never get speeds remotely close to an efficient C program in pretty much any other language (maybe except C++). Also, once you really understand the concept of pointers (and structures/unions) in C, there's not much more to learn - the only thing you have to focus on is to get even better at it.

C++

Initial learning curve: Medium
Barrier to mastery: Very High

At first glance, C++ doesn't seem too bad - the Hello World program might look a tad weird:

std::cout << "Hello World!" << std::endl;
Enter fullscreen mode Exit fullscreen mode

But then you slowly get used to it. And having way more built-ins than C such as an std::vector<T> type (like a dynamic array), an std::map<T1, T2> and an std::string means that it doesn't take very much effort to start writing small but non-trivial C++ programs. Granted, getting started with C++ is probably not as easy as starting with JavaScript, Python or Ruby but hey, you have to give credit to a programming language that's already about 35 years old!

The thing is, if you "learn" C++ that way, you'll be left completely clueless as to how C++ actually works and what you can do in C++ becomes severely limited - you'll never be able to define interesting, non-trivial user-defined types if you don't even understand how constructors/destructors work and their purpose. But in order to know C++ that way, you basically have to learn everything about C (pointers, structures, unions, static/dynamic memory allocation/deallocation) plus all those extra features that C++ brings - classes, order of construction/destruction, inheritance, static/dynamic binding, abstract classes, virtual and pure virtual functions, generic programming via templates ... you name it. It is rumoured that C++ has accumulated so many features over the years that even an advanced C++ programmer with half a decade of experience could encounter a program that he/she simply cannot understand. Perhaps one major thing about C++ is about to change though - rumour has it that the C++ committee is planning to slowly phase out raw pointers and the like starting from C++20 so future C++ programmers may be spared the pain of manual memory management and dangling pointers (which is only a very small part of C++).

Java

Initial learning curve: Medium
Barrier to mastery: Medium

If you've never programmed before, Java may give you a rather daunting impression of programming. Consider the minimal Hello World program:

// Program.java
public class Program {

  public static void main(String[] args) {
    System.out.println("Hello World!");
  }
}
Enter fullscreen mode Exit fullscreen mode

Your first questions might be: What is a class? What are all those keywords public, static and void? What are all those dots in System.out.println("Hello World!");? It all looks so scary! And the Java professor/teacher/tutorial doesn't seem to help by saying "Just ignore all of that boilerplate for now - we'll explain it later." But if you manage to get over that, you'll probably realize that Java is a rather simple language (compared to, say, C++) - there are a few primitive data types for handling numbers (byte, short, int, long, float, double), characters (char) and logical values (boolean), and everything else is an object (reference). Furthermore, Java's class hierarchy is rather simple - you have a base class Object for every object (reference) type, then every class inherits from it either directly or indirectly. And there are no weird surprises such as multiple inheritance (as seen in C++) or arbitrary operator overloading (so + only ever means adding numbers or concatenating Strings). Furthermore, Java might be rather restrictive, refusing to compile many of your programs early on, but that means that the worst runtime error you'd ever encounter would probably be a NullPointerException - no weird stuff such as segfaults, dangling pointers/references or memory leaks. Furthermore, from Java 8 onwards, it is possible to write (comparatively) short but concise (and often efficient) Java code using functional programming techniques made available by Java 8 Streams. It doesn't take too much effort to learn a sizeable subset of the entire Java specification, though as more features and syntactic sugar get added to Java (and few become deprecated/obsolete since Java aims to maintain backward compatibility), this may get harder over time.

Haskell

Initial learning curve: Very High
Barrier to mastery: High(?)

If you've been used to programming in "conventional" programming languages (which are pretty much all classical OOP languages) and want to tackle Haskell then get ready to re-learn three quarters of programming (itself!). Being strictly adherent to the functional paradigm, Haskell will force you to re-think what programming means. No more loops, no more mutable objects, no more imperative code ("do this, do that") - everything has to be done in terms of equations and pure functions, often involving advanced programming techniques such as recursion. And that is only the beginning. Be prepared to get your mind blow with algebraic data types, recursive data types, monads, monoids, functors ... A strong mathematical background and mathematical way of thinking is highly recommended for learning Haskell.

Prolog

Initial learning curve: Very High
Barrier to mastery: Medium(?)

The entire language of Prolog is based on Horn clauses, a subset of predicate logic in formal first-order logic (and the rule of inference known as "modus ponens"), so if you haven't taken a discrete maths course then you'll probably struggle hard on even the simplest of Prolog programs. However, if you manage to get through that, you'll probably find Prolog very simple, elegant, expressive and powerful - it doesn't take an expert to start writing parsers analyzing simple English sentences such as "A man eats an apple." Of course, this can be easily be extended to include analyzing proper programming languages as well (and by extension, compilers/interpreters for processing them). This is simply much more difficult to achieve in a conventional programming language such as C/C++/Java or even Haskell.


I hope this post was eye-opening. Feel free to leave your feedback in the comments! :D

Top comments (2)

Collapse
 
somedood profile image
Basti Ortiz • Edited on

As an experienced JavaScript programmer, you are definitely right about the low barrier of entry. It really helped me as a beginner to not bother myself with the differences between int and float number types. At the time, they were all just numbers to me. I would have seen no point in distinguishing between the two.

I would go as far as saying that without JavaScript, I wouldn't have understood the fundamentals of programming as effectively as I do now. Sure, I could read about C++ and all the hype around memory management and type systems as a beginner, but learning those topics would not have made me learn the actual fundamentals first (variables, functions, objects, arrays, hash tables, and the like). In fact, it would have only confused me more. I would have lost all my motivation to learn.

Collapse
 
hoelzro profile image
Rob Hoelz

Thanks for sharing your thoughts! However, I don't know if I entirely agree that C is easy to master - sure, the syntax and basic concepts of the language are simple, but oftentimes "master level" C programming involves cultivating a lot of discipline (especially around memory management), as well as learning a lot of specifics about the environment. In my opinion, a master C programmer needs to know:

  • Undefined behavior in the language
  • Hardware characteristics like caching, branch prediction, etc
  • Lots about their compiler and linker
  • Tooling like valgrind, perf, or the various sanitizers in use today

That being said, maybe my definition of master differs from yours - I'm thinking of the people working at Google coming up with things like the retpoline Spectre mitigation! I definitely agree that C++ requires more time to master than C - because you need to learn all of the C++ stuff on top of what I just listed!

Image description

Join the One Year Club

You can earn this badge by being a registered member of the DEV Community for at least one year. Create an account and get started today.