here you goThings I’ve made, read and saved — shared here.

Archive

9,565 entries: 46 from X, 8,923 from Pinboard, saved 1998 to 2026.

Browse by tag, site, author, folder or language

Tags

Sites

Authors

Folders

Languages

44 entries#programming-language ×

2025

"APL since 1978" in Proceedings of the ACM on Programming Languages

dl.acm.org

The Evolution of APL, the HOPL I paper by Falkoff and Iverson on APL, recounted the fundamental design principles which shaped the implementation of the APL language in 1966, and the early uses and other influences which shaped its first decade of enhancements.

By Roger Hui. (108 pages). Should be a comprehensive historical review of the APL language.

2024

C3 Programming Language

C3 programming language. Full C ABI compatibility, Module system, Generic modules, Design by contract, Zero overhead errors, Semantic macro system, First-class SIMD vector types, Struct subtyping, Safe array access using slices, Easy to use inline assembly, Cross-platform standard library which includes dynamic containers and strings, LLVM backend.

C3 Tutorial; has online playground.

C3 Blog by the creator, Christoffer Lernö

Also look at dlang's betterC - Better C - D Programming Language

notes#c#programming-language

2023

typescript

Typescript was created at Microsoft.

Learn

TypeScript Deep Dive by basarat is a good tutorial for TS. It helped me understand various terminology like what what package.json, tsconfig.json are. commonjs modules, exports; setting up projects for various target - node.js vs browsers etc.

Typescript Book by Simone Poggiali.

Cloud

Val Town -- If GitHub Gists could run And AWS Lambda was fun. Val Town is a social website to write and deploy TypeScript. Build APIs and schedule functions from your browser.

notes#javascript#programming-language

Java

Modern Java - an online book; a 2026 approach to learning Java in bite-sized lessons. Don't have to start in an IDE for one.

Internals

Articles

Interesting libraries

Permazen Permazen is a ground-up rethink of Java persistence. It has been in production use in commercial software since 2015.

 Instead of starting from the storage technology side, it starts from the programming language side, asking the simple question, "What are the issues that are inherent to persistence programming, regardless of programming language or database storage technology, and how can they be addressed at the language level in the simplest, most correct, and most language-natural way?"

notes#java#programming-language

Csharp

Why Tracebit is written in C#; Jan 2025. "Tracebit deploys and maintains tailored security canaries, proactively detecting intrusions across your organization.  From cloud infrastructure, to identity and endpoints."


bflat - C# as you know it but with Go-inspired tooling (small, selfcontained, and native executables)

  • Comes with two standard libraries: one (DotNet) that is compatible with .NET and supports everything from console to JSON, and another (Zero) that is stripped to bare minimum and doesn't even have a GC.
  • Run C# with no operating system, on bare metal
  • Build native code or .NET bytecode
  • Based on parts of the .NET 7 SDK
  • Invoke bflat directly from terminal, integrate with a shell script, Makefile, or even MSBuild.

notes#dotnet#programming-language

2020

Common Lisp

Why

Why I Chose Common Lisp — Dan's Musings; Jan 2025.

Core

Learning

If you are a beginner to CL, this challenge will help you to get started with setting up a development environment from scratch and begin the journey of learning CL together with other community members.

Reading /practicing CL programming

Scripting

Common Lisp as a Scripting Language, 2015 edition - Cybernethics / Cybernéthique — LiveJournal

Install cl-launch:

git clone https://gitlab.common-lisp.net/xcvb/cl-launch.git
cd cl-launch
make
make install
which cl
/usr/local/bin/cl

Example script -- cllaunch1.lsp:

#!/usr/bin/cl -sp lisp-stripper -E main
(defun main (argv)
  (if argv
      (map () 'print-loc-count argv)
      (print-loc-count *standard-input*)))

Run it: chmod +x cllaunch1.lsp

Fails with: Component "lisp-stripper" not found, required by #<SYSTEM "cl-launch-build-0">

To fix this, i cloned https://github.com/fare/lisp-stripper to ~/common-lisp, and the above problem goes away. Next it fails to find cl-ppcre.

I do remember installing it using quicklisp -- ls ~/quicklisp/dists/quicklisp/software/cl-ppcre-20190521-git.

Distributing CL binaries

Links

Common Lisp Books

Blogs

Projects

Fairly recent Common Lisp project that is not just a web application etc., -- https://github.com/atgreen/red-light-green-light -- "A git-centric policy management and enforcement tool designed to accelerate your CI/CD pipelines."

Opusmodus -- "Music Composition System"

Opusmodus revolutionizes music composition, fuses traditional notation with modern concepts, and streamlines the path to a finalized score.

Editing

notes#lisp#programming-language

Haskell Programming Language

Why Haskell

via

Why Not Haskell

Learning Haskell

Liquid Haskell

Write Simple Haskell

Read Haskell code

Video lectures and talks

Courses

  • Functional Programming an introductory course on functional programming in Haskell by Graham Hutton.
  • Introduction to Haskell at UPenn by Brent Yorgey, Joachim Breitner et al. This in my experience is the best introduction to Haskell in a classroom format you can find. The lecture notes are self-explantory and written in a conversational, easy to follow manner.
  • CMSC498V -- "Advanced Functional Programming Languages (Fall 2017)" taught by Dr Niki Vazou at UMD.

Developing with Haksell

Resources

Blogs

Blog posts / articles

Meta lists

Editors

  • Haskell idea plugin
  • Haskell for Mac
  • Code.world
  • Haskell-tools A GHC based toolset for Haskell programming. Currently featuring Haskell-tools Refact, a refactoring framework.
  • HyperHaskell -- is a graphical Haskell interpreter (REPL), not unlike GHCi, but hopefully more awesome. You use worksheets to enter expressions and evaluate them. Results are displayed using HTML.

Papers

My Notes

What are some of the low-friction ways of using Haskell?

  • Pandoc -- add custom elements, extract metadata from documents.
  • Hakyll -- build custom site renderers.
  • Shake -- build system where Make isn't sufficient.

If you get can't load .so/.DLL for when installing cabal package: put shared: True in ~/.cabal/config

Cabal

Sandbox:

    cabal sandbox init
    cabal init #to init a new proj.

remember to export HASKELL_PACKAGE_SANDBOX=.cabal-sandbox/x86_64-osx-ghc-7.6.3-packages.conf.d inside the cabal sandbox.

jupyter notebook

See www.btbytes.com/stack.yaml for dependencies.

stack new myproj
cd myproj
stack init
brew install zmq
stack exec ipython -- notebook

Note: iHaskell binary is installed in ~/.local/bin:

Copied executables to /Users/pgowda/.local/bin/:
- ihaskell

(not sure if the above two lines are actually important ...)

Libraries and tools

Haskell Reference

Misc

Links

Projects in haskell

notes#functional-programming#haskell#programming-language

Zig Programming Language

The Zig Programming Language is an open-source programming language designed for robustness, optimality, and clarity.

Introduction

Code

Learning

Articles

Project Management

FFI

Twitter

Provide or link to a small (50-200 ish lines) idiomatic Go program demonstrating concurrency. (Elegant use of goroutines, channels, etc)

I'll provide the equivalent Zig program using async/await and std.event.Loop for comparison.

My notes

Cross compiling zig

Code

# crosscompile.zig
const warn = @import("std").debug.warn;

pub fn main() void {
    warn("Hello, world!\n");
}

Compiling natively on Mac OSX

$ zig build-exe crosscompile.zig
$ file crosscompile
crosscompile: Mach-O 64-bit executable x86_64

Cross-compiling for Linux

The C ABI tuple of (operating system, architecture, C compiler environment) is defined by --target-os --target-arch --target-environ flags of zig. [ref]

zig build-exe crosscompile.zig --target-os linux --target-arch x86_64

Verify the executable file type created:

$ file crosscompile
crosscompile: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, with debug_info, not stripped

Software written in Zig

notes#programming-language#zig

D Programming Language

Why D?

Show off D

Semantics

Garbage Collection

Example code showing GCStats:

import std.stdio;

extern (C)
{
	void gc_stats(GCStats* stats) nothrow;
}

struct GCStats
{
    size_t poolsize;        // total size of pool
    size_t usedsize;        // bytes allocated
    size_t freeblocks;      // number of blocks marked FREE
    size_t freelistsize;    // total of memory on free lists
    size_t pageblocks;      // number of blocks marked PAGE
}

void main()
{
	GCStats stats;
	gc_stats(&stats);
	writeln(stats);
	auto p = new byte[200];
	gc_stats(&stats);
	writeln(stats);
	p = new byte[1000];
	gc_stats(&stats);
	writeln(stats);
	p = new byte[10000];
	gc_stats(&stats);
	writeln(stats);
}

To turn on garbage collection profiling

$ max_column_sum_by_key_v1 --DRT-gcopt=profile:1 ngrams.tsv 1 2
max_key: 2006 sum: 22569013
        Number of collections:  132
        Grand total GC time:  246 milliseconds
GC summary:   35 MB,  132 GC  246 ms

Summary of GC discussion

See June 2016 discussion on the Garbage collector

  • Precise GC is in the works. (todo: summarise progress)
  • "Only a few language features forces you to use the GC." (which ones?)
  • "For most uses you are not forced to use the GC in any form especially with the help of std.experimental.allocator." (How?)
  • Current GC is based on a forked version of Boehm GC. So, not easy to upgrade to current version without deep understanding of how D does Thread Local Storage etc.,
  • "we can disable the GC so it won't go ahead and scan upon allocation (only time it does)" (how?)

Memory allocations are /always/ expensive. Higher level languages like Java have the benefit of using pools and optimizing for this usage pattern, D does and will never have this. Keep in mind an allocation = usage of malloc + write to returned pointer. -- rikki c.

The point is, D doesn't have to have a GC. Not using it is way easier than in most other languages because all the tools to help you profile it and avoid it are provided by the compiler. Go without a good GC is a dead language. D without a good GC is just not as good as it could be. And btw we're generally faster than Go ;-) The point is: while a better GC is a work in progress we'll never have a GC that can fit all needs, but it's not as critical as it is in Go or in C# because we provide other ways to manage memory when limitations arise. -- cym13

"Has anyone thought about taking GC from .NET and reusing it in D?"

One significant point has been already mentioned: cost of write barriers. I'd like to mention another factor: .NET GC is a copying one, it moves data around. One good feature of current D is it never moves data, so you can very easily call C and C++ code and pass pointers to your buffers and stuff and C/C++ code just takes these pointers and works with them as usual. No pinning, no marshaling, zero overhead. If you take a moving GC like .NET's, you immediately make all C/C++ interaction much harder, now you need to worry about pinning stuff or copying "managed" data to "unmanaged" memory and back. This is all costly both in terms of CPU cycles and of programmer cycles. You'll need "FFI", what most other GC-ed languages have to have, and D doesn't. --thedeemon

Precise Garbage Collector

GSoC project

It is essentially in a similar state that it was when Rainer presented it at DConf2013. The version in the pull request is not different from the one Rainer presented at all. It's actually the same one, just updated with what has been changed in druntime recently and my attempts at making the marking phase faster.

Meta programming3

Debugging

Building

  • To build projects using ldc2 instead of dmd2 with dub, use the --compiler switch, thus: dub build --compiler=ldc2
  • To build the release version of the software, use the -b switch, thus: dub build -b release

Cross Compiling

Serialization

  • Orange library for serialization.

Concurrency

Range based programming

  • poita.org has couple of articles on range based programming.

Profiling / performance

D run time

Testing

C/C++ binding

Lexing and parsing

Another option is to use a lexer/state machine generator. Ragel supports D and Rust (as of the not-quite-released v7) as target languages. HN

Memory safety

Documenting D code

  • harbored-mod A documentation generator for D with support for both DDoc and Markdown in documentation comments.

Higher level programming

Resources

Introduction

Intermediary

Articles

Tutorials

Presentations

Editor

  • IntelliJ plugin for D language -- look at the screenshots. It is a fairly complete IDE with syntax highlighting, auto completion, compile checking, code linting (via Dscanner), navigate to classes etc.,

  • DDT -- the Eclipse based D IDE works as advertised. Use the 3.7(Indigo) version. [In Oct 2012, DDT did not work with the latest version of Eclipse: Juno].

  • Setting up TextAdept to autocomplete D code using DCD

Blogs

Talks

Read code

Discussions

Contributing to D development

Software written in D

Developing and distributing D software

Misc

User experience

Libraries

For some reason, many D programmers have this "collection of D libraries", which is interesting in the sense that more than one developer has found it just easy to write their own library to do X...

In addition to those of CWEB:

  • Markdown based -- very easy to read and write Literate source.
  • Generates readable and commented code in the target language (the generated code is usable by others)
  • Reports syntax errors back from the compiler to the right line in the literate source
  • Supports any language including syntax highlighting and pretty printing in HTML
  • Compatible with Vim (literate.vim)
  • Highly customizable (you can add your own HTML or CSS)
  • Runs fast -- wc.lit compiled for me in 7ms for both code and HTML output
  • Supports TeX equations with $ notation.

Inspired from CWEB:

  • Automatically generates hyperlinks between code sections
  • Formatted output similar to CWEB

Interop

The power of reflection | Átila on Code

import autowrap;
mixin(
    wrapDlang!(
        LibraryName("mylib"),
        Modules(
            Module("mymodule"),
            Module("myothermodule"),
        )
    )
);

The code above, when compiled, will generate a Python extension (shared library) that exposes every D function marked as “export” in the modules “mymodule” and “myothermodule” as Python functions. It’ll even convert their names from camelCase to snake_case. Any D exceptions thrown will become Python exceptions. D structs and classes become Python classses. If the original D functions take a D string, you’ll be able to pass Python strings to them in user code. Modulo bugs, this… works! The code shown above is the only code that needs to be written. Setting up the build system takes more work!

notes#dlang#programming-language

Forth

History

Chuck Moore -- inventor of FORTH. I saw Chuck at Strange Loop 2013. The picture on his home page is from his talk at that Event.

Articles

Presentations

Books

Implementations

See also: Factor

Discussions

Interesting take:

Forth is the language that taught me (among other things) that its possible to break problems into pieces that are too small to understand the whole. I'm not sure really what to call this other than something along the lines of can't see the forest for the trees. Its the opposite of having functions so large it takes hours to figure out what they do. In this case you have words that you can't figure out what they do for days because the call graphs step across 300 different modules and 10k other words all of which are like "update-pie-with-apples" and comprise two other words "dup pie, apple-pie-update" or something. -- via

notes#forth#programming-language

PHP Programming Language

25 years of PHP history a chronological story of PHP by JetBrains.

Jan 2019 Notes:

Success stories

Facebook’s backups were written in PHP. Well, the second version was, anyway. (T... | Hacker News

Multiprocess, forking, long-lived, server-side, I/O intensive PHP. And it worked brilliantly. Over the following years, it scaled from a backup set of a few hundred TB to many, many petabytes.

Alternatives

alekcz/pcp: PCP: Clojure Processor -- Like drugs but better

Just use it like PHP on a webserver (say nginx):

    #new pcp config => change .php to .clj
    index index.clj index.html index.htm;
    #new pcp config => change .php to .clj
    location ~ \.clj$ {
        #default nginx config on digital ocean lemp image
        #include snippets/fastcgi-php.conf;
        #fastcgi_pass unix:/run/php/php7.0-fpm.sock;

        include scgi_params;
        scgi_intercept_errors on;
        scgi_pass   127.0.0.1:9000;
    }

PCP has following libraries built in:

(require  '[cheshire.core :as json]
      '[clostache.parser :as clo]
      '[selmer.parser :as parser]
      '[selmer.filters :as filters]
      '[clj-http.lite.client :as client]
      '[next.jdbc :as jdbc]
      '[honeysql.core :as sql]
      '[honeysql.helpers :as helpers]
      '[postal.core :as email]
      '[clojurewerkz.scrypt.core :as sc])

FrankenPHP: the modern PHP app server "Uses the official PHP executor embedded in a state-of-the-art web server: Caddy"; written in golang

notes#programming-language

Clojure programming language

Clojure is a Lisp that runs on the Java Virtual Machine (JVM).

Learning resources

Clojure as a Lisp

Courseware

Presentations

Clojure like languages

IDE and infrastructure

  • Lightmod -- Lightmod is a tightly integrated tool for making full stack Clojure and ClojureScript web apps. It is fully self-contained -- no need to install the JDK or any build tool. It hot reloads both client and server code automatically with zero setup.

  • Nightlight is an editor you run inside your Clojure projects. Instead of being a separate application like traditional editors and IDEs, it's just a library that you add to your project. It spins up a web server and provides a completely browser-based interface to edit your code.

  • CIDER is the successor to nrepl.

  • Cursive Clojure IDE -- is an IDE built on IntelliJ

  • Parinfer

REPL

online playgrounds

Getting started with Lighttable

Via

Basic instructions. I use cmd for the shortcuts below, substitute ctrl on non-mac platforms.

  1. Install Leiningen http://leiningen.org/ you do not need to install clojure, lein will grab clojure for you.
  2. lein new playground from the command line to create a 'playground' project
  3. Open Light Table
  4. ctrl-space woto for "Toggle Workspace tree"
  5. Add the playground project folder you just created
  6. cmd-o core.clj to open the main clojure file for the project
  7. On an empty line type (+ 1 1) and hit cmd-enter

Things will grind away for a while as all the dependencies are downloaded and the JVM starts up. Get a cup of coffee or something. Eventually you'll see a green 2 show up.

You can then type anything in the tutorial and hit cmd-enter to evaluate it or cmd-shift-enter to evaluate the entire file. Think of the file as a shell with an editable history instead of something you'd want to commit to source control.

Documentation is searchable via ctrl-shift-d or moving your cursor on top of a function name and hitting ctrl-d. Autocomplete is available on tab, you can jump to definition with cmd-. and back with cmd-,

TODO: Explore CIDER + AC(autocomplete) + ritz.

Applications

Libraries

Spec

the biggest win from spec has been with parsing. This completely changes how you'd write a library that takes a data structure and parses it into something meaningful (for example, what hiccup does for html or what honeysql does for sql). In the past, this required a lot of very ugly parsing code and manual error-checking. With spec, you write specs and call s/conform. If it failed, you get a nice error, especially if you pair it with expound. If it succeeded, you get a destructured value that is really easy to pull data out of. I've done this in a half dozen different libraries and i'm pretty sure i wouldn't have even written them without spec.

Mallimalli and specmonstahspecmonstah are my favourite Clojure(Script) libraries built on top of Clojure Spec.

Clojure books

The first chapter, Names, explains why names define the structure of our software, and how to judge whether a name is any good.

The second chapter, Idioms, provides specific, syntactic advice for writing Clojure which is clean and readable.

The third chapter, Indirection, looks at how code can made simpler and more robust through separation.

The final chapter, Composition, explores how the constituent pieces of our code can be combined into an effective whole.

Clojurescript books

Experience reports and discussions

Articles

Talks and presentations

Tips and tricks

Cool projects / Read Code

Visualization / Notebook

Web development

Big data

Blogs

ClojureScript

Graal

  • This nextjournal notebook has a recipe for building Babashka "executing Clojure snippets or scripts in the same space where you would use Bash."

Web development

PCP

alekcz/pcp: PCP: Clojure Processor -- Like drugs but better

Just use it like PHP on a webserver (say nginx):

    #new pcp config => change .php to .clj
    index index.clj index.html index.htm;
    #new pcp config => change .php to .clj
    location ~ \.clj$ {
        #default nginx config on digital ocean lemp image
        #include snippets/fastcgi-php.conf;
        #fastcgi_pass unix:/run/php/php7.0-fpm.sock;

        include scgi_params;
        scgi_intercept_errors on;
        scgi_pass   127.0.0.1:9000;
    }

PCP has following libraries built in:

(require  '[cheshire.core :as json]
      '[clostache.parser :as clo]
      '[selmer.parser :as parser]
      '[selmer.filters :as filters]
      '[clj-http.lite.client :as client]
      '[next.jdbc :as jdbc]
      '[honeysql.core :as sql]
      '[honeysql.helpers :as helpers]
      '[postal.core :as email]
      '[clojurewerkz.scrypt.core :as sc])

Learning Journal

  • this is a good demo of how to use Clojure's -Sdeps at the command line to execute a script (even one hosted remotely on git):
clojure -Sdeps '{:deps
    {hello-clojure
        {:git/url "https://gist.github.com/athos/b68b15b08efedffaf14d8c020b125202"
        :sha "1c9a05106171f97f9b8e8ac8f58c7bd8dbe021f9"}}}'
    -m hello-clojure

See also: lisp, scheme.

notes#clojure#jvm#lisp#programming-language

Javascript

News

Learning

WAT

JS Alternatives

--

Reading

Functional programming

Tooling

Libraries

Visualization

  • Fabric.js Javascript Canvas Library -- via
  • Two.js -- two-dimensional drawing api geared towards modern web browsers. It is renderer agnostic enabling the same api to draw in multiple contexts: svg, canvas, and webgl. Jul 2015.

Frameworks

It is similar to JavaScript frameworks such as React and Vue, which share a goal of making it easy to build slick interactive user interfaces. But there's a crucial difference: Svelte converts your app into ideal JavaScript at build time, rather than interpreting your application code at run time. This means you don't pay the performance cost of the framework's abstractions, and you don't incur a penalty when your app first loads. You can build your entire app with Svelte, or you can add it incrementally to an existing codebase. You can also ship components as standalone packages that work anywhere, without the overhead of a dependency on a conventional framework.


The Bandolier: A Learn JavaScript the Hard Way Project by Zed Shaw. A fresh approach, and since it was built to teach JS programming, it should be easy to grok.

Links

Apps

Books

Talks


See also: webpack

notes#javascript#programming-language

A Programming Language (APL)

kdb, Q etc.,

APL learning resources

APL like languages

notes#apl#programming-language

Rust Programming Langauge

A modern alternative to C and C++ for system programming.

Why?

How

Articles / Talks

Books

The Little Book of Rust Books

Print books

Online books

Experience reports

Papers / reports

Videos / Talks

Blogs

Tutorials

Courseware

Source code to study

Links

Libraries and tools

WASM

  • Seed -- A Rust framework for creating web apps

Applications

To study code, library usage etc.,

  • mcux/kylyp: A new Forum. The project uses rust, rocket, diesel, postgresql, and responsive design to build a new Forum.

Command Line Tools in Rust: See also: Common *nix commands written in Rust – gcollazo

ekzhang/rustpad: Efficient and minimal collaborative code editor, self-hosted, no database required alternative to codepad.

Editor setup

Performance

Memory Management

Safety-critical programming

What is Ferrocene?

Ferrocene is the main Rust compiler - rustc - but quality managed and qualified for use in automotive and industrial environments (currently by ISO 26262 and IEC 61508) by Ferrous Systems. It operates as a downstream to the Rust project, further increasing its testing and quality on specific platforms.

References and borrowing

Lifetimes

Async / Await

Web

Embedded

This book is an "introductory course" on microcontroller-based "embedded systems" that uses Rust as the teaching language rather than the usual C/C++.

Comparisons (Rust vs X)

FFI

// rustimport:pyo3
use pyo3::prelude::*;

#[pyfunction]  // ← expose the function to Python
fn fibonacci(number: u64) -> u64 {
...
import rustimport.import_hook
from rustfib import fibonacci

Discussions

Cargo

Installing a package that is not on crates.io: cargo install -f --git https://github.com/cjbassi/ytop ytop

  • Cargo Dist distributes your binaries. and in combination with oranda it also generates websites.

Best Practices / Tips

Hardware / bare metal

Rust vs Python

Rust and Python

Rust vs Java for rest services

-- via reddit

I gave a talk (video) today about "Rust for Java programmers" at my local java users group. Part of the talk was comparing the implementation of a minimal rest service in a container for the following 4 approaches:

  1. Payara-micro (JEE/JAXRS)
  2. Wildfly-swarm (another JEE/JAXRS micro deploy)
  3. Javaspark (non JEE "lightweight" framework)
  4. Rust-rocket

The comparisons are striking, viewed in the same 1/2/3/4 sequence above:

  • Container Image Size: 173MB / 151MB / 104MB / 2MB

  • Container Startup Time: 22.2s / 17.6s / 1.6s / 0.6s

  • Memory Usage at Startup: 630MB / 401MB / 34MB / 1.6MB

  • Memory Usage under Stress: 647MB / 522MB / 74MB / 1.7MB

  • CPU usage and throughput show a similar progression as above.

Nice job, Rocket! (results are unscientific. fight me) -- Source code

Success Stories

We had a similar challenge supporting sending this many notifications at OneSignal, which we solved using Rust. We recently hit a peak of 850 Million notifications per second, and 5 billion notifications per day. Here's a blog post on how we do it. Written back when we were at "only" 2 billion notifications per week: https://onesignal.com/blog/rust-at-onesignal/


Rolling log of things

2017-09-08:

There is a new book -- Programming Rust by Jim Blandy, and Jason Orendorff. Jim Blandy has also written a concise short book Why Rust [PDF]

Rust is currently unable to call directly into a C++ library; so that way Rust is probably behind D.

Rust, by design, makes certain programming patterns more painful than others. This is a GOOD thing! It turns out that, for game development, the patterns that end up being the easiest to deal with in Rust closely mirror the patterns that are easiest for game development in any language. Rust highly rewards data-oriented design with simple, understandable ownership semantics, and this is great news because this is a really good fit for game development.


See also: rust2018

References

notes#programming-language#rust

Go Programming Language

Go is the only programming language that has been designed from the ground down. -- vzverovich

Go advocates for making thread creation easy and light-weight and for using message passing over shared memory for inter-thread communication. Indeed, we saw more gor-outines created in Go programs than traditional threads andthere are significant usages of Go channel and other message passing mechanisms. However, our study show that if not used correctly, these two programming practices canpotentially cause concurrency bugs.

Shared memory vs. message passing: Our study found that message passing does not necessarily make multi-threaded programs less error-prone than shared memory.In fact, message passing is the main cause of blocking bugs.To make it worse, when combined with traditional synchro-nization primitives or with other new language featuresand libraries, message passing can cause blocking bugs thatare very hard to detect. Message passing causes less non-blocking bugs than shared memory synchronization and sur-prisingly, was even used to fix bugs that are caused by wrongshared memory synchronization. We believe that messagepassing offers a clean form of inter-thread communicationand can be useful in passing data and signals. But they areonly useful if used correctly, which requires programmersto not only understand message passing mechanisms wellbut also other synchronization mechanisms of Go.

Project structure

A very common question Go beginners have is "how do I organize my code?". Some of the things folks are wondering about are:

  • How does my repository structure reflect the way users import my code?
  • How do I distribute commands (command-line programs that users can install) in addition to code?
  • How do modules change the way I organize my code?
  • How do multiple packages coexist in a single module?

Moving to Go

History

Learning

The Go Programming Language by Donovan and Kernighan.

Training

Reading

Development practices

The Go team has published official guidelines for organizing / structuring a Go project: https://go.dev/doc/modules/layout This includes recommended project layouts for different kinds of projects: a simple package, a command-line tool, a mix of the two, etc. via

Deployment practices

Performance monitoring

User Groups

Presentations

Libraries

Read Code

List of Lists on Go

  • Awesome Go -- A curated list of awesome Go frameworks, libraries and software.

Editors

FFI

Garbage Collection

Why Discord is switching from Go to Rust - Discord Blog

In Go, on cache key eviction, memory is not immediately freed. Instead, the garbage collector runs every so often to find any memory that has no references and then frees it. In other words, instead of freeing immediately after the memory is out of use, memory hangs out for a bit until the garbage collector can determine if it’s truly out of use. During garbage collection, Go has to do a lot of work to determine what memory is free, which can slow the program down. These latency spikes definitely smelled like garbage collection performance impact, but we had written the Go code very efficiently and had very few allocations. We were not creating a lot of garbage. After digging through the Go source code, we learned that Go will force a garbage collection run every 2 minutes at minimum. In other words, if garbage collection has not run for 2 minutes, regardless of heap growth, go will still force a garbage collection.

garbage collection - How fast is the go 1.5 gc with terabytes of RAM? - Stack Overflow

3-4ms pauses under 1.6, with about an 8GB heap and 150M allocations/minute.

Concurrency

Programming notes

Debugging notes

Copying core dumps

Build notes

Cross compiling a binary for Linux on Mac.

git clone git@github.com:xyproto/algernon.git
cd algernon
env GOOS=linux GOARCH=amd64 go build

Tools

Package management

Web

Frameworks

  • Go Blueprint Hello -- "Choose your desired features, and we'll generate the command you can use to create your project."

  • blackfyre/wga: Jumping forward ~30 years -- This repositry contains the code for the Web Gallery of Art project. The project is a web application that allows users to browse through a collection of paintings, sculptures and other forms of Art. This project is inteded to shave off the 3 decades of tech debt on the original website and provide a modern, responsive and user friendly experience with the same content. -- study this project and the choices it has made -- pocketbase, htmx, bulma, golang, sass, and goreleaser

  • anthdm/superkit still in development.

Templating

templ -- "A HTML templating language for Go that has great developer tooling." github

package main

templ Hello(name string) {
<div>Hello, { name }</div>
}

templ Greeting(person Person) {
<div class="greeting">
@Hello(person.Name)
</div>
}

notes#golang#programming-language

OCaml programming language

OCaml for the impatient . The web's quickest and dirtiest OCaml getting started guide This is the most up to date setup using Opam, jbuilder, Merlin, VSCode etc.,(. August 2017). (ed note, 2023-10-10: Since then the OCaml system has made huge strides in developer productivity.)

xvw.lol - Why I chose OCaml as my primary language, an opinion piece by a programmer that uses OCaml professionally at tarides. Is a good intro the ecosystem in 2025; via

Language

Concurrency

Learning OCaml

Courseware

Tutorials

Best practices

  • Our current OCaml best practices. -- part 1 and part 2 by Issuu Engineering; Dec 2018.

Books

Textbooks

Articles

Blogs

Resources

Papers

Package managers

OCaml Languages

Reason: a syntax for OCaml, so native development or melange development to compile to JS

ReScript: a syntax similar to Reason, but the entire toolchain. Closer to JavaScript, can't compile to native.

Talks

Yaron Minsky:

Miscellaneous

OCaml as a replacement language

Writing languages using OCaml

Tools, ecosystem and libraries

Js_of_Ocaml

  • js-skeleton -- sample project showing how to build a Javascript web-app using js_of_ocaml, TyXML and React
  • H.261 Video Decoding in OCaml. -- This notebook will demonstrate a simple H.261 Video Decoder written in OCaml and compiled to javascript with js_of_ocaml.

OCaml project tools

Build tools:

Some opinions on the merits of using these tools:

Code bits

Explicit Typing of a polymorphic variant

type download_result =
  [ `aborted_by_user
  | `network_failure of string
  | `success of filepath ]

via

Information

QQ

  • What is good about OCaml's module system?
  • What good is First class Modules?
  • "Using an error monad in a language like ocaml is superior to exceptions in almost every way." via

Sample code / Read Source

Multicore OCaml

Object oriened OCaml

Hindley-Milner type system

Semantics

Web programming with OCaml

PPX

Comparison

min-caml

esumii/min-caml: a complete optimizing native-code compiler for a reasonably usable subset of OCaml, in 2000 lines of OCaml. Paper.

Running log

PSA: Tired of inscrutable type errors from OCaml? If you use jbuilder/dune, just add this to your jbuild build stanza: (flags (:standard -short-paths)) and your type errors and inferred types from Merlin will magically improve!

NixOS

Data Science and AI

OCaml Garbage Collection

My notes

emacs + utop + merlin + typerex = Excellent IDE.

2014-11-25: Run ocamlbrowser in a shell to see a tk based documentaiton browser.

OCamlEditor

Fortunately, you can install it using opam install ocamleditor... unfortunately you are dealing with various idiosyncrasies of GTK on mac... ugh.. To keep it short, lablgtk installation by opam might fail with pkg-config errors. The fix is:

https://github.com/Homebrew/homebrew/issues/14123#issuecomment-37896791

... before running opam install ocamleditor. Solution via

Note: looks butt-ugly on mac, as expected.

opam allows you create "sandboxes" and install packages in them. See the -A --alias-of option.

See Setting up an OCaml environment for Programming. Use ocamlfind, ocamlbuild and make.

Apr 2016. See ogen -- a tool for creating new OCaml projects with OPAM, Oasis, and Merlin.

Compiling an ocaml file:

  • That has no dependecies

    ocamlopt foo.ml -o foo

  • that has a dependency (say csv)

    ocamlfind ocamlopt -o test -linkpkg -package csv test.ml

ocamlfind

  • ocamlfind is a program that finds all the ocaml packages that are installed on your system (or opam instance, for that matter).
  • ocamlfind -h to see list of commands available.
  • ocamlfind printconf shows the path configs etc.,
  • ocamlfind list will list all the packages installed.

ocamldep

typical usage: ocamldep *.ml, which will dumps dependency lines.

** Different file types **

  • .cmo --
  • .cmi --
  • .mli --

--

OCaml has good study materials -- textbooks, lecture notes. There is also the advantage of being able to roll-over to F# for "enterprise" stuff.

notes#ocaml#programming-language

Interesting Programming Languages

An opinionated collection of programming languages. This is a list of what I consider interesting. Requests to add to this list are welcome, but there is no guarantee I'll include them. As you can see many mainstream programming languages are missing from this list.

Of these, I try to maintain interest in -- ATS, Chapel, Zig, Nim, Flix, Crystal, Vale, and Roc, outside the mainstream languages.

  • Alore is a language that explores optional typing in a Python-like programming language.
  • Alpaca is a statically typed, strict/eagerly evaluated, functional programming language for the Erlang virtual machine (BEAM). At present it relies on type inference but does provide a way to add type specifications to top-level function and value bindings. It was formerly known as ML-flavoured Erlang (MLFE).
  • Amber -- "The Programming Language compiled to bash. Write your scripts in a modern type-safe and runtime-safe programming language that handles many bugs and mistakes during compilation process."
  • appcypher/astro: A multi-paradigm programming language that compiles to WebAssembly and native code. with Python syntax.
  • Arturo programming language; looks like REBOL? and claims "Want to ship your scripts anywhere? For any operating system? Without weird dependencies and without asking the user to install an endless list of modules/gems/packages? That's exactly what Arturo was designed for.", and batteries included.
  • Asymptote is a descriptive vector graphics language that provides a natural coordinate-based framework for technical drawing. Labels and equations are typeset with LaTeX, for high-quality PostScript output.
  • ATS is a statically typed programming language that unifies implementation with formal specification. It is equipped with a highly expressive type system rooted in the framework Applied Type System, which gives the language its name. In particular, both dependent types and linear types are available in ATS.
  • Ballerina "Ballerina is a compiled, transactional, statically and strongly typed programming language with textual and graphical syntaxes. Ballerina incorporates fundamental concepts of distributed system integration into the language and offers a type safe, concurrent environment to implement microservices with distributed transactions, reliable messaging, stream processing, and workflows." See ballerina.
  • Boomerang is a language for writing lenses—well-behaved bidirectional transformations—that operate on ad-hoc, textual data formats. Every lens program, when read from left to right, describes a function that maps an input to an output; when read from right to left, the very same program describes a "backwards" function that maps a modified output, together with the original input, back to a modified input.
  • Biscuit is simple imperative programming language using LLVM backend implemented in C. See Tine editor
  • Blorp; Blorp is meant to feel direct at the surface while keeping the compiler's safety and runtime choices explicit.. Static Types, Hindley-Milner-Style inference, Value Semantics, Perceus Ownership, Native Output. Blorp compiles to C, so idiomatic Blorp code is intended to run within range of hand-written C.
  • C2 an evolution of C, using LLVM.
  • C3 - Full C ABI compatibility, Module system, Generic modules, Design by contract, Zero overhead errors, Semantic macro system, First-class SIMD vector types, Struct subtyping, Safe array access using slices, Easy to use inline assembly, Cross-platform standard library which includes dynamic containers and strings, LLVM backend
  • Cell offers, among other things, a very flexible, entirely structural type system; deterministic, repeatable execution; support for reactive programming; the ability to use relations to store data; transactions and propagation of undefined values for error handling; and ortogonal persistence. "Cell is designed to complement and integrate with your primary language, not to replace it. Once a component of an application has been implement in Cell, the compiler will generate from it an easy-to-use Java, C++ or C# class that can be integrated into an existing project. Support for other languages will be added in the future."
  • Chapel is a modern programming language that is parallel, productive, portable, scalable and open-source by Cray.
  • Ciao is a modern prolog implementation and a general-purpose programming language which supports logic, constraint, functional, higher-order, and object-oriented programming styles. Its main design objectives are high expressive power, extensibility, safety, reliability, and efficient execution.
  • Circle compiler enables you to metaprogram C++ in C++. It encourages a seamless mixing of compile-time and runtime capabilities that upends decades of language design.
  • Cito automatically translates the Ć programming language to C, Java, C#, JavaScript, ActionScript, Perl and D. Ć is a new language, aimed at crafting portable programming libraries, with syntax akin to C#.
  • Clean is a general purpose, state-of-the-art, pure and lazy functional programming language designed for making real-world applications. Some of its most notable language features are uniqueness typing, dynamic typing, and generic functions. quick look.
  • Cool is a small language designed for use in an undergraduate compiler course project. While small enough for a one term project, Cool still has many of the features of modern programming languages, including objects, automatic memory management, and strong static typing. Used for Stanford CS1 Compiler class.
  • Crystal -- is a ruby syntax inspired, statically type checked language that compiles to binary. Mint is a language for writing Single page applications. Mint is written in Crystal.
  • Cuneiform is a functional programming language for large-scale data analysis workflows. Cuneiform uses distributed Erlang to scalably run in cluster and cloud environments. The flexible foreign function interface lets you integrate tools and libraries from many different sources. This allows you to drive a heterogeneous software collection through a uniform interface (Bash, Erlang, Python, Java, R, MATLAB, JS). Static type checking.
  • Curry -- Haskell with Logic Extensions
  • Cyber -- is a scripting language for fast, efficient, and concurrent scripting, written in Zig -- Dynamic and static types. Concurrency with fibers. Memory safe. FFI and Embeddable.Fast VM and JIT. Cross platform.
  • Dafny: A Language and Program Verifier for Functional Correctness - Microsoft Research
  • Dao is a lightweight and optionally typed programming language; Optional typing with type inference and static type checking; Object-Oriented Programming (OOP) with class and mixin class; Abstract interface and concrete interface to supplement class-based for OOP; Code section methods as a better alternative to functional methods; Support closures, anonymous functions; Deferred block and exception handling by defer-recover; Native support for concurrent programming; Concurrent garbage collection;
  • Derw -- is a programming language aimed at making complex apps in a simple way. It's built on top of TypeScript and Node, so it's easy to have interop with TypeScript. See also Gren
  • dg — it's a Python! No, it's a Haskell! -- "Slow. Stupid. Absolutely adorable.". Python with Haskell syntax.
  • Duet delta is an educational dialect of Haskell aimed at interactivity.
  • Eff Programming Language is a functional programming language based on algebraic effect handlers. This means that Eff provides handlers of not only exceptions, but of any computational effect, allowing you to redirect output, wrap state modifications in transactions, schedule asynchronous threads, and much much more… Try it out in the browser
  • The Egison Programming Language
  • Ela combines strict and lazy evaluation, dynamic typing and features, which are normally adopted by statically typed languages, such as algebraic data types andHaskell style type classes. Compiles to .NET
  • Euphoria -- the language that brought me back from the C++ induced panic :D
  • rxi/fe -- A tiny, embeddable language implemented in ANSI C. Used to make grid based game framework cel7
  • DRAKON, is a visual language for specifications. Discussions
  • Eyg
  • Elixir is a functional meta-programming aware language built on top of the Erlang VM.
  • Fay is a proper subset of Haskell that compiles to JavaScript
  • Fennel -- Lisp in Lua. "Full Lua compatibilty, Zero Overhead, Compile-time macros, Embeddable".
  • Felix claims to have its own type system based on a combination of Ocaml and Haskell. Like Ocaml it provides strong support for functional programming, whilst also supporting imperative programming. The type system is strict.
  • Flapjax is a new programming language designed around the demands of modern, client-based Web applications. Its principal features include: Event-driven, reactive evaluation; An event-stream abstraction for communicating with web services; and Interfaces to external web services. Flapjax is just a JavaScript framework. Flapjax is built entirely atop JavaScript, it runs on traditional Web browsers without the need for plug-ins or other downloads. It integrates seamlessly with existing JavaScript code and other frameworks.
  • Flask staged Functional Programming for Sensor Networks
  • Flex group at YC Research has a few interesting lanauges like: Ohm, Seymour, Purple, Trainee, and transcript.
  • Flix -- "takes inspiration from F#, Go, OCaml, Haskell, Rust, and Scala. Flix visually resembles Scala, but its type system is closer to that of OCaml and Haskell. Its concurrency model is inspired by Go-style processes and channels. Flix compiles to JVM bytecode and runs on the Java Virtual Machine. Flix supports full tail call elimination which means that tail calls (even to other functions) never overflow the stack."
  • Futhark - A High Performance Functional Array Language. "a small programming language designed to be compiled to efficient parallel code. It is a statically typed, data-parallel, and purely functional array language in the ML family, and comes with a heavily optimising ahead-of-time compiler that presently generates GPU code via OpenCL, although the language itself is hardware-agnostic."
  • Gleam is a statically typed functional programming language for building scalable concurrent systems. It compiles to Erlang and has straightforward interop with other BEAM languages such as Erlang, Elixir and LFE. Interview with the creator of Gleam
  • Gren is a functional programming language with carefully managed side-effects and a strong static type system. is a "fork" of Elm with a node.js target.
  • Gush: A stack based language eventually for genetic programming
  • Hazel, a live functional programming environment featuring typed holes.
  • hobbes -- a programming language, JIT compiler, and database system for low-latency, high-volume trading applications (built at Morgan Stanley).
  • Idris is is a general purpose pure functional programming language with dependent types.
  • Imba is a programming language for the web that compiles to performant and readable JavaScript. It has language level support for defining, extending, subclassing, instantiating and rendering dom nodes.
  • Inko " is a gradually-typed, safe, object-oriented programming language for writing concurrent programs. By using lightweight isolated processes, data race conditions can not occur. The syntax is easy to learn and remember, and thanks to its error handling model you will never have to worry about unexpected runtime errors."

"Inko is an object-oriented programming language, drawing heavy inspiration from Smalltalk, Self, and Ruby. There are no statements used for conditionals and loops, instead Inko uses message passing for (almost) everything." Processes don't share their memory, and communicate by passing messages, which are deep copied. This removes the need for explicit synchronisation, and makes data race conditions impossible. Inko uses a high performance parallel garbage collector, based on Immix. Each process is garbage collected independently, removing the need for a global stop-the-world phase. Inko is an interpreted programming language, with a bytecode virtual machine written in Rust. Inko is gradually typed, with static typing being the default. This gives you the safety of a statically typed language, and the option to exchange this for the flexibility of a dynamically typed language. Related reading: * Joe Duffy - The Error Model

  • ISPC -- Intel® SPMD Program Compiler is a compiler for a variant of the C programming language, with extensions for "single program, multiple data" (SPMD) programming. Under the SPMD model, the programmer writes a program that generally appears to be a regular serial program, though the execution model is actually that a number of program instances execute in parallel on the hardware. The story of ispc: origins (part 1)
  • Janet is a functional and imperative programming language. Janet makes a good system scripting language, or a language to embed in other programs. Think Lua or Guile. Janet also can be used for rapid prototying, dynamic systems, and other domains where lisp shines.
  • Jolie is a service oriented proramming language that compiles to the JVM. I'm reminded of Ballerina. Jolie crystallises the programming concepts of service-oriented computing as linguistic constructs. The basic building blocks of software are not objects or functions, but rather services that can be relocated and replicated as needed. A composition of services is a service.
  • Julia is a high-level, high-performance dynamic programming language for technical computing.
  • Kit is a “Compiles-to-C” language. It is strong, and statically typed with many modern language features like type inference, algebraic data types, pattern matching, generics, implicits, while still having low level features like raw pointers, and manual memory management. Kit is written in Haskell. kit notes.
  • Koka -- is a function-oriented programming language that seperates pure values from side-effecting computations, where the effect of every function is automatically inferred. The language is strict (as in ML), but seperates pure values from side effecting computations (as in Haskell). Through the effect types, there is also a strong connection to its denotational semantics, where the effect type of each function has a direct translation to the type signature of the denotational function. more Recently, Koka fully supports user-defined effects through algebraic effect handlers.
  • Koto -- language for adding scripting to applications developed in Rust. Koto's runtime is fast enough for many applications, with performance comparable to similar embedded scripting languages for Rust like Rhai and Dyon
  • lambdaway :: _ -- S-expression based markup, styling & scripting
  • The Lemon Programming Language -- python with curly braces. embeddable.
  • Lily -- an interpreted, statically typed programming language focusing on expressiveness and safety.
  • The Little Language is a statically typed, C-like scripting language. "... might be useful for you if you are still using Tcl (or Tcl/Tk) but wish it had a more C-like syntax. ". L forum on bitkeeper
  • Lobster is a game programming language. Unlike other game making systems that focus on an engine/editor that happens to be able to call out to a scripting language, Lobster is a general purpose stand-alone programming language that comes with a built-in library suitable for making games and other graphical things. Looks like python, but is statically typed.
  • Logtalk is an object-oriented logic programming language that can use most Prolog implementations as a back-end compiler.
  • Luna "is a data processing and visualization environment built on a principle that people need an immediate connection to what they are building. It provides an ever-growing library of highly tailored, domain specific components and an extensible framework for building new ones. Luna targets domains where data processing is the primary focus, such as data science, IoT, bioinformatics, graphic design and architecture."
  • LuxLang/lux: The Lux Programming Language "It's meant to be a functional, statically-typed Lisp that will run on several platforms, such as the Java Virtual Machine and JavaScript interpreters." Written in Clojure. tutorial.
  • Mercury is a logic/functional programming language, which combines the clarity and expressiveness of declarative programming with advanced static analysis and error detection features.
  • Myrddin is a programming language that runs close to the metal, giving the programmer predictable and transparent behavior and mental model. It also does strong type checking, generics, type inference, closures, and traits.
  • Mythryl is a rewrite of the SML/NJ compiler
  • Nim -- see my more exhaustive set of notes here.
  • Nitlanguage.org
  • Objective-Smalltalk is an evolution of Smalltalk based on the Objective-C runtime.
  • odinlang - Odin is a general-purpose programming language with distinct typing built for high performance, modern systems and data-oriented programming. Odin is the C alternative for the Joy of Programming. ed: seems to have gained much popularity among game developers.
  • Onyx -- A data-oriented, expressive, and modern programming language, targeted at WASM.
  • Opis reliable distributed systems in Ocaml (paper, 2009).
  • P: Safe Asynchronous Event-Driven Programming by Microsoft Research
  • P P provides a high-level state machine based programming language to formally model and specify distributed systems. See Youtube talk
  • Picat is a simple, and yet powerful, logic-based multi-paradigm programming language aimed for general-purpose applications. Picat is a rule-based language, in which predicates, functions, and actors are defined with pattern-matching rules. Picat incorporates many declarative language features for better productivity of software development, including explicit non-determinism, explicit unification, functions, list comprehensions, constraints, and tabling. Picat also provides imperative language constructs, such as assignments and loops, for programming everyday things. The Picat implementation, which is based on a well-designed virtual machine and incorporates a memory manager that garbage-collects and expands the stacks and data areas when needed, is efficient and scalable. Picat can be used for not only symbolic computations, which is a traditional application domain of declarative languages, but also for scripting and modeling tasks.
  • Pike - a dynamic programming language with a syntax similar to Java and C. "the World Wide Web servers Roxen WebServer and Caudium are both written in Pike. Pike’s advanced data types and built-in support for sockets makes it ideal for use in Internet applications."
  • Piplin is a language that lets you write Clojure to simulate and program FPGAs.
  • Ponylang -- is an object-oriented, actor-model, capabilities-secure, high-performance programming language.
  • Play -- a statically typed stack language (aka Forth)
  • Propane Language a language for simple, correct-by-construction network configuration
  • Pure -- is a modern-style functional programming language based on term rewriting. It offers equational definitions with pattern matching, full symbolic rewriting capabilities, dynamic typing, eager and lazy evaluation, lexical closures, built-in list and matrix support and an easy-to-use C interface. The interpreter uses LLVM as a backend to JIT-compile Pure programs to fast native code.
  • Pyret -- python like language (syntactially) with FP ideas. inbuilt testing emphasis with where: keyword. structured data like OCaml etc., Runs on top of Racket.
  • The QED programming language -- "[for]... designing complex graphical user interfaces the simple way. Its parallel GUI/business logic (GUI/BL - or guible) coding paradigm offers unequaled binding power, which considerably reduces the lines of code required to develop a GUI application. QED runs in both native and web environments, without changing a single line of code."
  • RacketScript is an experimental lightweight Racket to JavaScript (ECMAScript 6) compiler. RacketScript aims to leverage both JavaScript and Racket's ecosystem, and make interoperability between them clean and smooth. RacketScript takes in Racket source files, uses Racket's macro expander to produce Fully Expanded Programs, and then compile these fully expanded programs to JavaScript.
  • Rascal -- is a metaprogramming language that integrates source code analysis, transformation, and generation primitives on the language level
  • Red ; FAQ
  • Reva -- a small, cross-platform Forth. Recommended by @deech in the context of "read the source code of the programming language to learn how things work".
  • Roc's goal is to be a fast, friendly, functional language. tutorial; via
  • Rosie Pattern Language -- a better Regex. See MWPLS 2019 slides (PDF). Has a REPL, JSON output, Can use with C, Python, Haskell, Go.
  • Roy is a programming language that tries to meld JavaScript semantics with some features common in static functional languages and targets JavaScript.
  • Rye is a high level, homoiconic dynamic programming language based on ideas from Rebol, flavored by factor, Linux shell and golang. For Interactive use, backend, servers, information exploration and processing. It's written in Go and could also be seen as Go's scripting companion as Go's libraries are very easy to integrate, and Rye can be embedded into Go programs as a scripting or a config language.
  • Quirrel is a purely declarative query language designed for performing analytics and statistics on large-scale, multi-structured data sets.
  • Quorum -- an OOPs lang for teaching that compiles to Java byte-code.
  • scrapscript  solves the software sharability problem. Modern software breaks at boundaries. APIs diverge, packages crumble, configs ossify, serialization corrupts, git tangles, dependencies break, documentation dies, vulnerabilities surface, etc. To make software safe and sharable, scrapscript combines existing wisdom in new ways: 
    • all expressions are content-addressible “scraps” 
    • all programs are data 
    • all programs are “platformed”
  • Self is a prototype-based dynamic object-oriented programming language, environment, and virtual machine centered around the principles of simplicity, uniformity, concreteness, and liveness.
  • SharpScript, a scripting language for .NET Core and .NET Apps that utilizes a familiar expressive Syntax to enable dynamic scripting of .NET Apps via controlled access to pluggable methods and arguments within a sandbox environment. looks good for exploratory and literate programming.
  • Shen is a statically (optional) typed Lisp variant targeting Common Lisp, JavaScript, the JVM and possibly more targets
  • SparForte "... allows you to write small scripts (think bash) and when they (inevitably) grow, you can transform them piecewise into Ada. The approach is similar to starting with Python and extending it with Rust where necessary. The advantage is the language is explicitly designed to support that use case." -- via
  • syn·di·cate -- a language for interactive programs. Syndicate is an Actor-based programming language offering. Pub/sub pattern-based message routing, for mapping events to actors. Dataspaces, stores for semi-structured data, for managing shared state. State change notifications for keeping actors informed of changes in dataspaces. Integrated techniques for registering and discovering services and for cleaning up after both graceful and unexpected actor failures. Recursive layering of groups of actors, each group with a private dataspace of its own, for organising larger programs
  • Tab is a kind of general-purpose query language for text files.
  • Terra is a new low-level system programming language that is designed to interoperate seamlessly with the Lua programming language. Like C, Terra is a simple, statically-typed, compiled language with manual memory management. But unlike C, it is designed from the beginning to interoperate with Lua. Terra functions are first-class Lua values created using the terra keyword. When needed they are JIT-compiled to machine code.
  • Tree Language Tree Notation is a simpler kind of code. Tree Notation is an error-free base notation like binary. Check out the "dumbdown" (markdown) designer demo.
  • TXL is a unique programming language specifically designed to support computer software analysis and source transformation tasks.
  • Uiua - A stack-based array programming language (think FORTH + APL)
  • Vale -- "a fast, safe, and easy programming language." AOT compiled to LLVM, statically-typed, and uses the new generational references technique for memory safety with speed and flexibility. Read comparisons to JS, C++ and Rust.
  • Verse -- language by Epic Games, designed by SPJ et al
  • virgil - A Fast and Lightweight Systems Programming Language by Ben L. Titzer of CMU; WebAssembly co-founder, former V8 engineer.
  • wing - programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
  • Wuffs - Wrangling Untrusted File Formats Safely - is a memory-safe programming language (and a standard library written in that language) for wrangling untrusted file formats safely. Wrangling includes parsing, decoding and encoding. Example file formats include images, audio, video, fonts and compressed archives.
  • Wren is a small, fast, class-based concurrent scripting language # Think Smalltalk in a Lua-sized package with a dash of Erlang and wrapped up in a familiar, modern syntax. Used in luxe game engine.
  • Yaksha - A manual memory managed, compiled to C99, programming language with Python-like syntax.
  • Yeti is ML style functional programming language, that runs on the JVM.
  • Zig Programming Language is a system programming language which prioritizes optimality, safety, and readability. Ambition to replace C discussion on lobste.rs. Iterative Replacement of C with Zig
  • ZL is a C compatible and C++ like programming language that focuses on extensiblilty and giving the programmer control over how high-level constructs (such as classes) are implemented. ZL archives the first goal by means of a customizable grammar and a powerful Scheme-like macro system. ZL archives the second goal by using the macro system to define high-level constructs from a C-like core language in a similar in spirit to Scheme.

Other Programming Langauge Related Lists

Blogs etc.,

Courseware

Related Reading

Tools

Comby is a tool for matching and rewriting code. You start by writing a simple template to match syntax. Look at this Go function:

func main() {
    fmt.Println("hello world")
}

We can match the arguments to fmt.Println with this match template:

fmt.Println(:[arguments])

Learning Programming

Fun

Implementing programming languages

Blog posts

Books

Benchmarks

Linkbacks to this page


See also: D lang, Rust, OCaml, C, C++, Python

notes#programming-language

Lisp

What makes lisp special?

Starting to code in Common Lisp

CL-References

Other Lisps

T

Urn

Urn is a Lisp that compiles to Lua. Its tutorial is one of the friendliest to learn Lisp itslef.

Picolisp

uLisp

  • uLisp -- Lisp for Arduino, Adafruit M4, Micro Bit, ESP8266/ESP32, and MSP430 boards.

Notes

To add readline support to the SBCL REPL, use rlwrap

Use quicklisp to discover, install and manager Lisp libraries

Starting SBCL with QuickLisp pre-loaded.

$ rlwrap sbcl --load ~/quicklisp/setup.lisp

Quotes

In C, you are writing assembly constructs disguised as a high level language. In lisp, you are writing compiler constructs (abstract syntax trees) disguised as a high level language. Assembly language targets hardware-oriented geeks. Lisp targets compiler-oriented geeks. Since the two don't (generally) understand the other's viewpoint, each hates the other's favorite language.

-- gvb at i hate lisp.

Implement your own Lisp

Links

Blogs

Videos

Algorithms

Lisp Machines

Books

IDEs

The de-facto IDE for most lisps in Emacs. Howver Portacle - A Portable Common Lisp Development Environment is a good, ready-to-go, purpose-built distribution of Eamcs for use on Windows, Mac and Linux.

Talks

People

Implementations

Distributions

Interesting programs / libraries

Tips

lisp tip: run visual programs with (uiop:run-program '("sudo" "htop") :output :interactive :input :interactive) works for sudo, vim, htop, ncdu… see also (cmd:cmd "sudo htop" :<> :interactive)

Discussions/ Comparisons

Understanding the words "package", "system", "project" .. which have different meanings than commonly understood ones.. As explained by sjl on lobste.rs:

Common Lisp’s terminology is confusing because it’s old and uses a lot of words that we use now (like “package”) to mean different things than people mean today. Things get easier once you internalize what Common Lisp means by the terms.

A package in Common Lisp is a container for symbols. They’re a way to group related names (symbols) together so you don’t have to do the miserable prefixing of every name with mylibrary-... like you do in Emacs Lisp or C to avoid name clashes.

Unlike other languages like Python/Clojure/etc, packages and files on the hard disk are not tied strongly together in Common Lisp. You can have several files that all work with the same package, a single file that switches back and forth between packages, or even write code that creates/mutates packages at runtime. Files and packages are orthogonal in Common Lisp, which gives you maximum flexibility to work however you want.

A system in Common Lisp is a collection of code (mostly) and a description of how to load that code (and some metadata like author, license, version, etc). For example: my directed graph library cl-digraph contains a system called cl-digraph. That system has a description of how to load the code, and that description lives in the cl-digraph.asd file. It creates a Common Lisp package (called digraph).

The Common Lisp language itself has no knowledge of systems. ASDF is a Common Lisp library bundled with most (all?) modern implementations that handles defining/loading systems. (The name stands for Another System Definition Facility, so as you might guess there have been several other such libraries. ASDF is the one everyone uses today.)

Systems and packages are orthogonal in Common Lisp. Some systems (like small libraries) will define exactly one package. Some systems will define multiple packages. Rarely a system might not define any new packages, but will use or add to an existing one.

A project in Common Lisp is not an official term defined anywhere that I know of, but is generally used to mean something like a library, a framework, an application, etc. It will usually define at least one system, because systems are where you define how to load the code, and if it didn’t define a system how would you know how to load the code? My cl-digraph library mentioned above is a project that defines three systems:

  • cl-digraph which contains the actual data structure and interface.
  • cl-digraph.test which contains the unit tests. This is a separate system because it lets users load the main code without also having to load the unit test framework if they’re not going to be running the tests.
  • cl-digraph.dot which contains code for drawing the directed graphs with Graphviz. This is a separate system because it lets users load the main code without also having to load the cl-dot system (the graphviz bindings) if they don’t care about drawing.

If I were writing this today I’d use ASDF’s foo/bar system naming notation instead of separating the names with a dot, because there’s some nice extra support for that. I just didn’t know about it at the time, and don’t want to break backwards compatibility now.

We saw how Common Lisp has no concept of a system — that comes from ASDF. Similarly, ASDF has no concept of the internet, or reaching out to somewhere to download things. It assumes you have somehow acquired the systems you want to load, maybe by sending a check to an address and receiving a copy of the code on floppy disk, as many of my old Lisp books offer in the back pages.

Quicklisp is another library that works on top of ASDF to provide the “download projects from the internet automatically if necessary” functionality that people want in our modern world. So when you say (ql:quickload :cl-digraph) you’re asking Quicklisp to download cl-digraph (and any dependencies) if necessary, and then hand it off to ASDF to actually load the code of the cl-digraph system. Unlike ASDF, Quicklisp is relatively new in the Common Lisp world (it’s only about eight years old) bundled with any modern Lisp implementations (that I know of) (yet?), which is why you need to install it separately.

So to summarize:

  • Files are files on your hard drive.
  • Packages are containers of symbols. They are orthogonal to files.
  • Systems are collections of code, plus instructions on how to load this code. They are orthogonal to packages.
  • Projects are high-level collections of… “stuff” (code, documentation, maybe some image assets, etc). They are (mostly) orthogonal to systems (seeing a trend here?).
  • Common Lisp knows about files and packages. ASDF adds systems. Quicklisp adds the internet.

This is a pretty high-level view that glosses over a lot, but maybe it’ll clear things up and help you dive into the details later.


notes#lisp#programming-language

Nim Programming Language

NOTE: nim was previously known as nimrod.

A quick look at nim programming language

This is a short intro to a fun, productive language called nim.

nim is a new programming language developed by Andreas Rumph.

nim is a statically typed, compiled langauge.

What kind of language is it?

There are few things more irriting than a programming language or library webpage that doesn't show how the syntax/typical usage looks like. So, let's see how nim code looks like:

# compute average line length
var count = 0
var sum = 0

for line in stdin.lines:
    count += 1
    sum += line.len

echo "Average line length: ",
if count > 0: sum / count else: 0

The var keyword is familiar if you have used C#, which essentially means that the variable count has an implicit type. That is, you don't have to explicitly mention the type, in this case an integer.

The for loop line reads naturally for the Python programmer, including the : starting a new block.

nim is inspired by many popular languages old and new. It is quite easy to read and understand what is going on.

According to Araq, the creator of Nim:

Macro system inspired by Lisp.
Export marker taken from Oberon.
Argument passing semantics taken from Ada.
distinct types inspired by Ada.
Syntax also heavily influenced by Python.
Generics inspired by C++.
The 3 pointer like types ptr, ref, var taken from Modula 3.
async / await stolen from C#.
let taken from ML.
...

One could also argue that Nim is a statically typed Lisp with an
infix syntax extended by essential features necessary for
systems programming. And dumbed down to support efficient
compilation to C (where are my continuations?!)..

How to install it?

Checkout the code from github. (Note these steps are outdated since the language was renamed from nimrod to nim).

$ git clone git://github.com/Araq/Nimrod.git
$ cd Nimrod
$ git clone --depth 1 git://github.com/nimrod-code/csources
$ cd csources && ./build.sh
$ cd ..
$ bin/nimrod c koch
$ ./koch boot -d:release
$ ./kock install $HOME/nimrod

This installs nimrod under $HOME/nimrod. Add $HOME/nimrod/bin to the $PATH.

What is the performance like?

Nim compiles to C, so you can expect C-like performance (hard performance numbers are a game of benchmarks and nobody ain't got no time for that...). To go with Nim's authors' own word "it is performant for 'soft real time' systems like games". Take it as you may.

For me, Nim is a vast upgrade over dynamic languages like Python and Ruby without sacrificing a whole lot of expressiveness.

What are some of the quirks

By looking at examples and reading applications/libs written in Nim you would not guess it, but nim is case insensitive. That is var hello and var HELLO and var HeLlo are treated as the same by the compiler. Where nim takes it one step ahead is it's treatment of underscores, which means var H_E_l_lo is same as var hello. This might appear crazy, but this removes the entire bikeshed argument about which style of variable naming is best.

The nim programming community has it's own best practices for variable names, for instance, new types are declared as TFoo an inspiration from Pascal.

A quick tour of the command line

To compile a nim file foo.nim, you type

nim c foo.nim

which will give you a foo executable in the same directory, assuming there were no compilation errors. You will also see a nimcache directory.

This directory contains the intermediary C files generated.

What are the resources to learn more

The website: http://www.nim-lang.org The forum: http://forum.nim-lang.org -- this is probably the best place to get your questions answered.

How can I use nim?

For a young language like nim has not managed to corner itself into any one niche.

nim has been used to write: (Update, Aug 2024: See Awesome Nim and nimble.directory for a list of libraries for nim - a lot more diverse than you think!)

Personally, I have been using nim to replace a few of command line python applications that process large amounts of data.

Standard libraries

Nim's standard library has XML, CSV, Web, String, Regular expressions, OS, Database drivers, Network programming and more.... It also has wrappers to popular C libraries like X, GTK, pcre, cairo, sdl, OpenGL etc.,. nim libraries have you covered for day-to-day programming needs.

Web development

Editors and IDEs

Emacs has a nim-mode. A nim specific IDE called Aporia built using the GTK toolkit. I haven't used it much beyond installing it because I prefer using the Emacs nim-mode.

Aug 2024: I use zed, and it uses LSP.

Packaging and reusing libraries

nim libraries can be installed using the nimble package manager. The nim After successful compilation, copy the babel executable to a directory in your $PATH. I put it under $HOME/nim/bin along with other nimrod executables.

Distributing applications written in nim

A .nimble file is required at the root of your application source directory. Take for example the jester.nimble file that is part of the Jester web framework distribution" --

[Package]
name          = "jester"
version       = "0.1.0"
author        = "Dominik Picheta"
description   = "A sinatra-like web framework for Nimrod."
license       = "MIT"

SkipFiles = "todo.markdown"

The file is self explanatory. Once you have the nimble file in the directory, running nimble build will build binaries.

Cross Compilation

From SO

I was having the same issue getting nim to compile executables for Windows, from a GNU/Linux machine, so I made a bash script. It takes the path to the directory containing *.nim source files and the name of the executable file to output. I'm sure you could swap out the GCC compiler (MinGW in this case) and change the --os: switch as appropriate:

#!/usr/bin/env bash
# Nim must generate C sources only, to be fed to MingW
nim c --cpu:amd64 --os:windows --opt:speed --embedsrc --threads:on --checks:on -c -d:release $1/*.nim
# Copy nimbase.h so MingW32 can find it during compilation and linking
cp /opt/Nim/lib/nimbase.h $1/nimcache/nimbase.h
mkdir -p $1/bin
cd $1/nimcache && x86_64-w64-mingw32-gcc -save-temps $1/nimcache/*.c -o $1/bin/$2.exe
rm $1/nimcache/*.{i,s} # only care about *.o objects
ls -lAhF $1/nimcache
ls -lAhF $1/bin

Concepts

Memory Model

Related

Links

Books

Tutorials

Interop (FFI)

Nim+D

Testing

Interesting projects in Nim

Compile time

Libraries

Web development

Dev tools

Dev Notes

Upgrade nim to the latest version using choosenim:

$ choosenim update stable
# downloaded, built and installed 2.0.8 (Aug 2, 2024)
$ which nim
/Users/pradeep/.nimble/bin/nim
$ nim -v
Nim Compiler Version 2.0.8 [MacOSX: amd64]
...

Random notes

Nim's GC is per thread: You can easily have threads which are hard realtime and don't use the GC and happily use the GC in the other threads... And the type and effect system ensures you don't mix these different per thread heaps. -- Araq

[Nim has] C++-like features (generic types, operator overloading, function overloading, inline functions, optional O-O, optional data hiding, C pointers, bitwise-compatibility with C, your choice of manual memory management or GC) and C++-like run-time speed, combined with Python-like syntax and compile-time Lisp-like macros. -- HN comment

GC free Nim programming

The no GC future is --gc:stack which replaces the GC with memory regions. So any library that uses the GC really uses a memory region. The entire situation is ok. Note that the GC is always thread local anyway, so you can also just run realtime threads with other threads that use the stdlib and thus the GC. -- Araq

use these: alloc, dealloc, allocShared, deallocShared. You can cast the pointer from and to ptr types and then you have your manually managed heap memory. (This is a general answer to how to use non-GC'd memory and has nothing to do with memory regions) -- flyx

A good example of using FFI in nim in comparison to D and rust.

Discussion in /r/python about a nim article.


From a reddit thread: What problem does Nim solve?

Low friction, high performance development.

It feels like a scripting language in terms of writing code rapidly. Deferred GC means no need to worry about memory (although easy to manually manage it). So, a sort of statically typed, compiled Python with C-level speed and tiny, self contained executables.

High level AST metaprogramming that lets you hygienically extend the language, has static typing with inference and uses structural typing for generics which often means you don't even need object hierarchies, extensive compile time evaluation (to the point you can process files, create hash maps or pull web data by simply defining your desired variables as 'const').

It compiles to C, C++, LLVM (experimental), and Javascript. Excellent FFI so you can use all the C, C++ and JS libraries as well as Nim ones. Very fast compilation that's going to get faster from what I've read about future plans.

This may be subjective but I also like how clean it looks. Few $!;@ symbols and easy to read.

Personally, it's brought the fun back into development for me.


Stack vs GC vs Manual memory management

  • type Foo = object -> Value type, on the stack
  • type Foo = ref object -> Ref type, managed by GC
  • type Foo = ptr object -> Pointer type, manual memory management (malloc, free, memcopy ...)
  • Pointer arithmetic can be achieved using casts. via

Stack vs Heap from a Reddit thread:

By PMunch:

First order of business heap vs. stack: Whenever you call a function it creates a stack frame. Stacks are simply said first in last out, so when a function call is done it pops it's frame from the stack, and you return to the previous frame. When you declare a variable inside a scope in is typically allocated on the stack. This means that when the function returns that part of memory is not in use anymore and the value is gone (technically it's still there, but we shouldn't try to access it). The heap on the other hand is quite a bit different. Items on the heap are allocated and live there until you deallocate them. In C this is done manually with calls like malloc and free. In Nim however, and C# for that matter, we have the garbage collector (or GC), this nifty thing reads through our memory and checks if anything still points to things allocated on the heap and if nothing is pointing to that which was previously allocated it gets free'd. This means that we won't leak memory as easily as you would in C as things that we've lost every reference to get's automatically cleaned. Okay, now that we know where our stuff lives in memory, let's look at how Nim represents those things. Basic types are things like integers, floats, bools, and characters. Their size is known and static. Nim also calls strings a basic type, but those are not quite like the rest since they can change in size. Since our stack is first in last out it means that it makes sense to store everything in order. But storing things in order isn't possible if you want to change the size of something (for example appending to a string). So when we create numbers in our Nim code they will be stored on the stack, this is why you never need to free your numbers and don't have to set them to nil when you're done with them. So what are types? In Nim you can create aliases for types like type age = int this is just a way to say that age is an integer, and it will be treated like one for all intents and purposes. If we want to create collections of types to represent something particular we can create objects, don't think of these quite like objects in an object oriented language, think of them more like structs in C. Such objects are simply a collection of values. So in Nim when we create an object it will live with us on the stack. If we return an object it will be copied to our caller, and if we insert it into a data structure it will also be copied. While this might be practical in many cases (even offering a speed benefit if done right) we often don't want to copy our large objects around. This is when allocating on the heap comes into play. If we define our type as a ref object it means that the type is actually a reference to an object. I'll come back to the difference between a reference and a pointer later, but for now just remember that a reference is the memory location of an object on the heap. This means that if we return a ref object it means that we're only returning the memory address of that object, not copying the object itself. This also means that if we insert it into a data structure only the reference to the object is inserted. Whenever you see new SomeObject it means that it allocates memory for that object on the heap, and gives us a reference to this object. If we had simply done var myObject: SomeObject and SomeObject was defined as a ref object we would only have a reference on our stack, so trying to access it would crash saying we had an "Illegal storage access". This is because Nim defaults our value to nil, and no-one is allowed to access memory area 0. So imagine we had an object that contained the height, the weight, and the age of a person. That could be represented by three integers. If we wanted to return this object it would mean copying all those three values to our caller. If we defined it as a reference, we would only pass one integer, the position in memory (on the heap) where we stored the three others. Conveniently this also means that if one functions modifies a value in a referenced object, that change would be visible for all other functions using the same reference (since they all point to the same place in memory). This is practical for example if you want to make one list sorted by age, one by height, and the third by weight. Instead of copying our person three times, we could just use three references, one in each list. So now that we know where and how are values are stored we can look at the difference between a pointer and a reference. In pure Nim code you would typically only use references, these are what every call to new creates and what goes on behind the scenes most of the time when working with strings. A reference is also called a managed pointer, it simply means that Nim manages this area of memory, and that it will be automatically free'd for us by the garbage collector when Nim sees that we're not using it any longer. Pointers on the other hand are unmanaged meaning that Nim doesn't try to do anything with the memory behind that pointer, most of the time you won't even know what is there. The reason there are pointers in Nim is mostly to interface with C. In C every time you want objects on the heap you need to manually malloc and free them. Many C libraries work by passing around a pointer to a structure containing some state and all good libraries have some way of dealing with this memory. Typically you do it by calling some initialisation function when you begin and then some cleanup function when you are done. In Nim we might want to use a C library such as that, but since we might loose the reference in our own code while the library still keeps a reference somewhere which Nim doesn't know about we can't have a reference to it as Nim would garbage collect it. So instead we have pointers. I hope this made it somewhat clearer, if you want more examples or if anything was unclear, feel free to ask.

Benchmarks

Talks

Editors

Visual studio Code

Nimlime

Nimlime is a plugin for Sublime Text the provides Nim compatibility. This is my custom settings overriding the default settings:

{
    "nim.executable": "/Users/pgowda/src/Nim/bin/nim",
    "nimble.executable": "/Users/pgowda/.nimble/bin/nimble",
    "nimsuggest.executable": "/Users/pgowda/.nimble/bin/nimsuggest",
    "provide_immediate_nim_completions": true,
    "output.send": false
}

The output.send option set to false is an important one; withtout this, the plugin would create a new compiler output buffer everytime the file is built, which is everytime I saved the file!.

Blogs

Code

Code to read etc.,

Eventually I decided, that being able to do transformations on the AST (abstract syntax tree) of the programming language would greatly help to develop this toolbox. I tried out Rust, but I quickly found out that their macros are too weak to even implement println, and I had to look somewhere else. (At this point in time Rust also has procedural macros, but they still don't appear to be powerful enough to do the things I need to do for this project). Eventually with Nim I finally found a language that suited my needs. It has AST based macros, arbitrary code execution at compile time, static typing, reflection and a lot more.

News

See also: Crystal, Interesting Programming Languages, D, Python, Rust.

notes#nim#programming-language

Lua Programming Language

Learn

Lua associated languages

Pallene + Lua. Paper .Found via janet lang's gitter channel. It is a "Friendly Fork" of Titan Language. Pallene is a moon of saturn?

Terra -- low level lua like language.

teal; The compiler for Teal, a typed dialect of Lua

Luau is a fast, small, safe, gradually typed embeddable scripting language derived from Lua.

Links and references

Cool Lua stuff

2020-06-04 oasislinux/oasis: a small statically-linked linux system; uses lua for setup, building, package spec etc.,

Mako Server This tiny, ready-to-run application server packs a punch with its super compact and efficient Lua web framework and its non-blocking asynchronous sockets. Plus, it comes with everything you need built-in, including an integrated database, SMTP, HTTP client/server, and even IoT protocols like MQTT and industrial protocols like OPC-UA and Modbus.

People

  • Calvin Rose -- bakpakin.com (creator of Fennel lang, moonmint web framework, etc.,)

Compiling Lua source files

Let's say you have a lua program -- hello.lua.

print("Hello Lua!")

The source code can be compiled into a binary file using luac

$ luac -o hello.luac hello.lua

The file hello.luac can then be used in place of the source file. Using the binary file has some advantages like: faster loading, simple source hiding etc.,

To run a .luac file (this is my own convention, the Lua docs do not seem to prefer any particular suffix for the compiled file), you still need to call the lua interpreter,

$ lua hello.luac

Creating standalone executables for lua

A Lua source file can be converted into a executable using different methods. srlua appears to be the popular one.

Download srlua from here and build it using make. Copy glue and srlua files into a convenient location, say ~/bin.

You can now create standalone executable from the Lua source file --hello.lua thus:

$ ~/bin/glue ~/bin/srlua hello.lua hello
$ chmod +x hello
$ ./hello
Hello Lua!

Installing new software packages

Luarocks is the deployment and package management system for Lua. Think CPAN for Perl and PyPI for Python.

I have installed Lua in my $HOME directory. That is, lua interpreter resides in $HOME/bin, include files in $HOME/include etc.,

So, to install Luarocks:

$ export PREFIX=$HOME
$ ./configure --prefix=$PREFIX --sysconfdir=$PREFIX/luarocks --force-config

Installing new lua packages is as simple as:

$ cd
luarocks install luasocket

where luasocket is a new package that is fetched from the luarocks mirrors and installed.

To make this package available to the Lua interpreter export LUA_PATH thusly:

export LUA_PATH="/opt/local/share/lua/5.1//?.lua;/opt/local/lib/luarocks/?.lua;;"

Another LUA_PATH that makes more sense:

?;?.lua;/usr/local/lua/?/?.lua

Also, to explicitly add paths to a script:

# cat t_paths.lua
package.path = package.path.. ";/opt/local/share/lua/5.1/?.lua"
package.cpath = package.cpath.. ";/opt/local/lib/lua/5.1/?.so"
local s = require "socket"
print(s._VERSION)

Incidentally, on the day I was learning aobut luarocks, luaforge.net, the main lua modules repository was down. Friendly folks on the #lua IRC channel told me to add mirrors to the luarocks configuration.

$ vim ~/luarocks/config.lua

I replaced the luaforge.net line with

http://www.luarocks.org/repositories/rocks/",

Misc. Notes

Setting up LUA_PATH and LUA_CPATH is always more complicated than it needs to be. Remember not to have any spaces after the path seperator ;.

LuaDist appears promising to set up virtualenv like sandboxed environments (and more..) for lua.

Lua application packaging

luastatic README tells us that it can package lua applications into executables for windows, macos & linux. A few applications that use luastatic to do their packaging are given. It will be nice to find build setups which can compile to all the three OSes using github CI pipeline.

--

See also: Luarocks.

notes#lua#programming-language

Shell programming

notes#programming-language

Janet

Janet Programming Language is a Clojure like Lisp scripting language also suitable for embedding.

Why

Why Janet?; Apr 2023. Book "Janet for Mortals" by Ian Henry.

Learn

Notes

  • Project definitions go into a project.janet file.
  • Third party dependencies are defined like this: {:dependencies [{:repo "https://github.com/joy-framework/moondown" :tag "0.1.0"}]}

The structure of a project.janet file is: (See more here)

(declare-project
  :name "mylib" # required
  :description "a library that does things" # some example metadata.

  # Optional urls to git repositories that contain required artifacts.
  :dependencies ["https://github.com/janet-lang.json.git"])
  • See littleserver on how to build an executable from Janet source.

Cool projects in Janet

  • Bauble studio -- making art online with lisp(janet) and math.

  • Mendoza -- static website generator with a markdown language inspired by Scribble (of racket).

  • Tester -- testing framework. Readme file has an example of how to use fswatch to run the tests when files change.

  • Joy Framework -- a web framework for Janet.

    • jpm install joy.
    • has an ORM?
  • esv a web application built using Janet, (and circlet library).

Janet Shell

janetsh "A powerful new shell that uses the janet programming language for both the implementation and repl.". This is pretty cool when you want a regular shell that can do mundane things like ls -lart, but also use janet as a REPL and scripting language when you want to more advaned things without resolving to bash scripting. See this introductory article by the creator -- Andrew Chambers.

In this article, -- JSON in Janet Shell you can see how to use the ~/.janetsh.rc file to load additional modules (in this case ability to process JSON) to extend the capability of janetsh.

# Tell janet it can load janet and native modules from ~/janet-modules
(array/insert module/paths 0
   [(string (os/getenv "HOME") "/janet-modules/:all:.janet") :source]
   [(string (os/getenv "HOME") "/janet-modules/:all:.:native:") :native])

# copy combined dynamic library to janet-modules dir
cp build/json.so ~/janetsh-modules

# use it
$ (import json)
$ (var astronaut-in-space
    (json/decode ($$ curl http://api.open-notify.org/astros.json)))
# note: $$ appears to be the function call to invoke programs

# Print each one and the space craft they are in.
$ (each astronaut (astronauts-in-space "people")
    (print
      "Name: " (astronaut "name")
      ", Craft: " (astronaut "craft")))
...
Name: Oleg Kononenko, Craft: ISS
Name: David Saint-Jacques, Craft: ISS
Name: Anne McClain, Craft: ISS

This is a very nice capability (being able to extend the shell programming language).

notes#clojure#lisp#programming-language

Fennel programming language

Fennel is another clojure-like language that compiles down to lua created by Phil HagelBerg "technomancy".

Anywhere you can run Lua code, you can run Fennel code.

Phil Hagelberg/Technomancy has three.blog.posts about using Fennel to write a new game EXO_encounter that is hosted on itch.io (which itself is written by Lua-u* leafo).

Here is an introductory post on Fennel by Technomancy.

Software written using Fennel

*What's the demonym for a Lua programmer? (like Pythonista for Python programmers) -- Lua'r, Lua-oo?


See also: janet, lua

notes#clojure#lisp#lua#programming-language

C Programming Langauge

Why C?

"The Endurance of an Unmanageable Language" - Some Were Meant for C; via ATS As a Systems Programming Language.

Learning

Tooling

Why not C?

C Is Not a Low-level Language - ACM Queue

Books

People and blogs

Important

  • cdecl; C gibberish ↔ English
  • ~sircmpwn/cstyle -- style guidelines on the lines of "SHOULD" and "SHOULD NOT"s.

C libraries

Memory Management

C programming practices

Cool stuff

Programming Language Theory

we argue that the C standard does not allow Turing complete implementations, and that its evaluation semantics does not preserve typing. Finally, we claim that no strictly conforming programs exist. That is, there is no C program for which the standard can guarantee that it will not crash.

Discussions

Safe C

A Tour of Xr0 - Xr0

Xr0 is a new verifier for the C programming language that eliminates many classes of undefined behaviour, such as use-after-frees (of which double frees are a special case), dangling and null pointer dereferences, memory leaks and the use of uninitialised memory. Most importantly, we believe Xr0 is on a clear trajectory towards enabling programming in C with no undefined behaviour whatever.

notes#c#programming-language

Python Programming Language

My Python Stuff

Meta

Advanced Python

dabeaz-course/python-mastery: Advanced Python Mastery (course by David Beazley)

Books

  • Fundamentals of Python programming (PDF) -- "... introduction to computer programming textbooks are available in PDF form for free download. University and high school students and self learners around the world have found them helpful. See the terms of use in the preface of each book."

  • Intermediate Python -- "Fluent python" by Luciano Ramalho.

Learning sources

"This repository contains the text for the Tiny Python 3.6 Notebook. it is a notebook containing curated examples for Python 3 as well as the new features found in Python 3.6."

Internals

Developer Experience (DevEx)

Make Python DevEx -- this is very close to how I choose to do Python development. good read. I don't have such an extensive Makefile setup.

Debugging

Profiling

Web

Multiprocessing

Async

Sublime Text

Alternate Python implementations

To Install Zippy:

hg clone https://bitbucket.org/ssllab/zippy
cd zippy
TBD

Libraries

Data science libraries

Conferences

Python3

Pypy

Package management

python setup.py sdist
python setup.py bdist_wheel
twine upload --repository-url https://test.pypi.org/legacy/ dist/*

Project Managers

Do not use requirements.txt - quanttype -- instead choose Poetry, Hatch or pdm.

Poetry

I have been using poetry for a while.

Poetry uses the pyproject.toml standard, but it does not follow the standard specifying how metadata should be represented in a pyproject.toml file (PEP 621), instead using a custom [tool.poetry] table. This is partly because Poetry came out before PEP 621. -- from pdm's documentation

Hatch

pdm

Unlike Poetry and Hatch, PDM is not limited to a specific build backend; users have the freedom to choose any build backend they prefer.

Links

2019

Via My Python Development Environment, 2020 Edition | Jacob Kaplan-Moss:

notes#programming-language#python

Futhark

Futhark is a small programming language designed to be compiled to efficient parallel code. It is a statically typed, data-parallel, and purely functional array language in the ML family, and comes with a heavily optimising ahead-of-time compiler that presently generates GPU code via CUDA and OpenCL, although the language itself is hardware-agnostic and can also run on multicore CPUs. As a simple example, this function computes the average of an array of 64-bit floating-point numbers:

let average (xs: []f64) = reduce (+) 0.0 xs / r64 (length xs)

Futhark is not designed for graphics programming, but instead uses the compute power of the GPU to accelerate data-parallel array computations.

Code in Futhark

notes#programming-language

2019

Datalog

notes#programming-language

Ballerina programming language

"Ballerina" Could Become the Programming Language of Integration - By dhanushka

Ballerina is a static typed language.

Another special type of variable is that “anydata” data type. This type is a union of the ()|boolean|int|float|decimal|string|(anydata|error)[]|map<anydata|error>|xml|table data types. anydata variables can be used in places where you expect pure values.

Since Ballerina specifically designed to construct apps operating on networks, it natively supports JSON and XML.

json user = {
         fname: "Peter",
         lname: "Stallone",
         "age": age,
         address: {
             line: "20 Palm Grove",
             city: "Colombo 03",
             country: "Sri Lanka"
         }
    };
io:println(user.address.country);
xml x1 = xml `<book>The Lost World</book>`;
io:println(x1);

News

Articles

James Clark's blog:

notes#ballerina#jvm#programming-language

Scala programming language

See Also: Scala for Datascience, ScalaJS, coursier, select-scala

July, 2015 -- Scala book reviews Feb, 2018 -- Recursion and Trampolines in Scala

Random Notes

scala-cli—power repl -S 2.13 -A —ammonite-ver 2.5.11

Notes from Programming in Scala

Chapter 7 - built-in control structures.

  • has very few control structures
  • if while for try match and function calls.
  • scala accumulates control structs in libraries.
  • use val instead of var wherever possible. makes it easy to refactor. "equational reasoning".
  • no = sign while defining a function => returns a Unit value ()
  • while and do-while are NOT expressions. they return Unit.
  • prefer NOT to use while.
  • for
  • "generator" syntax -- file <- files. works on all collections.
  • file is a val.
  • Ranges -- 1 to 4 (yields 1,2,3,4)
  • 1 until 4 -- exlcude the upper bound (yields 1,2,3)
  • generators can also include filters -- for (f <- files if f.getName.endsWith('.py'))
  • nested iteration.
  • mid-stream variable bindings
  • new collection:
def pyFiles =
  for {
    file <- files
    if file.getName.endsWith('.py')
  } yield file
  • IMP: don't put yield inside the curlies.

Exceptions:

try {


} catch {
  case ex: FileNotFoundException => //handle
  case ex: IOException => //handle
}
  • like other control structures, try-catch-finally also results in a value. (this is unlike Java) //imp

Match:


val fruit =
    someArg match {
      case "foo" => "bar"
      case "banana" => "pepper"
      case _ => "what?"
}

Chapter 8- Functions and Closures

First class functions

(x: Int) => x+1

named function:

var increase = (x: Int) => x + 1
  • target typing: someNumbersList.filter((x) => x > 0). the type is inferred from the the list of integers.
  • alternatively: someNumbersList.filter(x => x > 0)

Placeholder syntax:

someNumbersList.filter( _ > 0)
val f = (_: Int) + (_: Int)

Chapter 12 -- Traits

Traits are like java interfaces with concrete methods + declare fields and maintain state.

Traits can do everything classes can do, except --

  1. trait cannot have any clas parameters (ie., those passed to primary constructors).
  2. super calls are not statically bound.

Unlike Java, adding a concrete method to scala trait is an one-time effort.

Chapter 15 -- Case classes and pattern matching


Notes from "Scala in Action"

Chapter 2 -- Getting started

// working with arrays and Lists
@ val nList = 1 :: 2 :: 3 :: 4 :: Nil
nList: List[Int] = List(1, 2, 3, 4)
@ nList.fil
filter     filterNot
@ nList.filter( _ > 2)
res17: List[Int] = List(3, 4)

@ // for comprehensions
@ oldList
res19: List[Int] = List(1, 2)
@ newList
res20: List[Int] = List(1, 2, 3)
@ for { a <- oldList; b <- newList } println (a+b)
2
3
4
3
4
5
@ // above is imperative form
@ // The functional form for comprehension is:
@ // also called the sequence composition
@ for { a <- oldList; b <- newList } yield a+b
res22: List[Int] = List(2, 3, 4, 3, 4, 5)

@ // Pattern Matching
@ val x = 3
x: Int = 3
@ def ordinal(number: Int):  Unit = number match {
    case 0 => println("One")
    case 1 => println("Two")
    case 2 => println("Three")
    case 3 => println("Four")
    case _ => println("what is this?")
  }
defined function ordinal
@ ordinal(x)
Four

@ // Pattern Matching Types
@ dBef printType(obj: AnyRef) = obj match {
    case s: String => println("This is a string")
    case i: java.util.Date => println("This is a Date")
    case l: List[_] => println("An array eh?")
    case _ => println("dunno who ye are")
  }
defined function printType
@ printType(List(1,1,2))
An array eh?


// Guards
@ def numCatcher(num: Int): Unit = num match {
    case x if x < 10 => println("Number less than 10")
    case y if (y%2 == 0) => println("Is an even number")
  }
defined function numCatcher
@ numCatcher(5)
Number less than 10

@ numCatcher(12)
Is an even number

Miscellaneous notes

sbt plays an important role in the day to day programming of scala. I believe 'sbt' stood for "scala build tool" at one time, but is no longer.

To start working on a scala program, you can start with a simple text editor, however using something like IntelliJ IDEA is probably far more productive.

Creating a "project structure" can be automated. Essentially this boilBs down to creating the build.sbt file, project directory and optional plugins.sbt file inside it, a scala file inside the proper src/main/scala/com/example/projectname/ directory etc., There is little reason to do all this manually, except when you are trying to understand the reason behind such a recommended directory layout.

giter8 ie., the g8 is a tool that can create a project structure based on pre-defined templates. Think of this as paster tool for Python.

When you have g8 installed, creating a new project (say, a basic scala project using this template ), all you have to do is:

$ g8 fayimora/basic-scala-project.g8

A basic scala project

name [Basic Project]: basic-scala
organization [com.example]: com.btbytes
version [0.0.1]:

Template applied in ./basic-scala

$ cd basic-scala
$ ls
build-sbt src

$ sbt run will download the dependencies defined in the build.sbt file,B compile source and run the program.

sbt can also create the files necessary to make this an "IntelliJ IDEA project". For this, we add a dependency to the plugins.sbt file:

#project/plugins.sbt -- add this line
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")

Running sbt gen-idea will generate the IDEA project files (.idea, some .iml).

Launch up IDEA and "open project" and open the root directory of the project. You are now set to work on the code.

Packaging the binary to a .jar:

$ sbt packageBin

Will produce target/scala-2.10/basic-scala_2.10-0.0.1.jar (where basic-scala is the name of the project).

Why not Scala

Concepts

Covariance, Contravariance and Invariance

Reading:

In general, covariant type parameter can be used as immutable field type, method return type and also as method argument type if the method argument type has a lower bound. Because of those restrictions, covariance is most commonly used in producers (types that return something) and immutable types.

Adhoc polymorphism

In this article we discussed the motivation for introducing ad hoc polymorphism and implementing it using the Type Class Pattern in Scala. It allows us to build abstractions which are completely decoupled from the underlying data types on which they operate. Hence we can implement polymorphic functions which operate on types we have no control over, such as types defined in the standard library or some other third party library, without sacrificing the static type safety.

Concurrency (Akka etc.,)

StBreams

Libraries

Tools

  • lihaoyi/Ammonite: Scala Scripting. Ammonite enables shell-like scripting in the Scala programming language.
  • Conscript -- is a tool for installing and updating Scala software programs.
  • giter8 -- is a command line tool to generate files and directories from templates published on github or any other git repository.

SBT

Ensime -- Enhanced Scala

Interaction Mode for Emacs.

Talks

Articles

Blogs

Libraries

  • kantan.csv has good documentation/tutorials.
  • Quill Quoted Domain Specific Language (QDSL) to express queries in Scala and execute them in a target language. The library’s core is designed to support multiple target languages, currently featuring specializations for Structured Query Language (SQL) and Cassandra Query Language (CQL).

REPL

Ammonite REPL is much more featureful than the default REPL and comes with a lot of ergonomic improvements and configurability that may be familiar to people coming from IDEs or other REPLs such as IPython or Zsh.

Links

Scalajs

Scala Native

Scala CLI

With scala-cli, it is quite easy to package a scala program into a standalone program:

scala-cli --power package --native-image Echo.scala -o echo -- --no-fallback

where Echo.scala is:

object Echo {
def main(args: Array[String]): Unit =
	println(args.mkString(" "))
}
$ ls -alrt echo
-rwxr-xr-x@ 1 pradeep  staff  14120984 Aug 23 17:15 echo
$ du -sh echo
 13M    echo

Books

Tutorials

Indyscala notes

Feb 6, 2017 -- Resource management in Scala

Presenter -- Ross A. Baker

May 1, 2017

notes#jvm#programming-language#scala

Mercury Programming Language

Mercury language -- Home page

Mercury combines (predicate) logic programming and one of the more rigorous type systems to give a programming language that is declarative, efficient and consistent.

-- Good explanation of Mercury syntax by Markus Triska, a prolog programmer; Apr 2019.

notes#programming-language

Racket Programming Language

Libraries

  • Video Language -- "Video is a language for making movies. It combines the power of a traditional video editor with the capabilities of a full programming language."

Articles

Code

Exciting

Videos

My notes

  • Racket cannot pin version dependencies yet. Does common-lisp have the same issue? Is it a Lispism?

notes#programming-language

2018

Logic Programming

To Read:

  • Sterling and Shapiro (Sterling and Shapiro 1986) is often recommended as the introductory text to Logic Programming.
  • Nominal Logical Programming (Cheney and Urban 2008) -- is an extension of first-order logic which provides a simple foundation for formalizing and reasoning about abstract syntax modulo consistent renaming of bound names (that is, alpha-equivalence). "powerful tool for informal reasoning about theoretical computer science. For me it made theoretical computer science tangible, and I hope these series of posts can do the same for the reader." -- swannodette
  • miniKanren -- is an embedded Domain Specific Language for logic programming. See also: Will Byrd's Thesis -- Relational Programming in miniKanren: Techniques, applications and implementations (Byrd 2010).
  • For real world applications of logic programming see -- Concepts, Techniques, and Models of Computer Programming by Roy, Haridi and Seif (Van Roy and Haridi 2004).

Software

  • logic-db is a js lib to combine logic programming and database

Misc

References

  • Sterling, Shapiro (1986). The Art of Prolog: Advanced Programming Techniques.
  • Cheney, Urban (2008). Nominal Logic Programming.
  • Byrd (2010). Relational Programming in Minikanren: Techniques, Applications, and Implementations.
  • Van Roy, Haridi (2004). Concepts, Techniques, and Models of Computer Programming.

notes#programming-language

Julia programming language

Learning

Blog Posts

Comparisons

2020-06-03 A Look at Chapel, D, and Julia Using Kernel Matrix Calculations – The D Blog; Julia comes out ahead in performance. Even handed comparison on Dlang's website.

Books/Tutorials

IDE/tools

Important information

twitter

notes#julia#programming-language

J programming language

J programming language

Code

Blogs

People

notes#apl#jlang#programming-language

ATS Lang

What is ATS?

Learning

Programs written in ATS

Talks

Blog posts

notes#programming-language

Vala Programming Language

STATUS: No longer Maintained.

Vala is a C# | Java like langauge that compiles down to C+glibc. Used heavily for developing gnome desktop applications. Before I discovered D (and to certain extent nim), I had hoped that Vala would be a nice compiled langauge to use. However, the community of Vala appears to not care beyond desktop applications.

notes#programming-language