views:

187

answers:

7
  • Is speed of the (main/only viable) implementation of an interpreted programming language a criteria today?

  • What would be the optimal balance between speed and abstraction?

  • Should scripting languages completely ignore all thoughts about performance and just follow the concepts of rapid development, readability, etc.?

I'm asking this because I'm currently designing some experimental languages and interpreters

+1  A: 

As fast as the developer need it to be.

There is no rules, just needs to be feed.

Klaim
+2  A: 

Speed is important, yes, but usually scripting languages are used in cases where speed of execution is outweighed by I/O costs, so it's not the end-all, be-all. Of far more importance is the language structure and features. Work on those first, then deal with execution speed.

That said, I think ultimately if you're looking to build a new general purpose language, you're going to go the route that most of them are going, which is pre-compilation into a bytecode and JIT compilation during execution.

Randolpho
On the other hand, just how many run time environments are we supposed to install or demand our users install?
Gilbert Le Blanc
@Gilbert Le Blanc: Well, that falls under the "Do we really need *another* language?" umbrella, which I agree is something that should always be asked before building a new language. The questioner mentioned experimental languages, so I assume (s)he sees a niche that needs filling, or is maybe just trying to learn the trade as part of a CS education.
Randolpho
@Randolpho: Not to get too far off the topic, but multiple languages can use a common run time environment. To get back on the topic, an alternative to generating bytecode is to generate source code for an existing language. Yes, there are extra steps involved for the person developing with the new language. But if the language is experimental, then there's the trade off of faster development of the language vs. faster development time with the language.
Gilbert Le Blanc
@Gilbert Le Blanc: Excellent points, both. The .NET framework is an example of multiple languages targeting the same runtime. And yes, translation rather than compilation is also an option.
Randolpho
A: 

There is no only answer to a question like this. No one answer can apply to all the possible purposes and audiences.

Probably the single biggest factor to take into account is whether you intend for the language to be mostly standalone, or used in conjunction with something else. If you write something like Lua that's intended primarily (or exclusively) for use along with something else (C in Lua's case) then speed becomes much less relevant and interesting. If you write something that's used primarily by itself, speed starts to matter a whole lot more.

Jerry Coffin
A: 
  1. Yes
  2. It depends on how your language is intended to be used.
  3. No. There is no reason one cannot design a readable language that is fast so that hardly would appear to be an excuse for ignoring performance.

You really have to answer these questions for yourself based on the goals of your experiments.

Christopher Barber
A: 

Speed is always relevant unless your language is useless. If it's useful, people are going to try to use it to do some heavy lifting, and if it doesn't fall on its face when they try, that's always better. This doesn't mean that it is worthwhile to optimize for speed (that depends on your goals), nor does it tell you how (e.g. fast compilation to bytecode vs. reworking how you access a high-level library written in C so that the interpreter has even less to do before calling it).

The optimal balance between speed and abstraction depends on the types of problems being solved. Computer time is generally less valuable than people's time, but both are worth something. Neglecting computer time entirely, it's still useful to consider how much time will be taken total by people working and waiting for results; users of the language ought to be maximally happy when the total coding + execution time is minimized. (Weight by salaries of coders vs. users if you want to make a maximally strong business case.)

Because of the previous two points, I think it's a bad idea for interpreted languages to completely ignore performance. Of course, if the language is experimental itself, you have to ask yourself how much time you want to spend working on performance instead of adding features. It can be okay for an initial implementation to be horribly slow if it will be gradually optimized as it is used more frequently and for more demanding tasks. JavaScript is an excellent example of this.

Rex Kerr
+2  A: 

I don't understand why anyone would write an interpreter these days. There are two excellent virtual machines, the CLR (+DLR) and the JVM. It's trivial to write a compiler for either runtime, and then you get the advantage of interoperability with the massive amounts of existing code out there, plus fantastic standard libraries, plus JIT compilers that will make the speed of your language a non-issue in many cases (certainly faster than any interpreter.)

If you want to make a language that will be more than just a curiosity to developers, this is definitely the way to go these days.

Eloff
That depends on what other languages the interpreted language in question is interopping with. I wouldn't ask C++ users to interop with my language in JNI.
DeadMG
I've written compilers, and I don't think *any* backend is "trivial", even the JVM. I certainly don't believe you get interop for free. (I also don't believe that either the .NET or JVM stdlibs are "fantastic", but that's another story!) For example, I'm working on a ("pure") functional language that requires tail-call optimization; how do I target the JVM and allow programmers to use existing Java libraries (where mutation is a core concept)? There are hard issues anywhere. How well the JVM (for example) works seems to be pretty directly related to how close your language is to Java.
Ken
@Ken - All good points, but I would say the standard libraries in Java, and .NET especially are excellent, better than anything else out there that I am aware of - with the limitations regarding mutability that you mention. Now that F# is a fully supported .NET language, there is quite a bit more support for immutable types in the CLR. And of course IronPython implements a faster (depending on the benchmark) Python on the CLR, and I wouldn't say it is very similar to C#. I've seem implementations of toy languages done on the CLR in a weekend, but of course a full language will take more work.
Eloff
A: 

I'd go for a language with a great API, personally. If you look at Lua, 90% of the Lua C code people write is just boilerplate. If a slower language, with much better C++ API came around, I'd switch to that in an instant.

Ultimately, "premature optimization is the root of all evil", and that is, your language needs some great features, AND it needs to be fast. It's no good being fast if it's as usable as assembler, with the user having to implement the operating system.

DeadMG