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

langblue

v0.0.1

Published

a simple bytecode, assembler, and runtime

Downloads

4

Readme

Langblue

Langblue is a simple bytecode. There are only 20 32-bit instructions and one 64-bit instruction. Because of this, langblue is very easy to implement compared to other bytecodes.

Along with a bytecode, this project ships with a langblue assembler and linker. The linker supports relocation, so it is easy to write scalable langblue programs.

Theoretically, it would be possible to compile C or C++ down to langblue, although I have not attempted to go about doing so.

Installing

You can only use the CoffeeScript tools if you have CoffeeScript and Node.js installed. To install Node.js, visit the Node.js website. To install CoffeeScript once you have Node.js, do this:

$ npm install -g coffee-script

Now, install the langblue binaries by running this in the root langblue directory:

$ npm install -g

Now, you have the langblue command to interpret langblue binaries, langblue-as to assemble langblue assembly, langblue-join to join object files, and langblue-juice to transform an object file into a binary.

Usage

Here is an example of how to write a program, assemble it, juice it, and run it. First, let's create a source file called hi.s:

sreg r0, 0x68 ; 'h'
pchar r0
sreg r0, 0x69 ; 'i'
pchar r0
sreg r0, 0xa ; '\n'
pchar r0
sreg r0, 0
exit r0

To assemble this program, we will use the langblue-as command. The command takes the source file as an argument and outputs the object data to stdout. We will write the object file to hi.json:

$ langblue-as hi.s >hi.json

At this point, if we had multiple files we would join them using the langblue-join command. However, since we only have one file, we will skip right to "juicing" it. The langblue-juice command takes the input and output files as arguments, since the raw binary is not suitable to be printed in a console:

$ langblue-juice hi.json hi.bin

Finally, we can use the langblue command to execute the binary:

$ langblue hi.bin
hi

Joining objects

Langblue object files list public symbols, their addresses, and every reference to them. This way, one source file can reference a function or constant from a different file.

The langblue-join command takes object files as arguments and outputs the joined object file to stdout. The objects are joined in the order they are specified as arguments, so the object with the entry point should go first. Here's an example:

langblue-join main.json printf.json math.json >program.json

An object file should not be juiced unless it has been completely linked: that is, it has no unresolved references.

Features

Langblue applications are provided with a pool of memory and 16 registers. They can exit the current program with the exit instruction. Additionally, programs may access the "console" through the pchar and gchar instructions.

At the moment, langblue has no built-in interface for system calls, but the bytecode could easily be expanded to include such a thing in the future.

The assembler allows you to embed strings and constants in the assembled blob. It supports hidden and exported symbols for named internal and external functions and constants.

Uses

Suppose your Computer Science homework is to write a program in some strange language that you despise–let's call it Flaskell. You could write the entire program in Flaskell, but that would be no fun. Instead, you could write a langblue interpreter in Flaskell, write the entire program to compile down to langblue, and then hand in a Flaskell program that contains a large binary blob and a langblue interpreter.

Langblue could also be used for fast platfrom-independent binaries.