sebastien / sugar Goto Github PK
View Code? Open in Web Editor NEWMakes JavaScript development sweeter !
Makes JavaScript development sweeter !
== Sugar == The secret sauce to make JavaScript a lot sweeter ! Sugar is a _new programming language_ designed to replace JavaScript for client-side (and server-side) web development. Sugar is inspired by languages such as Python, Smalltalk, Pascal, Eiffel and Lisp. Sugar can compile to JavaScript, ActionScript and Python. For the impatient, here is an example of Sugar's syntax: > @module helloworld > > @class HelloWorld > | This is a docstring for my hello world > > @property message > > @constructor > message = "Hello, World !" > @end > > @method say > alert ( message ) > @end > > @end Design goals ============ Sugar was designed with *software engineering in mind*, which means the core values are _readability_, _maintainability_ and _expressivity_. While Sugar does no forces you to use objects everywhere, it encourages you to use classes (yes, sugar also has class-based inheritance) and focus on your program architecture. Sugar design goals include: - Can be learned in a couple of days by average developers - Abstract from common JavaScript pitfalls - Minimize the differences in the code produced by different coders - Capture more information than other languages (be explicit) Sugar owes the following languages in different areas: - Python, for the simplicity and cleanliness of the syntax - Eiffel, for the design by contract support - Smalltalk, for blocks - Io, for the message sending syntax - ML, for the pattern-matching syntax - Lisp, for the map/reduce/filter support Installing sugar ================ Sugar is implemented in Python (2.4+) and uses the [DParser](http://dparser.sf.net), and relies on the [LambdaFactory](http://www.github.com/sebastien/lambdafactory) library. If you don't already have _dparser_, you should do the following: > cd Dependencies ; bash make-dparser.sh and then copy the 'Dependencies/dparser' directory to somewhere in your 'PYTHONPATH' or do > export PYTHONPATH=`pwd`/Dependencies/dparser:${PYTHONPATH} We're slowly getting away from DParser, as it has problems with 64 bits, and is not flexible enough for the future of Sugar. In the meantime, please bear with it ;) Once you have DParser and LambdaFactory installed, simply type: > python setup.py install And you'll have sugar install, and will have the 'sugar' command available in your path. Alternatively, if you'd like to hack on Sugar, you could do: > export PYTHONPATH=`pwd`/Sources > alias sugar=`pwd`/Sources/sugar/main (and you could later include these in your '~/.bash_profile', making sure to replace '`pwd`' by the actual Sugar directory). Using sugar =========== Compile a Sugar file to JavaScript > sugar -c hello.sjs Compile a Sugar file to Python > sugar -clpy hello.sjs Compile a Sugar file to ActionScript > sugar -clas hello.sjs Compile a Sugar file to a directory > sugar -cl -o. hello.sjs Add a library (LIBRARY) path to search for Sugar modules > sugar -cl -LLIBRARY hello.sjs Troubleshooting =============== I get the following error: > fail: unable to open `/usr/local/bin/d_parser_mach_gen.g` for write This is because Dparser is trying to write a tempoary file along with the executable. Move the 'sugar' command to a directory where you have write permission (like '~/bin'). We know it's annoying, and we're working on a new version without dparser. # EOF - vim: syn=kiwi ts=2 sw=2 et
it seems that a code like this:
var l = []
if True
for i in l
console log (i)
end
if True -> console log "coucou"
end
produce the following code :
var l=[];
if ( true )
{
extend.iterate(l, function(i){
console.log(i)
}, self)
}
else if ( true )
{
console.log('coucou')
}
so when there is a for loop, the following inline condition doesn't work well
for exemple:
var x, y = fctn (z)
gives us in javascript:
var x=self.fctn(z)[0];
var y=self.fctn(z)[1];
but it should be:
var tmp=self.fctn(z);
var x=tmp[0];
var y=tmp[1];
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.