views:

310

answers:

6

My definition of general purpose is a bit specific: a general purpose programming language should be able to handle all problem domains, including implementing operating system kernels, device drivers and all sorts of programming language facilities. This definition basically excludes all mandatory garbage collected languages (including LISP, Java, Ocaml etc), as you cannot fully implement a garbage collector in a fully garbage collected language.

The priorities I'm talking about here are:

  1. Simplicity. It should follow a small set of simple rules without many exceptions. It should be simple but not simpler. (C is quite simple but could be simpler. C++ is anything but.)
  2. Safety. It should not have any undefined behavior in any of its operations. It's often called type safety as safety is tightly coupled with type system. Both C and C++ are not safe, as there're many undefined behaviors resulting from casts alone.
  3. Performance - It should be at the same order of magnitude as C, less than 1.2x (taking 1.2x amount of time for the equivalent C program) slower is desirable, 1.5-2x slower is acceptable, >= 10x is undesirable.
  4. Expressiveness - It should support language constructs to express solutions to common problems succinctly. Examples: type inference, RAII, objects, closure, (hygienic) macro system and garbage collection. My ideal language would allow me to express scripting as easily as system programming in the same language, so I don't have to rely on any shell/perl scripts to build/deploy my programs.

The above is my order of priorities. What are your priorities? I think that (Walter Bright's) D language is a step in the right direction but far from my goals. Are there any other modern alternative general purpose languages besides D (and maybe Ada?)

Would you be interested in such a general purpose programming language that's as easy to use as a scripting language and as fast as C? With the advancement of modern dynamic compiling techniques/tools such as JIT and LLVM and dynamic loadable personas, I think these goals should be achievable in foreseeable future (10 years). What do you think? (I'll vote up all your serious answers :)

The question is inspired by my past projects that always involves multiple programming languages. Unlike many people who use the cliches like "best tools for the job" to stick to the status quo, I think there are better ways to do it. Having to maintain similar libraries in multiple languages is completely counter productive. A well defined general purpose language that could be a configurable collection of personas, can potentially solve all the problems in a consistent and DRY manner across all the domains of a project.

+4  A: 

I think being hamstrung by a "General Purpose Language" in today's world of a HUGE variety of platforms that work better in some domains than others is silly.

As has been pounded in to our skulls over and over and over again over the years, "right tool for the job", and some tools are simply better than others for different jobs.

So, rather than looking for some one size fits all, I'd rather consider the landscape along with the project, and make the decision there.

Oh, and things like Garbage Collection and other system level operations can and have been implemented in very high level languages. Consider, for example, Squeak Smalltalk which is completely written in Smalltalk (because they like to write in Smalltalk), they just use a more limited subset and then compile that directly to create their VM. But it's still Smalltalk. So, it's not necessarily the language, but the implementation of the language. Lisp and Scheme can (and do) make some very fast code.

Have you looked at Dylan? Mediocre to crummy implementations, but the language itself is quite nice.

So, simply, I don't look for problems to solve with a language. Rather I look for languages to solve problems. If my tool chest has enough to do the job efficiently, then I use that. Otherwise, crack open what is necessary and solve the problem that way.

When I find a general purpose problem, I'll use a general purpose language.

Will Hartung
Can you implement Smalltalk VM in smalltalk? That's was the meaning of *fully* in my original sentence.
ididak
OF course you can, Squeak DOES. They have an ST compiler, written in ST, which is used to create the VM. They compile to C for portability, but they could compile to machine code if they wanted to. They develop, debug and test the VM in ST though.
Will Hartung
It still generates C code and relies on an existing c compiler to translate it to machine code. How can you debug the VM *fully* in ST? What if the code generation is wrong? It doesn't really count in this case. Otherwise, I'd say that my shell script can generate Java VM as well.
ididak
They're using C as a "portable assembler". They CHOSE NOT TO compile straight in to machine code for portability, and lesser overall effort. Just because they didn't, doesn't mean they can't. Lisp Machines were coded in Lisp, back in the day.
Will Hartung
+3  A: 

Sorry, but your question is fundamentally flawed. There is no programming language that can handle all domains.

For example, there is no programming language that can handle both writing an operating system (C, C++), and quick web app development for automatic online deployment (Python, Ruby, Javascript). Not to mention slightly less mainstream activities like speed-optimized iPhone development (Objective C) or Android development (Java).

If you have an application in mind, perhaps you can find the ideal language for it. But you will never be able to find a programming language that is usable for anything, no questions asked.

lacker
I think your answer is fundamentally flawed. Have ever maintained a project with multiple languages? There is no programming language that can handle all domains doesn't means there cannot be one. I vote you up anyway :)
ididak
No, this answer is really right. i 100% agree
Johannes Schaub - litb
Nope, this answer is really wrong, I 100% disagree, and I'll say why if you do first. :>)
le dorfier
A: 

Any language as long as you have a decent user base of support to interact with.

Darian Miller
Can you name a few general purpose languages?
ididak
+1  A: 

First and most important, it must have lambdas, whose parameter and return types are automatically deduced.

It must have reference return, so you can return a reference to a primitive typed variable inside your object from a member function.

It must have templates like in C++, but with a cleaner syntax. The D way of doing this fits quite well.

It must have Compile Time Function Evaluation like i heard lisp has too, and must be able to accept strings as template arguments.

It must have an unsafe mode (but this must by no means on by default), where you can dereference arbitrary addresses like in C.

It must have const objects like C++ has, which are disallowed to change, in addition to const references like Java has.

I would like it if it had a big Standard Library, like Java has.

Johannes Schaub - litb
+1  A: 

I was thinking about this question a few minutes ago in terms of the evolution of the C language. Which has occurred because for so long is has been considered the lingua franca across platforms - you could port almost any app. (And other reasons ...) But it seems that extended versions of C have been evolved to the end of addressing pretty much the list of requirements you so nicely enumerated. C++, Objective C, java, javascript, C#, D, so many others are all variations and extensions of the same C syntax (hence relatively comprehensible to a larger audience.)

It seems to me that C# is maybe the current tip of the chain of evolution in terms of expressivity, type-safety, scope, generality, and extensibility, but not so great on portability. But I would probably most favor a language that barks up this tree.

EDIT:

Interesting - OS toolkit for .NET languages - http://www.gocosmos.org/index.en.aspx

le dorfier
But you cannot write device drivers or CLR VMs in C#, can you?
ididak
No, that's what I meant by portability. I don't think the language itself is the constraint, however, but rather the compilers and system libraries provided to be accessed and manipulated by the language. I.e. it could go further in that direction up the evolutionary tree.
le dorfier
+3  A: 

Essentially, when I am coding, I am looking for one of two language types.

Language 1: Bare metal. Strict types, very fast, very reliable. Compiles to machine code. Has abstraction capabilities for building large systems. Like C++, but with more consistent libraries plus templates designed in from the ground up. You can write operating systems in this baby, and you can track every bit written to memory with its code. Has pointers.

Language 2: High-level. Dynamic types, pretty fast, very reliable. Ideally, compiles to a byte-code interpretable across different operating systems. Can dink with bits, but really, more of a language to manage files, database connections, guis, etc. Threading supported natively. Think PHP, C#, Lisp.

C++ is pretty good for a Language 1. Not...great. But I've not found a better so far. C++0x is probably going to solidify its place in my heart for a Language 1.

For a language 2, I've not really found a good solution. The languages here seem to be split between the *nix world and the MS world. Java would be great, if ran faster, used less memory, and was less "pure" of an OO language.

Paul Nathan
This is a good answer. Thanks!
ididak