Hi all,
Over the years, I accumulated a fair amount of code and a long
list of wishes, and finally turned them into a new language --
JudoScript (http://www.judoscript.com).
I wish this would spawn some discussions and exchange of
ideas, and in the end you may find it a useful tool.
Thank you all in advance!
-James Huang
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Java APIs + open source provide many of our programming needs;
this same resource can also be used for our daily needs,
because object-orientation is good for at least two reasons:
better software engineering and object scripting.
So I did everything in Java, rarely used shell scripts (not
good at it; never want to be). But I had some problems: Java
APIs are too low-level, they are not efficient for everyday
uses.
Thus, JudoScript was born. Beyond general Java scripting just
like Jython/BeanShell/Rhino/..., it does "new scripting",
defined as:
| Scripting (in computer sense) is to do things easily,
| intuitively, obviously and accurately, so much so that
| when another person with the same domain knowledge sees
| a chunk of code, he immediately understands it without
| even a hint of reasoning (ideally).
|
| Scripting support means very-high-abstraction-level
| language constructs or even domain-specific languages.
The following JudoScript examples demonstrate this definition:
[Example: JDBC Scripting]
connect to 'jdbc:oracle:thin:@host:1521:db',
'dbuser', 'dbpass';
executeSQL {
create table people (
personID int primary key,
name varchar(20) not null
);
create table media (
folderID varchar(512) not null,
fileName varchar(128) not null
);
}
prepare qry:
select name from people where personID=?
;
executeQuery qry with @1 = '01234';
while qry.next() {
println qry.name;
}
disconnect();
[/Example]
[Example: XML Scripting - SAX Style]
do 'some.xml' as xml {
<book>: println $_.title;
TEXT<date>: println ' Date: ', $_, ' (', $_.type, ')';
TEXT<title>: println ' Title: ', $_;
TEXT<author>: println 'Author: ', $_;
TEXT<isbn>: println ' ISBN: ', $_;
}
[/Example]
[Example: SGML Scraping]
do 'http://www.yahoo.com' as sgml {
<a>: if $_.href != null { println $_.href; }
<img>: println $_.src;
}
[/Example]
[Example: Copy Files to Dir or Archives]
copy '*' except '*/alfa, */save/*'
in 'c:/temp/x/' recursive echo
to 'c:/temp/y/';
copy '*' except '*.class,*/alfa,*/save/*,*.zip'
in 'c:/temp/x/' recursive echo
into 'foo.zip'; // or 'foo.tar';
zf = createZip('~~/archives/20011101.zip');
copy '*.h,*.cpp,*.c'
in '/export/dallas/' recursive echo
into zf under 'src/c';
copy '*.java'
in '~~/java/src/' recursive echo
into zf under 'src/java';
zf.close();
[/Example]
[Example: ActiveX Scripting]
sc = createActiveXComponent('ScriptControl');
sc.Language = 'VBScript';
for i=0; i<10; ++i {
println sc.Eval(i @ '+1001');
}
[/Example]
[Example: Run Executables]
exec 'java test.ToLower | java test.Echo'
input { // pump into stdin of the cmdline
println <pipe> 'You should see LOWER CASE!';
}
exec 'java test.ToLower'
needSystemIn
from 'c:/temp'
with ABCDEFG=1234567, PATH="c:\\bin";
output { // read from stdout of the cmdline
for cnt=1; (line = readPipe()) != eof; ++cnt {
println 'Line #', cnt, ': ', line;
}
}
[/Example]
[Example: Send Mail]
sendMail
from: '[EMAIL PROTECTED]'
to: '[EMAIL PROTECTED], [EMAIL PROTECTED]'
cc: more_emails
subject: 'The software. Thank you!'
attach: 'readme.txt, software.zip'
body: [[*
Thank you!
-JudoScript
*]]
htmlBody: [[*
<html><body>Thanks!<br>-JudoScript
</body></html>
*]]
;
[/Example]
[Example: Multi-Theaded HTTP Server]
const #docroot = '~~/docroot';
thread httpHandler(a) {
a.serveFile(#docroot);
}
ss = startServer(8088);
while {
start thread httpHandler(acceptHttp(ss));
}
[/Example]
[Example: HTTP Client]
h = httpGet('http://www.yahoo.com');
for x in h.getHeaders() {
println x, ': ', h.(x);
}
[/Example]
[Example: Java Unit Test]
public class Foo // in file: Foo.java
{
/*[judo]
function ut_sum {
println 'UnitTest: int sum(int[])';
x = javanew Foo;
ia = javanew int[] { 1, 3, 5 };
println 'Is this 9? -- ', x.sum(ia);
println 'For null -- ', x.sum(null);
catch:
$_.printStackTrace();
}
[judo]*/
public int sum(int[] ia) {
int sum=0;
for (int i=0; i<ia.length; i++) sum += ia[i];
return sum;
}
}
/*[judo]
println '[UnitTest: class Foo]';
ut_sum();
println '[/UnitTest]';
[judo]*/
[/Example]
Hope you are not tired reading so much code all at once!
They are available all at once, though.
Install is easy -- drop judo.jar in your classpath and run:
java judo yourscript.judo param1 param2
And this concludes this message.
[Reference]
Home: http://www.judoscript.com
WhitePaper: http://www.judoscript.com/articles/whitepaper.html
Articles: http://www.judoscript.com/articles
Examples: http://www.judoscript.com/examples
Docs: http://www.judoscript.com/ref
[/Reference]
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail
____________________________________________________
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm
Be respectful! Clean up your posts before replying
____________________________________________________
