Lightweight Scripting/Extension Languages? 176
Andy Tai asks: "Extension languages are designed to be embedded in applications to support customization of the application behavior. Common scripting languages, like Perl and Python, are fairly 'large' with powerful run-time engines and libraries and are widely available and 'script' writers usually assume their stand-alone existences in the deployment environment. However, if one is looking for a language that's small enough so its source can be embedded in the distribution of and built as part of the application, Python and Perl may be 'overweight.' For the real lightweight choices there are Lua and Tinyscheme. Are there others? What are people's preferences and opinions regarding lightweight extension languages?"
Anything but odd/new language... (Score:3, Insightful)
Unless there are extremely good grounds for using some annoying new/odd language, use something mainstream.
Re:Anything but odd/new language... (Score:2, Insightful)
Re:Anything but odd/new language... (Score:2, Informative)
Why so many languages? (Score:3, Interesting)
"...learning LUA takes exactly 1 hour."
I couldn't read the reference manual in one hour. I couldn't learn the quirks of co-routines in one hour.
I think there is a big, big misunderstanding about computer languages. The "quick and dirty" ones are incomplete and limited. The complete languages are necessarily complex. At one time, Perl was like Lua. Then it needed this and that until now it is beginning to be as complex as C++. The same will happen with Lua, I'm guessing, if it remains popular.
It
EiC? (Score:3, Informative)
Re:Why so many languages? (Score:2)
Pascal was the most taught language. (Score:2)
Pascal wasn't just any language. It was the most taught computer language in the world at one time. It died within a few years. No one seems to be mourning it. So, how many languages do we really need, if one can die without causing problems?
My vote: Put all the good stuff into one language.
Re:Pascal was the most taught language. (Score:2)
Been there, done that ... it was called PL/I.
It takes great ability... (Score:2)
Re:It takes great ability... (Score:2)
No, anyone can put stuff into a language. The hard part is identifying the 'good stuff'. The creator's of PL/I did a great job of integrating all of the concepts of Fortran, Algol, and COBOL into a single language. Unfortunately, they put ALL of the concepts into PL/I, not just the good ones. So instead of voting to 'Put all the good stuff into one language', why don't you start identifying the g
How could those features be sensibly added? (Score:2)
Why do we have to abandon a language and invent new ones, with new quirkinesses?
Re:Why so many languages? (Score:2)
Fun. Brain excercise. It makes you a better programmer in general even if you don't end up using that language.
I can almost guarantee that if you took any Java/C programmer, taught them some Scheme and Forth, they would end up being a better Java programmer for it.
I'm looking for a permanent relationship. (Score:2)
Re:Anything but odd/new language... (Score:2)
Re:Anything but odd/new language... (Score:2)
Re:Anything but odd/new language... (Score:2)
Yes, it's HUGE, when you're adding it to the software you've written yourself; and it's seriously overkill if you only want people to control a few things inside you're own program.
Take a look at AppleScript [apple.com], a beautifully simple way to control GUI-apps on a Mac.
Re:Anything but odd/new language... (Score:2)
Re:Anything but odd/new language... (Score:2)
No, it is NOT huge. 300 MB is huge, 2-3 MB is peanuts. The loss of efficiency to my brain having to learn a new language is much greater than the loss of efficiency to my computer having to use a couple more megs of RAM. Stop punishing your users.
Re:Anything but odd/new language... (Score:2)
Re:Anything but odd/new language... (Score:3, Insightful)
Also, read this:
Extend vs Embed [twistedmatrix.com]
Often people only think of putting python(etc) inside their program, rather than the other way round - putting their program inside of python. Read the above link.
Re:Anything but odd/new language... (Score:2)
Thinking on the popular applications out there that I know of that embed Python, you wouldn't want to write ANY of them in Python. Blende
Re:Anything but odd/new language... (Score:3, Informative)
say I have a program, written in C, and I want to add full python scripting support.
One way would be to try to add in the python interpreter into the program, and this is the way you immediately think of.
The second way would be to have a small python program that calls your program (so all you rewrite in python is your main() function and the function that does event handling.)
The link I provided gives reasons on why they consider the second way better.
Re:Anything but odd/new language... (Score:3, Informative)
This is old enough it will probably never be read, but that isn't true. There are utilites that do this in a snap, in addition to findi
Re:Anything but odd/new language... (Score:3, Insightful)
One thing I would strongly urge, is to pick a "real" language that already exists. Ideally, something like those listed below. Even if it's a fairly
Re:Anything but odd/new language... (Score:2)
* Scheme, due to it's small size and powerful, easily extendable syntax, seems to be quite common when it comes to extension langauges. A list of programs that use Scheme (or a similar lisp dialect) off the top of my head includes: SIAG Office, The Gimp, Emacs, TeXmacs, Gnumeric, AutoCAD, Sawfish, GnuCash, Snd Sound Editor, etc.
Well, add Cadence (one of prolly 2 or 3 top-notch IC (ASIC) design suites, sellable to the tune of couple 100,000/seat) to the list, and take AutoCAD off (it's not really Scheme,
There's nothing wrong with Python anyway. (Score:2)
There's no reason *not* to use Python for your embedded scripting, IMO.
Re:There's nothing wrong with Python anyway. (Score:2)
It's 800k on windows, BTW.
Guile (Score:4, Informative)
Re:Guile (Score:3, Funny)
Re:Guile (Score:1, Redundant)
TinyTCL (Score:3, Informative)
Its easy to learn and use (very good if the people using our embeded language are not programmers). Its mature, supposed to be extensible, and if you decide you need something more powerful later on even the current full verion is not that bloated.
Re:TinyTCL (Score:5, Informative)
Tcl/Tk [www.tcl.tk] proper is not a bad idea either. If one does not need the GUI part (Tk) then Tcl is relatively easy to integrate into a project, and is under 200k.
HowToEmbed [wiki.tcl.tk] from the Tcl Wiki is a good starting point, and MkTclApp [hwaci.com] may help.
Tcl has very consistent and simple syntax (although it can get rather confusing at times), and it is very simple to add new command into your application that are exposed via Tcl. One of the nicest aspects of Tcl is that is it seriously multi-platform.
Of course this all depends on the requirements: how powerful does the language need to be, what functions must it provide, what types do you need it to be able to handle, how small is "lightweight", etc.
Re:TinyTCL (Score:5, Informative)
Another nice aspect of Tcl is that it can easily evaluate code in a different stack frame (example: in the caller's context), and source code can be easily passed to procedures as strings between braces (as it is usually done), so extending/reimplementing the language control structures is as simple as writing a new procedure (and no special/ugly syntax is required).
That's as close to Lisp macros as you can get.
Re:TinyTCL (Score:2)
YMMV, of course, but I prefer a language with real control str
How much do you need? (Score:2, Informative)
Just how much customising do you need?
From my experiance if you only need a little customisation then you can do most of that stuff from a config file, .ini if you want it to be easy to edit, xml if your going to write a gui to do it or your users are compertant. Any more than that your better off going with something like python or perl, they are widely known, and have rich libraries to let the people using the app do some really imaginative things.
The other thing that you can do is write your app in
COM interfaces and stuff like it (Score:3, Informative)
COM/ActiveX works swimmingly in this regard in that you have a choice of languages for both producing and consuming COM/ActiveX components, and COM allows you
Re:COM interfaces and stuff like it (Score:2)
For many organizations, the issue is hiring and efficient staffing. If you have 7 languages, but you can only find programmers that know 3 of them, then you can only use those programmers for some of your projects. They go without work while you can't even find staff for some of your other projects.
The place where
5 teams and 7 languages (Score:2)
SUN and Java i
The need for "extension languages" (Score:5, Insightful)
I can see why you might want to stay with C/C++ for a major commercial application (not because of speed reasons, but because the maturity of the implementations of alternative high-level languages) but it pains me to see tons of OSS software, especially non-speed-critical GUI apps, still being written in C!
Re: (Score:2, Funny)
Re:The need for "extension languages" (Score:2)
Re: (Score:2)
Re:The need for "extension languages" (Score:2)
I'm not the original poster, but I do agree that C gets in the way in many situations.
For example, consider implementing a sort algorithm, say, quicksort. Ideally, you only want to implement it once (e.g. using C's qsort()). However, comparison and swap operations for different types (e.g. integers vs structs) are quite different, and in some cases (e.g. integers or floats) can be made quite cheap. So if it matters, you definitely want to opt
Re:The need for "extension languages" (Score:2)
In the interests of balance, here's the same workplace as seen from the Python programmer's point of view:
Re:The need for "extension languages" (Score:4, Insightful)
- C is entirely serially, and the compiler has to infer paralellism from the code. Modern hardware is significantly parallel.
- C is entirely memory-based, while modern hardware does everything it can to avoid referencing memory.
- C has no primitives to describe branching, to aid things like speculative execution.
- C has no vector types, while most modern processors have vector units.
etc,etc,etc.
C has a very nice, simple machine model, but C programmers don't really understand what the computer is doing "under the hood."
Re:The need for "extension languages" (Score:2)
Re:The need for "extension languages" (Score:2)
Re:The need for "extension languages" (Score:2, Interesting)
However, when it comes to statically type checked, non-C/C++ languages on Linux, there isn't much choice:
Re:The need for "extension languages" (Score:2)
java could and *should* have been it, but as you say, some idiotic design de
Re:The need for "extension languages" (Score:3, Insightful)
I don't see how the need for an extension language indicates that at all. An extension language (IMHO) is usually needed so that the end user of the application can script that app and extend it to do things you, the application engine writer, did not supply. The needs of the engine and the needs of the extension language are totally different.
I'm going to want to write the engine to be fast,
efficient, and easy for me to maintain. The extension m
Re:The need for "extension languages" (Score:3, Informative)
1. scripting languages speed development
2. high-level code does not need to be optimized
Then for an app like Neverwinter Nights, it would make sense to use a scripting language for the high-level code (e.g. menu handling code), while leaving the performance-critical code (e.g. 3-D rendering) in C, C++ or assembler.
Coded like this, NN might not crash as frequently because either
- The crashy code would be implemented in a scripting language, and so memory handling would not be
Re:The need for "extension languages" (Score:2)
Re:The need for "extension languages" (Score:2)
Any code can be optimized, but the question is whether it should. Code optimization (as opposed to compile-time optomization) should only be done where it has a noticeable impact on performance. Most code does not have an obvious impact on performance, and so it should be left alone, so it's more readable.
If your high-level code has a significant performance impact, it may not be as high-level as you believe.
Re:The need for "extension languages" (Score:2)
Re:The need for "extension languages" (Score:2)
Re:The need for "extension languages" (Score:3, Informative)
In contrast, there are many high-level languages like Common Lisp, Dylan, Scheme, ML, Ocaml, etc, that have very powerful native compilers. They do optimizations that C/C++ compilers simply cannot do, because of the low-level C memory model. Literally decades of research has gone into making these compi
Re:The need for "extension languages" (Score:2)
However... then we get into a situation where the programming team has to ask themselves:
- Do we know the language well enough to program in it without increasing our development time?
- If not, would the increase in time on this project end up benefitting us on the other projects in the pipeline? (Do we even have a 'pipeline'?)
- Do we know
Re:The need for "extension languages" (Score:2)
Javascript! (Score:5, Interesting)
Re:Javascript! (Score:5, Informative)
And btw, ECMAScript/JavaScript can be pure functional as well.
s-lang (Score:2)
ICI (Score:4, Interesting)
It's sufficiently C-like to suit anyone who has done C/C++/Java/Perl/... but high level enough to be a feasible extension language.
Of course it depends on what type of person you expect to use your extension language. Are they programmers?
paxscript (Score:2, Informative)
it's the most complete and quickest of any embedded source stuff that we've investigated.
supports basic, c, objectpascal (ie delphi) and javascript.
not free, but you get the source when you purchase it (US$179).
delphi and borland c++ builder only.
Re:paxscript (Score:2)
REBOL (Score:3, Informative)
didn't see anyone else mention it, so i thought i would.
REBOL [rebol.com] is a ridiculously simple and easy-to-learn web-oriented language. so easy, in fact, that i wrote a fully-functional IRC dice bot in under 400 lines, overnight. and if that weren't impressive, then might i add that i was running on ZERO caffeine, learning the language for the first time, learning IRC Client protocol for the first time, and came up with a few unusually witty statements and insults to boot?
now the bad part: REBOL is not open source. poo. (i really was a bit disappointed.) but REBOL/Core is free (for any use, i gather), and the license fees for View and Command seem rather reasonable.
the nice part: it has been ported to and runs on about 43 platforms, last i checked, and is light enough that the executable weighs in at around 250kb for the win32 release. (haven't used the other platforms, so no comment.)
it runs on just about every unix i've heard of, on every relatively common configuration, and works beautifully and seamlessly. and, after a quick glance, i see it runs on serveral major embedded systems, including WinCE, QNX, and Linux, and will even run on my friend's dated Amiga.
enjoy and happy coding.Re:REBOL (Score:4, Informative)
And.. Finally.. How does one embed REBOL in an open source application?
Re:REBOL (Score:2)
But I too have had the same guilty-love of REBOL. It is a very capable and handy language, definately one of the more useful so-called "scripting" languages I've ever seen or used.
Other than this, there is no way to embed REBOL in an app directly, though you could call the interpreter over a pipe. Yo
Developing for windows? (Score:5, Informative)
Object Forth? (Score:5, Informative)
A portable object oriented forth at less than 100K for a full implementation, able to handle calls from your apps as well as call your apps fgunctions or other dll's.
Under a BSD-ish license.
The upside:
1) Its tiny
2) The forth code you write will be tinier
Downsides:
1) You need to learn forth (I mean properly) to appreciate it.
Forth is unlike most other languages, it was designed to avoid the debug, recompile cycle that is so common.
Sam
Re:Object Forth? (Score:2)
Forth, unlike most other compiled languages, reduces the length of each iteration of the edit, compile, debug cycle by making it possible to edit definitions in an application interactively.
In many Forths, there is most definately a compile step, but it happens so quickly, it is easy to miss.
Re:Object Forth? (Score:2)
Yes, and with forth you get to alter the compiler.
Oooh, scary!
Sam
Re:Object Forth? (Score:2)
Forth is as ugly as mechano
Sam
How about JavaScript? (Score:5, Informative)
Re:How about JavaScript? (Score:2)
Re:How about JavaScript? (Score:2)
Rich.
Re:How about JavaScript? (Score:2)
Re:How about JavaScript? (Score:2)
Rich.
Re:How about JavaScript? (Score:2)
I think Boost.Python [boost.org] does what you're asking.
Re:How about JavaScript? (Score:2)
Re:How about JavaScript? (Score:2)
1. The kjsembed library provides access to the existing objects with no (repeat *no*) need for the host app to write any extra code. ie. it can extend apps that were not intended to support this stuff (though obviously it is better if they are).
2. A huge proportion of kde apps already link kjs via either khtml or via kdeinit. This adds no extra overhead (rather than a large python interpreter).
3. We would have huge version skew problems because the distros (and us
Re:How about JavaScript? (Score:2)
If the bindings are already there, why couldn't this be extended to another language as well?
2. A huge proportion of kde apps already link kjs via either khtml or via kdeinit. This adds no extra overhead (rather than a large python interpreter).
Python can work
Copy of an advogato article (Score:4, Informative)
http://www.advogato.org/article/735.html [advogato.org]
It would be useful if he could state what his requirements and limits are, in detail, because that's a very necessary part of evaluating what would work.
Why another language? (Score:5, Insightful)
Well you're not obligated to provide the libraries. For instance, Blender, which uses Python, did not include Python libraries ; however it was possible for people which really wished it, to set paths to point to libraries. Forcing the users to learn a new language, just to cut the size of the distribution is misguided IMHO. Just provide the extension language (& support) as an optionnal individually downloadable shared library.
Consider Ruby (Score:3, Informative)
see the Ruby book [rubycentral.com] (section Embedding a Ruby Interpreter
Depends on the host programming language and OS (Score:3, Interesting)
On Windows you likely will use Visual Basic for Applications or Visual Basic Script or any other Active Scripting language.
If you write ONLY Java, like I do in our days, its easy: the scripting language will be either Java(Dynamic Java, see: http://koala.ilog.fr/djava/ or Bean Shell, aka bsh, see: http:www.beanshell.org) or Java Script, aka Rhino, see: http://www.mozilla.org/rhino/ or any other language running on a JVM see: http://grunge.cs.tu-berlin.de/~tolk/vmlanguages.h
If you write your program ina C-ish language I would consider to use CORBA --- yes indeed!! --- to be able to script it with everything.
If you want to use traditional scripting languages like TCL, PERL etc. you likely will want to look into SWIG, see: http://www.swig.org.
But
The bigger your applicatin gets, the more complex will be the access layer for the scripting languages.
When you have reached that point you likely regret not to have used something more suiteable, like CORBA or the Java stuff I sketched above or you are to the point where you throw it away and rewrite it in a "embed" approach where you will use a scripting language as development language and write certain modules as plugins into that language.
Then however you are bind to the scripting language as host language.
BTW: there are a lot of free mini orbs which make CORBA a toy. And writing IDL is not much harder than writing SWIG config files. If you like to shield your customer from CORBA give him a lib for his scripting language, which hides the fact that CORBA is used.
Regards,
angel'o'sphere
forgot for Java... Tcl (Score:2)
You forgot a big one: Tcl. There is a pure Java Tcl interpreter Jacl [www.tcl.tk]. It's trivial to embed and use. I've used it to add scripting to tools, and t
Perl 4 (Score:2)
I can think of a couple of big, $$ applications that embed it.
Nasal, a javascript-like language (Score:3, Informative)
LUA (Score:2, Informative)
Nasal (Score:3, Informative)
When I was answering this question, I ended up looking at nasal [plausible.org]. While not perfect, it was the closest to what I wanted ... and was under a compatible license (LGPL). But then I wanted something small, lua is way too big.
Re:Lua too big? Are you on crack? (Score:2)
And it's much easier to tweak n
TCL! (Score:2)
Small (without the Tk part), multi-platform, truly interpretive, and created to be embeddable. From John Ousterhout's introduction to his book [amazon.com] about his language:
Re:!!TCL (Score:2)
And so does Unix -- if you listen to Windows zealots -- the 1970-ies technology...
Yes, and penguins are pretty ugly creatures. It is a matter of perception and -- as you mention -- partiality.
SWIG can generate TCL wrappers (and Python, and Perl) just as well. TCL, however, was created to be embeddable. And its syntax allows for eas
I'm doing this with Ruby (Score:2, Interesting)
Ruby is also easy to embed as well, but we decided to use swig to wrap our C++ classes so that they're accessable from Ruby and then script the whole thing in Ruby. This offers several advantages for our application since we wanted to allow users
LISP? (Score:2)
Check out Ferite (Score:4, Informative)
I love that it was designed from the Start to be Thread Safe and Embeded, unlike PHP or Python.
Extensions and Spammers..... (Score:2)
Now the serious comment... (Score:2)
Re:Io, Groovy (Score:2)
Re:Freedom Force (Score:2)