From: "Tristan (kesuari)" Date: 2003-08-24T20:02:04+09:00 Subject: Re: Why did you switch from Python to Ruby? Rudolf Polzer wraet: > Scripsit ille aut illa �Doug Kearns� : > >>http://groups.yahoo.com/group/judoscript/message/295 > > > What does stand there? I get a cyclic redirect. > > Copy-paste with selected headers. Date: Fri, 22 Aug 2003 19:39:08 -0000 To: judoscript@yahoogroups.com Subject: JudoScript is great for hacks! (#1) Message-ID: User-Agent: eGroups-EW/0.82 X-Mailer: Yahoo Groups Message Poster From: "j2geek" .... I just wanted to be the first one to say it... Please allow me to gush at length about JS for a moment. After playing w/ JudoScript for about a week I am astonished at the power of JudoScript. James, this language has such incredible potential it's mind boggling. I'm going to be dedicating at least 25% of my development to JudoScript, and am abandoning ruby (which superseded perl) for JS as my default scripting language. And James, I'm not even talking about JS as a scripting language in your sense of #2 or #3, although I will write about that in future posts. JudoScript qua a general purpose scripting language is exceptional. Let me offer an example from the programming language shootout: a simple version of the unix 'wc' command. Here is my JS version, w/ thanks to Brendan for his RegEx patch, along with the Ruby, Perl, and Python versions (yes, I know, there are slight differences between mine and the others): -----------wc.judo----------------------------- do #args[0] as lines { ::lines++; ::words += $_.split('\\S+').length(); ::chars += $_.length; } .. lines, ' ', words, ' ', chars; -----------wc.python----------------------------- import sys def main(): nl = nw = nc = 0 rl = sys.stdin.readlines lines = rl(4096) while lines: nl += len(lines) for line in lines: nc += len(line) nw += len(line.split()) lines = rl(4096) print "%d %d %d" % (nl, nw, nc) main() ------------wc.ruby--------------------------------------- nl = nw = nc = 0 loop do data = (STDIN.read(4096) or break) << (STDIN.gets || "") nc += data.length nl += data.count("\n") ((data.strip! || data).tr!("\n", " ") || data).squeeze! nw += data.count(" ") + 1 end puts "#{nl} #{nw} #{nc}" ------------wc.perl---------------------------------------- use strict; my($nl, $nw, $nc); while (read(STDIN, $_, 4095)) { $_ .= ; $nl += scalar(split(/\n/)); $nc += length; $nw += scalar(split); } print "$nl $nw $nc\n"; ----------------------------------------------------------- Not only is the judoscript version the most terse, it's also seems to me to be the most intuitively obvious. Okay, I admit that the use of .. and :: aren't as clear as 'println' or explicitly declaring the variables in the global scope, but they are "the judo way". Which bring me to a couple random other thoughts: 1- Have you considered dropping "script" from JudoScript, and just calling it "Judo"? It lends itself to metaphor, much like Java did (beans, cafe, hot spot, etc..). This is strickly a marketing issue. Would Java have been Java if it remained "Oak"? 2- Have you thought about a convenience syntax for printing variables within quoted text? (maybe even, (yuck!) printf style (yuck!)? Don't follow ruby here: Ruby's interpolation is too hard to type "#{}". I'd rather stick with "'',". Has anyone seen a really great in-quotes interpolation syntax that could be co-opted? Anyone got a great idea here? 3- Have you considered using both ';' and '\n' (line ends) as terminators? This allows semis to be optional in standard "one line one expression" style coding. Lovin' JS, Jake (aka J2gEEk) --End Quote -- Tristan.