Programming languages

No-code

Rust

Rust basics

Graydon Hoare created Rust as a personal project while working at Mozilla Research in 2006. Mozilla officially sponsored the project in 2009. In December 2022, it became the first language other than C and assembly to be supported in the development of the Linux kernel.

Rust is syntactically similar to C++, but can guarantee memory safety by using a borrow checker to validate references. Rust achieves memory safety without garbage collection, and reference counting is optional. Essentials:

Rust installation

See LTK.

Rust hello_world.rs

On GrayTiger, create directory /home/marc/Rustprojects, with subdir hello_world. There create a file hello_world.rs with contents
fn main() {
    println!("Hello, world!");
}
Observation: println! calls a Rust macro. If it had called a function instead, it would be entered as println (without the !).

Then Observation: simple compilation without makefile. More complicated builds use cargo.

Rust hello_cargo.rs

Go to your Rustprojects directory, then Results in It also initialised a new Git repository along with a .gitignore file. Git files won’t be generated if you run cargo new within an existing Git repository.

From your hello_cargo directory, build your project by entering $ cargo build. This creates an executable in /target/debug/hello_cargo rather than in the current directory. Because the default build is a debug build, Cargo puts the binary in a directory named debug. To run it: $ ./target/debug/hello_cargo . If all goes well, Hello, world! should print to the terminal.

Running cargo build for the first time also causes Cargo to create a new file at the top level: Cargo.lock. This file keeps track of dependencies. Cargo manages its contents for you.

We just built a project with cargo build and ran it with ./target/debug/hello_cargo, but we can also use cargo run to compile the code and then run the resultant executable all in one command.

This is more convenient than remembering to run cargo build and then use the whole path to the binary, so most developers use cargo run.

Cargo also provides cargo check which checks code to make sure it compiles but doesn’t produce an executable:

To compile with optimisations. use cargo build --release. The executable goes to target/release instead of target/debug.

Tip: to see how cargo calls rustc, you can do cargo build --verbose, and it will print out each rustc invocation.

To work on any existing projects, the following commands check out the code using Git, change to that project’s directory, and build:

Regarding cargo and crates:

Selective Cargo stuff

Selective Rust stuff

TBD

Rust and TEE

For info on TEEs refer to local info. Importance of 'bindgen'.

Fortanix Enclave Development platform

Arm TrustZone, Rust and OP-TEE

Intel SGX and Rust

Go, Erlang

Reactive Programming

RP basics

RP is a declarative programming paradigm concerned with data streams and the propagation of change. With this paradigm it is possible to express static (e.g., arrays) or dynamic (e.g., event emitters) data streams with ease, and also communicate that an inferred dependency within the associated execution model exists, which facilitates the automatic propagation of the changed data flow.

DSL

Python

Python basics

iPython

Ada

Rooted in language design competition sponsored by US DOD, principal design was Jean Ichbiah (then @ Honeywell Bull France) Ada is a GP language that can be used for real-time, as opposed to a specialised real-time language. Used in avionics, aerospace, atc, steel mill control, trains, communications and nuclear reactor control.

Ada standards: