Re: [Boston.pm] perl6/pugs (ook!)

2005-03-01 Thread Ian Langworth
I like bananas and have been using the Ook programming language
and Ook# .Net framework for a large number of corporate
projects. For example, since the phone conversations of many
younger teenagers probably consists of apeish grunts, it is
entirely logical to write cell phone applications in a language
designed to be written by orangutans.

http://www.dangermouse.net/esoteric/ook.html

On 28.Feb.2005 11:12AM -0800, Ben Tilly wrote:

 Ruby is easier for Perl people to get into than Haskell.  By
 the same token, learning Ruby will expand your horizons less
 than Haskell.

-- 
Ian Langworth
Project Guerrilla
Northeastern University
College of Computer and Information Science
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] perl6/pugs (ook!)

2005-03-01 Thread Ian Langworth
I like bananas and have been using the Ook programming language
and Ook# .Net framework for a large number of corporate
projects. For example, since the phone conversations of many
younger teenagers probably consists of apeish grunts, it is
entirely logical to write cell phone applications in a language
designed to be written by orangutans.

http://www.dangermouse.net/esoteric/ook.html

On 28.Feb.2005 11:12AM -0800, Ben Tilly wrote:

 Ruby is easier for Perl people to get into than Haskell.  By
 the same token, learning Ruby will expand your horizons less
 than Haskell.

-- 
Ian Langworth
Project Guerrilla
Northeastern University
College of Computer and Information Science
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] perl6/pugs

2005-03-01 Thread Ben Tilly
On Tue, 1 Mar 2005 16:02:08 -0500, Adam Turoff [EMAIL PROTECTED] wrote:
 On Mon, Feb 28, 2005 at 03:39:30PM -0500, Gyepi SAM wrote:
  It must be: I am using LISP, after a long hiatus, and really liking it. I
  simply did not appreciate its power upon introduction six years ago.
 
 Yep.  I never fully understood closures until I used them in Perl.
 After that, Lisp and Scheme were no big deal.  [Except for the
 Y-Combinator, and ((call/cc call/cc) (call/cc call/cc)); those still
 make my brain hurt].

The Y-Combinator made my brain hurt until I figured it out.
Heavy use of continuations still make my brain hurt, and I'm
favourable to the opinion that a continuation is like a goto,
only worse.

Here's an explanation of the Y-Combinator.  It won't work in
Perl because Perl doesn't do lexical binding of input
parameters.  JavaScript does and most should know that, so
I'll do it in JavaScript.

Our goal is to be able to write a recursive function of 1
variable using only functions of 1 variables and no
assignments, defining things by name, etc.  (Why this is our
goal is another question, let's just take this as the
challenge that we're given.)  Seems impossible, huh?  As
an example, let's implement factorial.

Well step 1 is to say that we could do this easily if we
cheated a little.  Using functions of 2 variables and
assignment we can at least avoid having to use
assignment to set up the recursion.

  // Here's the function that we want to recurse.
  X = function (recurse, n) {
if (0 == n)
  return 1;
else
  return n * recurse(recurse, n - 1);
  };

  // This will get X to recurse.
  Y = function (builder, n) {
return builder(builder, n);
  };

  // Here it is in action.
  Y(
X,
5
  );

Now let's see if we can cheat less.  Well firstly we're using
assignment, but we don't need to.  We can just write X and
Y inline.

  // No assignment this time.
  function (builder, n) {
return builder(builder, n);
  }(
function (recurse, n) {
  if (0 == n)
return 1;
  else
return n * recurse(recurse, n - 1);
},
5
  );

But we're using functiions of 2 variables to get a function of 1
variable.  Can we fix that?  Well a smart guy by the name of
Haskell Curry has a neat trick, if you have good higher order
functions then you only need functions of 1 variable.  The
proof is that you can get from functions of 2 (or more in the
general case) variables to 1 variable with a purely
mechanical text transformation like this:

  // Original
  F = function (i, j) {
...
  };
  F(i,j);

  // Transformed
  F = function (i) { return function (j) {
...
  }};
  F(i)(j);

where ... remains exactly the same.  (This trick is called
currying after its inventor.  The language Haskell is also
named for Haskell Curry.  File that under useless trivial.)
Now just apply this transformation everywhere and we get
our final version.

  // The dreaded Y-combinator in action!
  function (builder) { return function (n) {
return builder(builder)(n);
  }}(
function (recurse) { return function (n) {
  if (0 == n)
return 1;
  else
return n * recurse(recurse)(n - 1);
}})(
5
  );

Feel free to try it.  alert() that return, tie it to a button, whatever.
That code calculates factorials, recursively, without using
assignment, declarations, or functions of 2 variables.  (But
trying to trace how it works is likely to make your head spin.
And handing it, without the derivation, just slightly reformatted
will result in code that is sure to baffle and confuse.)

You can replace the 4 lines that recursively define factorial with
any other recursive function that you want.

 /me wonders how different the world would be if EvilLarry didn't let map
 and filter^Wgrep slip into Perl...

I'm rather more thankful for closures.  After all, being list-oriented,
I can define map/grep quite easily.  But closures I need to be in
the language...

Cheers,
Ben
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] perl6/pugs

2005-03-01 Thread Mike Burns
--- Ben Tilly mumbled on 2005-03-01 14.56.51 -0800 ---
 Here's an explanation of the Y-Combinator.  It won't work in
 Perl because Perl doesn't do lexical binding of input
 parameters.  JavaScript does and most should know that, so
 I'll do it in JavaScript.

Also see The Little JavaScripter:
 http://www.crockford.com/javascript/little.html

-- 
Mike Burns [EMAIL PROTECTED] http://mike-burns.com
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] perl6/pugs

2005-02-28 Thread Aaron Sherman
On Mon, 2005-02-28 at 12:51, Benjamin Kram wrote:
 Has anyone had a chance to play with pugs?
 I just svned down a copy and was going to toy with it a bit.

Only a little bit. I am, however, sure that the correct way to boost the
popularity of your favorite niche language is to write a compiler /
interpreter in it for a popular language. Pugs will certainly boost
Haskell in this way ;-)

-- 
 781-324-3772
 [EMAIL PROTECTED]
 http://www.ajs.com/~ajs

 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] perl6/pugs

2005-02-28 Thread Kenneth A Graves
On Mon, 2005-02-28 at 13:32, Aaron Sherman wrote:
 On Mon, 2005-02-28 at 12:51, Benjamin Kram wrote:
  Has anyone had a chance to play with pugs?
  I just svned down a copy and was going to toy with it a bit.
 
 Only a little bit. I am, however, sure that the correct way to boost the
 popularity of your favorite niche language is to write a compiler /
 interpreter in it for a popular language. Pugs will certainly boost
 Haskell in this way ;-)

I haven't gotten around to playing with Pugs yet, but I did build
Haskell this weekend.  It's a functional-programming conspiracy.

--kag


 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] perl6/pugs

2005-02-28 Thread Ben Tilly
Ruby is easier for Perl people to get into than Haskell.  By the same
token, learning Ruby will expand your horizons less than Haskell.

Which is preferable depends on your point of view.

Cheers,
Ben

On Mon, 28 Feb 2005 13:49:59 -0500, Benjamin Kram [EMAIL PROTECTED] wrote:
 I just grabbed binary of Haskell. I'm thinking of poking around with that as 
 well, and Ruby...
 
 b
 
 On Mon, Feb 28, 2005 at 01:40:35PM -0500, Kenneth A Graves wrote:
  On Mon, 2005-02-28 at 13:32, Aaron Sherman wrote:
   On Mon, 2005-02-28 at 12:51, Benjamin Kram wrote:
Has anyone had a chance to play with pugs?
I just svned down a copy and was going to toy with it a bit.
  
   Only a little bit. I am, however, sure that the correct way to boost the
   popularity of your favorite niche language is to write a compiler /
   interpreter in it for a popular language. Pugs will certainly boost
   Haskell in this way ;-)
 
  I haven't gotten around to playing with Pugs yet, but I did build
  Haskell this weekend.  It's a functional-programming conspiracy.
 
  --kag
 
 
 
  ___
  Boston-pm mailing list
  Boston-pm@mail.pm.org
  http://mail.pm.org/mailman/listinfo/boston-pm
 
 --
 it would be horrid to be robbed
  by the wrong kind of people
  -archy
  Don Marquis, the big bad wolf, 1935
 
 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm

 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] perl6/pugs

2005-02-28 Thread Gyepi SAM
On Mon, Feb 28, 2005 at 01:40:35PM -0500, Kenneth A Graves wrote:
 I haven't gotten around to playing with Pugs yet, but I did build
 Haskell this weekend.  It's a functional-programming conspiracy.

It must be: I am using LISP, after a long hiatus, and really liking it. I
simply did not appreciate its power upon introduction six years ago.

As I recall, there are quite a few cross language programmers on this
list...

-Gyepi
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] perl6/pugs

2005-02-28 Thread Benjamin Kram
On Mon, Feb 28, 2005 at 03:43:24PM -0500, Aaron Sherman wrote:
 On Mon, 2005-02-28 at 15:39, Gyepi SAM wrote:
 
  As I recall, there are quite a few cross language programmers on this
  list...
 
 I've never used cross, but I hear it's a great language. What do you use
 it for?

Warding off zombie processes.


.b
-- 
it would be horrid to be robbed
 by the wrong kind of people
 -archy
 Don Marquis, the big bad wolf, 1935 
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] perl6/pugs

2005-02-28 Thread Greg London
Aaron Sherman wrote:
 
 On Mon, 2005-02-28 at 15:39, Gyepi SAM wrote:
 
  As I recall, there are quite a few 
  cross language programmers on this list...
 
 I've never used cross, but I hear it's 
 a great language. What do you use it for?

It's most useful for stuff like
Hey, you kids! Get off of my yard!

I also found I was running some cross scripts
after seeing Star Wars ep 1 and 2.

stuff like that...
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm