Skip to content

Instantly share code, notes, and snippets.

View benchristel's full-sized avatar

Ben Christel benchristel

View GitHub Profile
@benchristel
benchristel / language.md
Last active August 10, 2019 18:23
Sketch of an ideal application programming language

Sketch of an ideal application programming language

The language described below

  • leverages the strengths of procedural, functional, and OO programming styles
  • distinguishes cleanly between mutable and immutable datatypes and variables
  • does not have null or anything like it
  • is typesafe, though some type checking has to be performed at runtime
@benchristel
benchristel / main.js
Created June 14, 2018 15:16
A tiny test framework in Verse
define({
displayText() {
return getTestResults()
},
getTestResults() {
return Object.keys(window)
.filter(name => startsWith('test ', name))
.map(title => ({title, failure: getTestFailure(title)}))
.filter(result => result.failure)
@benchristel
benchristel / wizard-names-in-verse.js
Last active September 9, 2018 23:48
Wizard name generator in Verse
define({
*run() {
yield log('Press any key to generate a name.')
yield function* loop() {
yield waitForChar()
yield log(generateName())
yield retry(loop())
}
},
@benchristel
benchristel / main.js
Last active March 31, 2018 23:45
Pico, Fermi, Bagel in Verse
/**
* This is a (not-yet-functional) sketch of a game that uses the Verse UI framework.
* It is intended to show how Verse might be used for a moderately complex program.
* The core logic of the game is not implemented here, since it is irrelevant for
* illustrating the use of Verse.
*
* The rules of Pico, Fermi, Bagel can be found here:
* http://www.mathfairy.com/wp/kids/pico-fermi-bagels/
*/
@benchristel
benchristel / futilities.js
Last active February 19, 2018 00:48
Functional utilities. Futilities, if you will.
// test-driven with Ji (http://benchristel.github.io/ji/)
// PRODUCTION CODE
function head(iterable) {
for (let item of iterable) {
return item
}
}
@benchristel
benchristel / README.md
Created December 10, 2017 19:44
Data vs. Information

Data vs. Information

Computers do two types of data transformation

commands: data -> data (state change)

  • limited set of interactions
  • need to validate data
  • worth optimizing UX
  • same type of interactions repeatedly (e.g. data entry) -> streamlined UI, workflows, wizards...
@benchristel
benchristel / index.js
Last active December 10, 2017 18:03
Coroutine Framework
/**
* Demo of a coroutine-based framework, in which the application code repeatedly
* yields control to its environment (e.g. to receive input or wait for a period of time).
* This allows JavaScript programs to be written in a synchronous style.
*/
// Test-driven with Ji (benchristel.github.io/ji)
function Program(code) {
var eventGenerator = null
@benchristel
benchristel / terminal-settings.json
Created November 4, 2017 21:35
My settings for cool-retro-term
{
"ambientLight": 0.501,
"backgroundColor": "#000000",
"bloom": 0.0962,
"brightness": 0.5,
"burnIn": 0.0282,
"chromaColor": 1,
"contrast": 0.85,
"customCommand": "",
"flickering": 0.302,
@benchristel
benchristel / untested_bs.js
Last active August 26, 2017 19:46
Eval code in a web worker and get the result
function startWorkerWithCode(code) {
return new Worker(URL.createObjectURL(new Blob([code])))
}
function evalAsync(code, funcName, callback) {
var worker = startWorkerWithCode(code + ';self.postMessage(' + funcName + '());')
var timeout = setTimeout(function() {
worker.terminate()
callback('timeout')
@benchristel
benchristel / index.js
Created August 20, 2017 17:48
Object-oriented Grove state
// "class"-like method container
// allows JSON serialization for persistence
// since state properties can be persisted and method
// properties are treated as immutable.
type('KeyTracker', {
lastKey: null,
receive: function(event) {