Simple scripting language
started 4/4/2004; 6:28:02 PM - last post 4/7/2004; 2:10:55 PM
|
|
andrew cooke - Simple scripting language
4/4/2004; 6:28:02 PM (reads: 360, responses: 10)
|
|
What's the simplest scripting language? By simplest, I mean easiest to implement an interpreter for. Obviously, there's going to be a trade-off between simplicity and power, but what wins out despite that? I suspect it's tcl or scheme.
I've just been reading R5RS and it's fairly complicated. Has anyone defined a subset of Scheme that is simpler to implement, but which could be extended if required (ie might include guidelines for implementation to avoid traps later)?
|
|
Darius Bacon - Re: Simple scripting language
4/4/2004; 8:57:06 PM (reads: 358, responses: 2)
|
|
"What's the simplest scripting language" amounts to "What's the least you're willing to get by with?" I have a Forth derivative in about 1500 lines of C that I use to add programmability to random C programs (so you don't have to write custom config file parsers and such). It works for that, but nobody will ever mistake it for Haskell.
A minimal R4RS Scheme without the macro appendix weighs in at about 5000 lines, part C and part Scheme.
|
|
Ehud Lamm - Re: Simple scripting language
4/5/2004; 4:16:45 AM (reads: 332, responses: 0)
|
|
I posted links to a few cool Scheme interpreters in the past (including a cool Javascript hack). Another project that's worth a look is SIOD.
|
|
andrew cooke - Re: Simple scripting language
4/5/2004; 5:18:10 AM (reads: 342, responses: 1)
|
|
i'd forgotten forth, but is it still a win if you're writing an interpreter rather than a compiler? i guess so. hmmm. thanks!
[edit: google led me from forth to joy, which appears to have an ml implementation already (what i needed). brilliant!]
|
|
Darius Bacon - Re: Simple scripting language
4/5/2004; 1:04:46 PM (reads: 299, responses: 0)
|
|
Oh yeah, Lua's pretty small, too, and Norman Ramsey wrote an ML implementation. It's not nearly as odd as Joy, but you can't have everything. :)
|
|
Neel Krishnaswami - Re: Simple scripting language
4/5/2004; 3:48:41 PM (reads: 293, responses: 1)
|
|
What language are you implementing in? It seems to me that the core interepreter should fit into a couple of hundred loc, but that you can spend arbitrarily many loc adding utility functions. If you've got strings, functions, numbers, lists, hash tables, files and regexps, then you've got yourself a modern scripting language. But really, how many reinventions of Scheme does the world need? Just go ahead and pick one and use it. [Actually, looking at the responses, it seems that you've already chosen Joy. Good for you, and even I must admit it's not Scheme in drag.]
If you did want to write a new scripting language, I urge would you to go in a different direction. People have Scheme (or Lua, or Python) already. My suggestion: build a language around the twin ideas of transactions and constraint/logic programming. Use transactions -- with the usual delimit-transaction/commit/rollback primitives -- and make sure that your IO operations (like reading/writing files) are transaction-aware. Then, add some logic programming primitives, in the spirit of Prolog. If you're feeling really ambitious, throw in a Presburger arithmetic solver too. Now you can write fairly substantial scripts in a very declarative style. Your "IO" operations can be written in the obvious way but will only get committed in the right order, no matter how the constraint solver finds a solution, because they have a transactional semantics.
Since it's novel, it's virtually certain the design would contain mistakes and crocks. But at least they'd be cool and interesting mistakes, rather than old and boring ones. :)
|
|
Luke Gorrie - Re: Simple scripting language
4/6/2004; 1:06:04 AM (reads: 252, responses: 0)
|
|
Novel? What's novel about make ? ;-)
Okay, not really, even with GNU extensions. But close?
|
|
andrew cooke - Re: Simple scripting language
4/6/2004; 3:20:42 PM (reads: 216, responses: 0)
|
|
thanks for the encouragement :o)
i just want something to fix together some code written in ml. at the moment it looks like i'll write a stack based language or use the joy interpreter i found. i'm thinking of adding pattern matching to joy, which would make reading the programs a bit easier on my eyes.
|
|
Frank Atanassow - Re: Simple scripting language
4/7/2004; 12:22:32 PM (reads: 165, responses: 2)
|
|
andrew: What's the simplest scripting language?
What distinguishes a scripting language from an ordinary programming language?
If I need a `simple' programming language as an example, I usually use something close to
the Q language, that is, a first-order functional language with call-by-value semantics, where a program is just a set of recursive equations (plus a term to evaluate). PCF (see any decent PLT textbook) is also a commonly cited as a `simplest possible' programming language.
If your ML supports dynamic linking, you might just consider using the embedding of untyped typed languages which I showed once.
|
|
andrew cooke - Re: Simple scripting language
4/7/2004; 1:12:58 PM (reads: 164, responses: 0)
|
|
What distinguishes a scripting language from an ordinary programming language?
yeah, any language would do. i'm less bothered about "programming in the large" which might mean namespaces, libraries, compilers, i guess. although i'm thinking of adding namespaces to joy (or whatever i understand by joy, twisted by various ideas that are currently fighting it out in my head).
however, i had a look at q and it's pretty neat. thanks. also, i need to go back and read that post about embedding, because i skipped it at the time.
|
|
andrew cooke - Re: Simple scripting language
4/7/2004; 2:10:55 PM (reads: 158, responses: 0)
|
|
it turns out that i posted about q here years ago! in the same post i mentioned the haskell companion. the link was a pretty printer or similar. now today i am looking at the q site and see it mentions the same pretty printer, which reminded me of jan skibinski and the haskell companion (which disappeared off the net some time way back when).
anyway, it turns out that jan skibinski has spent the time working on konka - the same site has links to much of his old stuff via the wayback machine, including the haskell companion. hurray!
(i've never emailed or talked to the guy, but he disappeared so suddenly it was worrying - various people commented on it. good to see he's reappeared.)
|
|
|
|