[nodejs][moe] Moescript language

139 views
Skip to first unread message

Belleve Invis

unread,
Apr 26, 2012, 8:26:20 AM4/26/12
to nod...@googlegroups.com
I've made it for years. Mostly inspired by Python and Haskell.

Doc:

Belleve Invis

unread,
Apr 26, 2012, 8:27:40 AM4/26/12
to nod...@googlegroups.com
Code Example

def async randPrintNums(n):
    def tasks = []
    for(var i in 0..n)
        tasks.push async :>
            wait sleep (100 * Math.random())
            trace index
        where index = i
    wait join tasks

randPrintNums 100

在 2012年4月26日星期四UTC+8下午8时26分20秒,Belleve Invis写道:

Oliver Leics

unread,
Apr 26, 2012, 8:32:50 AM4/26/12
to nod...@googlegroups.com
On Thu, Apr 26, 2012 at 2:27 PM, Belleve Invis <typeo...@gmail.com> wrote:
> Code Example
>
> def async randPrintNums(n):
> def tasks = []
> for(var i in 0..n)
> tasks.push async :>
> wait sleep (100 * Math.random())
> trace index
> where index = i
> wait join tasks
>
> randPrintNums 100

What is the resulting JavaScript?

Belleve Invis

unread,
Apr 26, 2012, 8:34:33 AM4/26/12
to nod...@googlegroups.com, oliver...@gmail.com
Functions using wait, ! and <- are specially compiled. 
  1. function F1$_(){
  2. var randPrintNums$;
  3. randPrintNums$ = async$({build:function(SCHEMATA$_){return function(n$){
  4. var T1$_, T8$_, T9$_;
  5. var i$, tasks$;
  6. function block_T2(T2$_){
  7. tasks$ = [];
  8. for(((i$ = 0), (T1$_ = n$)); i$ < T1$_; (i$ = i$ + 1)){
  9. (function F3$_(){
  10. var index$;
  11. index$ = i$;
  12. return tasks$.push(async$({build:function(SCHEMATA$_){return function(){
  13. var T4$_, T5$_;
  14. function block_T3(T3$_){
  15. T4$_ = (sleep$);
  16. T5$_ = ((100 * Math$.random()));
  17. return SCHEMATA$_.yield(T4$_(T5$_,block_T6));
  18. };
  19. function block_T6(T6$_){
  20. T6$_;
  21. trace$(index$);
  22. return SCHEMATA$_["return"]();
  23. };
  24. return block_T3;
  25. }}}));
  26. }());
  27. };
  28. T8$_ = (join$);
  29. T9$_ = (tasks$);
  30. return SCHEMATA$_.yield(T8$_(T9$_,block_Ta));
  31. };
  32. function block_Ta(Ta$_){
  33. Ta$_;
  34. return SCHEMATA$_["return"]();
  35. };
  36. return block_T2;
  37. }}});
  38. randPrintNums$(100);
  39. }

在 2012年4月26日星期四UTC+8下午8时32分50秒,Oliver Leics写道:

Brandon Benvie

unread,
Apr 26, 2012, 8:39:33 AM4/26/12
to nod...@googlegroups.com, oliver...@gmail.com
Moescript! Glad to see you finally putting this up for review.

Belleve Invis

unread,
Apr 26, 2012, 8:40:40 AM4/26/12
to nod...@googlegroups.com, oliver...@gmail.com
Thanks. This young thing needs ISSUES!

在 2012年4月26日星期四UTC+8下午8时39分33秒,Brandon Benvie写道:

Axel Kittenberger

unread,
Apr 26, 2012, 8:50:31 AM4/26/12
to nod...@googlegroups.com
Awesome!

I've been longing for a functional programming language that compiles
to Javascript!

At http://be5invis.github.com/moescript/ the english is hard for me to
understand. This way its twice as difficult to delve into a new
design.

What does @foobar mean?

"== and === has the same meaning in Moe". Please not, just make *one*
valid way, instead of unnecessarily creating ambitiousness.

It would be nice instead of mathematical demos to have real-life
minimal programs to make it look sweet. Like a http server written in
moescript with the node.js runtime.

BTW: Has the name to do with Moe Szyslak?
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

Belleve Invis

unread,
Apr 26, 2012, 8:56:41 AM4/26/12
to nod...@googlegroups.com
English is not my native language. Sorry. (我母语汉语)

@foobar === this.foobar

For capacity. (Originally there is only ==, And I always write ===)

Examples will be here soon.

在 2012年4月26日星期四UTC+8下午8时50分31秒,Axel Kittenberger写道:

Brandon Benvie

unread,
Apr 26, 2012, 8:59:03 AM4/26/12
to nod...@googlegroups.com
I've talked to Invis a bit over the last few months, and there is a significant language barrier. But he does speak enough to be able to interpret his meaning, with some effort. He's quite intelligent, very much driven, and apparently language design is his thing. =D

Belleve Invis

unread,
Apr 26, 2012, 9:08:25 AM4/26/12
to nod...@googlegroups.com
I am chemistry major actually in the university. And I hate things designed "organic-synthesis-ish", like CSS in 2007.
I think there should be no exceptional situations in anything I designed.

在 2012年4月26日星期四UTC+8下午8时59分03秒,Brandon Benvie写道:

Nuno Job

unread,
Apr 26, 2012, 9:23:58 AM4/26/12
to nod...@googlegroups.com
I can't say I see the ressemblance with Haskell at all. At least not
in your code example which looked rubyish to me, def. not functional.

Roy (http://roy.brianmckenna.org/) looks much more like haskell imho.

nuno

Belleve Invis

unread,
Apr 26, 2012, 9:31:17 AM4/26/12
to nod...@googlegroups.com
I don't want made Moe "that" haskellish. Roy (and of cource, haskell) is pure and perfect, and so far away from daily development. 

在 2012年4月26日星期四UTC+8下午9时23分58秒,Nuno Job写道:
> nodejs+unsubscribe@googlegroups.com

Brandon Benvie

unread,
Apr 26, 2012, 9:35:49 AM4/26/12
to nod...@googlegroups.com
Whatever the opinions of Moe, it seems amiss to me that someone who has spent the time to design any programming language should say they're "day job" is chemistry. Not to dismiss chemistry, but it's clear you have a passion and knowledge set that has no involvement with chemistry.

Dan North

unread,
Apr 26, 2012, 10:13:05 AM4/26/12
to nod...@googlegroups.com
On 26 April 2012 13:50, Axel Kittenberger <axk...@gmail.com> wrote:
Awesome!

I've been longing for a functional programming language that compiles
to Javascript!

Have you looked at ClojureScript?

I'm not necessarily advocating anything that compiles to JavaScript - it has some reasonably nice functional affordances itself, especially combined with libraries like underscore - but I can see why you might want one.

And Clojure fits in my head better than Haskell, which has sharp edges and makes my nose bleed.

Cheers,
Dan

JeanHuguesRobert

unread,
Apr 26, 2012, 10:17:41 AM4/26/12
to nod...@googlegroups.com
I like the concise syntax for lambda, including f{stuff}. Maybe f(a,b){stuff} could behave like Ruby's?

Also: {|x| x * 3} could be { it * 3 } where "it" stands for the single parameter of the lambda.

Jann Horn

unread,
Apr 26, 2012, 1:22:03 PM4/26/12
to nod...@googlegroups.com
On Thu, Apr 26, 2012 at 05:34:33AM -0700, Belleve Invis wrote:
> Functions using *wait*, *!* and *<-* are specially compiled.
>
> 1. function F1$_(){
> 2. var randPrintNums$;
> 3. randPrintNums$ = async$({build:function(SCHEMATA$_){return
> function(n$){
> 4. var T1$_, T8$_, T9$_;
> 5. var i$, tasks$;
> 6. function block_T2(T2$_){
> 7. tasks$ = [];
> 8. for(((i$ = 0), (T1$_ = n$)); i$ < T1$_; (i$ = i$ + 1)){
> 9. (function F3$_(){
> 10. var index$;
> 11. index$ = i$;
> 12. return tasks$.push(async$({build:function(SCHEMATA$_){return
> function(){
> 13. var T4$_, T5$_;
> 14. function block_T3(T3$_){
> 15. T4$_ = (sleep$);
> 16. T5$_ = ((100 * Math$.random()));
> 17. return SCHEMATA$_.yield(T4$_(T5$_,block_T6));
> 18. };
> 19. function block_T6(T6$_){
> 20. T6$_;
> 21. trace$(index$);
> 22. return SCHEMATA$_["return"]();
> 23. };
> 24. return block_T3;
> 25. }}}));
> 26. }());
> 27. };
> 28. T8$_ = (join$);
> 29. T9$_ = (tasks$);
> 30. return SCHEMATA$_.yield(T8$_(T9$_,block_Ta));
> 31. };
> 32. function block_Ta(Ta$_){
> 33. Ta$_;
> 34. return SCHEMATA$_["return"]();
> 35. };
> 36. return block_T2;
> 37. }}});
> 38. randPrintNums$(100);
> 39. }
>
>
> 在 2012年4月26日星期四UTC+8下午8时32分50秒,Oliver Leics写道:
> >
> > On Thu, Apr 26, 2012 at 2:27 PM, Belleve Invis <typeo...@gmail.com>
> > wrote:
> > > Code Example
> > >
> > > def async randPrintNums(n):
> > > def tasks = []
> > > for(var i in 0..n)
> > > tasks.push async :>
> > > wait sleep (100 * Math.random())
> > > trace index
> > > where index = i
> > > wait join tasks
> > >
> > > randPrintNums 100

That looks like it's going to be pretty slow... is that an issue or isn't it as bad as it looks?

Belleve Invis

unread,
Apr 27, 2012, 1:06:28 AM4/27/12
to nod...@googlegroups.com
You can use #0 for the first argument. `{|x| x * 3}` could be `{ #0 * 3 }`, but it is slower than `{|x| x * 3}` due to `arguments` in moe is a REAL array.

在 2012年4月26日星期四UTC+8下午10时17分41秒,JeanHuguesRobert写道:

Belleve Invis

unread,
Apr 27, 2012, 1:08:14 AM4/27/12
to nod...@googlegroups.com
Only code blocks using "wait", "!" and "<-" (called Monadic Primitive) is compiled into such a complicated and "slow" form.

在 2012年4月27日星期五UTC+8上午1时22分03秒,Jann Horn写道:

Belleve Invis

unread,
Apr 27, 2012, 9:16:49 AM4/27/12
to nod...@googlegroups.com
You can use #0 for the first argument. `{|x| x * 3}` could be `{ #0 * 3 }`, but it is slower than `{|x| x * 3}` due to `arguments` in moe is a REAL array.

在 2012年4月26日星期四UTC+8下午10时17分41秒,JeanHuguesRobert写道:
I like the concise syntax for lambda, including f{stuff}. Maybe f(a,b){stuff} could behave like Ruby's?

Morteza Milani

unread,
Apr 28, 2012, 7:24:47 AM4/28/12
to nod...@googlegroups.com
Hi,

It is aimed to deal with common troubles in JavaScript development. Moe has neatly crafted grammar so that most JavaScript development will be simplified.

What are those problems you tried to address with Moe language?:) It does not motivate me to use it before knowing what it is trying to do.

akira

unread,
Apr 28, 2012, 8:01:44 AM4/28/12
to nodejs
This looks interesting, I am a Node.js comming from Python, It would
be nice if I could code in something similar :)

On Apr 28, 1:24 pm, Morteza Milani <fireboy.m...@gmail.com> wrote:
> Hi,
>
> *It is aimed to deal with common troubles in JavaScript development. Moe
> has neatly crafted grammar so that most JavaScript development will be
> simplified.*

Belleve Invis

unread,
May 20, 2012, 9:37:53 AM5/20/12
to nod...@googlegroups.com
The similarity between Moe and Scala/Haskell is stronger than Moe and Python.

在 2012年4月28日星期六UTC+8下午8时01分44秒,akira写道:
Reply all
Reply to author
Forward
0 new messages