Code Monkey home page Code Monkey logo

nice.js's Introduction

Nice.js extends JS syntax

You create less code. Code looks better

I worked last years with python language. And when I tried to switch to node.js and create both backed and frontend on JavaScript only - I found that JS lacks some cool features from other part of the World.

In this project I implement compiler from Nice.js syntax to plain JavaScript (now on python, but in near future - on JS). I believe that you are using Underscore.js to simplify your coding life. I also use it, and in resulting code you will see _() syntax.

Resulting code is readable like your original code on Nice.js. We transform only short forms of code to full form of plain JS.

And the greatest part of this project that you can use classes like in other OOP languages.

Current implementation

Now you can use small JavaScript file that extends your JavaScript syntax with new useful tools. for example, you can get last element of array in this way arr.last() or first element with arr.first(). Also you can get shifted element from start or end of array in this way arr.first(2) and arr.last(1).

This library is very easy and you can find source code in file nice.js

To use this script just include it in your HTML page before all other script tags.

<script src="https://raw.githubusercontent.com/webui/nice.js/master/nice.js"></script>
<!-- use it before jQuery and your own scripts -->
<script src="/static/libs/jquery/jquery-2.1.1.min.js"></script>

Your Pull Requests are welcome!


The main problems in JavaScript code

  • ommited keyword new to create instance of class
  • ommited ; in end of line
  • omitter { and appropriate }
  • forget to use var for local variables

Syntax (discussion, not implemented yet)

You can find syntax description in folder tests.

This is part of them:

  • classes - class MyClass extends BaseClass {...}
  • conditions - if (10 not in list) or if (a == b or c and d)
  • loops - for (x, y in obj) and [user.age for user in users if user.age <= 30]
  • etc

Thank you for interest to this project. It's fun. And it's helpful. I am trying to change our development life to implement our amazing ideas faster and easier.

Feel free to contact me, add new propositions in comments to files or by creating issues. It will be happy to review your pull requests and discuss with you.

-- Anton Danilchenko

nice.js's People

Contributors

1st avatar

Stargazers

okwrtdsh avatar Sheena Artrip avatar  avatar Andy Eastwood avatar

Watchers

James Cloos avatar

Forkers

andreweastwood

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.