const PROG_DEFAULT = "Merge Sort"; const HEADLINES = [ `You Won't Believe What This Programming Language Can Do!`, `The Best Programming Language You Haven't Heard Of (It Will Surprise You!)`, `Shocking New Programming Language Bewilders Programmers at Google and Facebook!`, `Programmer Who Made Everything Now Predicts the Next Big Language!`, `The Secret Programming Language Every 10x Programmer Recommends!`, `Programmers at Microsoft Hate This One Trick to Get Good at that Code Thing!`, `How To Lose Brain Fat With This Programming Language!`, `Your Friends Will Be Jealous About This New Programming Language!`, `You Can Earn Millions With This Programming Language!`, `The Cure For Cancer Could Be Found With The Programming Language!` ]; function randomHeadline() { return HEADLINES[~~(Math.random() * HEADLINES.length)]; } const { Component, } = window.Torus; class Editor extends Component { init() { this.prog = PROGRAMS[PROG_DEFAULT]; // script appends to it this.output = ''; this.errors = ''; this.handleRun = () => this.eval(); this.handleInput = evt => { this.prog = evt.target.value; this.render(); } this.handleKeydown = evt => { if (evt.key === 'Tab') { evt.preventDefault(); const idx = evt.target.selectionStart; if (idx !== null) { const front = this.prog.substr(0, idx); const back = this.prog.substr(idx); this.prog = front + ' ' + back; this.render(); evt.target.setSelectionRange(idx + 4, idx + 4); } } } } setProgram(programName) { this.prog = PROGRAMS[programName]; this.output = this.errors = ""; this.render(); } eval() { this.output = ''; this.errors = ''; try { const tokens = tokenize(this.prog); const nodes = new Parser(tokens).parse(); const env = new Environment({ print: s => { this.output += s.toString().toUpperCase() + '!\n'; this.render(); }, input: s => { return prompt(s); }, }); env.run(nodes); } catch (e) { this.errors = e.toString(); } this.render(); } compose() { return jdom`
${this.prog.split('\n') .map(line => jdom`

${line.trim() ? line : '-'}

`)}
${this.output ? this.output .split('\n') .map(line => jdom`${line}`) : jdom`No output.`}
${this.errors ? jdom`
${this.errors.split('\n').map(line => jdom`${line}`)}
` : null}
`; } } class App extends Component { init() { this.editor = new Editor(); } compose() { return jdom`

${randomHeadline()}

Tabloid: The Clickbait Headline Programming Language

${this.editor.node}

What?

Tabloid is a turing-complete programming language for writing programs in the style of clickbait news headlines.

Here are a few things${' '}the Top Five Most Popular Quirks and Features of the Tabloid programming language (Number Four Will Shock You!)

But why?

Didn't want to do homework for my database systems class, and needed something to do to procrastinate. Will I finish the homework? Did I get enough sleep?

Stay tuned to find out!

Does it actually work?

Yes. Tabloid is a fully functioning, Turing complete programming language with an interpreter written in JavaScript. Tabloid currently only supports numbers, strings, and booleans, but with these elements, you can write any program you'd want to write. You can edit and run the program above, or see how it works for yourself.

Besides this online interpreter, Tabloid now also has a mostly compatible implementation in Racket and a small library of helper functions ... for some reason.

Before making Tabloid, I also created a more useful and well-designed${' '}boring and unpopular programming language, called Ink.

How much is there?

Here's the full list of standard keywords that Tabloid currently uses:

`; } } const app = new App(); document.body.appendChild(app.node);