Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Given that a program (under development) needs a scripting language, and that for various reasons it's not possible to use an off-the-shelf one as is, I'm considering basing it on the syntax and some of the semantics of JavaScript, being something pretty much everyone is familiar with, including using the .js file extension so that e.g. editors will know how to syntax highlight scripts.

It's necessary to make some changes anyway, for certain technical reasons. It strikes me as reasonable to make some other changes that most people would consider improvements. For example, eliminating the 'semicolons are optional' rule that sometimes trips people up, and making a block within a function a new lexical contour. But I'm not certain this is what most people actually want. So of the following options:

  1. Stick as close to JavaScript as I possibly can, even aspects of it that everyone agrees are mistakes in and of themselves, deviating only when technical considerations make it absolutely necessary. (There is no question of being able to use existing JavaScript code in any case, I'm talking purely about the benefits of familiarity from the user's viewpoint.)

  2. Go with the plan currently under consideration, make something that looks pretty much like JavaScript but differs in various regards.

  3. All or nothing, if I can't use actual JavaScript, create a new scripting language that is visibly completely different (e.g. not C-style syntax) so there's no possibility of confusing it with JavaScript.

Which option would generally be considered preferable? Is there a fourth option I'm missing?

share|improve this question
Please elaborate: Why can't you use an existing scripting language? Are you creating a custom DSL? Can't it be expressed nicely with existing scripting languages? –  Falcon Aug 25 '11 at 14:29
I'm creating a general inference engine for NP search problems; among other things it has to do total introspection, perfect sandboxing and transparent distribution of workloads across machines, all in problem domains where being out of memory is a permanent condition. No existing scripting language can do all that. –  rwallace Aug 25 '11 at 14:39
Have you considered tcl? –  Bryan Oakley Aug 25 '11 at 20:08
add comment

1 Answer

up vote 4 down vote accepted

If you have to write your own scripting language, I wouldn't decide to write it similar to another one only because it's something already seen and programmers are familiar with.

First you have to consider the needs of this scripting language: Is it needed to make complex code structures or just small unrelated scripts and/or data changes on-the-fly? What functionalities you need? Is preferable for it to be more abstract, more fast, or with a more clear syntax?

What kind of data structures must be implemented? Which of these structures are best described using a particular syntax? Given a fairly complicated problem you may need to solve using your language, try to solve it using various syntaxes: what syntax is best at describing what the code does?

I think after you have found out what are the requirements of the language, and tried various syntax, you will have an idea of what syntax is best suited for the job.


As Spencer commented

This is a perfect example of a domain specific language. You don't want it to solve any problem, it just has to easily describe your specific problem set.

share|improve this answer
I'm not sure your scripting language needs to be completely novel. There are many c-like languages that all use curly braces, and they seem to coexist quite happily. –  Robert Harvey Aug 25 '11 at 14:40
Maybe I haven't been very clear in my answer. I'm not stating one should not use a familiar syntax, but that you shouldn't think about it unless you first understood what is required by your language. Having a familiar syntax is perfectly acceptable of course. –  Jose Faeti Aug 25 '11 at 14:44
Yep. It turns out that the requirements are more on the back end than the front end; they prevent use of an off-the-shelf implementation, but do not sufficiently constrain the syntax and more easily visible elements of semantics, so there are degrees of freedom that can only be constrained by reference to what people actually want. –  rwallace Aug 25 '11 at 14:49
@rwallace That's the point. You have the great opportunity of shaping a language based on your needs and preferences, it's a great chance to offer programmers what they want and expect. The syntax won't be a problem then, everything will be perfectly natural. –  Jose Faeti Aug 25 '11 at 15:05
This is a perfect example of a domain specific language. You don't want it to solve any problem, it just has to easily describe your specific problem set. –  Spencer Rathbun Aug 25 '11 at 15:57
show 1 more comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.