Hacking BeanShell with JavaCC

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

Hacking BeanShell with JavaCC

Daniel Leuck
Hi Guys,

I recently wrote a blog post that may be of interest to BeanShell
developers.  The short post demonstrates how easy it is to add simple
features to the language:
http://www.techhui.com/profiles/blog/show?id=1702911%3ABlogPost%3A10425

I plan to do a few follow up posts covering additional features such
as named arguments and extender methods.

--
Daniel Leuck
President
Ikayzo, inc.
+1 (808) 539-3804 (US Direct)
+81 03-3655-2829 (Japan Direct)
+1 (808) 393-9119 (Mobile)
+1 (808) 591-1496 (Fax)
http://www.ikayzo.com
http://www.javaui.net

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

Re: Hacking BeanShell with JavaCC

Bob Fischer
Hey thanks, this is really neat stuff, and along the lines of what  
I've been wanting.

I would love to see a BeanShell-based MATLAB replacement.  I have all  
the computational components needed for it, I just need a good syntax  
from within BeanShell; that includes matrix notation (similar to the  
lists described here), as well as a bunch of funny infix operators.  
With this base, it should not be hard.

Alas, I don't have the time now, but is anyone else interested in  
picking it up?  I can certainly point out the matrix libraries I  
think one should use.

-- Bob


On Apr 15, 2008, at 10:43 PM, Daniel Leuck wrote:

> Hi Guys,
>
> I recently wrote a blog post that may be of interest to BeanShell
> developers.  The short post demonstrates how easy it is to add simple
> features to the language:
> <a href="http://www.techhui.com/profiles/blog/show?id=1702911%3ABlogPost%">http://www.techhui.com/profiles/blog/show?id=1702911%3ABlogPost% 
> 3A10425
>
> I plan to do a few follow up posts covering additional features such
> as named arguments and extender methods.
>
> --
> Daniel Leuck
> President
> Ikayzo, inc.
> +1 (808) 539-3804 (US Direct)
> +81 03-3655-2829 (Japan Direct)
> +1 (808) 393-9119 (Mobile)
> +1 (808) 591-1496 (Fax)
> http://www.ikayzo.com
> http://www.javaui.net
>
> ----------------------------------------------------------------------
> ---
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save  
> $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http:// 
> java.sun.com/javaone
> _______________________________________________
> Beanshell-developers mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-developers


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

Re: Hacking BeanShell with JavaCC

Daniel Leuck
Thanks Bob.  I'll cover implementation of new operators in the next post.

On Tue, Apr 15, 2008 at 5:11 PM, Bob F <[hidden email]> wrote:

> Hey thanks, this is really neat stuff, and along the lines of what I've been
> wanting.
>
>  I would love to see a BeanShell-based MATLAB replacement.  I have all the
> computational components needed for it, I just need a good syntax from
> within BeanShell; that includes matrix notation (similar to the lists
> described here), as well as a bunch of funny infix operators.  With this
> base, it should not be hard.
>
>  Alas, I don't have the time now, but is anyone else interested in picking
> it up?  I can certainly point out the matrix libraries I think one should
> use.
>
>  -- Bob
>
>
>
>
>  On Apr 15, 2008, at 10:43 PM, Daniel Leuck wrote:
>
>
> >
> >
> >
> > Hi Guys,
> >
> > I recently wrote a blog post that may be of interest to BeanShell
> > developers.  The short post demonstrates how easy it is to add simple
> > features to the language:
> > http://www.techhui.com/profiles/blog/show?id=1702911%3ABlogPost%3A10425
> >
> > I plan to do a few follow up posts covering additional features such
> > as named arguments and extender methods.
> >
> > --
> > Daniel Leuck
> > President
> > Ikayzo, inc.
> > +1 (808) 539-3804 (US Direct)
> > +81 03-3655-2829 (Japan Direct)
> > +1 (808) 393-9119 (Mobile)
> > +1 (808) 591-1496 (Fax)
> > http://www.ikayzo.com
> > http://www.javaui.net
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> > Don't miss this year's exciting event. There's still time to save $100.
> > Use priority code J8TL2D2.
> >
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> > _______________________________________________
> > Beanshell-developers mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/beanshell-developers
> >
>
>



--
Daniel Leuck
President
Ikayzo, inc.
+1 (808) 539-3804 (US Direct)
+81 03-3655-2829 (Japan Direct)
+1 (808) 393-9119 (Mobile)
+1 (808) 591-1496 (Fax)
http://www.ikayzo.com
http://www.javaui.net

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

Re: Hacking BeanShell with JavaCC

Stevenson, Scott W
In reply to this post by Bob Fischer
Bob,

I share you desire for an open source MATLAB replacement/competitor.  If
you've never scene Groovy, check it out at http://groovy.codehaus.org/.
It's a Java based scripting language that is a lot more "MATLAB like"
then BeanShell.  It supports operator overloading and lots of other
features to make it a more suitable base for MATLAB.  Someone has even
started such an effort called GroovyLab
http://groovy.codehaus.org/GroovyLab.  It hasn't gotten very far, but it
is getting some attention.  I've been pushing this idea in Boeing for
years, but these efforts have to reach a certain critical mass before
they catch on.

Scott...
 

-----Original Message-----
From: Bob F [mailto:[hidden email]]
Sent: Tuesday, April 15, 2008 10:12 PM
To: Daniel Leuck
Cc: [hidden email]
Subject: Re: [Beanshell-dev] Hacking BeanShell with JavaCC

Hey thanks, this is really neat stuff, and along the lines of what I've
been wanting.

I would love to see a BeanShell-based MATLAB replacement.  I have all
the computational components needed for it, I just need a good syntax
from within BeanShell; that includes matrix notation (similar to the  
lists described here), as well as a bunch of funny infix operators.  
With this base, it should not be hard.

Alas, I don't have the time now, but is anyone else interested in
picking it up?  I can certainly point out the matrix libraries I think
one should use.

-- Bob


On Apr 15, 2008, at 10:43 PM, Daniel Leuck wrote:

> Hi Guys,
>
> I recently wrote a blog post that may be of interest to BeanShell
> developers.  The short post demonstrates how easy it is to add simple
> features to the language:
> <a href="http://www.techhui.com/profiles/blog/show?id=1702911%3ABlogPost%">http://www.techhui.com/profiles/blog/show?id=1702911%3ABlogPost%
> 3A10425
>
> I plan to do a few follow up posts covering additional features such
> as named arguments and extender methods.
>
> --
> Daniel Leuck
> President
> Ikayzo, inc.
> +1 (808) 539-3804 (US Direct)
> +81 03-3655-2829 (Japan Direct)
> +1 (808) 393-9119 (Mobile)
> +1 (808) 591-1496 (Fax)
> http://www.ikayzo.com
> http://www.javaui.net
>
> ----------------------------------------------------------------------
> ---
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save
> $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://
> java.sun.com/javaone
> _______________________________________________
> Beanshell-developers mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-developers


------------------------------------------------------------------------
-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't
miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/j
avaone
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

Re: Hacking BeanShell with JavaCC

Yemi I. D. Bedu
In reply to this post by Bob Fischer
Hello,
 You should set up some info and websites links on a blog that others
can look at. Some one with time may just try to implement whatever
concept you are thinking of manifesting in their leisurely. Thank you.
Good day.

Yemi Bedu

P&R Fasteners, Inc.
P&R Castings, LLC.
325 Pierce St
Somerset, NJ 08873
(T) 732-302-3600
(F) 732-302-3636

-----Original Message-----
From: Bob F [mailto:[hidden email]]
Sent: Tuesday, April 15, 2008 11:12 PM
To: Daniel Leuck
Cc: [hidden email]
Subject: Re: [Beanshell-dev] Hacking BeanShell with JavaCC

Hey thanks, this is really neat stuff, and along the lines of what  
I've been wanting.

I would love to see a BeanShell-based MATLAB replacement.  I have all  
the computational components needed for it, I just need a good syntax  
from within BeanShell; that includes matrix notation (similar to the  
lists described here), as well as a bunch of funny infix operators.  
With this base, it should not be hard.

Alas, I don't have the time now, but is anyone else interested in  
picking it up?  I can certainly point out the matrix libraries I  
think one should use.

-- Bob


On Apr 15, 2008, at 10:43 PM, Daniel Leuck wrote:

> Hi Guys,
>
> I recently wrote a blog post that may be of interest to BeanShell
> developers.  The short post demonstrates how easy it is to add simple
> features to the language:
> <a href="http://www.techhui.com/profiles/blog/show?id=1702911%3ABlogPost%">http://www.techhui.com/profiles/blog/show?id=1702911%3ABlogPost% 
> 3A10425
>
> I plan to do a few follow up posts covering additional features such
> as named arguments and extender methods.
>
> --
> Daniel Leuck
> President
> Ikayzo, inc.
> +1 (808) 539-3804 (US Direct)
> +81 03-3655-2829 (Japan Direct)
> +1 (808) 393-9119 (Mobile)
> +1 (808) 591-1496 (Fax)
> http://www.ikayzo.com
> http://www.javaui.net
>
> ----------------------------------------------------------------------

> ---
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save  
> $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http:// 
> java.sun.com/javaone
> _______________________________________________
> Beanshell-developers mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-developers


------------------------------------------------------------------------
-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/j
avaone
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

Re: Hacking BeanShell with JavaCC

fschmidt
Administrator
In reply to this post by Bob Fischer
I think the best way to do this would be to add a general way for users to define the meaning of operators for a class/object similar to how Python does it.  This shouldn't be hard for BeanShell.

By the way, since there is no progress on BeanShell, I made a BeanShell fork here:

http://code.google.com/p/beanshell2/

Anyone is welcome to contribute.  I did implement long string literals:

http://code.google.com/p/beanshell2/issues/detail?id=20&can=1

And I suggested a simpler way of creating collections here:

http://code.google.com/p/beanshell2/issues/detail?id=14&can=1

I actually could use a BeanShell based MATLAB clone, so when you have time to work on this, let me know and I can implement the operator overloading described above.


Bob Fischer wrote
I would love to see a BeanShell-based MATLAB replacement.  I have all  
the computational components needed for it, I just need a good syntax  
from within BeanShell; that includes matrix notation (similar to the  
lists described here), as well as a bunch of funny infix operators.  
With this base, it should not be hard.
Reply | Threaded
Open this post in threaded view
|

Re: Hacking BeanShell with JavaCC

fschmidt
Administrator
In reply to this post by Stevenson, Scott W
Not to start a language war, but Groovy is the epitome of bad design.  I just looked at their operator overloading page:

http://groovy.codehaus.org/Operator+Overloading

and I see that they actually change the meaning of standard Java operators like this:

a == b a.equals(b) or a.compareTo(b) == 0
a != b ! a.equals(b)

If you want interpreted Java, stick with BeanShell or Pnuts.  If you want a good interpreted language other than Java, use Python or Ruby.  There is no reason to ever use Groovy.

And by the way, I hear that Python has a very nice MATLAB clone.


Stevenson, Scott W wrote
If you've never scene Groovy, check it out at http://groovy.codehaus.org/.
It's a Java based scripting language that is a lot more "MATLAB like"
then BeanShell.  It supports operator overloading and lots of other
features to make it a more suitable base for MATLAB.
Reply | Threaded
Open this post in threaded view
|

Re: Hacking BeanShell with JavaCC

Stevenson, Scott W
CODE WAR?  Ohh it's on baby!

Some of us REALLY like the way Groovy does operator overloading.
Programming by convention is the next big thing.  The Groovy way lets
you plug in pure java classes and still take advantage of operator
overloading.  Groovy has all the best features of Java, BeanShell, Ruby,
and Python; while doing an excellent job of leveraging the full power of
Java.  As for Python, I can't stand that the syntax is tab/whitespace
dependent.  BeanShell is good if you just want a small embeddable
interpreter, but it stopped evolving somewhere around Java 1.3/1.4.

In my opinion, Groovy is by far the best Java based scripting language
out there.  It's only weakness, and its still significant, is in the
embedded shell.  But those problems have been fixed for the interpreted
shell, and should soon be fixed for embedded users.

Scott...


-----Original Message-----
From: fschmidt [mailto:[hidden email]]
Sent: Wednesday, April 16, 2008 1:08 PM
To: [hidden email]
Subject: Re: [Beanshell-dev] Hacking BeanShell with JavaCC


Not to start a language war, but Groovy is the epitome of bad design.  I
just looked at their operator overloading page:

http://groovy.codehaus.org/Operator+Overloading

and I see that they actually change the meaning of standard Java
operators like this:

a == b a.equals(b) or a.compareTo(b) == 0
a != b ! a.equals(b)

If you want interpreted Java, stick with BeanShell or Pnuts.  If you
want a good interpreted language other than Java, use Python or Ruby.
There is no reason to ever use Groovy.

And by the way, I hear that Python has a very nice MATLAB clone.



Stevenson, Scott W wrote:
>
> If you've never scene Groovy, check it out at
http://groovy.codehaus.org/.
> It's a Java based scripting language that is a lot more "MATLAB like"
> then BeanShell.  It supports operator overloading and lots of other
> features to make it a more suitable base for MATLAB.
>

--
View this message in context:
http://www.nabble.com/Hacking-BeanShell-with-JavaCC-tp16715411p16727268.
html
Sent from the BeanShell - Dev mailing list archive at Nabble.com.


------------------------------------------------------------------------
-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/j
avaone
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

Re: Hacking BeanShell with JavaCC

fschmidt
Administrator
No code war needed.  Language is a matter of personal preference, and I assume people on this list are here because they prefer BeanShell to Groovy.  I was just expressing my opinion.  Operator overloading should be added in a clean way to BeanShell.  I have been adding to BeanShell beyond Java 1.3/1.4 in my BeanShell fork here:

http://code.google.com/p/beanshell2/


Stevenson, Scott W wrote
CODE WAR?  Ohh it's on baby!

Some of us REALLY like the way Groovy does operator overloading.
Programming by convention is the next big thing.  The Groovy way lets
you plug in pure java classes and still take advantage of operator
overloading.  Groovy has all the best features of Java, BeanShell, Ruby,
and Python; while doing an excellent job of leveraging the full power of
Java.  As for Python, I can't stand that the syntax is tab/whitespace
dependent.  BeanShell is good if you just want a small embeddable
interpreter, but it stopped evolving somewhere around Java 1.3/1.4.
Reply | Threaded
Open this post in threaded view
|

Re: Hacking BeanShell with JavaCC

Daniel Leuck
In reply to this post by Stevenson, Scott W
Hi Guys,

BeanShell and Groovy are both great tools.  I also really like C# 3.0
:-)  Its best not to view languages as religions.

I like a lot of Groovy's features (object builders, operator
overloading, named arguments, etc.), but I agree with fschmidt that
changing the semantics of Java's == operator was a bad design choice
because it violates PLS (principal of least surprise) for Java
programmers.  As I mention in the blog post I implemented a <>
equivalence operactor that works like Groovy's ==.  I'll write about
this in the next blog post.

Note that the design goals of Groovy and Beanshell are quite
different.  The intent of the blog post was to demonstrate how easy it
is to hack BeanShell with a little knowledge of JavaCC and JJTree.
This is useful if you want to add a language feature or create a
little DSL.  I was not looking to start a language war :-)

Dan

On Wed, Apr 16, 2008 at 8:41 AM, Stevenson, Scott W
<[hidden email]> wrote:

> CODE WAR?  Ohh it's on baby!
>
>  Some of us REALLY like the way Groovy does operator overloading.
>  Programming by convention is the next big thing.  The Groovy way lets
>  you plug in pure java classes and still take advantage of operator
>  overloading.  Groovy has all the best features of Java, BeanShell, Ruby,
>  and Python; while doing an excellent job of leveraging the full power of
>  Java.  As for Python, I can't stand that the syntax is tab/whitespace
>  dependent.  BeanShell is good if you just want a small embeddable
>  interpreter, but it stopped evolving somewhere around Java 1.3/1.4.
>
>  In my opinion, Groovy is by far the best Java based scripting language
>  out there.  It's only weakness, and its still significant, is in the
>  embedded shell.  But those problems have been fixed for the interpreted
>  shell, and should soon be fixed for embedded users.
>
>  Scott...
>
>
>
>  -----Original Message-----
>  From: fschmidt [mailto:[hidden email]]
>  Sent: Wednesday, April 16, 2008 1:08 PM
>  To: [hidden email]
>  Subject: Re: [Beanshell-dev] Hacking BeanShell with JavaCC
>
>
>
>
> Not to start a language war, but Groovy is the epitome of bad design.  I
>  just looked at their operator overloading page:
>
>  http://groovy.codehaus.org/Operator+Overloading
>
>  and I see that they actually change the meaning of standard Java
>  operators like this:
>
>  a == b   a.equals(b) or a.compareTo(b) == 0
>  a != b  ! a.equals(b)
>
>  If you want interpreted Java, stick with BeanShell or Pnuts.  If you
>  want a good interpreted language other than Java, use Python or Ruby.
>  There is no reason to ever use Groovy.
>
>  And by the way, I hear that Python has a very nice MATLAB clone.
>
>
>
>  Stevenson, Scott W wrote:
>  >
>  > If you've never scene Groovy, check it out at
>  http://groovy.codehaus.org/.
>  > It's a Java based scripting language that is a lot more "MATLAB like"
>  > then BeanShell.  It supports operator overloading and lots of other
>  > features to make it a more suitable base for MATLAB.
>  >
>
>  --
>  View this message in context:
>  http://www.nabble.com/Hacking-BeanShell-with-JavaCC-tp16715411p16727268.
>  html
>  Sent from the BeanShell - Dev mailing list archive at Nabble.com.
>
>
>  ------------------------------------------------------------------------
>  -
>  This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
>  Don't miss this year's exciting event. There's still time to save $100.
>  Use priority code J8TL2D2.
>  http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/j
>  avaone
>  _______________________________________________
>  Beanshell-developers mailing list
>  [hidden email]
>  https://lists.sourceforge.net/lists/listinfo/beanshell-developers
>
>  -------------------------------------------------------------------------
>  This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
>  Don't miss this year's exciting event. There's still time to save $100.
>  Use priority code J8TL2D2.
>  http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
>  _______________________________________________
>  Beanshell-developers mailing list
>  [hidden email]
>  https://lists.sourceforge.net/lists/listinfo/beanshell-developers
>



--
Daniel Leuck
President
Ikayzo, inc.
+1 (808) 539-3804 (US Direct)
+81 03-3655-2829 (Japan Direct)
+1 (808) 393-9119 (Mobile)
+1 (808) 591-1496 (Fax)
http://www.ikayzo.com
http://www.javaui.net

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

Re: Hacking BeanShell with JavaCC

Daniel Leuck
In reply to this post by fschmidt
Hi Fschmidt,

Note that my <> example is not operator overloading.  Its an example
of implementing a new operator.

I could implement generic operator overloading, but that might be a
long blog post :-)

re: Your list(Object... objs) suggestion

This is a good approach.  I use it in regular Java apps and statically
import the method.

Dan

On Wed, Apr 16, 2008 at 7:39 PM, fschmidt <[hidden email]> wrote:

>
>  I think the best way to do this would be to add a general way for users to
>  define the meaning of operators for a class/object similar to how Python
>  does it.  This shouldn't be hard for BeanShell.
>
>  By the way, since there is no progress on BeanShell, I made a BeanShell fork
>
> here:
>
>  http://code.google.com/p/beanshell2/
>
>  Anyone is welcome to contribute.  I did implement long string literals:
>
>  http://code.google.com/p/beanshell2/issues/detail?id=20&can=1
>
>  And I suggested a simpler way of creating collections here:
>
>  http://code.google.com/p/beanshell2/issues/detail?id=14&can=1
>
>  I actually could use a BeanShell based MATLAB clone, so when you have time
>  to work on this, let me know and I can implement the operator overloading
>  described above.
>
>
>
>
>  Bob Fischer wrote:
>  >
>  > I would love to see a BeanShell-based MATLAB replacement.  I have all
>  > the computational components needed for it, I just need a good syntax
>  > from within BeanShell; that includes matrix notation (similar to the
>  > lists described here), as well as a bunch of funny infix operators.
>  > With this base, it should not be hard.
>  >
>
>  --
>  View this message in context: http://www.nabble.com/Hacking-BeanShell-with-JavaCC-tp16715411p16722790.html
>
> Sent from the BeanShell - Dev mailing list archive at Nabble.com.
>
>
>  -------------------------------------------------------------------------
>  This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
>  Don't miss this year's exciting event. There's still time to save $100.
>  Use priority code J8TL2D2.
>
>
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
>  _______________________________________________
>  Beanshell-developers mailing list
>  [hidden email]
>  https://lists.sourceforge.net/lists/listinfo/beanshell-developers
>



--
Daniel Leuck
President
Ikayzo, inc.
+1 (808) 539-3804 (US Direct)
+81 03-3655-2829 (Japan Direct)
+1 (808) 393-9119 (Mobile)
+1 (808) 591-1496 (Fax)
http://www.ikayzo.com
http://www.javaui.net

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

MATLAB-like Tool

Bob Fischer
In reply to this post by Stevenson, Scott W
Hello,

It looks like there's some interest in this, so I wanted to say a bit  
more about where I'm coming from and what I've found so far.

The good thing about MATLAB is that it's really easy to start messing  
around with matrices and try things out.  This interactivity is  
really good, especially when you're trying to explore a dataset and  
you don't know what you'll find.  In particular, MATLAB has some very  
convenient syntax, the importance of which should NOT be overlooked.  
Good syntax makes things easy in ways they would not be with bad  
syntax.  MATLAB also has a relatively well constructed set of  
numerical libraries.

The bad things about MATLAB are legion:
  1. MATLAB has no static type-checking and is therefore not suitable  
for large, complex projects.
  2. MATLAB is missing many other features that make it ill-suited  
for large software projects as well.
  3. MATLAB language is slow, and there's no easy way to speed it  
up.  Sure, the matrix operations are lightning fast, but a wimpy for  
loop can be deathly slow.  This distorts the way the programmer  
writes code.

With this in mind, the obvious thing is to prototype your numerical  
routines in MATLAB, then insert those routines into a larger  
framework in a language more suitable for software development (such  
as Java or C# or something).  But this also does not work because:

  4. You cannot embed a MATLAB subroutine in anything else (at least  
not easily).  MathWorks has a "way" to do this, but it involves inter-
process communication to a MATLAB process that is inherently single-
threaded.  Not the basis for a fast, robust system in my view.

What I WANT is a MATLAB-like system with the following properties:
  1. Retains the good features of MATLAB.  Easy to prototype stuff  
in, responsive on the command line.
  2. Once a subroutine is developed, it should easily and naturally  
integrate into a larger project, preferably a Java project.

Some thoughts on what's been put out there so far:

  1. As far as I know, no existing language is "best" for this task;  
they all fall short in terms of specialized matrix syntax.  I've not  
looked closely at the SciPy, it might do better.  But from what I've  
seen so far, its syntax is still significantly more encumbered than  
MATLAB's.

  2. It would be death to build a nice system like this and use a  
substandard matrix library.  The matrix library one uses defines the  
rest of the system, since it is such a basic data type.  After trying  
them all, I've settled on MTJ (Matrix Toolkit for Java) as my base  
matrix library.  It is based on the LAPACK/BLAS subroutines.  You can  
use either LAPACK/BLAS converted to Java, or a native C version  
(called through JMI).  MTJ avoids many mistakes that I've seen so  
often in Java matrix code:
    a) MTJ does not try to do generic matrices.  One can certainly  
write a matrix library that does matrices of ints or fields or  
something "just" as easily as doubles.  But it will be too slow to  
use.  MTJ supports matrices of doubles, and it does so at full speed.
   b) MTJ does not use arrays of arrays; these are also not really  
appropriate as a matrix representation for numerics.  MTJ uses  
FORTRAN-style column-major matrices.  Some packages use row-major  
instead; I can live with that.  But arrays of arrays are not really  
acceptable for numerics, and they don't allow for many of the  
"tricks" that are needed either.
    c) MTJ does not build a Complex class, then tell us that we can  
have complex matrices by building a matrix of Complex instances.  
That will be at least an order of magnitude too slow --- as well as  
using 3 times as much memory --- as traditional FORTRAN-style  
complexes.  Supporting complex in Java is tricky.  But at the base of  
it all, complex matrices need to basically be 2-D arrays with twice  
as many elements in them as similar double matrices.

  3. When I looked at Groovy, it seemed to be heavily oriented toward  
non-Numerical, highly generic computation, highly runtime-typed  
computation.  I was not comfortable with it as a platform for high-
efficiency numerical computation.


  4. Whatever is done, I need it to integrate seamlessly with Java.  
Groovy's approach of compiling code at run-time is very good in this  
respect, and it allows Java's JIT to get into the action and really  
make things fast.  This will be a good approach in the end, since it  
will minimize the speed differential between Java code and our MATLAB-
like code (and thereby avoid distorting the way the programmer  
produces code).  BeanShell is known to be pretty slow in general, so  
that's a big reason NOT to use it for this purpose; one would start  
building up some routines and then discover that the interpreter is  
not fast enough to run time.  Then you're kind of stuck.  The PySci  
approach looks promising; I would want to see that it integrates well  
with Java when running under Jython.  However, I still have the  
reservation that it might be too slow in the end for more complex  
subroutines.

Hope that helps!


On a slightly different note: I was very excited when I first learned  
about Java scripting languages.  They seemed like an obvious good way  
to easily add extensibility to my applications.  But more and more,  
I've ended up not using them, opting for extensibility via plain old  
compiled Java instead.  The reasons for this are:
  1. Plain old Java integrates the most seamlessly, and it operates  
with a well-defined security model.
  2. Plain old Java is very well supported with millions of dollars  
of on-going investment.
  3. NetBeans offers a lot of syntax aids for writing plain old  
Java.  It always helps you look up which methods you can call, what  
the arguments are, etc.  It is a big boon.  When I leave plain old  
Java, I cannot make use of these features any more.

Therefore, I've gotten good extensibility results so far by expecting  
that the person doing the extensions will write them in Java and load  
a Jar file.  Every project is different, of course, but it's worked  
well for me so far.


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

Re: Hacking BeanShell with JavaCC

Daniel Leuck
In reply to this post by Daniel Leuck
Hi Folks,

I posted Part II which includes implementation of Python / Groovy
style named arguments:
http://www.techhui.com/profiles/blog/show?id=1702911%3ABlogPost%3A12211

Again, I'm not proposing new features for BeanShell or trying to
create a new language.  The purpose of the post is to demonstrate how
to modify BeanShell and other languages that are defined with JJTree
grammars.  This is also a useful way to jump into JavaCC and JJTree if
you plan to eventually write an entire language from scratch.

I hope you find it useful.

Cheers,
Dan

On Wed, Apr 16, 2008 at 11:11 PM, Daniel Leuck <[hidden email]> wrote:

> Hi Fschmidt,
>
>  Note that my <> example is not operator overloading.  Its an example
>  of implementing a new operator.
>
>  I could implement generic operator overloading, but that might be a
>  long blog post :-)
>
>  re: Your list(Object... objs) suggestion
>
>  This is a good approach.  I use it in regular Java apps and statically
>  import the method.
>
>  Dan
>
>
>
>  On Wed, Apr 16, 2008 at 7:39 PM, fschmidt <[hidden email]> wrote:
>  >
>  >  I think the best way to do this would be to add a general way for users to
>  >  define the meaning of operators for a class/object similar to how Python
>  >  does it.  This shouldn't be hard for BeanShell.
>  >
>  >  By the way, since there is no progress on BeanShell, I made a BeanShell fork
>  >
>  > here:
>  >
>  >  http://code.google.com/p/beanshell2/
>  >
>  >  Anyone is welcome to contribute.  I did implement long string literals:
>  >
>  >  http://code.google.com/p/beanshell2/issues/detail?id=20&can=1
>  >
>  >  And I suggested a simpler way of creating collections here:
>  >
>  >  http://code.google.com/p/beanshell2/issues/detail?id=14&can=1
>  >
>  >  I actually could use a BeanShell based MATLAB clone, so when you have time
>  >  to work on this, let me know and I can implement the operator overloading
>  >  described above.
>  >
>  >
>  >
>  >
>  >  Bob Fischer wrote:
>  >  >
>  >  > I would love to see a BeanShell-based MATLAB replacement.  I have all
>  >  > the computational components needed for it, I just need a good syntax
>  >  > from within BeanShell; that includes matrix notation (similar to the
>  >  > lists described here), as well as a bunch of funny infix operators.
>  >  > With this base, it should not be hard.
>  >  >
>  >
>  >  --
>  >  View this message in context: http://www.nabble.com/Hacking-BeanShell-with-JavaCC-tp16715411p16722790.html
>  >
>  > Sent from the BeanShell - Dev mailing list archive at Nabble.com.
>  >
>  >
>  >  -------------------------------------------------------------------------
>  >  This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
>  >  Don't miss this year's exciting event. There's still time to save $100.
>  >  Use priority code J8TL2D2.
>  >
>  >
>  > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
>  >  _______________________________________________
>  >  Beanshell-developers mailing list
>  >  [hidden email]
>  >  https://lists.sourceforge.net/lists/listinfo/beanshell-developers
>  >
>
>
>
>
>
> --
>  Daniel Leuck
>  President
>  Ikayzo, inc.
>  +1 (808) 539-3804 (US Direct)
>  +81 03-3655-2829 (Japan Direct)
>  +1 (808) 393-9119 (Mobile)
>  +1 (808) 591-1496 (Fax)
>  http://www.ikayzo.com
>  http://www.javaui.net
>



--
Daniel Leuck
President
Ikayzo, inc.
+1 (808) 539-3804 (US Direct)
+81 03-3655-2829 (Japan Direct)
+1 (808) 393-9119 (Mobile)
+1 (808) 591-1496 (Fax)
http://www.ikayzo.com
http://www.javaui.net

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

Re: Hacking BeanShell with JavaCC

fschmidt
Administrator
In reply to this post by Daniel Leuck
Daniel Leuck wrote
Note that my <> example is not operator overloading.  Its an example
of implementing a new operator.
Yes but to create a MATLAB replacement, you need operator overloading too, so that you can do things like add matrices.

And by the way, "<>" is used for "not equal" in Basic, so maybe "<=>" would be better for "equivalent", and this is the mathematical symbol for equivalent propositions.  Then "<>" could be used for "not equivalent" (less than or greater than).

I could implement generic operator overloading, but that might be a
long blog post :-)
But this might be quite useful.  It would be great to see a discussion about what is the best way to do generic operator overloading, and then to implement this in BeanShell.
Reply | Threaded
Open this post in threaded view
|

Re: MATLAB-like Tool

fschmidt
Administrator
In reply to this post by Bob Fischer
I think the idea of any scripting language is to prototype and interact and try things.  A big system, where speed matters, should be built with a statically typed language like Java.  So I don't think speed is an issue for scripting languages.  BeanShell will always be slow because it doesn't generate bytecode.  Pnuts is probably the best Java scripting language, and it does generate bytecode, but it has a tiny user base and an author who is almost as unresponsive as BeanShell's author.  I picked BeanShell as a compromise because it has a fair size user base, and while not as good as Pnuts, is not nearly as bad (for me) as Groovy.  I was hoping that BeanShell's user base would take some initiative if I forked the source and made it easy to contribute, but unfortunately, this hasn't happened.

Bob Fischer wrote
BeanShell is known to be pretty slow in general, so  
that's a big reason NOT to use it for this purpose; one would start  
building up some routines and then discover that the interpreter is  
not fast enough to run time.  Then you're kind of stuck.
No, then you translate your time-critical routines into Java.  This should be painless compared to, say, translating code from Python to C.

The PySci  
approach looks promising; I would want to see that it integrates well  
with Java when running under Jython.
This won't work because SciPy is based on a big C library and Jython is pure Java.
Reply | Threaded
Open this post in threaded view
|

Re: Hacking BeanShell with JavaCC

Daniel Leuck
In reply to this post by fschmidt
Hi fschmidt,

>  Yes but to create a MATLAB replacement, you need operator overloading too,
>  so that you can do things like add matrices.

I'm just writing a few blog posts about how to use JJTree to hack
BeanShell.  I'm not trying to create a new language or replace MATLAB.
 I hope these posts help you get started if you decide to take on this
ambitious project.  Note, if you are trying to do computationally
intensive tasks you might want to work with a language that generates
bytecode or even native code.  As someone mentioned earlier in this
thread, Groovy might be a good starting point.  BeanShell only emits a
minimal amount of bytecode to enable subclassing.

>  And by the way, "<>" is used for "not equal" in Basic, so maybe "<=>" would
>  be better for "equivalent", and this is the mathematical symbol for
>  equivalent propositions.  Then "<>" could be used for "not equivalent" (less
>  than or greater than).

Good point.  When I have time I'll make this change to the example.

>  > I could implement generic operator overloading, but that might be a
>  > long blog post :-)
>
>  But this might be quite useful.  It would be great to see a discussion about
>  what is the best way to do generic operator overloading, and then to
>  implement this in BeanShell.

I've used C#'s operator overloading for matrix operations.  Its well
designed.  If I were to implement such a feature I would probably use
C#'s approach as a basis.

Cheers,
Dan

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

Re: MATLAB-like Tool

Yemi I. D. Bedu
In reply to this post by fschmidt
Hello,
 What would be the patterns of transliteration for operator overloading?
What about for new syntax? If they worked as sugar and you allows have a
clean method backed structure then it would be more favored over Pnuts
and Groovy. That probably is one of the best features to probably have
in the language. I don't care if I can't overload old ops if I can
introduce new pseudo-ops. Is this possible or even already available? I
have been using the 1.3 documents to program against 2.0b4 for that past
year. Good day.

Yemi Bedu

P&R Fasteners, Inc.
P&R Castings, LLC.
325 Pierce St
Somerset, NJ 08873
(T) 732-302-3600
(F) 732-302-3636

-----Original Message-----
From: fschmidt [mailto:[hidden email]]
Sent: Thursday, April 17, 2008 3:58 PM
To: [hidden email]
Subject: Re: [Beanshell-dev] MATLAB-like Tool


I think the idea of any scripting language is to prototype and interact
and
try things.  A big system, where speed matters, should be built with a
statically typed language like Java.  So I don't think speed is an issue
for
scripting languages.  BeanShell will always be slow because it doesn't
generate bytecode.  Pnuts is probably the best Java scripting language,
and
it does generate bytecode, but it has a tiny user base and an author who
is
almost as unresponsive as BeanShell's author.  I picked BeanShell as a
compromise because it has a fair size user base, and while not as good
as
Pnuts, is not nearly as bad (for me) as Groovy.  I was hoping that
BeanShell's user base would take some initiative if I forked the source
and
made it easy to contribute, but unfortunately, this hasn't happened.


Bob Fischer wrote:
>
> BeanShell is known to be pretty slow in general, so  
> that's a big reason NOT to use it for this purpose; one would start  
> building up some routines and then discover that the interpreter is  
> not fast enough to run time.  Then you're kind of stuck.
>

No, then you translate your time-critical routines into Java.  This
should
be painless compared to, say, translating code from Python to C.



> The PySci  
> approach looks promising; I would want to see that it integrates well

> with Java when running under Jython.
>

This won't work because SciPy is based on a big C library and Jython is
pure
Java.

--
View this message in context:
http://www.nabble.com/Hacking-BeanShell-with-JavaCC-tp16715411p16753214.
html
Sent from the BeanShell - Dev mailing list archive at Nabble.com.


------------------------------------------------------------------------
-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/j
avaone
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers