1
1
Fork
You've already forked blue
0
No description
  • Go 56.9%
  • C 33.4%
  • Limbo 8.2%
  • CSS 1.4%
2026年06月27日 00:14:55 -04:00
.github/workflows
ast tests: cleanup 2026年05月25日 11:21:40 -04:00
b_test_programs lint: update for linter errors and vulncheck 2026年06月27日 00:14:55 -04:00
bd
blueutil lint: update for linter errors and vulncheck 2026年06月27日 00:14:55 -04:00
cmd lint: update for linter errors and vulncheck 2026年06月27日 00:14:55 -04:00
code lint: update for linter errors and vulncheck 2026年06月27日 00:14:55 -04:00
compiler lint: update for linter errors and vulncheck 2026年06月27日 00:14:55 -04:00
consts
lexer lint: update for linter errors and vulncheck 2026年06月27日 00:14:55 -04:00
lib gg: add new object for use by previous fun that was added 2026年06月14日 08:29:28 -04:00
man lint: update for linter errors and vulncheck 2026年06月27日 00:14:55 -04:00
manual_tests tests: fix space-invaders spacing when wall hit 2026年06月14日 07:45:14 -04:00
object lint: update for linter errors and vulncheck 2026年06月27日 00:14:55 -04:00
parser lint: update for linter errors and vulncheck 2026年06月27日 00:14:55 -04:00
repl lint: update for linter errors and vulncheck 2026年06月27日 00:14:55 -04:00
token lint: update for linter errors and vulncheck 2026年06月27日 00:14:55 -04:00
util
vendor lint: update for linter errors and vulncheck 2026年06月27日 00:14:55 -04:00
vm lint: update for linter errors and vulncheck 2026年06月27日 00:14:55 -04:00
ws_vendor deps: update 2026年05月23日 18:20:08 -04:00
.gitignore
b.txt
benchmark-things.bat
benchmark-things.sh
blue-TODO.txt todo: update 2026年06月15日 10:24:22 -04:00
gen-man.sh
go.mod lint: update for linter errors and vulncheck 2026年06月27日 00:14:55 -04:00
go.sum lint: update for linter errors and vulncheck 2026年06月27日 00:14:55 -04:00
go.work
go.work.sum
hf.md
LICENSE
main.go
make_release
make_release.bat
make_release_static
make_release_static.bat
README.md readme+docs: update 2026年05月24日 22:57:16 -04:00
scratchfile.b

blue - a fun programming language

Background

I started this project in 2020 and have been on and off adding features to it and developing it since then. The language draws inspiration from many others but mostly I just wanted a scripting language that was fun to use and fun to develop.

Note: Its not blazingly fast but that was never the point. It may be practical to eventually compile the language to go which could improve its speed?!

Details

  • recursive descent parser
  • one pass (non-parallel) tokenizer
  • interpreted
  • 3rd party libs used liberally and appropriate licenses should be found within their respective vendored folder
  • there are bugs!
  • Fun! (imo)

Building

  • go1.25 required
    • brew install go or scoop install go or here
  • C Compiler
    • brew install gcc or scoop install gcc
  • Install deps for fyne
  • make sure no errors with go build
    • had this error on mint
      • added export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig to ~/.bashrc
    • windows has no requirements
    • tested on macos that still works on my old macbook (latest may or may not work)
  • Install upx here (or other methods) to make the binary super small
    • small exe cmd = go build -ldflags="-s -w -extldflags='-static'" && strip blue && upx blue
  • Static build now available (with no CGO) making it much easier to cross compile
    • See make_release_static.* to see how its being built and tested locally
  • govulncheck via go install golang.org/x/vuln/cmd/govulncheck@latest

Notes

  • bundler will only work with ui deps installed (on linux/mac)
    • does not work cross-platform yet for building (gh actions handles it)
    • This will soon work with static builds (no ui or gg)
  • set BLUE_DISABLE_HTTP_SERVER_DEBUG to true to disable http server route/welcome message printing
    • it will also prevent the stack trace from returning in http request failures
  • set BLUE_INSTALL_PATH to the directory where blue is installed to
    • this is used for the bundler currently
    • if there are no files at the given path git will be used to clone the repo there once to cache it
  • set NO_COLOR or BLUE_NO_COLOR to true to disable color printing in the terminal
  • my BLUE_INSTALL_PATH is set as export BLUE_INSTALL_PATH=~/.blue/src
  • my blue exe is located at ~/.blue/bin with PATH set to export PATH=$PATH:~/.blue/bin

Features

  • builtin libs for ui, math, http, net, crypto, time, db, config, more to come!
  • default args
  • string interpolation
  • list, set, map comprehensions
  • first class functions
  • return last expression
  • "immutable" and mutable variables (val vs var)
  • eval()
  • processes (builtin on goroutine with channels)
  • (x in y) - sets, lists, str, maps
  • errors, assert, try-catch-finally
  • match - basic sort of pattern matching
  • if's are expressions

Examples

  • default args
fun main(name="You") {
 println('Hello #{name}!');
}
main() # "Hello You!"
main('me') # 'Hello me!' 
# also works with main(name='World')
  • http client
import http
http.get("https://danluu.com/")
  • matching (not quite pattern matching - more like switch)
# from core.b
fun send(obj, value) {
 return match obj {
 {t: "pid", v: _} => {
 _send(obj.v, value)
 },
 {t: "ws", v: _} => {
 import http
 http.ws_send(obj.v, value)
 },
 _ => {
 error("obj `#{obj}` is invalid type")
 },
 };
}
  • check out files in b_test_programs for more

Space Invaders Example

SpaceInvaders

Usage

  • Download the binary from the latest release
    • only amd64 being built and tested
  • Ensure the binary is executable
    • chmod +x BINARY_NAME
  • For bundler
    • ensure BLUE_INSTALL_PATH is set to an empty dir
      • ex: export BLUE_INSTALL_PATH=~/.blue/src
    • blue bundle my_prog.b - files should all be in the same directory with 1 file at the root level
blue is a tool for running blue source code
Usage:
 blue <command> [arguments]
The commands are:
 lex start the lexer repl or lex the given file (converts the file to tokens and prints)
 parse start the parser repl or parse the given file (converts the file to an inspectable AST without node names)
 
 --all-parser-errors show all parser errors instead of stopping at the first one
 bundle bundle the given file into a go executable with the runtime included (bundle accepts a '-d' flag for debugging)
 (NOTE: currently non-functional)
 doc print the help strings of all publicly accesible functions in the given filepath or module
 
 note: the file/module will be compiled to gather all functions
 vm run the given string or file through the VM
 
 --all-parser-errors show all parser errors instead of stopping at the first one
 
 --no-exec do not allow executing programs or scripts
 
 -e, e, eval alternative ways to trigger the vm evaluation
 compile compiles the given string or file to bytecode
 
 --all-parser-errors show all parser errors instead of stopping at the first one
 help prints this help message
 version prints the current version
The default behavior for no command/arguments will start an vm repl. (If given a file, the file will be evaluated with the vm)
Environment Variables:
BLUE_DISABLE_HTTP_SERVER_DEBUG set to true to disable the gofiber http route path printing and message
BLUE_INSTALL_PATH set to the path where the blue src is installed. ie. ~/.blue/src
NO_COLOR or BLUE_NO_COLOR set to true (or any non empty string) to disable colored printing
PATH add blue to the path variable to access it anywhere. ie. ~/.blue/bin could be added to path with the blue exe inside of it