CoffeeScript and future haXe syntax

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

CoffeeScript and future haXe syntax

David Arno

Being a Flash refugee that is looking to move away from Flash to other technologies after Adobe’s recent decisions over its long term future, I have been learning a number of new languages lately, not just haXe. Whilst I like a lot of the idioms of haXe, I’ve really been taken by the succinctness of compact languages like CoffeeScript.

 

I was wondering therefore if the idea of supporting a short-form syntax for haXe had been suggested before and/or whether there was any support for such an idea? I’m thinking in terms of the way Dart supports long and short syntax forms for example. Or are the established haXe fans happy with things as they are and so do not need a troublesome newbie like me trying to propose changes before I even know what I’m doing? :)

 

Regards,

David Arno.

 


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: CoffeeScript and future haXe syntax

MarcWeber
Excerpts from David Arno's message of Thu Dec 08 11:07:09 UTC 2011:
> Being a Flash refugee that is looking to move away from Flash to other
> technologies after Adobe's recent decisions over its long term future, I
> have been learning a number of new languages lately, not just haXe. Whilst I
> like a lot of the idioms of haXe, I've really been taken by the succinctness
> of compact languages like CoffeeScript.
Isn't CoffeeScript just sugar for JS? don't know whether should count it
as language.

> I was wondering therefore if the idea of supporting a short-form syntax for
> haXe [..]
You must be more specific. Yes. Search old mailinglist for "lambda",
monads, ... have been proposed. I even wrote a patch for short lambdas
allowing you to do
list.map($1 + 2) instead of list.map(function(x) return x+2;);

N.C doesn't like it for reasons I don't understand. I'd prefer Ruby like
syntax:

def
catch
end

instead of
function (){
  try {
  } catch {
  }
}

I don't have time to maintain my own HaXe branch. I'd like to spend more
time on other languages such as urweb before spending that much time on
HaXe compiler internals.

Yes - and of course we could be missing Scala like short class
definitions:

  class (val x:Int, val y:Int){
  }

You can partially emulate this by generating types using macro language:
http://haxe.org/manual/macros/build

and such. Whatelse are you thinking about when talking about a "shorter
syntax"?

Marc Weber

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

RE: CoffeeScript and future haXe syntax

David Arno
Well taking the example at http://haxe.org/byexample/math/flash9/sine, I'm thinking of a syntax like:

import flash.display.MovieClip
import flash.display.Sprite
import haxe.Timer
import flash.Lib

class MathSinbyexample
    @RED: Int = 0xFF0000
    _stage:MovieClip
    _view_mc:Sprite
    _wide:Int
    _step:Int
    _amplitude:Int
    _timeStep:Int
    _timer:Timer
    _x:Int
    _y:Float
    _dAngle:Int
    _radians:Float
    _angleChange:Float
   
    new _wide, _step, _amplitude, _timeStep, _dAngle ->
        _stage = Lib.current
        _radians = 0
        _angleChange = _dAngle * Math.PI/360
        _init
   
    _init ->
        _createView
        _view_mc.graphics.lineStyle 0, RED, 1
        _timer = new Timer _timeStep
            .run = _drawSine
   
    _createView ->
        _stage.addChild _view_mc = new Sprite
            .x = 10
            .y = 20

    _drawSine ->
        _timer.stop if (_x += _step) > _wide
        _radians += _angleChange
        _y = _amplitude * Math.sin _radians
        _view_mc.graphics.lineTo _x, _y
   
    @main ->
        new MathSinbyexample
            .wide = 760
            .step = 3
            .amplitude = 200
            .timeStep = 30
            .dAngle = 5

So it borrows the idea of whitespace being significant from Python, it allows creation and initialisation of new classes to be handled via indented lines starting with ., _ denotes private, @ denotes static, nothing in front of an identifier means its public, listing a private var as a parameter to the constructor means that value is automatically written to the variable etc.

Obviously this is just off the top of my head stuff and I'm not proposing haXe change, I'm just curious as to whether people would be interested in having some sort of alternative syntax or not.

Regards,
David.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Marc Weber
Sent: 08 December 2011 11:30
To: haxe
Subject: Re: [haXe] CoffeeScript and future haXe syntax

Excerpts from David Arno's message of Thu Dec 08 11:07:09 UTC 2011:
> Being a Flash refugee that is looking to move away from Flash to other
> technologies after Adobe's recent decisions over its long term future,
> I have been learning a number of new languages lately, not just haXe.
> Whilst I like a lot of the idioms of haXe, I've really been taken by
> the succinctness of compact languages like CoffeeScript.
Isn't CoffeeScript just sugar for JS? don't know whether should count it as language.

> I was wondering therefore if the idea of supporting a short-form
> syntax for haXe [..]
You must be more specific. Yes. Search old mailinglist for "lambda", monads, ... have been proposed. I even wrote a patch for short lambdas allowing you to do
list.map($1 + 2) instead of list.map(function(x) return x+2;);

N.C doesn't like it for reasons I don't understand. I'd prefer Ruby like
syntax:

def
catch
end

instead of
function (){
  try {
  } catch {
  }
}

I don't have time to maintain my own HaXe branch. I'd like to spend more time on other languages such as urweb before spending that much time on HaXe compiler internals.

Yes - and of course we could be missing Scala like short class
definitions:

  class (val x:Int, val y:Int){
  }

You can partially emulate this by generating types using macro language:
http://haxe.org/manual/macros/build

and such. Whatelse are you thinking about when talking about a "shorter syntax"?

Marc Weber

--
haXe - an open source web programming language http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: CoffeeScript and future haXe syntax

Baluta Cristian
This is not too far of making us learn a new language.
I also like a lot of strange things but i prefer not to mix them.

On Thu, Dec 8, 2011 at 12:34 PM, David Arno <[hidden email]> wrote:
Well taking the example at http://haxe.org/byexample/math/flash9/sine, I'm thinking of a syntax like:

import flash.display.MovieClip
import flash.display.Sprite
import haxe.Timer
import flash.Lib

class MathSinbyexample
   @RED: Int = 0xFF0000
   _stage:MovieClip
   _view_mc:Sprite
   _wide:Int
   _step:Int
   _amplitude:Int
   _timeStep:Int
   _timer:Timer
   _x:Int
   _y:Float
   _dAngle:Int
   _radians:Float
   _angleChange:Float

   new _wide, _step, _amplitude, _timeStep, _dAngle ->
       _stage = Lib.current
       _radians = 0
       _angleChange = _dAngle * Math.PI/360
       _init

   _init ->
       _createView
       _view_mc.graphics.lineStyle 0, RED, 1
       _timer = new Timer _timeStep
           .run = _drawSine

   _createView ->
       _stage.addChild _view_mc = new Sprite
           .x = 10
           .y = 20

   _drawSine ->
       _timer.stop if (_x += _step) > _wide
       _radians += _angleChange
       _y = _amplitude * Math.sin _radians
       _view_mc.graphics.lineTo _x, _y

   @main ->
       new MathSinbyexample
           .wide = 760
           .step = 3
           .amplitude = 200
           .timeStep = 30
           .dAngle = 5

So it borrows the idea of whitespace being significant from Python, it allows creation and initialisation of new classes to be handled via indented lines starting with ., _ denotes private, @ denotes static, nothing in front of an identifier means its public, listing a private var as a parameter to the constructor means that value is automatically written to the variable etc.

Obviously this is just off the top of my head stuff and I'm not proposing haXe change, I'm just curious as to whether people would be interested in having some sort of alternative syntax or not.

Regards,
David.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Marc Weber
Sent: 08 December 2011 11:30
To: haxe
Subject: Re: [haXe] CoffeeScript and future haXe syntax

Excerpts from David Arno's message of Thu Dec 08 11:07:09 UTC 2011:
> Being a Flash refugee that is looking to move away from Flash to other
> technologies after Adobe's recent decisions over its long term future,
> I have been learning a number of new languages lately, not just haXe.
> Whilst I like a lot of the idioms of haXe, I've really been taken by
> the succinctness of compact languages like CoffeeScript.
Isn't CoffeeScript just sugar for JS? don't know whether should count it as language.

> I was wondering therefore if the idea of supporting a short-form
> syntax for haXe [..]
You must be more specific. Yes. Search old mailinglist for "lambda", monads, ... have been proposed. I even wrote a patch for short lambdas allowing you to do
list.map($1 + 2) instead of list.map(function(x) return x+2;);

N.C doesn't like it for reasons I don't understand. I'd prefer Ruby like
syntax:

def
catch
end

instead of
function (){
 try {
 } catch {
 }
}

I don't have time to maintain my own HaXe branch. I'd like to spend more time on other languages such as urweb before spending that much time on HaXe compiler internals.

Yes - and of course we could be missing Scala like short class
definitions:

 class (val x:Int, val y:Int){
 }

You can partially emulate this by generating types using macro language:
http://haxe.org/manual/macros/build

and such. Whatelse are you thinking about when talking about a "shorter syntax"?

Marc Weber

--
haXe - an open source web programming language http://haxe.org


--
haXe - an open source web programming language
http://haxe.org



--
Băluță Cristian
http://ralcr.com
http://imagin.ro

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: CoffeeScript and future haXe syntax

Tarwin Stroh-Spijer
Wow, why would you go form AS3 to that ? It's like a messier version of Obj-C :D Actually, I understand why some of it might be nice shorthand, but if you've got a good IDE, you don't end up typing much in haXe anyway with all the completion ...


Tarwin Stroh-Spijer
_______________________

Touch My Pixel
http://www.touchmypixel.com/
phone: +61 3 8060 5321
_______________________


On Thu, Dec 8, 2011 at 4:55 AM, Baluta Cristian <[hidden email]> wrote:
This is not too far of making us learn a new language.
I also like a lot of strange things but i prefer not to mix them.


On Thu, Dec 8, 2011 at 12:34 PM, David Arno <[hidden email]> wrote:
Well taking the example at http://haxe.org/byexample/math/flash9/sine, I'm thinking of a syntax like:

import flash.display.MovieClip
import flash.display.Sprite
import haxe.Timer
import flash.Lib

class MathSinbyexample
   @RED: Int = 0xFF0000
   _stage:MovieClip
   _view_mc:Sprite
   _wide:Int
   _step:Int
   _amplitude:Int
   _timeStep:Int
   _timer:Timer
   _x:Int
   _y:Float
   _dAngle:Int
   _radians:Float
   _angleChange:Float

   new _wide, _step, _amplitude, _timeStep, _dAngle ->
       _stage = Lib.current
       _radians = 0
       _angleChange = _dAngle * Math.PI/360
       _init

   _init ->
       _createView
       _view_mc.graphics.lineStyle 0, RED, 1
       _timer = new Timer _timeStep
           .run = _drawSine

   _createView ->
       _stage.addChild _view_mc = new Sprite
           .x = 10
           .y = 20

   _drawSine ->
       _timer.stop if (_x += _step) > _wide
       _radians += _angleChange
       _y = _amplitude * Math.sin _radians
       _view_mc.graphics.lineTo _x, _y

   @main ->
       new MathSinbyexample
           .wide = 760
           .step = 3
           .amplitude = 200
           .timeStep = 30
           .dAngle = 5

So it borrows the idea of whitespace being significant from Python, it allows creation and initialisation of new classes to be handled via indented lines starting with ., _ denotes private, @ denotes static, nothing in front of an identifier means its public, listing a private var as a parameter to the constructor means that value is automatically written to the variable etc.

Obviously this is just off the top of my head stuff and I'm not proposing haXe change, I'm just curious as to whether people would be interested in having some sort of alternative syntax or not.

Regards,
David.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Marc Weber
Sent: 08 December 2011 11:30
To: haxe
Subject: Re: [haXe] CoffeeScript and future haXe syntax

Excerpts from David Arno's message of Thu Dec 08 11:07:09 UTC 2011:
> Being a Flash refugee that is looking to move away from Flash to other
> technologies after Adobe's recent decisions over its long term future,
> I have been learning a number of new languages lately, not just haXe.
> Whilst I like a lot of the idioms of haXe, I've really been taken by
> the succinctness of compact languages like CoffeeScript.
Isn't CoffeeScript just sugar for JS? don't know whether should count it as language.

> I was wondering therefore if the idea of supporting a short-form
> syntax for haXe [..]
You must be more specific. Yes. Search old mailinglist for "lambda", monads, ... have been proposed. I even wrote a patch for short lambdas allowing you to do
list.map($1 + 2) instead of list.map(function(x) return x+2;);

N.C doesn't like it for reasons I don't understand. I'd prefer Ruby like
syntax:

def
catch
end

instead of
function (){
 try {
 } catch {
 }
}

I don't have time to maintain my own HaXe branch. I'd like to spend more time on other languages such as urweb before spending that much time on HaXe compiler internals.

Yes - and of course we could be missing Scala like short class
definitions:

 class (val x:Int, val y:Int){
 }

You can partially emulate this by generating types using macro language:
http://haxe.org/manual/macros/build

and such. Whatelse are you thinking about when talking about a "shorter syntax"?

Marc Weber

--
haXe - an open source web programming language http://haxe.org


--
haXe - an open source web programming language
http://haxe.org



--
Băluță Cristian
http://ralcr.com
http://imagin.ro

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org