Any comments? It seems to borrow some stuffs from Ruby, like closure
(which is very much like Ruby’s block), the =~ regex matching operator,
and even the “Principle of Least Surprise”. But syntax-wise it’s
basically a mixture of Python, Ruby, and Java. It has some stuffs that
Ruby doesn’t currently have like keyword arguments, easier embedding,
and native threads, but it’s still not Ruby
yes, It seem many rubyist are even groovytes. If you look in the
groovy wiki you may find even matz’ quotes
It seems to borrow some stuffs from Ruby, like closure
(which is very much like Ruby’s block),
actually they get the whole block/yield syntax
the =~ regex matching operator,
and even the “Principle of Least Surprise”. But syntax-wise it’s
basically a mixture of Python, Ruby, and Java. It has some stuffs that
Ruby doesn’t currently have like keyword arguments, easier embedding,
and native threads, but it’s still not Ruby
even GPath is cool. But mostly I love the key: value syntax for
hashes. Luckily we’ll see it in ruby soon
I think is interesting that groovy received a much better acceptance
from java people than, say, jruby or jython. I believe that somehow
relates to the number of { and }
Any comments? It seems to borrow some stuffs from Ruby, like closure
(which is very much like Ruby’s block), the =~ regex matching operator,
and even the “Principle of Least Surprise”. But syntax-wise it’s
basically a mixture of Python, Ruby, and Java. It has some stuffs that
Ruby doesn’t currently have like keyword arguments, easier embedding,
and native threads, but it’s still not Ruby
it looks cool. and it might improve the productivity for java programmers.
I like java a lot but everytime I port one of my Java programs to Python or
Ruby I am annoyed about how much I have to type in Java (System.out.println
vs. puts/print, or opening and printing a file).
so this might be a great addition to the java developer’s toolbox.
only future will tell if this will be a huge success or not.
Any comments? It seems to borrow some stuffs from Ruby, like closure
(which is very much like Ruby’s block), the =~ regex matching
operator, and even the “Principle of Least Surprise”. But syntax-wise
it’s basically a mixture of Python, Ruby, and Java. It has some stuffs
that Ruby doesn’t currently have like keyword arguments, easier
embedding, and native threads, but it’s still not Ruby
borrow some stuff<<- seemed to me it borrowed a lot, i was
surprised at how much.
gabriele renzi wrote >>number of { and }<< and semi colons too - i
really miss those
markusjais@yahoo.de wrote: >>only future will tell if this will be a
huge success or not<< my guess is that it will be a big success as
scripting languages supplant compiled ones as biz decision makers begin
to see that you can get real work done with them in less time. this is a
good thing for ruby, me thinks, as there are so many java shops who
could benefit from groovy immidiately and get them thinking of script
languages for real work. if i were a java guy(or mgr) i’d be all over it.
markusjais@yahoo.de wrote: >>only future will tell if this will be a
huge success or not<< my guess is that it will be a big success as
scripting languages supplant compiled ones as biz decision makers begin
to see that you can get real work done with them in less time. this is a
good thing for ruby, me thinks, as there are so many java shops who
could benefit from groovy immidiately and get them thinking of script
languages for real work. if i were a java guy(or mgr) i’d be all over it.
It is certainly easier to use than Java (I write Java code for a living,
and I’ve played with Groovy), but the already-resource-hungry Java
environment becomes even more so when using Groovy. Groovy does not use
any of Java’s primitive types–everything is an object, which means
ints, etc. all get boxed into Integer objects. This means iteration
over a range is MUCH slower in Groovy than in Java. I was, frankly,
very disappointed when I discovered that, since I would otherwise have
started using Groovy in a heartbeat, and told my supervisors about it
after I’d already snuck Groovy apps into production.
Any comments? It seems to borrow some stuffs from Ruby, like closure
(which is very much like Ruby’s block), the =~ regex matching operator,
and even the “Principle of Least Surprise”. But syntax-wise it’s
basically a mixture of Python, Ruby, and Java. It has some stuffs that
Ruby doesn’t currently have like keyword arguments, easier embedding,
and native threads, but it’s still not Ruby
it looks cool. and it might improve the productivity for java programmers.
I like java a lot but everytime I port one of my Java programs to Python or
Ruby I am annoyed about how much I have to type in Java (System.out.println
vs. puts/print, or opening and printing a file).
so this might be a great addition to the java developer’s toolbox.
only future will tell if this will be a huge success or not.
One interesting thing about Groovy is the GString class, which exposes
the process of string interpolation to the programmer. We can extend
this class to modify the behaviour of interpolation. This probably will
be more interesting if implemented in Ruby because we can modify the
existing builtin class, so for example we can change String so that all
interpolation is HTML-escaped. This will become a very good protection
for cross-site scripting.
All of the web tools/template processor I’ve worked with, including PHP,
Perl’s HTML::Mason, Embperl, etc. unfortunately it seems that only
Embperl puts an emphasis on escaping. By default, all strings output
will be HTML-escaped or URL-escaped, depending on the context.
If more tools were like this, then the occurence of SQL injection,
cookie theft, and all that silly website deface could be reduced
dramatically. Currently many many applications are vulnerable to XSS,
the big offender being PHP and Perl/CGI scripts, but big apps like
Oracle Suite are once vulnerable too.
It’s more a matter of focus. JRuby and Jython are focused on porting an
entire language Java platform, each with their own standard libraries.
They talk to the Java libraries, but they feel more comfortable with
‘their own kind’. Groovy doesn’t have the baggage of its own standard
library, and thus feels more natural for a Java programmer who wants to
use a more dynamic language to interact with existing Java libs.
Charles
···
On 17/03/2004, at 7:09 PM, gabriele renzi wrote:
I think is interesting that groovy received a much better acceptance
from java people than, say, jruby or jython. I believe that somehow
relates to the number of { and }
One interesting thing about Groovy is the GString class, which exposes
the process of string interpolation to the programmer. We can extend
this class to modify the behaviour of interpolation. This probably will
be more interesting if implemented in Ruby because we can modify the
existing builtin class, so for example we can change String so that all
interpolation is HTML-escaped. This will become a very good protection
for cross-site scripting.
All of the web tools/template processor I’ve worked with, including PHP,
Perl’s HTML::Mason, Embperl, etc. unfortunately it seems that only
Embperl puts an emphasis on escaping. By default, all strings output
will be HTML-escaped or URL-escaped, depending on the context.
If more tools were like this, then the occurence of SQL injection,
cookie theft, and all that silly website deface could be reduced
dramatically. Currently many many applications are vulnerable to XSS,
the big offender being PHP and Perl/CGI scripts, but big apps like
Oracle Suite are once vulnerable too.
I considered similar idea for similar needs. However I found that it
can be used for various purposes other than sanitizing.
For example, gettext can know literal part of “…#{…}…”. This
makes possible to use only literal part as a key for i18n message
dictionaly. This eases i18n application development.
Another example is confusing String#gsub’s 2nd argument. gsub can
interpret “…#{1}…” as ‘…\1…’. This avoids confusing escape
mechanism.
Another example is confusing String#gsub’s 2nd argument. gsub can
interpret “…#{1}…” as ‘…\1…’. This avoids confusing escape
mechanism.
I’d like to see it in Ruby. RCR?
With oniguruma (Rubys new regexp engine) you can use named backreferences.
But that is not what you ask for.
Another possibility would be to pass a block to gsub
str.gsub!(/(\s\w)(\w+)(\w\s)/) do |m|
$3 + $2 + $1
end
And then use $1…$9, but it seems more complex.
BTW: Why is ‘m’ of class String. It would be nice if it were
an instance of MatchData. If it had been a MatchData object,
then the following piece would have worked.
str.gsub!(/(\s\w)(\w+)(\w\s)/) do |m|
m[3] + m[2] + m[1]
end
···
On Wed, 24 Mar 2004 20:50:17 +0900, Tanaka Akira wrote:
With oniguruma (Rubys new regexp engine) you can use named backreferences.
For named capture, “…#{:foo}…” can be used as
gsub(/…(?…)…/, “…#{:foo}…”). Anyway it avoids
backslash escape in the argument.
But that is not what you ask for.
Yes. This is another issue. However I considered it too.
Another possibility would be to pass a block to gsub
str.gsub!(/(\s\w)(\w+)(\w\s)/) do |m|
$3 + $2 + $1
end
And then use $1…$9, but it seems more complex.
Yes. gsub’s block avoids the confusion.
However, people tends to gsub without block because it seems simpler.
BTW: Why is ‘m’ of class String. It would be nice if it were
an instance of MatchData. If it had been a MatchData object,
then the following piece would have worked.
str.gsub!(/(\s\w)(\w+)(\w\s)/) do |m|
m[3] + m[2] + m[1]
end
I think a regexp with named capture should binds local variables.
It makes possible to describe your example as follows.
following suggestion from flgr on #ruby-lang it would be nice to have
gsub yielding a MatchData with to_str defined to still allow stuff
like
str.gsub(rgx) do |m|
‘str’+m
end
···
il Wed, 24 Mar 2004 22:48:29 +0900, Tanaka Akira akr@m17n.org ha scritto::
BTW: Why is ‘m’ of class String. It would be nice if it were
an instance of MatchData. If it had been a MatchData object,
then the following piece would have worked.
str.gsub!(/(\s\w)(\w+)(\w\s)/) do |m|
m[3] + m[2] + m[1]
end
On Wed, 24 Mar 2004 14:29:06 +0000, gabriele renzi wrote:
il Wed, 24 Mar 2004 22:48:29 +0900, Tanaka Akira akr@m17n.org ha
scritto::
BTW: Why is ‘m’ of class String. It would be nice if it were
an instance of MatchData. If it had been a MatchData object,
then the following piece would have worked.
str.gsub!(/(\s\w)(\w+)(\w\s)/) do |m|
m[3] + m[2] + m[1]
end
following suggestion from flgr on #ruby-lang it would be nice to have
gsub yielding a MatchData with to_str defined to still allow stuff
like