No subject


Tue Nov 30 21:47:11 CET 2010


are required, and which are optional, but it seems like the following
features are in coffee script but not jMacro
* no need for the var keyword, scope is intelligently taken care of.
* no need for semi-colons
* no need for parentheses around conditionals for ifg
* list comprehensions (as in python), an extremely useful feature.
* removal of brackets and commas for objects
* argument splats
* single line conditionals
* ranges
* class/super class conveniences
* 'this.' aliased to '@'
* multi-line strings
* string and regular expression variable interpolation

There are other things that might be missing/different, but I can't tell
because they aren't documented, such as:
* removal of triple-equal- double equal acts as triple equal (or is this in
just the lambda syntax?)

Another feature of JMacro as opposed to CoffeeScript is that almost

all valid JavaScript code is *also* valid JMacro. So you can take a

code-sample or snippet from the web and place it directly into your

application, refactoring it into a more functional style incrementally

and at whatever pace you want. CoffeeScript allows for "escaping" into

raw javascript, but that's in my opinion a much weaker alternative.


This is also true of coffeescript, but to a lesser extent. Function syntax
must be converted, and the var keyword removed. After that, plain javascript
should works, and there are usually many improvements that can be made
incrementally. While this provides some downside, it also provides upside-
there is one unified function syntax that is as convenient as the haskell
anonymous lamba syntax instead of 2 different function syntaxes with
different rules.

I really like what you have done with jMacro. My previous comments were
really directed to thinking about it in a different context. I think we just
need to clarify that these are different tools for different jobs.
For the goal of writing javascript instead of generating it, coffee-script
holds a lot of advantages over jMacro.
For the goal of generating javascript from haskell (which you are using it
for), jMacro seems like the perfect tool, and I will definitely look into
using it for that purpose in the Yesod framework or my Yesod applications.

Greg Weber

--0003255755c2d851e3049ac2071e
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div>Thanks for the great extra info on JMacro. I think haskellers would en=
joy hearing about it and how you use it as a blog post.</div><div><br></div=
><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-right: =
0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border=
-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1e=
x; ">

Hi! Author of JMacro here. You&#39;re right that JMacro has a few less</blo=
ckquote><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-=
right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px;=
 border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-l=
eft: 1ex; ">

features than CoffeeScript. In particular, it lacks pattern matching.</bloc=
kquote><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-r=
ight: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; =
border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-le=
ft: 1ex; ">

Outside of that, however, most CoffeeScript features are to make</blockquot=
e><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-right:=
 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; borde=
r-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1=
ex; ">

CoffeeScript more rubylike in syntax. Haskell-style anonymous lambdas</bloc=
kquote><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-r=
ight: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; =
border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-le=
ft: 1ex; ">

coupled with whitespace function application on their own, however,</blockq=
uote><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-rig=
ht: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; bo=
rder-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left=
: 1ex; ">

suffice to allow exceedingly Haskell/ML-like code. JMacro can be used</bloc=
kquote><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-r=
ight: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; =
border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-le=
ft: 1ex; ">

as a nicer syntax for JavaScript, but the big win is that it is a</blockquo=
te><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-right=
: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; bord=
er-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: =
1ex; ">

better way to *generate* JavaScript -- in particular via hygiene and a</blo=
ckquote><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-=
right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px;=
 border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-l=
eft: 1ex; ">

shared namespace with surrounding Haskell code. So bear in mind also</block=
quote><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-ri=
ght: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; b=
order-left-color: rgb(204, 204, 204); border-left-style: solid; padding-lef=
t: 1ex; ">

that JMacro syntax is infinitely-extensible in the sense that you can=A0</b=
lockquote><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margi=
n-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1p=
x; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding=
-left: 1ex; ">

not only write JavaScript combinators in JMacro, but Haskell</blockquote><b=
lockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-right: 0px=
; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-le=
ft-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; =
">

combinators which produce JMacro that can be spliced directly back</blockqu=
ote><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-righ=
t: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; bor=
der-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left:=
 1ex; ">

into a block of code. Jeff and I have, for instance, written a tiny</blockq=
uote><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-rig=
ht: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; bo=
rder-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left=
: 1ex; ">

set of infix combinators for chaining jQuery selectors.</blockquote><div><b=
r></div><div>coffee-script isn&#39;t designed to give javascript a ruby-lik=
e syntax. It is designed to add useful language level features and get rid =
of superfluous syntax, which Ruby and haskell also try to do. Maintaining a=
 certain amount of javascript compatibility makes it look more like Ruby an=
d less like Haskell. But there are definitely influences from other languag=
es. For example, it uses layout syntax instead of an &#39;end&#39; keyword =
(or brackets) in ruby. You can use groovy&#39;s existential operator.</div>

<div><br></div><div>From looking at the jmacro README I am slightly confuse=
d as to what syntaxes are required, and which are optional, but it seems li=
ke the following features are in coffee script but not jMacro</div><div>

* no need for the var keyword, scope is intelligently taken care of.=A0</di=
v><div>* no need for semi-colons</div><div>* no need for parentheses around=
 conditionals for ifg=A0</div><div>* list comprehensions (as in python), an=
 extremely useful feature.</div>

<div>* removal of brackets and commas for objects</div><div>* argument spla=
ts</div><div>* single line conditionals</div><div>* ranges</div><div>* clas=
s/super class conveniences</div><div>* &#39;this.&#39; aliased to &#39;@&#3=
9;=A0</div>

<div>* multi-line strings</div><div>* string and regular expression variabl=
e interpolation</div><div><br></div><div>There are other things that might =
be missing/different, but I can&#39;t tell because they aren&#39;t document=
ed, such as:=A0</div>

<div>* removal of triple-equal- double equal acts as triple equal (or is th=
is in just the lambda syntax?)</div><div><br></div><blockquote class=3D"gma=
il_quote" style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204=
, 204); border-left-style: solid; padding-left: 1ex; ">

Another feature of JMacro as opposed to CoffeeScript is that almost</blockq=
uote><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-rig=
ht: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; bo=
rder-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left=
: 1ex; ">

all valid JavaScript code is *also* valid JMacro. So you can take a</blockq=
uote><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-rig=
ht: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; bo=
rder-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left=
: 1ex; ">

code-sample or snippet from the web and place it directly into your</blockq=
uote><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-rig=
ht: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; bo=
rder-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left=
: 1ex; ">

application, refactoring it into a more functional style incrementally</blo=
ckquote><blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; margin-=
right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px;=
 border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-l=
eft: 1ex; ">

and at whatever pace you want. CoffeeScript allows for &quot;escaping&quot;=
 into</blockquote><blockquote class=3D"gmail_quote" style=3D"margin-top: 0p=
x; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-w=
idth: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid;=
 padding-left: 1ex; ">

raw javascript, but that&#39;s in my opinion a much weaker alternative.</bl=
ockquote><div><br></div><div><div>This is also true of coffeescript, but to=
 a lesser extent. Function syntax must be converted, and the var keyword re=
moved. After that, plain javascript should works, and there are usually man=
y improvements that can be made incrementally. While this provides some dow=
nside, it also provides upside- there is one unified function syntax that i=
s as convenient as the haskell anonymous lamba syntax instead of 2 differen=
t function syntaxes with different rules.</div>

<div><br></div><div>I really like what you have done with jMacro. My previo=
us comments were really directed to thinking about it in a different contex=
t.=A0I think we just need to clarify that these are different tools for dif=
ferent jobs.</div>

<div>For the goal of writing javascript instead of generating it, coffee-sc=
ript holds a lot of advantages over jMacro.</div><div>For the goal of gener=
ating javascript from haskell (which you are using it for), jMacro seems li=
ke the perfect tool, and I will definitely look into using it for that purp=
ose in the Yesod framework or my Yesod applications.</div>

<div><br></div><div>Greg Weber</div></div><div><br></div>

--0003255755c2d851e3049ac2071e--



More information about the web-devel mailing list