Programming Languages Overview

CSCI 1913 – Introduction to Algorithms, Data Structures, and Program Development
Adriana Picoral

What is a programming language?

What is a programming language?

  • Instructions that can be understood by a machine
  • Programming languages are created to allow people to write code that be read by other people, and that the computer can understand and execute

Types of programming language

High-Level Languages:

  • Python, Java, C++, JavaScript
  • Closer to human/natural language

Low-Level Languages:

  • Assembly language, Machine code
  • Closer to machine code, or binary
  • More difficult for humans to read (but easier to read than zeros and ones)

Compilation vs. Interpretation

Both compilers and interpreters convert human-readable code to a computer-readable set of instructions

  • Compiled languages are translated into bytecode (machine code) before runtime
    • C, C++
  • Interpreted languages are run line by line by an interpreter
    • Python, JavaScript

Compilation vs. Interpretation

  • Caveat: interpreted vs. compiled is not necessarily a property of a language but a property of the implementation

  • Many programming languages can be executed as either a compiled program or as an interpreted language in interactive mode

  • When you write code in an interpreted language, you can run it directly from the command line or from an IDE without the need for a separate compilation step

  • Nowadays, for most applications, the difference in runtime between programming languages is often very small

Compilation vs. Interpretation

  • Compiled languages usually result in faster programs – the translationg of code at run time during interpretation adds to the overhead
  • Compilers are platform specific – they need to know what machine code they are translating to, the compiled code is optimized for the specific hardware and operating system of the machine it is intended to run on
  • Interpreters are platform independent
  • Interpreted languages tend to be more flexible

Compilation

  • A compiler is a program written to read code in a programming language
  • You write code in that programming language
  • You run the compiler on the code
  • The compiler converts code to “bytecode”
  • Your CPU runs the bytecode

Interpretation

  • An interpreter is a program that reads code and just runs it
  • You write your code
  • You run the interpreter on your code
  • The CPU runs the interpreter, the interpreter runs your code

Java

  • Programming language released in 1995

Java both compiles and interprets

  1. Programmer writes Java code
  2. Java compiler turns Java code into Java bytecode
  3. Java virtual machine interprets Java bytecode

Python

  • Programming language released in 1991
  • You can type directly into the interpreter or run a file of commands
  • Interpreted Language:
    • You don’t have to compile programs into binary before running them
    • Current iteration of python is Python3