Introduction to programming languages. What are they and what are the differences? Which ones should lawyers learn?

Introduction to programming languages. What are they and what are the differences? Which ones should lawyers learn?

Much like real (or ‘natural’) languages, there are hundreds of programming languages with great differences between them. However, instead of using them to communicate with other human beings, programming languages are a set of instructions that help us communicate with computers. They are universal, meaning that a code written by a Spanish programmer in one language would be understood by an Indonesian programmer who knows that language – there are no ‘regional’ varieties, and fortunately, no accents. However, not only do computers not understand natural languages, but they themselves also do not understand programming languages, as they natively only understand ‘binary code’ (a sequence of 1’s and 0’s called binary digits or ‘bits’). Below is a simplified example of how computers read a code we instruct it with.

We can see that the code had to first be compiled (‘translated’ in simple terms) so that the CPU (the central processor of a computer) can directly understand it and output our desired value “Hello Lawyer!”. In the past, people were programming while engaging directly with sequences of binary code, and although there are still circumstances in which someone might want to do that, it is much less common. Programming languages are also differentiated by the so-called ‘high and low level’ spectrum. A lower-level language is a language closer to a machine-like code being understood by the CPU, while high-level languages (i.e. Python, and Java) have to be interpreted, and in return, are easier to understand as their syntax is clearer (they contain actual readable words). However, it is also important to note that high-level languages take longer to reach the hardware (the CPU) and are, therefore, slower. TheCodingLawyer tutorials will mostly focus on high-level languages, but it is important to understand how low-level languages work and that they have to go through various layers of interpretation or compilation to reach the processor. Additionally, lower-level languages (i.e. Java or C++) allow for better memory management, enabling us to decide the ‘size’ of our data. On the other hand, higher-level languages like Python do it automatically for us, which can be viewed both positively or negatively, depending on the project and we are working on. For those interested to learn more about this topic, I recommend the following two videos: [1] and [2].

HTML and CSS – are they programming languages?

Many of us might already know that something like HTML (Hypertext Markup Language) or CSS (Cascading Style Sheets) exists, or even have perhaps learned about them before. Both of them are the building stones of most of the internet’s websites. When programmers mention a programming language, however, they will most likely never refer to either CSS or HTML. HTML is a markup and format-structure language and CSS is a style-sheet language, both can be perhaps labelled as a coding language, since we are, in fact, interacting with a code, but we are not writing a program of any sort (and hence, they are not programming languages). To be more specific, HTML is responsible for providing the actual content (such as images or text) of the website, whereas CSS is responsible for its presentation and style. Programming languages, on the other hand, dictate a function of the code we are writing.

Illustrations similar to the above are often used as a part of many tutorials, but they are, in my opinion, not quite accurate. Since HTML provides the actual content (while CSS does not do that), then HTML should be portrayed as not only the skeleton but all of the clothes, the skin, the muscles, the hair and so on. CSS then styles the properties of all those to get the final presentation (i.e. haircut, hair colour, muscle volume, skin tone).

In other words, HTML and CSS are used to create the visual content of websites, and both are used regardless of what other languages a website was written in. HTML and CSS are collectively (along with JavaScript as explained below) referred to as the ‘front-end’ of the website, where ‘back-end’ is the content invisible to users (such as databases).

What are the different programming languages?

Source: iStockphotos

According to Wikipedia’s list of programming languages, there are now over 700 of them (both historical and those in use). Good news is that knowing what the major five do is for the most part more than enough. The main reason that there are so many is simply the fact that most are used for different purposes. Some are easier to write and learn but are slower in execution, some are more difficult to write and learn, but are faster (as shown above). Nearly all of the existing languages can be used for any purpose, but because that would be inconvenient, people use different languages fit for different purposes.

Below is a simple infographic I made regarding the most used programming languages. I also included for each of them a demonstration of their syntax for the exact same desired result: the output of the words “Hello Lawyer!”.

Syntax example:

console.log('Hello, Lawyer!');

Syntax example:

#include <iostream>
using namespace std;
int main()
{
    cout << "Hello, Lawyer!"; // std output stream
    return 0; // exit status
}

Syntax example:

print("Hello, Lawyer!")

Syntax example:

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

Syntax example:

<?php
echo "Hello, Lawyer!";
?>

Below is also an interesting table showing which languages do the most famous websites use (HTML and CSS is not included, as that is given for nearly every website in the world).

WHICH CAN BE THE MOST USEFUL FOR LAWYERS?

To answer this question, we first have to look at what lawyers might want to achieve through programming. It is indisputable that much of what lawyers do on a day-to-day basis entails dealing with often lengthy documents written in natural languages (i.e. English). We are, therefore, looking for programming languages that are suitable for natural language processing, machine learning and some degree of automation (i.e. to classify documents according to their topics) – such purposes can be collectively labelled as AI. The most common languages for this kind of purpose are either C++ or Python. As described above, Python is, however, much easier to learn due to its simple syntax. Although it does indeed run slower than C++, as far as personal document automation and natural processing are concerned, it is better to spend less time on coding where speed is not the most important value (we are talking about a couple of seconds, not minutes). Additionally, many libraries that Python can use (think of libraries as modules that someone else wrote and we can use them) attempt to implement C-like performance, enabling us to develop a hybrid of the two (sometimes called a Cython).

Python is also used instead of PHP and Node.js (a JavaScript back-end environment) to develop websites. The most common frameworks called Flask and Django (the former being easier to learn) allow for a webpage or web application to be developed fully through Python.

Furthermore, Robert Ambrogi, a lawyer and legal tech journalist, has asked in 2017 the following question on his twitter: “For lawyers who want to learn to code, which language should they start with? Python?” Most of the responses did, indeed, recommend Python as the first programing language to begin with:

Mostly of the responses did indeed recommend Python, mainly due to its simplicity and availability of resources.

To conclude, Python is becoming more popular among professionals who wish to pick up learning a programming language to automate some of their day-to-day tasks. Due to the language’s syntax, the growing online Python community and the availability of resources and libraries, learning to code in Python is very easy. For the above reasons, most of the programming tutorials on this website are/will be focused on Python learning (alongside HTML and CSS). I will, however, further add more regarding basics of other languages such as JavaScript or C/C++.

Here is also an interesting video showing which programming languages were popular at each year since the 1965.

2 thoughts on “Introduction to programming languages. What are they and what are the differences? Which ones should lawyers learn?

  1. Reply
    Nn
    June 20, 2020 at 8:44 am

    Since all laws and cases are declarations, surely you should start with ‘declarative’ languages.

    1. Reply
      Adam K. H.
      June 20, 2020 at 10:34 am

      Thank you for the suggestion. I actually plan to release an article (followed by tutorials) focusing on relational databases and SQL in the coming weeks.

Leave a Reply

Your email address will not be published. Required fields are marked *