Git Product home page Git Product logo

fram's Introduction

Fram

A small domain specific language which compiles to JS and assumes the environment of the Framer Editor.

Synopsis

To build the project you need to satisfy the dependencies here (see below) and ANTLR4TS's dependencies (for building the grammar).

  • To install dependencies: npm i

  • To build the project: npm build

  • To build the grammar: npm run build-grammar

  • To run the tests: npm run test

  • To watch changes and re-run tests: npm run test -- --watch

Why the heck is this?

I guess the intimidation from all the weird stuff people need to know to get started with the cool programming stuff sometimes may be an entry barrier too high.

This language is a try to smoothe the learning curve, the goal was to get as close as possible to what a designer would write on a paper in English, this DSL-ish thing is intended as a gateway drug to real, general programming languages, so the basic concepts (variables, scoping, calls, event listeners) are in there, just in a different way, i hope it may alleviate some of the fears people have when they are just getting started.

Syntactic sugar, and?

Yeah, yeah, it's an evil programming language, just with a nice(r) front, so it still has scoping and variables and all that, and it may feel like CONFUSING ARRGGH for the first time. After talking to a minimal amount of designers (2), i think there's a fix for that, but it's not syntactical, it turns out designers favor and understand concepts better when visualized. 🤔

I guess - this is just a sketch - visualizing scopes, providing outstanding tooling and the friendliest error handling ever™ in a way that it's easy to slip out from this sandbox world into the real JS environment may be an acceptable first try to help people adapt to the good stuff faster.

tell me more?

What the heck is this?

It's a kind of language, for animations and stuff. It looks like this:

// Comments look like this, you can leave them here to remember stuff, it's like the sticky note of the internets. 📚

fastTime is 50ms; // You can say things are something, like define what they mean, build your own vocabulary, woo-woo!

animate playButton: set color to tomato in 120ms; // You can make things change! This will change playButton's color to tomato in 120ms. Fab!
animate playButton: set color to papayawhip in fastTime; // You can just say fastTime, if you tell the language what it is.

// You can react to other people doing things. 🆒
when playButton is clicked {
    // Hide the button because the video starts.
    animate playButton: set opacity to 0% in fastTime;
}

// OH DID I MENTIONED YOU CAN DO THE LOCO LOCO? 🏄🏿
animate playButton: set
    opacity to 0%,
    color to blue,
    border-color to "#333",
    border-radius to "12px"
    in 10ms; // <- the semicolon thingie is important business around here, don't forget to put it at the end of animations and when you define stuff!

Imagined use

This may be used inside the Framer Editor, as embedded Fram instead of embedded JavaScript, a precompiler could go through it before CoffeeScript's compiler does and convert Fram to JavaScript. This way people could make things easy inside the embedded Fram, but could get out as soon as they feel ready. :)

This approach may make everything way harder at the tooling part.

Integrating

You can get started parsing, validating and translating Fram like this:

import { FramTranslator, FramValidator } from 'fram';
import { SymbolType } from 'fram/listener/symbol/Symbol';
import VariableSymbol from 'fram/listener/symbol/VariableSymbol';

const sourceCode = "niceRed is tomato;" // Get the Fram source text.
const globalVariables = [new VariableSymbol("playButton", SymbolType.Layer)]; // Declare your global variables, such as layers (optional in FramValidator).

const rootNode = FramValidator.parseAndValidate(sourceCode, globalVariables); // This parses Fram code and checks the scopes and references.
const esTree = FramTranslator.translateToECMAScriptAST(rootNode); // ESTree spec AST.
const esCode = FramTranslator.translateToECMAScriptSourceText(rootNode); // Generated ECMAScript source code. 

For more information, please see classes FramTranslator and FramValidator.

What's up?

These:

  • add a bit of test coverage
  • add the friendliest error handling ever™
  • add syntax for timing curves
  • add syntax for states
  • as a side project: editor visualizing scopes?
  • add syntax for animation instances?
  • bunch of other stuff in my mind! 🙋‍♂️

Disclaimer

I have no idea what i'm doing or if it's useful or future-proof at any degree, just trying around.

fram's People

Stargazers

Elekes Tamás avatar

Watchers

Dániel Gulyás avatar

Forkers

lxdong

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.