Table of Contents

Programming Languages

The thing about learning how to code is not about choosing the best language among programming languages or a future proof language, but to understand the paradigm of Imperative Programming itself. You can learn this with any (imperative) programming language. Once you have understood the general concept of imperative programming (which means a set of instructions), you can switch between these languages.

The list below is not complete, but a common list of languages.

C++

C++ is used when you want to develop as close as possible to the hardware. Think of C++ as the object oriented version of C. You will need a compiler to create binary code directly executed by the CPU. As this is directly executed by the CPU, you can use it to implement things on microcontrollers, like the open smartwatch OS I’m currently working on. If you make mistakes in your code you are likely to get cryptic messages which are harder to understand. Not so nice when you start learning to code. You also need to know the hardware to properly use it. You will have to know datatypes and allocate memory yourself.

Java

Java is further away from hardware, the compiled code in the form of byte code that runs in the Java Virtual Machine (JVM). Due to the hardware abstraction by using a JVM your compiled Java program will run on any operating system that has a JVM (which is again implemented in C++). If you make mistakes in your code, the JVM will tell you exactly in which line of code something went wrong. This is nice when you start learning to code. You have to know the datatypes, but simpler than with C/C++, and memory allocation is handled by the JVM.

Python

Python is a scripting language, i.e. the source files are run by the Python Interpreter (also written in C++). Similar to Java the interpreter better supports the detection/description of runtime errors, i.e. telling you where something went wrong. Python scripts will run on any OS that has a Python Interpreter. There are, lets say, scaled down versions of python interpreters that run on embedded hardware, called Circuit Python, so you might have the benefit of writing code that you can test on your desktop, and which runs on a Microcontroller. You don’t have to explicitly know the datatypes, this is handled by the interpreter.

Organization of code

Arduino

Arduino is a framework and a collection of libraries written in C/C++. This means Arduino is not a programming language, but a nice utility that abstracts the underlying hardware. You don’t have to remember which port map and pin registers you need to set to which value to tell a controller to set a certain pin X to input or output.

Framework

A framework is a piece of code where your code functions are called by the framework code. For example, for Arduino you have to provide the void setup() and void loop() functions. The main function of Arduino framework is nothing but:

void main() {
  setup();
  while(true){
      loop();
  }
}

Library

A library is a piece of code where *your code calls the library functions. For example the Arduino Serial library:

void yourCode() {
    Serial.begin(9600);
    Serial.println("Hello World");
}

Where do you start?

To chose a programming language you have to think about a small project that you would like to do.

You might find that you get stuck on one approach. Great! Try to switch to a different language, you will be able to carry over what you have learnt and remembered so far. Your success will greatly depend on the availability of examples and documentation. Most likely you are not the first to stumble across an error message and you will find the same question already posted online. Search engines will be your friend, or directly on https://stackoverflow.com. So if you think a programming language may be old or outdated, this means there is already tons of information to look up.

First you will be copy and pasting code a lot from others. Like painting over an existing painting. At some point you will realise the amount of copy and pasting you will have to do will become less and less, and you will need to look up things less and less, because you will learn how to navigate libraries and frameworks from within an IDE using code suggestions and autocompletions. Don’t try to remember too much. Remember how to look it up.

I still have too look up simple things as “JavaScript reverse string” just to end up on https://www.w3schools.com/jsref/jsref_reverse.asp ;).

Are the programming languages so differen?

See for yourself: http://rosettacode.org/wiki/Rosetta_Code or http://rosettacode.org/wiki/Reverse_a_string.

C++

#include <iostream>
#include <string>
#include <algorithm>
 
int main()
{
  std::string s;
  std::getline(std::cin, s);
  std::reverse(s.begin(), s.end()); // modifies s
  std::cout << s << std::endl;
  return 0;
}

Java

public static String reverseString(String s) {
    return new StringBuffer(s).reverse().toString();
}

Python

''.join(reversed(string))

JavaScript

function reverseStr(s) {
  return s.split('').reverse().join('');
}

In the end its more about knowing the language’s frameworks and libraries instead of the languages themselves (to a certain degree ;) ).