Rover, the BarkScript mascot: a golden retriever in an orange bandana, looking up

Your code is barking.

The world's least serious programming language.

BarkScript is a real language written in dog commands. A lexer, a parser, a type checker and a compiler turn it into plain JavaScript you could ship. Whether you should is between you and your dog.

npm install -g barkscript
main.bark
JavaScript

          
Console

Fifteen commands. You already know most of them.

Familiar dog commands, used for what they sound like. Strings, numbers, lists, objects and operators work the way they do in JavaScript, because underneath, that is what they are.

BarkScriptJavaScriptWhy
woof "hi"console.log("hi")Dogs announce everything.
sit treats = 3let treats = 3It sits there until you move it.
stay name = "Rover"const name = "Rover"It does not move. Ever.
fetch giveTreat() ... endfunction giveTreat() {}Goes off, does a job, comes back.
come here giveTreat()giveTreat()You call, it comes.
drop it treatsreturn treatsHands back what it was holding.
if ... otherwise ... endif {} else {}Dogs do not do conditionals, so these stay human.
again 3 ... endfor (...) {}Also again while, again each, again i from 1 to 10, again forever.
nobreakStops whatever is happening.
leave itcontinueSkip this one, move on.
wait 2 secondsawait sleep(2000)Makes the fetch async for you.
beg "Name? "await ask("Name? ")Asks for input, very nicely.
play deadprocess.exit(0)The program stops moving.
treats.bury("bones", 3)localStorage.setItem("bones", 3)Then treats.grab and treats.eat. Still there next visit.
good boy, bad dog, empty bowltrue, false, nullgood girl is also true.

When something is wrong, Rover says so.

The compiler checks the whole program before any of it runs, and every error has a line, a column, and usually the fix. These are produced live by the same compiler the playground uses.

Put it straight in your HTML.

One script tag, then write BarkScript inside <script type="text/barkscript">. It compiles in the browser when the page loads. data-output also prints each woof into an element.


          
This page, running that

Install

Node.js 20 or newer. Then three steps.

  1. Install the bark command

    npm install -g barkscript
  2. Write hello.bark

    woof "Hello, world!"
  3. Run it, or compile it to JavaScript

    bark run hello.bark
    bark compile hello.bark   # writes hello.js

Editor support: a TextMate grammar and VS Code extension live in editors/vscode.

Teach Rover a new trick.

BarkScript is MIT licensed and built in the open. The compiler is four small TypeScript files: lexer, parser, checker, code generator. Grammar changes start as an issue, so we can agree on the words first.