Polyglot Programming Concepts

https://en.wikipedia.org/wiki/Programming_language

Imperative vs Functional

  • In a imperative program: a function depends on two things

    • the parameters it is passed and also
    • the current state of the machine store.
  • In a functional language:

    • only the parameters it is passed matters.

Dynamic vs Static

dynamically typed language. This means that variables do not have types; only values do. There are no type definitions in the language. All values carry their own type.

Standard vs. Implementation

Standard is the language specification, listing all the definitions and features of the language, however nothing "physical". Implementation is the actual engine that can execute the code that comply with the spec. E.g. in Java world, there's one JVM specification however multiple implementations, like OpenJDK, Oracle JDK etc.

The Standard

ECMAScript: the standard, a.k.a. ECMA-262, the latest is ECMAScript 2015 (PDF)

The Implementation

JavaScript, JScript and ActionScript are all implementations of ECMA-262 standard

The implementations are compatible with ECMAScript though may also provide additional features.

System Programming Languages

wiki

A system programming language usually refers to a programming language used for system programming; such languages are designed for writing system software, which usually requires different development approaches when compared with application software. System software is computer software designed to operate and control the computer hardware, and to provide a platform for running application software.

  • C/C++
  • Go
  • Rust

Virtual Machines

  • JVM(Java Virtual Machine): Java, Scala, Groovy, Kotlin
  • CLR(Common Language Runtime): C#
  • HipHop Virtual Machine (HHVM): PHP/Hack

Mutability

  • Immutable: cannot be changed once created
  • Mutable: can be changed

Java: String and all of the number classes, such as Integer,Double, Character, and BigInteger.

Compiled vs Scripts

  • compiled to standalone executables: C/C++, COBOL
  • ran in an interpreter: Perl, Tcl

Java’s need for both a bytecode compiler and a runtime interpreter.

Stack vs Heap

  • Stack: primitive values, references to objects, and methods

  • Heap: object created by new

    • Young gen
    • Old gen
    • PermGen(replaced by Metaspace, which uses native memory, in Java 8)
  • use -Xmx, -Xms to specify the size of Heap

  • use -Xss to specify the size of stack

Recursive methods usually use much more stack space, and therefore more memory, than an iterative counterpart.

Language Features

Java:

  • Autoboxing and Unboxing: primitive to object wrapper classes, and back

  • String vs. StringBuilder

Lua

Lua - a powerful, lightweight and embeddable scripting language that’s incredibly fast. All Lua actions start from C code in the host program calling a function from the Lua library.

Lua is good for

  • run inside nginx
  • in Redis
  • in games

Coroutines: also called collaborative multithreading. A coroutine in Lua represents an independent thread of execution. Unlike threads in multithread systems, however, a coroutine only suspends its execution by explicitly calling a yield function.

Rust

Go vs Rust

  • Rust competes for mindshare with C++ and D for programmers who are prepared to accept more complex syntax and semantics (and presumably higher readability costs) in return for the maximum possible performance. For example, micro controllers, AAA game engines, and web rendering engines.
  • Go competes for mindshare in the post 2006 Internet 2.0 generation of companies who have outgrown languages like Ruby, Python, and Node.js (v8) and have lost patience with the high deployment costs of JVM based languages.

Hack/HHVM

HHVM JIT compilation, executed PHP or Hack code is first transformed into intermediate HipHop bytecode (HHBC), which is then dynamically translated into x86-64 machine code, optimized, and natively executed. This contrasts with PHP's usual interpreted execution, in which the Zend Engine transforms PHP source code into opcodes that serve as a form of bytecode, and executes the opcodes directly on the Zend Engine's virtual CPU.

HHVM similar to CLR and JVM

Communities

  • Java/Scala: Maven Central
  • Python: Python Package Index
  • Node.js: npm(Node Package Manager)
  • Ruby: RubyGems.
  • Perl: Comprehensive Perl Archive Network (CPAN)
  • R: Comprehensive R Archive Network (CRAN).

Why Groovy is more Popular than Scala

Languages like Groovy on the other hand ARE 100% Java compatible because they ARE Java; take any Java class, change the extension to from '.java' to '.groovy' and it WILL compile (NOTE: one must have groovy library installed).

4th Generation Programming Language

https://en.wikipedia.org/wiki/Fourth-generationprogramminglanguage

Reactive Programming

In a nutshell reactive programming is about non-blocking, event-driven applications that scale with a small number of threads with backpressure as a key ingredient that aims to ensure producers do not overwhelm consumers.

A practical challenge when switching from imperative-style logic to non-blocking is the ability to compose async logic without getting lost in “callback hell”.

The basic idea behind reactive programming is that there are certain datatypes that represent a value "over time". Computations that involve these changing-over-time values will themselves have values that change over time.

Compile Time and Run Time

Python and R have no compile-time type-safety,

Haskell/Haxl

https://github.com/Gabriel439/post-rfc/blob/master/sotu.md

Dependency Injection

The main use case for DI was ease of testing

Optimizations

  • Flyweight Pattern: minimizes memory use by sharing as much data as possible with other similar objects.
  • String Interning: is a method of storing only one copy of each distinct string value, which must be immutable.

COBRA vs RMI

  • RMI is a Java-specific technology. CORBA has implementations for many languages. You can use CORBA to share objects between programs written in different languages (e.g. C++ and Java).
  • CORBA uses IDL (Interface Definition Language) to separate interface from implementation. RMI just uses Java interfaces.

5 things about programming I learned with Go

http://mjk.space/5-things-about-programming-learned-with-go/

  1. It is possible to have both dynamic-like syntax and static safety;
  2. It’s better to compose than inherit;
  3. Channels and goroutines are powerful way to solve problems involving concurrency;
  4. Don’t communicate by sharing memory, share memory by communicating;
  5. There is nothing exceptional in exceptions.

Good comment section: C++ can do all that, Erlang did all that before, Go doesn't make you do all that.

Javascript

Javascript does not have an integer type. JavaScript is only able to handle 52bit integers.

Modern js cheatsheet: https://github.com/mbeaudru/modern-js-cheatsheet

Language Benchmark

https://benchmarksgame.alioth.debian.org/u64q/go.html https://insights.stackoverflow.com/survey/2017 http://githut.info/ https://www.githubarchive.org/ https://madnight.github.io/githut/

PPL: Probabilistic Programming Language

http://dippl.org/