Subscribe to Abgorns Blog of Doom!        RSS Feed
-----

Scripting and You

Icon 1 Comments
Have you ever coded in a scripting language? Be it Python, Ruby or even Beanshell, they're really handy. They can be used for a wide variety of things like GUI, Job Control, text processing, etc programming. They make life easier for you and I; the working people. Groovy is my favourite scripting language because it has simple commands that do alot the work for you and with that you can shorten regular Java code from 50 lines to less than half the size.

But one thing I'd love to see is more scripting languages that are powerful and simple. I really like Batch for that reason, I can add output with the echo command and it's simple as that. Save, run and the job's done! I've recently been thinking about scripting languages and how they work and it's surprising how easy they are to make a simple one. It only really consists of four parts: The parser, syntax models, interpreter and compiler (the last two depends). Here's what each do (the hypothetical language is called Grinch witch doesn't need an interpreter):
The Parser:
This takes the source files (in this case .grinch files) and turns the commands/statements/methods/etc into the language of choice e.g Grinch: display:Hi = Java:System.out.print("Hi\n");
This is done in one of two ways: The first uses a loop to read/change line-by-line. The other uses a tokenizer method witch searches for words individually and changes them.

Syntax Models:
A well-defined list of commands and their exceptions along with what they should be replaced with.

Compiler:
Takes the .java file witch has been changed from a .grinch file (thanks to the parser) and compiles it into an executable Java file.

When you break it down anyone can do it, I'm personally thinking of creating my own scripting language with a little bit of everything for my needs. I haven't yet decided a name (please don't take Grinch because that's a candidate) but I hope you enjoy it when it's done.

Thanks for reading! :)
Paul Kenny

1 Comments On This Entry

Page 1 of 1

Raynes 

17 April 2009 - 05:38 AM
I bet Clojure could shorten it even more. I wouldn't be surprised if Scala could too, but I'm not vouching for it as it has a rather noisy syntax.
0
Page 1 of 1

Recent Entries

7 user(s) viewing

7 Guests
0 member(s)
0 anonymous member(s)