It’s just data

DSL for JavaScript

W

Jeremy Ashkenas: “work towards building a language that is to ES6 as CoffeeScript is to ES5”… close, but—do it for [ES6+HTML+CSS], and you’ll win ;)

It occurs to me that there is a shortcut available.  Let a library like React replace [ES6+HTML+CSS].  Then build a DSL for that library.

JavaScript isn’t exactly known for its ability to build DSLs.  Ruby, however, is.  And has an excellent parser library.  By transforming the AST, I can convert calendar.js.rb into calendar.js.

In the process, I start by replacing JSX with a library which was inspired by Builder, Markaby, and Tagz.  These libraries, in turn were presumably inspired by earlier works like Perl’s CGI.

But there is more.  JSX can’t directly express iteration.  Look at CommentList from the React tutorial.  Instead you build up a list, and then subsequently wrap that list.  For nested lists, it appears worthwhile to split out separate components.  There is nothing wrong with doing that, but I will suggest that the primary reason to split out a component shouldn’t be to pander to the limitations of the programming language syntax.

In Ruby you can directly express iteration.  So where a comment box in the tutorial takes four classes, an entire calendar month can be expressed in one.

And there is even more.  Functions in JavaScript are the swiss army knives of programming language features.  The can be used to express classes, blocks, lambdas, procs.  But this flexiblity comes at a price.  Ruby2JS can detect when idioms like var self=this are needed and automatically apply them.

The net is that I can write smaller, more understandable code.  And in the process focus more on the problem I’m trying to solve.

Like with CoffeeScript, "It’s just JavaScript". The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime.  You can use any existing JavaScript library seamlessly from Ruby2JS (and vice-versa). The compiled output is readable and pretty-printed, will work in every JavaScript runtime, and tends to run as fast or faster than the equivalent handwritten JavaScript.

Now I don’t expect to have the success or impact that CoffeeScript has had.  But I can say that I’m having fun.  And in the process, I’m seeing the benefits with applications I write.


If you are going for most excellent contents like myself,
just pay a visit this web site every day because it presents quality contents, thanks

Posted by uhaul discount code at

This article is very useful and increasingly add my insights, thanks for the information and tips
The post is explained clearly so that we are able to understand it clearly.
whatsapp plus

Posted by whatsapp plus at

thanks for sharing this amazing post.if you are looking for some free movie apps where you could download movies for free then you must check out the cartoon hd app for pc laptop.

Posted by cartoon hd apk at

Calorie Counter App

Posted by Offers at Flipkart Online Shopping at

Sudden Weight Gain

Flipkart Diwali Sale

Amazon Online Shopping

Posted by Deal Of The Day at

ITS GOOD THAT YOU SHARED THIS INFO WITH US. STILL M DOING ADVANCED JAVA, SO YOUR INFO WILL HELP ME.

Posted by routersupport at

Java is the basic language for any software language or for any software developer. The basics of Java should be cleared to every software developer.
The information posted here is of very much use, it is very helpful.
Thanks for sharing this important article.

Posted by Dell Tech Support at

This is one zone where governments are demonstrating a visually impaired eye towards the breeze vitality. This can turn out to be great option for customary power and has many preferences in utilizing this vitality which is absolutely contamination free and no characteristic assets are squandered. It is great that now these tasks are getting money related help this will expand the utilization of wind vitality.

Posted by Write My Case Study at

This is one area where governments are showing a blind eye towards the wind energy. This can become good alternative for traditional electricity and has many advantages in using this energy which is purely pollution free and no natural resources are wasted. It is good that now these projects are getting financial assistance this will definitely help to increase the use of wind energy.

Posted by Research Paper Town at

a debt of gratitude is in order for sharing this astonishing post.if you are searching for some free film applications where you could download motion pictures with the expectation of complimentary then you should look at the toon hd application for pc portable PC.

Posted by Buy Essay at

We assure you that all your difficulties will be addressed in the most appropriate manner by the representatives of the Outlook Customer Support. Outlook Customer Care

Posted by outlook support at

Hey, this is very nice and informative article and please keep post amazing article like this if you have any query related to this then you can visit us

Posted by Lenovo Support at

It is a very interesting blog.You have so much knowledge about this issue and so much passion.

Posted by Canon Support Number at

Java script is a very useful programing for the developer. And if any need support for Gmail then contact us
Gmail Support Number

Posted by Gmail Support at

Add your comment