Code Monkey home page Code Monkey logo

sugar's Introduction

== 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

sugar's People

Contributors

sebastien avatar

Stargazers

Camilo Cunha de Azevedo avatar Sean Hagstrom avatar Seçkin Kükrer avatar Dean Oemcke avatar Max Pleaner avatar Peeyush Kushwaha avatar Angus H. avatar Anthony Fiorani avatar  avatar zspecza avatar ant cosentino avatar Zura Guerra avatar Bob TheBuilder avatar  avatar Bloo Alien avatar Jonatan Santos avatar roadlabs avatar mishrash avatar David Watson avatar Amal Khailtash avatar Timur avatar Emily Marigold Klassen avatar Souen Boniface avatar Dmitry avatar Philippe Ombredanne avatar  avatar Willie Möller avatar Xiaoli Wang avatar brandonjp avatar 延 avatar Alexandre Gravem avatar Daniel Marchant avatar Mickael Mithouard avatar Doug Holton avatar Jason Warner avatar Jim Myhrberg avatar pedro vasconcelos avatar Julien Desrosiers avatar Chris Faulkner avatar vikram bhandoh avatar  avatar Josh Perez avatar Yong Joseph Bakos avatar Felipe Coury avatar Jean-Francois Couture avatar

Watchers

 avatar roadlabs avatar James Cloos avatar  avatar  avatar

sugar's Issues

inline condition syntax error

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

optimisation in "var x, y = z" syntax

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];

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.