npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ludus/ludus-js-pure

v0.1.36

Published

A Ludus interpreter in a pure JS function.

Downloads

724

Readme

Ludus logo

Ludus: A friendly, dynamic, functional language

Ludus is a scripting programming language that is designed to be friendly, dynamic, and functional.

This repo currently contains a work-in-progress implementation of an interpreter for the Ludus programming language, using Janet as a host language. Ludus is part of the Thinking with Computers project, run by Scott Richmond at the University of Toronto, with collaborator Matt Nish-Lapidus; Bree Lohman and Mynt Marsellus are the RAs for the project. Ludus is our research language, which aspires to be a free translation of Logo for the 2020s.

Here are our design goals:

Friendly

Ludus, like Logo, is meant to be a teaching language, often for students who don't think of themselves as "computer people." Our intended audience are humanities and art people at the university level (undergrads, grads, faculty). Everything is kept as simple as possible, but no simpler. Everything is consistent as possible. We aspire to the best error messages we can muster, which is important for a language to be teachable. That means being as strict as we can muster, in order to be friendlier.

Our current development target is Ludus on the web: https://web.ludus.dev. That wires what we do on the langauge interpreter (here in this repo) to a web frontend.

Naturally, it starts with Logo's famed turtle graphics.

Dynamic

Statically typed programming languages generally give more helpful error messages than dynamic ones, but learning a type system (even one with robust type inference) requires learning two parallel systems: the type system and the expression system (well, and the pattern system). Type systems only really make sense once you've learned why they're necessary. And their benefits seem (to us, anyway) to be largely necessary when writing long-lived, maintainable, multi-author code. Ludus code is likely to be one-off, expressive, and single-authored.

To stay friendly, Ludus is dynamic. But: despite the dynamism, we aim to be as strict as possible. Certainly, we want to avoid the type conversion shenanigans of a language like JavaScript.

Functional

Ludus is emphatically functional: it uses functions for just about everything. This is both because your humble PI had his world reordered when he learned his first functional language (Elixir), and because the research into Logo and the programming cultures of MIT in the 1970s revolve around extremely functional Lisp code (i.e., Scheme). Logo is a weird little language, but it is a descendant of Lisp. So is Ludus.

Also, we believe that Ludus's immutable bindings and persistent or immutable data structures and careful approach to manipulating state lead to a lot of good pedagogical results. Learning a programming language involves learning how to model what's going on inside the computer; Ludus, we think, makes that both simpler and easier.

If you're looking for cognate languages, Ludus takes a lot of design inspiration from Clojure and Elixir (which itself took a lot from Clojure). (The current--quick, dirty, and slow--version of Ludus is written in Janet.) Clojure and Elixir are great! If you're asking why you should use Ludus instead of them, you're already at the point where you should be using them. Ludus is, maybe, for the people whom you'd like to work with in 5 years at your Pheonix shop (but even then, probably not).

Status

Pre-alpha, still under active development. Lots of things change all the time.

The current version of Ludus is a pure function that runs in JavaScript as a WASM blob. We have plans for more and better things.

Use

Current emphasis is on the web version: https://web.ludus.dev.

Main features

  • Expression-oriented: everything returns a value
  • Pattern matching in all the places
  • No operators: everything is called as a function
  • Easy-peasy partial application with placeholders
  • Function pipelines
  • Persistent or immutable data structures
  • Careful, explicit state management using boxes
  • Clean, concise, expressive syntax
  • Value-based equality; only functions are reference types

Under construction

  • Actor-model style concurrency.
  • Faster, bytecode-based VM written in a systems language, for better performance.
  • Performant persistent, immutable data structures, à la Clojure.

Hello, world!

Ludus is a scripting language. At current it does not have a good REPL. Our aim is to get interactive coding absolutely correct, and our efforts in ludus-web are currently under way to surface the right interactivity models for Ludus.

Either:

"Hello, world!"

=> "Hello, world!"

Ludus scripts (and blocks) simply return their last expression; this script returns the bare string and exits.

Or:

print! ("Hello, world!")
=> Hello, world! 
=> :ok

Here, we use the print! function, which sends a string to a console (stdout on Unix, or a little console box on the web). Because print! returns the keyword :ok when it completes, that is the result of the last expression in the script--and so Ludus also prints this.

Some code

Fibonacci numbers:

& fibonacci!, with multi-clause fns/pattern matching

fn fib {
	"Returns the nth fibonacci number."
	(1) -> 1
	(2) -> 1
	(n) -> add (
		fib (sub (n, 1))
		fib (sub (n, 2)))
}

fib (10) &=> 55

More on Ludus

See the language reference and the documentation for the prelude.