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

Archive

9,692 entries: 92 from X, 8,929 from Pinboard, saved 1998 to 2026.

Browse by tag, site, author, folder or language

Tags

Sites

Authors

Folders

Languages

Showing 3,951–4,000 of 9,692

2020

Interesting Websites

Trying to collect websites that are intersting, free-standing, with a bit (or a lot) of personality. Preference given to "hand-made" websites. And to do so, all you may need is HTML.

The art of building "personal" websites is a thing of the 90s, it appears.. (See also the idea of IndieWeb).

Why have a personal website?


Meta

Related

Portals


See also:

notes#web

FUNctional programming

See also: <functional-programming.html>

Blog-posts and articles

People

  • Hudak
  • Pierce
  • Milner
  • Harper
  • Peyton-Jones
  • Don Stewart
  • The Racket people - [Brown, IU, NEU]
  • The OCaml people - [INRIA]
  • The Haskell people - [MSR]

See Also: My pinboard bookmarks tagged functional-programming

notes#programming

Nextjournal

nextjournal.com

@JamesMarsh79 @trishankkarthik @ryankon I've been meaning to try myself for exploratory dat…

nextjournal.comPinboardPermalink

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

Software tools

List of programs and shell scripts that I find useful.

Meta (lists made by other people)

Chrome extensions

Safari extensions

  • Ghostery -- block intrusive javascript.

Pandoc

pandoc is a fantastic program to convert text to various output formats.

Typcial usage: To convert a markdown formatted text file to html

$ pandoc somefile.txt -f markdown -t html --standalone -o somefile.html

See the detailed pandoc page.

Command line tools

abcde

Command line tool to rip CDs to .mp3.

Installation: $ sudo apt-get install abcde id3v2

Insert Disc #1 of a 3-cd audio book $ abcde -o mp3 -p -W 1.

bcat

bcat pipe to browser utility.

Typical usage: To see the git log.

$ git log -p --color | bcat

fd

sharkdp/fd: A simple, fast and user-friendly alternative to find.

gist

gist pastes code, text to [gist.github.com] from command line.

$ gist one.txt

partimage

partimage is a Linux disk imaging software. It has a curses based interface to guide you through the options.

Typical usage: make a backup of an entire HDD(say SSD/Flash of a prototype) to your desktop.

Make Image:

$ partimage -z1 save /dev/sdg1 $HOME/backup/prototype-hdd-20100707.partimg.gz

Restore:

$ partimage restore /dev/sdg1 $HOME/backup/prototype-hdd-20100707.partimg.gz

qpdf

qpdf -- is a command-line program that does structural, content-preserving transformations on PDF files.

http-prompt

pip install http-prompt

fzf

junegunn/fzf: A command-line fuzzy finder written in Go

peco

q

entr

entr(1) -- Run arbitrary commands when files change

ripgrep

ripgrep recursively searches directories for a regex pattern. See rga, like rg, but also search in PDFs, E-Books, Office documents, zip, tar.gz, etc.

sd

sd is an intuitive find & replace CLI.

rargs

rargs xargs + awk with pattern matching support. ls *.bak | rargs -p '(.*)\.bak' mv {0} {1}

rak

lizmat/App-Rak: 21st century grep / find / ack / ag / rg on steroids

Code tools

Database tools

  • dbeaver -- crossplatform database manager for all popular sql dbs and some nosql dbs.

Web development tools

Data Cleaning

Interesting ~/bins on github

Some more linked on this page: 15 Greatest Open Source Terminal Applications Of 2012

Interesting

  • ronn - the opposite of roff.

Lorem ipsum

OCR

ASCII Banner

Use Figlet and Toilet to generate ascii text banners in linux terminal.

notes#macos#tools

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

Advaita

Heard about "nityaanityavivekachaara" via Arvind Iyer. Some more reading here - (Bhaja Govindam verse 30). (Feb 12, 2020).

Nityanitya vivekavicaram is the discrimination or viveka between nitya and anitya. Let my intellect be engaged in discrimination. Let me become an enquiring, thinking or contemplative person. Let me not take things for granted. There are so many notions and assumptions in our life, which we have never stopped to analyze. Therefore, let me consider what is nitya and what is anitya, or what is permanent and what is impermanent.

SADHANA CHATUSTAYA (BASIC QUALIFICATIONS) | Advaitam and Science

The sadhana catustaya are:

  1. Viveka or differentiation

  2. Vairagya or dispassion

  3. Samadi-satka-sampatti or the six diciplines (or virtues) of the mind

  4. Mumuksutvam or the desire for liberation.

notes

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

Meta list of book recommendations by people

Book lists

Medical books for non-medicine people by Michael Sanger, MD

  • Learn Physiology: John E. Hall PhD, Guyton and Hall Textbook of Medical Physiology (Guyton Physiology)
  • Systems Medicine. Editors: Schmitz, Ulf, Wolkenhauer, Olaf (Eds.) Includes cutting-edge methods and protocols.
  • Didier Sornette. Critical Phenomena in Natural Sciences: Chaos, Fractals, Selforganization and Disorder: Concepts and Tools

Hackernews

Lobsters

Probabilistic Computing

ML and AI

Business and economics

Programming and software development

Book reviews by people:

Book lists

Other

Blog posts

Websites


See also: Twitter Book Recommendations, lists, 100-page-book

notes#books#reading#software

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

GNU Guix

Guix is a package manager.

NixOS:Nix::GuixSD:Guix


Links

Talks

notes