Giter VIP home page Giter VIP logo

foilscript's Introduction

FoilScript

FoilScript: a new dialect accent variant of JS that fixes the sucky parts but still looks and feels like JS.

Why?

Some people will assume that I'm making FoilScript because I dislike JS. The truth is, I love JS. Seriously. I'm all in on JS. I just have things I don't like about it. In fact, there's a few things I hate about it.

The problem is, I've tried to get these things "fixed" in JS by making proposals, and I've been told several times, basically, "you're doing it wrong." Get shut down enough times, and you give up.

But I'm not giving up on JS. I'm just going to make the fixes myself. I'm not making a new language, I'm fixing what I hate about JS. The stuff that I love about JS is staying. FoilScript will look an awful lot like JS, on purpose. Because I love JS. And FoilScript will transpile to JS. In fact, most FoilScript will just be JS itself. Only the new stuff gets transpiled.

What's out

JS "stuff" that FoilScript will not have:

  • typeof null === "object"
  • with
  • eval()
  • ASI
  • class
  • new
  • "inheritance"
  • document.write()
  • ...probably more

What's in

FoilScript will have this "stuff" that JS doesn't:

  • (a+b)*(c+d) type expressions will automatically be FOIL expanded to a*c + a*d + b*c + b*d (note: this part is kind of a joke but is the namesake feature for this language!)
  • Add ! to infix operators (like in, instanceof, etc) to negate them, like a !in b instead of !(a in b)
  • conditional catch clauses, where you can do try { .. } catch (err if err instanceof TypeError) style coding
  • NaN will be renamed InvalidNum, in addition to isNaN() becoming isInvalidNum()
  • let (foo = 42) { .. } styled let-block-statements (even though ES6 abandoned them) via something like BlockScoper's technique
  • currentThis binding for determining where in the [[Prototype]] chain the current executing function is found (basically currentThis.__proto__ is equivalent to a super)
  • # operator for soft-binding of 'this' (I hope, I dunno)
  • @ operator for statement-localized continuations (I hope, I dunno)
  • a ? b shortened "ternary" where the : clause is optional and defaulted to undefined
  • regular expressions will have a '/n' flag that lets you turn off defaulted capturing of ( ) groups
  • a few new annotations (similar to asm.js) that let you control implicit coercions more sanely
  • the compiler will include some "linting" like the rules proposed in "use restrict";
  • ...more

Strategy

FoilScript will be extremely similar to (and almost syntax-compatible with) JavaScript. That's a key differentiator to something like CoffeeScript. The parts that are different will be small (but useful) compared to what's still valid JS.

Think of it a little bit like LESS compared to real CSS. LESS looks like CSS and has a few differences. As opposed to something like SASS (not SCSS but indentation-sensitive SASS) which is more like CoffeeScript to JS.

FoilScript's compiler will use a JS parser (hopefully an ES6 one) that has some tweaks to it. It will not rewrite most of your code, but will pass it through un-touched (also so different from CoffeeScript).

When it does have to re-write your code, it will "annotate" your compiled JS code with comments that include signals which the compiler can use to reverse-transpile from JS back into your source FoilScript. This should make it easier to collaborate with others who only write JS if you use FS. There will be tools for the transpiling (compiling) and the reversing.

foilscript's People

Contributors

getify avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

foilscript's Issues

State

Are you still working on this? Do you want to look into build a compiler for this? The compiler won't be able to solve all of these directly as a lot of these are actually engine changes.

Similar to Typecast

Hey KS,

Saw you started this repository. Sounds similar to my newest project: Typecastjs.org

Let me know if you see any opportunity for cross-over!

Bz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.