Git Product home page Git Product logo

lunar-logo's Introduction

Lunar Logo

Welcome to Lunar Logo, an experimental scripting language based on Logo and Lua, with a tiny core and clean, minimal syntax. Example usage:

$ ./lunar.py sqrt add mul 3 3 mul 4 4
5.0

That's right, you can type Lunar Logo code at a Bash prompt without escaping it (within reason). For a bigger sample, put this code in a file, say repl.lulz:

print [Welcome to Lunar Logo. Enter your commands, or BYE to quit.]
while [true] do
	type >
	type space
	make cmd readlist
	if eq nil :cmd do
		break
	end
	if eq 0 count :cmd do
		continue
	end
	if eq bye lowercase first :cmd do
		break
	end
	foreach i results parse :cmd do
		if neq :i nil do
			show :i
		end
	end
end

Now you can load it as follows:

$ ./lunar.py load repl.lulz

Indeed, Lunar Logo doesn't need a built-in interactive mode because you can code one yourself in just a few lines!

Features

  • A blend of two programming languages famous for friendliness.
  • First-class functions with lexical scoping (and blocks with dynamic scoping).
  • Metaprogramming: code is data; the parser and evaluator are procedures in the language.
  • Tiny core: under 200 lines of code in the prototype -- squeaky-clean code, too!
  • Easily extensible and embeddable: many built-in procedures are literal one-liners.

Project goals

  • A language that needs little or no escaping when embedded into string literals, command lines and such.
  • A language that doesn't run too slowly when implemented in another interpreted language.
  • A language that throws few exceptions. A surprising amount of modern languages in widespread use have other error handling mechanisms.

Uses

You know how modern command line applications have a lot of options, and invocations can become really hairy? For that reason, many of them grow an option to load more options from a file... which of course just complicates things even more.

Lunar Logo solves that problem neatly. Note how in the example above load isn't some special command line option, but an ordinary Logo procedure. You just got the aforementioned ability for free!

Of course, now your application is driven by a whole scripting language, and that requires more care. With great power comes great responsibility.

Other possible uses are as a fancy calculator (much more powerful than expr), or for writing Awk-style filters: Lunar Logo should handle TSV files very well indeed.

As of 08 February 2017, Lunar Logo is used to drive Stereo Imagination, a command-line tool to automate the generation of 3D models.

History

This is the second time I do a Logo dialect. The first time around I kept much closer to the original language, but the result was a messy implementation that left much of the heavy lifting to individual procedures, and still didn't have much in the way of speed or capabilities.

Status

As of 31 January 2017, Lunar Logo has two implementations that can run all the examples correctly. The language supports over 100 procedures (you can find a concise list at the end of lunar.py). See the tutorial for an overview.

The software is considered beta quality. More real-world testing is needed, and the feature set may still change. Anything mentioned in the tutorial and examples should stay put from now on, though.

To Do

Error reporting needs some way to provide better context.

lunar-logo's People

Contributors

felixp7 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

bosconi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.