Alternatives to C++
Table of Contents
- 1. Alternatives to C++/Cpp
1 Alternatives to C++/Cpp
1.1 Overview
This notes provides alternatives to C++ programming language that can fulfill the following requirements:
- Native code compilation
- System programming language
- No or optional garbage collector
- High performance as C++
- Compatibility with C or how easier is to call C-APIs (C-functions and structures).
Niches where C++ is used
- HPC - High Performance Computing
- CFD => Computational Fluid Dynamics (See: OpenFoam library)
- FEM => Finite Element Methods
- Computational Engineering
- Oil and Gas
- Geophysics
- Astrophysics
- Particle Physics
- High Energy Physics
- Games and computer graphics
- Requirements: high performance and soft real time system.
- System Programming
- Kernel mode programming; device drivers; hardware interface; foundation libraries such as user interface toolkits and so on.
- Embedded Systems (also can be regarded as system programming)
- Resource constrained systems => Firmware running in microcontrollers, embedded computers, SBC - Single Board Computers and so on.
- IoT - Internet Of Things
- Foundational Libraries and software infrastructure:
- Database servers
- Operating Systems
- Note: despite that most operating system used nowadays were written in C, it is possible to create operating systems or embedded operating systems in C++.
- Device Drivers
- Firmware
- High performance math libraries that can be called from any programming language via foreign-function-interface or native-extension API (similar to JNI - Jave Native Interface).
- GUI - Graphical User Interface Libraries
- Qt
- WxWidgets
Features of System Programming Languages
Some reasonable features that a System Programming Language should have are:
- Compilation to native code
- Stack allocation - Note: Most programming languages does not alllocate on the stack virtual memory segment of a process, only a few system programming languages are able to do it.
- Bare metal compilation - compilation without operating system, for building kernel or firmware (embedded systems' program).
- Be able to run without garbarge collector or to disable garbarge collector in resource constrained systems.
- Interoperability with C - Support C calling convention and linking
against C APIs and functions.
- Languages with this feature: C++; DLang (D programming language); Rust; ADA;
- Operating systems often expose functionalities and encapsulated system-calls for user-space applications via C libraries or runtime libraries exposing functions and symbols with C-calling convention and C-ABI (Application Binary Interface). Aside that, many foundational libraries are implemented in C or exposing C compatible-symbols, such as OpenGL API; OpenSSL; GTK GUI libraries and so on.
- extern-"C" like statements - Support for creating C-compatible
functions with C-calling convention.
- Languages with this feature: C++; ADA; Rust; DLang (D programming language); Pascal; Fortran (Note: no a system prog. language).
- Many operating systems, including Windows-NT and Linux and other Unix-like ones, define a C standard calling convention and ABI, which is the common denominator for binary interoperability. As a result, system programming languages, such as C++, DLang and Rust, provide extern-C like annotations for defining functions with C calling convention and C-ABI that allows calling those functions from any other language supporting C ABI or via FFI (Foreign-Function Interface).
- This type of annotation allows creating: C-compatible libraries in C++ or Rust; Python native code modules (shared libraries) in C++ or Rust; create shared libraries that can be loaded via FFI foreign function interface from interpred languages such as Python, Ruby, JavaScript (NodeJS) and so on.
- Inline assembly - Some sitatutions where inline assembly is needed are:
- SIMD (Single-Instruction and Multiple Data) which is provide data parallelism, which is essential for high perfomance computing.
- Access port-mapped IO instructions on x86 or x86-64 architecture.
- Define functions with another calling convention.
- Define ISR - interrupt-service routines, which may use other calling conventions.
- Invoke operating systems' system calls.
- Create CRT (C runtime libraries), such as GLIBC or MUSL that encapsulate system calls.
- Support for Pointers
- Memory reinterpretation - ability to cast pointers in order to access memory-mapped IO in kernel mode or in embedded devices.
What should be taken into consideration
- Standardization
- Availability of documentation and examples.
- Availability of documentation about how to interface C-subroutines; call C libraries and link against C-libraries.
- Reasonable standard library.
- The standard library of most programming languages provide platform-agnostic: threads, sockets, file system access, coroutines, multiplexed-IO (non-blocking IO).
- Availability of general and domain-specific libraries
- Network Effect => Enough critical mass that enables community support and enough libraries.
- Hardware Support:
- Availability of compilers for different hardwares such as CPU core architectures; microcontrollers, DSP - Dgitial Signal Processors and so on.
- Support from IC (Integrated Circuits) or Hardware Vendors
- Compile-time speed:
- Compile-time has a large impact on productivity as the workflow on many compiled-programming languages is edit, compile, fix compile-time errors and run. Longer the compile-time: more is spent on hourly rate; longer the development time and the time-to-market. The zero compile-time and fast iteration is one of the reasons dynamically-typed language, such as Python, Ruby, PHP are often chosen for web development.
- Tooling support:
- IDE - Integrated Development Support
- Refatoring tools
- Debuggers
- Profilers for measuring peformance
- Building systems
- Package managers
- IDE Support - some IDE services are invaluable such as:
- code completion
- Improves code discoverability and saves time that would be spent browsing the documentation or searching the source code.
- code navigation
- makes easier to view and jump between functions, classes, definitions and files. This service is essential for dealing with large code bases with hundreds or thousands of files.
- Code refactoring => refactoring menu.
- allows safe and fast changes such as renaming, changing method signature and so on.
- Debugging interface to GDB, WindDBG (Windows Debugger), LLVM and so on.
- Debuggers help fixing bugs by introspecting the program execution state and control flow at any given time and also allows user manipulation of program state and variables.
- Integration with revision control systems or version control system such as GIT, SVN and etc.
- code completion
Major Problems of C++
- Slow compile-time
- No pre-compiled libraries, project dependencies have to be compiled from source due to ABI incompatibility. This is why header-only libraries are popular.
- Lack of module system
- Macros and preprocessor
- Code repetitition, every class' source file .cpp needs a matching header file which is not an interface as it exposes implementation details, for instance, the signature of private functions and private member variables need to be in header files.
- Undefined behavior
- Undefined behavior may cause bad surprises as it can cause bugs that are hard to detect and may go under the radar for a long time allowing a program to run with unpredictable and/or invalid state.
- Object Model
- => C++ uses multiple inheritance that has been proved to be flawed as it can cause the infamous diamond-of-death problem. Most object oriented programming languages solved it by only allowing single inheritance with multiple interface inheritance.
- => Value semantics: C++ treats classes as primitive value and performs deep copy and passes all parameters by copy by default, however most of the time, classes are intended to be passed by reference and not by copy and it has to be done explicitly.
- => Value semantics does not work with polymorphic types.
- => Object Slicing
- High Degree of Complexity
- Binary compatibility among compilers.
- Lack of ABI makes unfeasible to build C++ components or shared libraries without a C API. In C#, the user has just to add a DLL and in Java, the user has just to add jar package to include a dependency in a project. In C++, it is not possible, all dependencies need to compiled from source.
- Complexity of building systems
- No Standard Tooling - Despite that there are some widely used
tools such as CMake "building system", they are still no
standard. So, as result there are no:
- NO standard package manager
- NO standard building system
References:
- Modern C++ Won't Save Us. - Alex Gaynor
- C++ and the culture of Complexity
- The Problem With C++ - Jeff Atwood.
- Why C++ sucks (2016.02 edition) – dorinlazăr.ro
- flyx.org - Reasons why C++ sucks
- The C++ Programming Language Sucks for a Very Good Reason | Why Does It Suck?
- Criticism of C++ - Wikipedia
- Most vexing parse - Wikipedia
1.2 Alternatives Map
Listing of suitable C++ alternatives by field for better informed decisions about technology stack choice.
Alternatives [---------------------------] + Packaged Software C# (CSharp) with WPF (Windows Presentation Foundation) +------->> + Desktop Graphical GUIs -------> C# with Windows Form | + Desktop utilities Free Pascal with Lazarus IDE | Java Swing | Python + Qt with Pyinstaller for packaging | | | Alternatives | [----------------------------] | (HPC) High Performance Fortran (commmercial compilers) +----->> Numerical Computing ------------->> Julia language (drawbacks: more resource usage) | Or Scientific Computing C language | | Alternatives | [---------------------------] | System software C language | ---------------- Rust +---->> ( operating systems -------------->> DLang (garbage collection can be disabled) | , device drivers, Zig language | , background services Golang (if garbage collection is allowed) | , low level stuffs | , shared libraries | , implementation of interpreters | ) | Alternatives | [-----------------------------] | Network Servers (TCP/IP, UDP/IP) ------------->> Golang +--->> High performance and resource-efficient Rust | DLang | OCaml | | | Embedded Systems Alternatives | --------------------------------------------->> [--------------------------] +--->> + MCU - Microcontrollers C programming (there are architectures where only C is avaiable) | + MPU - Application Processors ADA | + DSPs - Digital Signal Processors Rust | + Single Board Computers Zig language (not ready yet) | + Industrial Computers Forth | + Car ECU (Engine Control Unit)
1.3 General Purpose
1.3.1 Rust
- Rust - (2010) Created by Mozzila Foundation
- Official Web Site: https://www.rust-lang.org/
Features:
- Compilation to native code and web assembly.
- Easy cross compilation to other operating systems and ISA (Instruction Set Architectures).
- No gabarge collector, instead it uses its unique feature, the borrow-checker mechanism, for ensuring memory-safety and thread-safety.
- Type inference feature which allows type-safe programming with minimum type annotations without the verbosity of Java.
- Based on ML functional programming languages such as Haskell, OCaml and so on.
- Modules (No header-files code duplication nightmare)
- Standard building system and package manager: cargo - which makes it easier to reuse libraries and code.
- Supported paradigms: imperative, functional programming, quasi-object oriented programming via traits.
- Generic traits that are similar to C++ generic programming (template programming) with C++20 concepts. Note: Rust generics support type constraints.
- Hygienic macros that unlike C or C++ macros, are flexible like lisp macros and also type-safe that can generate and modify Rust code at compile-time.
- Endorsed by many companies such as: Microsoft, Mozilla, Apple, Amazon and so on. Rust is gaining traction as an safer system-programming language to C and C++.
Drawbacks:
- Slow compile-time
- Cannot call C-libraries directly as C++ can by using #include<> headers. - ref1
- Less available libraries than C++.
- Less talent pool than C++.
- Lack of compilers for embedded targets can be a problem for embedded systems development.
- Not all programming tasks requires high level of security such as: games, GUI (Graphical User Interfaces) and numerical computing. Applications that are most likely to require high level of security are the ones that runs with high privilege (kernel, device drivers, bootloader); deals with embedded systems and machine control, such as firmware or embedded operating systems; or deals with external untrusted input, such as parsers, interpreters, opcode virtual machines, network TCP/UDP/IP servers.
- Lack of OpenMP support, which is a high performance computing (HPC) C and C++ language extension that allows harnessing multi-processor and multicore systems for parallelizing numerical code using simple preprocessor code annotations.
- Vendoring C libraries (static linking C libraries) => C++ building systems, such as CMake, allow compiling and static linking against C libraries source dependencies placed in the same C++ source tree. Whereas, Rust's cargo building system is still not able to compile C source code in the same Rust source tree and link against the object code generated from the C library source code. Some libraries widely used C libraries in C++ code-bases are: GLFW, SDL, Lua language interpreter, GSL - Gnu Scientific Library and etc.
Online Books:
- Tour of Rust - TOC (Table of Contents)
- Note: Not an book, but it is a quick introduction to Rust with several runnable examples.
- Book: The Rust Programming Language [OFFICIAL]
- Book: The Cargo Book [OFFICIAL]
- Book focused on Cargo package manager.
- Book - MIT - The Rust Programming Language
- Book - Rust and WebAssembly
- Book - A Guide to Porting C/C++ to Rust
- Book - Rust for C++ programmers
- Book: Asynchronous Programming in Rust
- Book: The Embedded Rust Book (Embedded Systems)
- Book: Rust's Unsafe Code Guideline Reference
- Book: The Rustonomicon - The Dark Arts of Unsafe Rust
- "The Rustonomicon digs into all the awful details that you need to understand when writing Unsafe Rust programs."
- Microsoft MSFT - Take your first steps with Rust
- Rosetta Code => Contains code example grouped by task.
Big Tech Endorsement of Rust:
- Microsoft MSFT - Rust for Windows, and the windows crate
- Microsoft MSFT - Take your first steps with Rust
- Microsft - MSFT / Announcing Rust for Windows v0.9
- Rust programming language: We want to take it into mainstream, says Facebook
Articles:
- https://blog.rust-lang.org/ (Rust official Blog)
- The Great Rewriting in Rust - Adrian Kosmaczewiski
- Technology from the past come to save the future from itself [PDF] (Project Servo - Mozilla Annual Summit - 2010)
- What is the Rust language? Safe, fast, and easy software development | InfoWorld
- Rust 2018: Improving Safety and Ergonomics for Low-LevelProgramming | Bobbin Blog
- Integrating Rust and C++ in Firefox
- Librsvg, Rust, and non-mainstream architectures
- Speed of Rust Vs C
- Rust Generics vs Java Generics
- The Rust Programming Language Is Now One Step Closer To Entering The Mainline Linux Kernel
- Goole Security Blog - Rust in the Android Platform
- LWN - Rust support hits linux-next
- Linus Torvalds on where Rust will fit into Linux
- 32 Companies usign Rust in production
- https://github.com/rust-lang/rustlings/
- "crab Small exercises to get you used to reading and writing Rust code!"
Interoperability
- https://github.com/rust-lang/rust-bindgen
- Brief: "bindgen automatically generates Rust FFI bindings to C (and some C++) libraries."
- https://doc.rust-lang.org/std/alloc/trait.Allocator.html
- Custom allocator.
Videos
- Rust for C++ developers - What you need to know to get rolling with crates - Pavel Yosifovich
- Brief: "The session is about using the Rust language to write safe, concurrent and elegant code, contrasting with C++"
- A Firehose of Rust, for busy people who know some C++ - Jack O'Connor
- Building on an unsafe foundation - Jason Orendorff
- Brief: "Beneath every safe programming language, library, or virtual machine is a whole lot of unsafe code. Rust is no exception. This talk will explain why “unsafe” code is allowed at all in a safe language, show the unsafe code at work inside safe features like Vec, and teach how to write a safe library that uses unsafe code."
- How Do Programmers Use Unsafe Rust?
- Brief: "Hello, I am Vytautas, a PhD student at ETH Zurich, supervised by Peter Müller. In our paper, we explored how and why programmers use unsafe Rust: a powerful and dangerous feature that allows disabling certain type-system checks. https://doi.org/10.1145/3428204"
- Writing Linux Kernel Modules in Safe Rust - Geoffrey Thomas & Alex Gaynor
- Brief: "Writing Linux Kernel Modules in Safe Rust - Geoffrey Thomas, Two Sigma Investments & Alex Gaynor, Alloy With 65% of recent Linux kernel vulnerabilities being the result of memory unsafety (buffer overflows, pointers used after being freed, etc.) and not logic errors, both kernel developers and downstream users have wondered whether it's possible to use a safer language than C for kernel development. This talk will explore the presenters' work building a framework for writing kernel modules in Rust and accessing kernel APIs in safe Rust. In particular, the talk will discuss some of the challenges of building binary-compatible kernel modules in Rust, techniques for working with existing C code, and how to design safe bindings over raw kernel APIs. It will also discuss advantages and difficulties for integrating Rust in upstream kernel development and possible directions the upstream kernel community could go."
- EuroBSDCon - Rust: Systems Programmers Can Have Nice Things
- Brief: "Rust is a new programming language, originally from Mozilla, that combines the safety and productivity of a high-level language with the performance and low-level control of a traditional systems language. Rust achieves this combination through clever and pragmatic programming language design — along with awesome tooling and libraries. In this talk, I will dive into the features that make Rust the right choice for 21st-century systems programming. I will give a general introduction to the language and an overview of the Rust ecosystem. I will also walk through the process of developing Rust on BSD."
- Rust programming for the object-oriented developer
- Brief: "If you've been curious about learning Rust, but have been scared off because you prefer object-oriented languages like Java, JavaScript, Python, Ruby and C++, then you should watch this talk! In this practical introduction, Tim covers a lot of material that has something for beginners and experienced programmers alike. How does Rust handle errors if there are no exceptions? How does Rust implement shared behavior if there is no inheritance?"
- RustConf 2018 - Writing Crates for Complete Beginners
- Brief: "Turtle is a Rust graphics crate for creating animated drawings. It is designed to be used to teach programming to complete beginners using Rust. In this talk, you'll learn the inner workings of turtle. We'll show you how we managed to create a library that is both full of features and very easy to learn. We'll go deep into how turtle works and tell you the key aspects of creating a crate that is accessible for anyone of any skill level. You'll leave with new ideas for your own crates and a good understanding of what went into making turtle so beginner friendly."
- The Rust language: memory, ownership and lifetimes {linux.conf.au 2014}
- Brief: "In 2010, Mozilla announced it was working on a new systems language, aiming to match the performance and C-interoperability profile of C++ in a provably safe language with concurrency, immutability, isolation and expressiveness properties closer to languages like Erlang, Haskell or Scala. While Rust presents a good variety of familiar, expressive tools from other mainstream languages, it also borrows from research languages two lesser-known key technologies: "owning pointers" and "borrowed pointers". This talk will briefly describe the Rust language in general terms, then focus in on these two key technologies, how they shape Rust's memory model, performance and safety guarantees, and why you might consider using Rust in your next project."
- Demo Zoo: Zero Cost Abstractions in C++20, Rust, & Zig
- Brief: "Well, they aren't quite zero, but modern compilers for efficient languages do pretty well in this demo of abstract vector norm calculations in C++, Rust, & Zig."
- Rust Concurrency Explained
- Brief: "The Rust programming language purports the bold claim that it guarantees thread safety while retaining the ability to write zero-cost abstractions. In this talk we'll explore precisely how Rust can make such a claim. We'll also explore the ecosystem that makes up the concurrency toolkit in Rust to see how these language principles are extended to common abstractions such as channels, thread pools, work stealing algorithms, concurrent data structures, and asynchronous I/O."
Applications built with Rust
- Firecracker (Developed by AWS - Amazon inc.)
- Brief: "Firecracker is an open source virtualization technology that is purpose-built for creating and managing secure, multi-tenant container and function-based services. Firecracker enables you to deploy workloads in lightweight virtual machines, called microVMs, which provide enhanced security and workload isolation over traditional VMs, while enabling the speed and resource efficiency of containers. Firecracker was developed at Amazon Web Services to improve the customer experience of services like AWS Lambda and AWS Fargate . Firecracker is a virtual machine monitor (VMM) that uses the Linux Kernel-based Virtual Machine (KVM) to create and manage microVMs. Firecracker has a minimalist design. It excludes unnecessary devices and guest functionality to reduce the memory footprint and attack surface area of each microVM. This improves security, decreases the startup time, and increases hardware utilization. Firecracker is generally available on 64-bit Intel, AMD and Arm CPUs with support for hardware virtualization."
- Zellij - Terminal Multiplexer, similar to GNU Screen or Temux.
- Brief: "Zellij is a terminal workspace and multiplexer written in Rust, aiming to become a general purpose application development platform in the future."
- Helix Terminal Modal Text Editor
- Modal text editor for terminal, similar to vim and Kakoune editor. Unlike vim, this editor has a selection-action paradigm inspired by Kakoune editor. When the editor is in normal mode, a key is typed for selecting a text block (subject) and the next key applies an action (verb) on the selected text. This approach provides more self-explanatory and intuitive keybind than vim with better feedback since the user always is able to see the text block that the command will be applied to.
- RusTLS
- TLS (Transport Layer Security) library, similar to OpenSSL, implemented in Rust programming language
- wastime
- Standlone runtime for WebAssembly & WASI written in Rust.
1.3.2 D Language (DLang)
D (DLang or D-Language) (Since 2001)
Overview:
- Official Web Site: https://dlang.org/
- The D Language was created by Walter Bright, a former Mechanical Engineer at Boeing and the creator of the first true C++ compiler Zortech C++. D was also co designed by Andrei Alexandrescu, a well-known C++ speaker, guru and author of the revolutionary book: 'Generic Programming and Design Patterns Applied'.
- Note: When the C++ was created, it was first implemented as a preprocessor for generating C code.
- Note: some people claim that D looks like a "compiled Python"
Features:
- Multi-Paradigm
- Imperative
- Object Oriented Programming
- Metaprogramming
- Functional
- Concurrent - actor model
- Easier to learn for a C or C++ developer than Rust.
- Inspired by: C, C++, C# (Csharp), Eiffel, Java and Python.
- Native code compilation with static linking.
- Much faster compile-time, D can even by used as a statically-typed scripting language.
- Optional garbage collection => it can be disabled in application where it is not acceptable such as audio, system programming and games.
- Modules
- Design-by-contract
- Metaprogramming Support
- More comprehensive standard library
- Built-in package manager and building system - dub
- Central package repository: https://code.dlang.org
Interoperability:
- Interoperability with C
- Supports calling C functions directly, although it does not support including C header files.
- Interoperability with C++
- D is one of the few languages that understands the C++ ABI and allows calling C++ from D and D from C++.
- Interoperability with Objective-C
- Windows Win32 API - COM Programming
- ABI - Application Binary Interface
- Interoperability with Assembly
- Supports inline assembly
Miscellaneous:
- Universal Function Call Syntax (UFCS)
- Brief: Allows calling ordinary functions as they were member functions by using dot. This feature allows extending classes without creating utility methods and also improves the code base discoverability by harnessing code completion.
- Models of Generics and Metaprogramming: Go, Rust, Swift, D and More.
- Memory Management
- D Tetris running on Webassembly
- DLang - Unit Tests
Fixes lots of C++ problems due to earlier design decisions:
- Classes are reference types => Instead of being passed by value by default, they are passed by reference implicitly without the C++ annotations for reference (&) or const referece(const &). It simplifies the language as one does not need to care about copy-constructors, move-constructors or potential problems of copy-constructor deep-copy or copy-overhead.
- Provides structs that are value types like all C++ types and by value by default just as in C++ and C#. D Structs also allows RAII Resource-Acquisition-Is-Initialization technique for resource handling.
- Fixes C++ multiple-inheritance diamond-of-death problem by allowing only single inheritance with multiple interface inheritance in a similar fashion to Java.
- Fixes the object-slicing problem that happens when a polymorphic type is returned or passed by value losing its polymorphic abilities.
- Provides ranges instead of complicated and non-composable iterator pair.
- Modules, instead of C preprocessor which dramatically reduces the compile-time.
Drawbacks:
- Plugins for enabling D language support in existing IDEs don't work out of the box.
- Less tooling than C++
- Lower popularity than Golang, Rust and so on.
- Smaller community
- Less IDE support and refactoring tools.
- Unlike C, C++ or Rust still lacks industry recognition.
- Less known than C++ or Rust.
Articles
- Flagship Webframework: https://vibed.org/ (VIBE.D)
- Saving Money by Switching from PHP to D
- Summary: A italian company switched the backend implementation from PHP do D language, which allowed the company to cut the instances of the Amazon AWS virtual machines in half and consequentely save cloud hosting costs. The cost was reduced due the less RAM memory and computational resources usage. Besides the cost, other benefit were the performance gain and the reduced latency.
- Project Highlight: Auburn Sounds
- Summary: Company that creates audio plugins in D (DLang).
- Functional Programming with D
- DLang contract programming
- DLang - Using Fibers to implement Gameboy's Timing
- Dlang - Fibers (aka Greenthreads, coroutines)
- Concurrency inthe D Programming Language
- DLang - Better C
- Component Oriented Programming with D
Applications built with DLang
- Tilix (Gtk3 Terminal Emulator)
- Brief: "A tiling terminal emulator for Linux using GTK+ 3. The Tilix web site for users is available at https://gnunn1.github.io/tilix-web."
- GitHub - Netflix/vectorflow
- Neural network library for machine learning that can deal with sparse data.
- See:
- A Gas Dynamics Toolkit in D | The D Blog
- "The Eilmer flow simulation code is the main simulation program in our collection of gas dynamics simulation tools. An example of its application is shown here with the simulation of the hypersonic flow over the BoLT-II research vehicle that is to be flown in 2022."
- DFeed
- Brief: "D news aggregator, newsgroup client, web newsreader and IRC bot"
- Dlang / Excel API bindings and wrapper API for D; Dlang; spreadsheet; finance; quant
- Library that allows creating Microsoft Excel Addins in DLang.
- Brief: "Excel API bindings and wrapper API for D This dub package contains D declarations for the Excel SDK as well as a D wrapper API. This allows programmers to write Excel worksheet functions in D. Motivation and background for the project can be found here. See also the DConf 2017 lightning talk about excel-d. Run makedocs.sh to generate the documentation Generated documentation - a work in progress - is available at dpldocs. A working XLL example can be found in the example directory. Running dub build there will create an XLL (myxll32.xll) that can be loaded in Excel making all of the functions in test/xlld/test_d_funcs.d available to be used in Excel cells. The types are automatically converted between D native types and Excel ones. To build the example: dub build -c example [–arch=x86_mscoff|–arch=x86_64]."
Some Videos
- C++Now 2017: Ali Çehreli “Competitive Advantage with D"
- DConf 2014 Day 3 Keynote: High Performance Code Using D – Walter Bright
- Three Unlikely Successful Features of D - Andrei Alexandrescu
- DConf 2019: D for a @safer Linux Kernel – Alexandru Militaru
- Cryptography in D - Amaury Séchet | DConf2017
- Quantum Break: AAA Gaming With Some D Code - Ethan Watson | DConf2016
- Jean-Louis Leroy: Open Methods for D (The Expression Problem - solved)
- DConf 2013 Day 1 Talk 4: Writing Testable Code in D by Ben Gertzfield
- Using Floating Point Without Losing Your Sanity - Don Clugston | DConf2016
1.3.3 GO - Golang
Go - Golang (Since 2009)
- Programming language created at Google by Robert Griesmer, Rob Pike and Ken Thompson.
- Official Web Site:
- Repository:
- Package registry:
Features:
- Most used for Network Servers, Web Servers, Web Applications, distributed systems and message systems due its concurrency features such as go-routines based on Hoare's CSP - Communicating Sequential Processes.
- Easier to learn for developers coming from languages such as Java, Python, and so on.
- Lightweight threads (user-space threads), called Goroutines which are more lightweight than kernel threads making it possible to handle far more concurrent connections with less resources. For instance, on Linux each Kernel thread costs 2 megabytes (2048 kb).
- Multicore support, Golang can take advantage of all CPU cores and run hundreds of thousands of goroutines on each core.
- Wraps multiplexed IO, such as Slect (Unix), Poll (Unix), Epoll (Linux), KQueue (BSD) and IOCP (Windows), which allows handling multiple IO file descriptors and TCP/IP connections in a single thread.
- Gabarge collector which automates memory managment.
- Fast compile-time to native code. Fast compile-time also means fast iteration, faster development and less time-to-market.
- Statically-linked native executables that can be deployed without any dependencies on any Linux distribution, in other words, just works, just copy an executable binary to remote host and run it. Golang can also bypass the GlibC dependency-hell problem on Linux-based operating systems by performing system calls directly.
- Easy to create Pre-built binaries for all platforms!! Linux, Windows, and all possible platforms!! :)) :)
- =>> As most golang applications are fully statically linked, developers can provide pre-built binaries for Linux and avoid the Linux package manager work-duplication problem.
- =>> Easy Cross-compilation makes easier to build binaries for other platforms.
- =>> Eliminate dependency on Linux package managers.
- Easy cross-compilation to Linux, Windows, MacOSX and even embedded Linux targets for ARM, PowerPC and other architectures just be setting an environment variable. It even possible to build native executable for MacOSX with Golang compiler from a Linux or Windows hosts and without any Apple tooling which are not allowed to be installed on non MacOSX machines.
- Own implementation of TLS (Transport Layer Security), aka SSL (Socket Secure Layer) which allows Golang applications to be fully self contained and not even depend on OpenSSL installed on the host machine.
- Multiple return values
- Reflection It is the ability of a programming language to introspect and examine its own objects, classes and data structures at runtime or compile-time. Reflection is useful for creating DLS (Domain Specific Languages), implementing ORM (Object Relational Mapper), implemeting automatic serialization and deserialization, and code generation.
- Safety features:
- Avoids unsafe pointer arithmetics.
- Array-bound checking
- Easy to embed and to bake static files and folders in the compiled executable binary.
- Facilities for serving static files => Many web frameworks such as Django, Ruby-on-Rails or ASP.NET often use web servers such as Apache, Nginx or IIS for serving static files due to complexity and performance reasons. For instance serving static files requires dealing with cache, etags, range request, partial reponses and zero-copy network system calls, such as sendfile. Golang provides facilities for serving static files in its standard libraries that eliminates the need for servers such as Nginx or Apache, as a result in addition to be self-contained, Golang applications can even be almost self reliant.
Drawbacks:
- "Ungoogable name" "go" which is hard to search about without getting many unrelated results since "go" is one of the most common words of the English Language, better search for "golang" or "go programming".
- Not easy link against C libraries or C subroutines as in C++, DLang (D) or Rust.
Lack of generics and template metaprogramming. The new Golang 1.18 release has brought generics feature.- Lack of function overloading =>> It is not possible to define multiple function sharing the same name, but with different type signatures.
- Lack of exceptions, GO returns errors as values, just like C. However unlike C, in GO the type system explicitly indicates that a function returns error by returning multiple values and an extra parameter denoting error. The advantage of this approach is that it avoids hidden control flow that exceptions would introduce; it lets the calling code know that the function may fail in advance without any exception crashing the application at runtime; and there is no way to the developer implemeting the calling code forget to handle the error that the function would issue.
- Lack of ternary operators
- Gabarge collector can be a curse for the applications that C++ shines, namely, system programming, embedded systems, real-time systems (including games) and high performance computing.
- Too much opinionated: A golang code may not even compile if a import is not used or curly braces are not formatted in a proper way.
- Forces the code to be written in a single way and in a single style.
- Due to the garbage collection Golang may not be suitable for games. Although Golang might be a suitable replacement for C++ (+) Boost.ASIO.
- Not suitable for numerical, scientific computing and machine learning since Golang lacks operator overloading support, higher level abstractions and simd support.
- Lack of GUI libraries for building desktop applications.
- Lack of opinionated and full-featured production-ready web frameworks such as Django, Ruby-on-Rails or ASP.NET.
Best use-cases:
- Command line tools
- => GO is suitable for building portable command line applications, due to the compilation to native executable and static linking of dependencies which allows seamless deployment and portability across many Linux distributions.
- Network Services; aka servers; web servers; TCP or UDP servers.
- Network infrastructure tools
- Http servers and web applications.
- Distributed systems
- Micro services
Some projects built with Golang
- Docker
- => Most used container runtime on Linux.
- See: https://github.com/docker/cli (Docker CLient)
- Kubernetes (k8)
- => The rockstar of the cloud, the most widespread and most used container orchestration tool that is becoming a universal cloud API providing a multi-cloud Heroku-like experience.
- Ubuntu Snap package manager (developed by Canonical)
- Caddy Web Server (Nginx-like web server written in GOLang)
- Official Web site: https://caddyserver.com/
- Download: https://caddyserver.com/download
- Download: https://github.com/caddyserver/caddy/releases
- Note: Caddy is available for download as a single self-contained executable that can be run on any Linux distribution.
- Brief: "Caddy simplifies your infrastructure. It takes care of TLS certificate renewals, OCSP stapling, static file serving, reverse proxying, Kubernetes ingress, and more. Its modular architecture means you can do more with a single, static binary that compiles for any platform. Caddy runs great in containers because it has no dependencies—not even libc. Run Caddy practically anywhere."
- See:
- Gitea
- https://gitea.com/
- https://docs.gitea.io/en-us/comparison/
- Download: https://github.com/go-gitea/gitea/releases
- Self hosting git service, similar to Gitlab (ruby app) with a web interface, but uses less resources and less memory. Even Sqlite database is supported.
- Brief: "The goal of this project is to make the easiest, fastest, and most painless way of setting up a self-hosted Git service. Using Go, this can be done with an independent binary distribution across all platforms which Go supports, including Linux, macOS, and Windows on x86, amd64, ARM and PowerPC architectures. Want to try it before doing anything else? Do it with the online demo! This project has been forked from Gogs since 2016.11 but changed a lot."
- Terraform
- Infrastructure-As-A-Code tool for multi-cloud automation, allows automating AWS, Google Cloud, Azure cloud with code.
- Brief: "Terraform enables you to safely and predictably create, change, and improve infrastructure. It is an open source tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned."
- Hugo - Static web site generator
- Brief: "Hugo is a static HTML and CSS website generator written in Go. It is optimized for speed, ease of use, and configurability. Hugo takes a directory with content and templates and renders them into a full HTML website. Hugo relies on Markdown files with front matter for metadata, and you can run Hugo from any directory. This works well for shared hosts and other systems where you don’t have a privileged account. Hugo renders a typical website of moderate size in a fraction of a second. A good rule of thumb is that each piece of content renders in around 1 millisecond. Hugo is designed to work well for any kind of website including blogs, tumbles, and docs."
- CockroachDB
- Brief: "CockroachDB is a cloud-native SQL database for building global, scalable cloud services that survive disasters."
- Teleport
- Brief: "Teleport is an identity-aware, multi-protocol access proxy which understands SSH, HTTPS, Kubernetes API, MySQL and PostgreSQL wire protocols. On the server side, Teleport is a single binary which enables convenient secure access to behind-NAT resources such as: SSH nodes - SSH works in browsers too! Kubernetes clusters PostgreSQL and MySQL databases Internal Web apps Teleport is trivial to set up as a Linux daemon or in a Kubernetes pod. It's rapidly replacing legacy sshd-based setups at organizations who need: Developer convenience of having instant secure access to everything they need across many environments and cloud providers. Audit log with session recording/replay for multiple protocols; Easily manage trust between teams, organizations and data centers. Role-based access control (RBAC) and flexible access workflows (one-time access requests)"
- MailHog
- Download: https://github.com/mailhog/MailHog/releases
- See: Using MailHog via Docker for testing email – Rob Allen's DevNotes
- Golang web application that provides web user interface for a SMTP testing server. This application makes it easier to test and simulate trasactional email systems of web applications, such as Django or Ruby-on-Rails applications.
- Yggdrasil Mesh Network
- https://yggdrasil-network.github.io/
- Download: https://github.com/yggdrasil-network/yggdrasil-go/releases
- Decentralized peer-to-peer mesh network without any central authority. It allows easy self hosting of any web or network application without opening any router port or without any complex network configuration.
- "Yggdrasil is an early-stage implementation of a fully end-to-end encrypted IPv6 network. It is lightweight, self-arranging, supported on multiple platforms and allows pretty much any IPv6-capable application to communicate securely with other Yggdrasil nodes. Yggdrasil does not require you to have IPv6 Internet connectivity - it also works over IPv4."
- Gotty - Tool that allows accessing the terminal and command line applications remotely from any web browser.
Articles about Golang
- Go (programming language) - Wikipedia
- https://gobyexample.com/
- https://golang.org/doc/faq => Frequent Asked Questions
- https://go-proverbs.github.io/
- Book: Learn Go with Tests - Learn Go with tests
- Book: Writing A Compiler In Go | Thorsten Ball
- golang-notes/OOP.md at master · luciotato/golang-notes · GitHub
- https://github.com/golang/go/wiki/GoUsers =>> Companies using Golang.
- Go at Google: Language Design in the Service of Software Engineering
- Brief: "(This is a modified version of the keynote talk given by Rob Pike at the SPLASH 2012 conference in Tucson, Arizona, on October 25, 2012.) The Go programming language was conceived in late 2007 as an answer to some of the problems we were seeing developing software infrastructure at Google. The computing landscape today is almost unrelated to the environment in which the languages being used, mostly C++, Java, and Python, had been created. The problems introduced by multicore processors, networked systems, massive computation clusters, and the web programming model were being worked around rather than addressed head-on. Moreover, the scale has changed: today's server programs comprise tens of millions of lines of code, are worked on by hundreds or even thousands of programmers, and are updated literally every day. To make matters worse, build times, even on large compilation clusters, have stretched to many minutes, even hours. Go was designed and developed to make working in this environment more productive. Besides its better-known aspects such as built-in concurrency and garbage collection, Go's design considerations include rigorous dependency management, the adaptability of software architecture as systems grow, and robustness across the boundaries between components. This article explains how these issues were addressed while building an efficient, compiled programming language that feels lightweight and pleasant. Examples and explanations will be taken from the real-world problems faced at Google."
- https://go-proverbs.github.io/
- VIDEO: Gopherfest 2015 | Go Proverbs with Rob Pike
- Don't communicate by sharing memory, share memory by communicating.
- Concurrency is not parallelism.
- Channels orchestrate; mutexes serialize.
- The bigger the interface, the weaker the abstraction.
- Make the zero value useful.
- interface{} says nothing.
- Gofmt's style is no one's favorite, yet gofmt is everyone's favorite.
- A little copying is better than a little dependency. (NodeJS + NPM)
- Syscall must always be guarded with build tags.
- Cgo must always be guarded with build tags.
- Cgo is not Go.
- With the unsafe package there are no guarantees.
- Clear is better than clever.
- Reflection is never clear.
- Errors are values.
- Don't just check errors, handle them gracefully.
- Design the architecture, name the components, document the details.
- Documentation is for users.
- Golang Official - GO: A Documentary
- Brief: "This document collects many interesting (publicly observable) issues, discussions, proposals, CLs, and talks from the Go development process, which intents to offer a comprehensive reference of the Go history."
- GO-Blog - How Go Mitigates Supply Chain Attacks
- Brief: "Modern software engineering is collaborative, and based on reusing Open Source software. That exposes targets to supply chain attacks, where software projects are attacked by compromising their dependencies. Despite any process or technical measure, every dependency is unavoidably a trust relationship. However, the Go tooling and design help mitigate risk at various stages."
- Go Toolchain Primer – Will's Blog
- Brief: "A toolchain is a package composed of the compiler and ancillary tools, libraries and runtime for a language which together allow you to build and run code written in that language. The GNU toolchain is the most commonly used toolchain on Linux and allows building programs written C, C++, Fortran and a host of other…"
- Going Infinite, handling 1M websockets connections in Go - Speaker Deck
- "Go HTTP server provides great scalability, allocating a goroutine per connection, and reusing the efficient multiplexing and scheduling of the Go runtime. While this technique is almost ideal for most scenarios, it comes with limited scale for websockets applications due to high memory consumption In this talk, we will show how we’ve implemented our own event loop mechanism to overcome those limitations and efficiently manage millions of concurrent connections while minimizing resource utilization. We will compare the memory footprint of a naive implementation, relying on the standard way to handle those connections with go-routines, and explore the difficulties of using epoll and select in pure go to efficiently schedule and maintain all those concurrent connections All the examples in the slides are also available here: https://github.com/eranyanay/1m-go-websockets/"
- A Million WebSockets and Go
- Brief: "This article is about how we developed the high-load WebSocket server with Go. If you are familiar with WebSockets, but know little about Go, I hope you will still"
- Go-Blog - When To Use Generics - The Go Programming Language
- Brief: "The Go 1.18 release adds a major new language feature: support for generic programming. In this article I’m not going to describe what generics are nor how to use them. This article is about when to use generics in Go code, and when not to use them. To be clear, I’ll provide general guidelines, not hard and fast rules. Use your own judgement. But if you aren’t sure, I recommend using the guidelines discussed here."
- GitHub - luk4z7/go-concurrency-guide
- Brief: "Practical concurrency guide in Go, communication by channels, patterns"
- Building a WebRTC video and audio Broadcaster in Golang using ION-SFU, and media devices
- "Several tips to write scalable WebSocket servers with Go language and beyond."
1.3.4 NIM
- Nim Language (2008)
- Official Web Site: https://nim-lang.org/
- Features:
- Native code compilation by generating C-code (Nim is a transpiler)
- Simple syntax
- Gabarge Collection
- Problems:
- Did not reach version 1.0 yet. Still under development.
- Less tooling support.
- Gabarge Collection can also be a problem in performance-critical applications.
1.3.5 Crystal
- Crystal Programming language (2014)
- Official Web Site: https://crystal-lang.org/
- Github: https://github.com/crystal-lang/crystal
1.3.6 ATS - Applied Type System
ATS Programming Language (2015)
- Official Web Site: http://www.ats-lang.org/
- Community: http://ats-lang.sourceforge.net/COMMUNITY/
- ATS stands for Applied Type System
Suitability:
- Systems Programming
- Device drivers
- Embedded Systems
- High performance libraries
Features:
- Statically-typed functional programming language based on Standard ML (OCaml) that transpile to C, or generate C-code.
- C-interoperability
- Can take advantage of the availability of C-compilers for many platforms, hardwares and devices.
- Memory-safe
- All ML perks: pattern matching; algebraic data types and so on.
- Can run without garbage collector.
- Can compile or generate code to: C, JavaScript and Erlang.
Problem:
- New programming language
- May not be mature enough.
- Sparse documentation
1.4 Scientific and numerical computing
- Fortran (1954)
- Fortran (Formula Translation), designed by John Backus at IBM in 1954, was the first high level programming language which the purpose was to assist physics and engineering calculations. The reason why Fortran was math-centric is that computers were initially developed for number crunching and earlier devices called computers such as slide rules, abacus and analog computers were built for numerical computations, solving differential equations or peform control system tasks.
- Features:
- Array-based notation, support for arrays, matrices and multi-dimensional arrays (also called tensors).
- Matrix and array indexes starting with 1 instead of 0.
- Compilation to native code
- Fortran libraries can be called and used from C or C++.
- Lots of legacy domain-specific code for science, physics and engineering are available in Fortran.
- Forbids pointer aliasing, which allows the compiler to generate more performant code. In C or C++, forbiding pointer aliasing requires using the 'restrict' keyword in C or compiler-proprietary annotation in C++.
- Drawbacks:
- Pretty old programming language.
- No longer widely used outside certain scientific niche fields.
- Open source Fotran compilers such as GFortran (GNU Fortran) cannot match the performance of expensive proprietary compilers.
- Domain-specific
- See:
- Intel Fortran Compiler Manual [PDF]
- PGI Fortran Compiler [PDF]
- An Introduction to Vectorization with the Intel Fortran Compiler [PDF]
- Nasa Modelling Guru - C++ code for C++ class and C interfaces
- Why are Climate models written in programming languages from 1950?
- Why are most climate models in Fortran?
- G-Fortran - GNU Fortran
- Installation of GFortran in Windows 10
- Language Impact on Vectorization: Vector Programming in Fortran [PDF]
- Basics of Vectorization for Fortran Applications [PDF] - Inria / HAL archives ouvertes.
- Fortran 90 - Array Assignment Statement
- Sub-Array Manipulations in Fortran
- Map, Filter, Reduce in Fortran (2018)
- LAPACK - Linear Algebra Routines
- LINPACK - Linear Algebra Routines
- Julia Language (2012)
- Value proposition: Syntax and convenience of Matlab and Fortran; almost the speed of C and C++; flexibility and convenience of Python.
- Features:
- Dynamically typed with optional type anntations.
- JIT - Just In Time compiler. The script code is compiled to machine code during runtime which increases the performance.
- Built-in types convenient for numerical computing: arrays; matrices; multi-dimensional arrays.
- Interoperability:
- Can use Python packages via CPython native interface C API.
- Can call C++, C or Fotran.
- No need to vectorized for-loops which decreases the performance in Matlab; Python + Numpy; Octave; Scilab and so on.
- Support for functions and variables with unicode symbols such as greek letters: δ, ∇, ι …
- Multiple Dispatching
- Lisp-like macros and metaprogramming features.
- Disadvantages:
- Slow startup time
- Not suitable for low latency applications, such as games, since Julia is a garbage collected language.
- Less efficient. Despite the possible performance gains, Julia still uses more CPU time and memory resources than C++, which is still one of the best ways to get the maximum ROI (Return on Investment) on the hardware and take full advantage of every penny spent on it.
- Best use cases:
- Scientific and numerical computing
- Machine learning
- Engineering design
- Prototyping numerical algorithms and numerical methods before a more efficient implementation in C++ or any other more efficient language.
1.5 Embedded Systems or Real Time Systems
Ada - programming language (Since 1980)
- Native code compilation, stronger static typing than C++; more memory-safe than C or C++; no gabarge-collector; pascal-based; built-in design-by-contract; concurrency in the language specification and several runtime checks, that has some performance costs.
- Most used technology stack:
- PowerPC + Real Time Operating System (VxWorks or Green Hills) + ADA Spark
- Value propositions:
- Unlike C++, which the motto is speed over safety, the motto of ADA language is safety first.
- Most paranoid and unforgiven type system ever. Even integer numerical ranges can be type checked.
Articles About ADA
- Ada for Embedded Systems: Issues and Questions
- Ada Language System/Navy (ALS/N) For Embedded Real Time Systems
- Low-Level Programming in Ada | Jalada
- Making the Ada Drivers Library - Embedded Programming with Ada
- Assessing ADA language for audio Applications - Electronic Design
- Ada Control Jet Flights
- Boeing Flies on 99% Ada
- Airbus chooses AdaCore for autonomous aircraft software testing
- Embraer chooses AdaCore GNAT Pro Ada software
- ADALang / Maximum Security Vision (Nvidia + AdaCore)
- "NVIDIA works with AdaCore to leverage Ada and SPARK programming languages for software security."
- SAAB - Evolving / Formalising / Automating an Embedded Real-Time Software Architecture [PDF]
Some Videos:
1.6 Graphical User Interface RAD - Rapid Application Development
- Free Pascal Programming Language + Lazarus
- Official Web Site: https://www.lazarus-ide.org/
- Other sites:
- Lazarus is an open source IDE for Object Pascal programming language where is possible to build graphical user interface fast visually by picking and placing user interface components in the same fashion as Visual Basic or Borland Delphi (now Embarcadero Delphi).
- Features:
- Based on Borland Delphi
- Compilation to native code
- Much Faster compile-time than C++
- Can ship the application as a single executable which makes the deployment of Desktop GUI apps easier.
- Build graphical user interfaces fast by dragging and dropping UI components like in Visual Basic 6 or Embarcadero (Old Borland) Delphi.
- Static compilation with all dependencies.
- Cross-platform - the same project can be recompiled with the IDE on Windows, Linux and Mac-OSX.
- Lots of built-in user interface components
- Can reuse Delphi components
- Lots of database connectivity components
- Ability to call C-APIs, C-code and shared libraries. C++ code can be called with a C-interface (extern "C" …)
- Problems:
- Some people may not like object-pascal syntax that is different from the C-like syntax.
- Small community
- Scattered documentation
- Without proper discipline, the application can easily become an spaghetti as it is easier to mix the application code with the graphical user interface GUI code, although this shortcoming can be mitigated with MVC - Model View Controller.
- Applications built with Lazarus IDE + Object Pascal
- Coedit - IDE for D language - Github
- TorChat - Initially written in Python, then switched to Lazarus IDE.
- CheatEngine - Github
- PascalScada - Github
- Lazarus Application Gallery (full list of applications)
1.7 C++ code as a component or as Library
- Shared Library with C-interface
- The C++ code can be turned into a shared library by manually writting a C-interface (lots of extern "C") that can be loaded from any programming language via foreign-function interface such as Python C-types, Java JNA or .NET / C# P-invoke.
- Shared Library with Programming Language Specific C native interface
- Many programming languages such as Python, Ruby or Java (JNI) are written in C or C++ and provide a native interface API where is possible to create native modules or libraries in C and load them as they were ordinary libraries. So, a C++ code can be turned into a Python library by compiling the code with its bindings or adapter code for Python native API. The drawback of this approach is that, it will be hard to reuse the library with other programming languages.
- Swig Wrapper Genrator
- The SWIG wrapper generator parses Swing interface files, C and C++ header files and then generates binding code for a native C interface of some specified programming language. So, SWIG can generate native Python, Ruby or Java and other languages native libraries.
1.8 C++ with Embedded Scripting Languages
Embedded programming languages can make easier for non-technical or non-programming users to extend, configure and customize applications without any recompilation. They also allow end users to build add-ons, extensions or plugins. This approach is widely used by games for allowing non-programmers to create higher level logic, gameplay, animation and mods. Some programming languages were designed specifically to be embedded:
- TCL - Tool Command Language (1988)
- Widely used as embedded scripting language in EDA - Electronic Design Automation Tool. This happens due to the language creator, John Ousterhout, initially develped TCL as an scripting extension language for EDA applications.
- See:
- Lua (Moon in Portuguese) Programming Language (1993)
- Feature: Lua programming language is lightweight and minimal and avaialable as C-library easier to be embedded in a C or C++ application.
- Used in:
- Games;
- Nginx web server;
- LuaTex;
- MediaWiki (Wikipedia wiki engine) - uses lua as a template engine
- Nmap network scanner
- More at: list of applications using Lua
- Video: CppCon 2017: "Howling at the Moon: Lua for C++ Programmers" (32 minutes)
- Python (CPython implementation) (1991)
- As Python is written in C, its runtime can be embedded in a C++
application allowing it to be extended and customized by
end-users and take advantage of users previous knowledge as
Python is being used more and more for introducing
programming. The disadvantage is that Python it is not so
lightweight as language designed to be embedded in other
applications and its native interface C-API is harder to use.
- Note: The header-only library Pybind11 makes easier to embed Python in C++ applications.
- Embedding Python in C++
- Video: Embedding Python in a C++ Project - Visual Studio - Ogre Game Engine + PyBind11 (17 minutes)
- Video: Embedding Python: Charming the Snake with C++ (28 minutes)
- Video: James Powell - Embedding of Python (1:28:00)
- As Python is written in C, its runtime can be embedded in a C++
application allowing it to be extended and customized by
end-users and take advantage of users previous knowledge as
Python is being used more and more for introducing
programming. The disadvantage is that Python it is not so
lightweight as language designed to be embedded in other
applications and its native interface C-API is harder to use.
- mruby - Embeddedable Ruby Implementation
- Github: https://github.com/mruby/mruby
- "mruby is the lightweight implementation of the Ruby language complying to (part of) the ISO standard. Its syntax is Ruby 1.9 compatible. mruby can be linked and embedded within your application. We provide the interpreter program "mruby" and the interactive mruby shell "mirb" as examples. You can also compile Ruby programs into compiled byte code using the mruby compiler "mrbc". All those tools reside in the "bin" directory. "mrbc" is also able to generate compiled byte code in a C source file, see the "mrbtest" program under the "test" directory for an example."
- Scheme / Lisp (Chibi Scheme Implementation)
- "Chibi-Scheme [1] is a very small library intended for use as an extension and scripting language in C programs. In addition to support for lightweight VM-based threads, each VM itself runs in an isolated heap allowing multiple VMs to run simultaneously in different OS threads."
- Github: https://github.com/ashinn/chibi-scheme
- Embedding Scheme for a game mission scripting DSL
- Scheme / Lisp (TinyScheme Implementation)
- Official Web Site: http://tinyscheme.sourceforge.net/home.html
- Small embeddable Scheme implementation used by GNU GIMP image editor.