The Polyglot

Why more than one?

  • Each computer language has different strengths and weaknesses
  • Computer languages are designed for specific or general tasks
  • The hardest language to learn is the first one

How to choose

  • Simplicity/Familiarity
  • Suitability for the task at hand:
    • Task
    • Performance
    • Platform
    • Distribution
  • Maintanability/Code longevity

Hammer or screwdriver

Considerations

  • Interpreted or compiled
  • General purpose or domain specific
  • Procedural, functional or declarative

Interpreted or compiled

  • Compiled languages tend to run faster
  • But the development cycle is typically slower
  • A good combination is to prototype in an interpreted language, and if needed then port to compiled for speed
  • Many interpreted languages offer "tricks" to achieve performance close to compiled languages, but this often requires specialized knowledge.
  • But writing performante compiled code is hard
  • i.e. writing performant programs is hard!

General purpose or domain specific

  • Domain specific languages can simplify the learning curve and make code shorter and more manageable as they provide common functionality and abstractions
  • But they can be harder to deploy on other people's systems
  • And they do some things very well, but others badly or at all.

Procedural/Imperative languages

  • The programmer must clearly describe the procedure and order in which things are to be done
  • This often obscures the actual goal of the code for others reading it.
#include <stdio.h>

int main()
{
    int a = 3;
    int b = 2;
    
    int c = a + b;
    
    printf("%i", c);
    
    return 1;
}

C

Functional languages

  • All code is function calls
  • Often, there is no persistent state
(println (+ 3 4))

Clojure

Declarative languages

  • Describe the what, not the how
  • Useful when building static systems (the system is static but it can respond to interactive events)

Rectangle {
    width: 30
    height: width
    color: #ff0000
    
    Circle {
        width: parent.width /2
        height: width
        color: #00ff00
    }
}

QML

The Polyglot

By mantaraya36

The Polyglot

  • 994