Skip to content

Instantly share code, notes, and snippets.

@matthewp
Last active March 28, 2016 07:19
Show Gist options
  • Save matthewp/7be531e14b20e9751270 to your computer and use it in GitHub Desktop.
Save matthewp/7be531e14b20e9751270 to your computer and use it in GitHub Desktop.
programming-language.md

Motivation

Writing JavaScript libraries that are stable is hard, too hard. The extreme level of modularity we practice has only made things worse, as it's become very easy to depend on quirks/bugs that exist in other libraries.

The approach that is most often taken to increase stability in a programming language is to introduce Types. That is, trade expressiveness for better static reasoning. The point being, the compiler should be able to find bugs in your program.

I'm interested in another approach; make it easier for the developer to find bugs themselves. To that end, the motivation for this language is to be easy to test. What if everything within a programs closure was available to be mocked.

exports.getName = function(person){
  return upperCase(person.name);
};

function upperCase(txt) { ... }

What if we could replace the upperCase function when testing, to ensure that the function we are testing adjusts behaves according to that change.

The idea is to have much more robustly tested code. Code that is tested against all possible scenarios, if possible.

Aside from this type of dependency injection, I'd also include features such as Monads and Immutability that ensure tested code always produces the same outcome.

Requirements

  1. Immutable by default a = 1 is immutable. Maybe provide a fallback, maybe not.
  2. Must be targeted at JavaScript from the start, written in JS.
  3. Good source map support
  4. Good interfaces - must be easy to write tests for.
  5. Built-in support for dependency injection. Not sure what this means, but it probably means that all of the imports are some how available to you for manipulation.
  6. Some way to do type signatures. Not sure if this will be required (maybe) but at least as good as Haskells.
@Hypercubed
Copy link

Sorry to jump in on your thoughts here but I think a = 1 is already immutable. Nothing can be done to change the value 1, only thing that can change is what a is assigned to. const a = 1 is immutable and constant. const a = {...} is constant but not immutable, the properties of a can change. const a = Object.freeze({...}) is constant and immutable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment