Giter VIP home page Giter VIP logo

atscript-playground's Introduction

AtScript Playground

This is an empty repo to make it easy to experiment with AtScript.

Initial setup

# Clone the repo...
git clone https://github.com/vojtajina/atscript-playground.git
cd atscript-playground

# Then, you need to install all the dependencies...
npm install

# If you want to be able to use global commands `karma` and `gulp`...
npm install -g karma-cli gulp

The minimal example

Our example consists of two files:

  • atscript-playground/src/something.ats defines a simple class that returns the sum of two input values
  • atscript-playground/src/main.ats imports that class and prints a message to the console

Running the example in the browser

To run in the browser, you need to first build the project. This creates a build/ directory that contains the transpiled *.js files that are created from your AtScript project.

# Do initial build, start a webserver and re-build on every file change...
gulp build serve watch

Open a browser and look in the console log to see the result.

Running the tests

The tests are in atscript-playground/test/something_spec.ats. Run them using Karma, like so:

karma start

Karma opens a browser window for running tests. To see the actual test output (and errors), look for the log in the terminal window where you issued the karma start command.

What are all the pieces involved?

Transpiles AtScript code into regular ES5 (today's JavaScript) so that it can be run in a current browser.

Traceur is configured to transpile AtScript modules into AMD syntax and we use RequireJS to load the code in the browser. This is just temporary until we improve the ES Module Loader polyfill (more details).

Assert library

When typeAssertions: true option is used, Traceur generates run-time type assertions such as assert.type(x, Object). The assert library does the actual run-time check. Of course, you can use your own assert library.

The idea with type assertions is that you only use them during the development/testing and when deploying, you use typeAssertions: false.

Test runner that runs the tests in specified browsers, every time that you change a file.

Task runner to make defining and running the tasks simpler.

atscript-playground's People

Contributors

igorminar avatar naomiblack avatar ocombe avatar vojtajina avatar

Stargazers

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

Watchers

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

atscript-playground's Issues

gulp build error

Hi Vojta,

I'm seeing an error after cloning, npm install and running gulp build:

Setup:
node v0.10.33
npm 1.4.28
OSX Yosemite

I also tried with node v0.11.14 and npm 2.0.0 but am seeing the same error:

 $ gulp build                                                                                                                                                                                                                                                        [18:07:04]
[18:07:09] Using gulpfile ~/code/atscript-playground/gulpfile.js
[18:07:09] Starting 'build'...
[18:07:09] Finished 'build' after 10 ms

events.js:85
      throw er; // Unhandled 'error' event
            ^
TypeError: Cannot read property 'length' of undefined
    at DestroyableTransform._transform (/Users/mikewilcox/code/atscript-playground/node_modules/gulp-traceur/index.js:44:18)
    at DestroyableTransform.Transform._read (/Users/mikewilcox/code/atscript-playground/node_modules/gulp-traceur/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write (/Users/mikewilcox/code/atscript-playground/node_modules/gulp-traceur/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:172:12)
    at doWrite (/Users/mikewilcox/code/atscript-playground/node_modules/gulp-traceur/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:237:10)
    at writeOrBuffer (/Users/mikewilcox/code/atscript-playground/node_modules/gulp-traceur/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:227:5)
    at DestroyableTransform.Writable.write (/Users/mikewilcox/code/atscript-playground/node_modules/gulp-traceur/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:194:11)
    at write (/Users/mikewilcox/code/atscript-playground/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
    at flow (/Users/mikewilcox/code/atscript-playground/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)
    at DestroyableTransform.pipeOnReadable (/Users/mikewilcox/code/atscript-playground/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:664:5)
    at DestroyableTransform.emit (events.js:104:17)
FAIL

Thanks,
Mike

What is the syntax for default param values?

Hi,

according to Misko's keynote slides from ng-europe, Atscript is a superset of ES6. So what would be valid syntax for default values of a parameter?

Something like this(?):

sum(a: number = 0, b: number = 0): number {
  ...
}

Sorry if this is not the right place for asking such questions.

Hosted playground

Would be great to have ability to play with AtScript in browser without downloading/installing/building anything.

This is available for TypeScript, JSX, CoffeeScript, why not to create one for AtScript?

No support for field annotations

Tried very simple example:

class Point {
  x:int;
  y:int;
}

And it doesn't seem to work. Throws:

Error:
main.ats:2:4: Unexpected token :
main.ats:2:8: Unexpected token ;
main.ats:3:3: Unexpected token y
main.ats:3:4: Unexpected token :
main.ats:3:5: Semi-colon expected
main.ats:4:2: Unexpected token End of File

npm install error

Seeing this when trying npm install.

npm ERR! Error: No compatible version found: assert@'angular/assert#dist'
npm ERR! Valid install targets:
npm ERR! ["0.4.9","1.0.0","1.0.1","1.0.2","1.0.3","1.1.0","1.1.1","1.1.2"]
npm ERR!     at installTargetsError (/usr/local/lib/node_modules/npm/lib/cache.js:719:10)
npm ERR!     at /usr/local/lib/node_modules/npm/lib/cache.js:638:10
npm ERR!     at saved (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:142:7)
npm ERR!     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:133:7
npm ERR!     at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

Anyone else?

No support for TypeScript interfaces

In some presentations @mhevery insisted on the fact atScript is just a layer above ES6 and TypeScript.
But it seems that traceur is not able to parse TypeScript "interface" and "implements" tokens.
I'm aware that because of the duck typing in ES5 we dont need interfaces. But it is still usefull in development to assert we are using the code correctly.

Is it a problem with atscript-playground configuration file ?
Is it an issue of the traceur-compiler project ?
Or is it because interfaces will not be supported in atScript ?

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.