views:

267

answers:

9

Hello,

I got tired of searching and never finding a programming language that fits my needs (and I suppose most good programmers feel somewhat the same way). Anyway, I do have an idea of what I'd like for a programming language, and I'd like to try to develop my own. I'm interested in information on how hard it is and how long it takes (I mean, to get a minimally useful language). I already know what resources I'd need, but I still feel like it's almost impossible to accomplish something like that without dedicating myself full time (or having others help me, which I don't think will happen).

Anyway -- when I say "programming language" and "minimally useful", I the core language ready, working FFI for calling C code, and an Emacs IDE at least as useful as Quack.

I'd be grateful for any experience reports...

Thank you!

+10  A: 

Whatever you are trying to do - stop it.

If there is no programming language that can satisfy you, maybe is time to improve your programming skills?

If I was you I would describe the problem (i.e. what kind of the application you need to write) and ask WHICH language would be best for it.

All super-inventions usually end up as being rewritten to more standard language so more people can work on it. I've heard about many companies trying to invent their own in-house language and they were ending up rewriting it to C or C# to actually be able to hire someone who can work on it straight away.

Bad move, really, bad move.

rochal
"If there is no programming language that can satisfy you, maybe is time to improve your programming skills?"I have been using Scheme and Common Lisp; tried Haskell, ML, Prolog, C, C++, Java and several others (have been programming for 25 years). but there is still this feeling that I'm not supposed to keep sacrificing something good, because I can't have all I need in one single tool. (I usually give up interactive development, or code efficiency, or developent speed, or ability to debug, etc...)As to others rewriting in C, that's fine. I'd like something or my own projects.
Jay
@rochal; perfect answer
sirmak
@rochal: "WHICH language would be best for it." -- yes, I know. The usual answer that pops up in my mind is "a language that is a mix of Haskell, C, Scheme and also has some array processing features, AND some other features not found anywhere".
Jay
@Jay so why does that entail writing a new LANGUAGE? What you are describing might require a new TOOL.
San Jacinto
The conclusion is - just write your own class in C supporting mentioned by you features of Haskell.
rochal
I disagree. While it's not the most easy or practical undertaking, this sort of attitude prevents programming language evolution.
mmagin
+2  A: 

This really depends on the person. Some people write a grammar as if they are writing a letter in their native tongue.

Some people, can fiddle with this forever (like me). Let alone creating a compiler or interpreter from it.

If this is your first language, then this process can take quite a while before the language becomes practical.

After this is completed you'll be needing tons of libraries, before you can do anything useful with it, which also takes a lot of time and dedication

So, even if you're a compilerveteran, this will eat up a lot of time. But bo doubt be a lot of fun too

Toad
"Some people write a grammar as if they are writing a letter in their native tongue." -- I have a basic idea of how syntax and semantics would work (syntax would be a bit more complex than Lisp, semantics would be "interesting" but not overengineered)"After this is completed you'll be needing tons of libraries" -- the plan is to have a very clean FFI to call C stuff (and of course I'd be then using C native types in my language, plus maybe some more types that would translate into gmp stuff)
Jay
only using c libraries won't cut it I'm guessing... For the basic stuff (io etc) it's nice to have dedicated libraries which work in harmony with your language
Toad
@reiner: yes; Imeant, for things like OpenGL, BLAS and other libraries -- I wouldn't dream of reinventing the wheel. But the basic libraries I'd write myself.
Jay
A: 

Which language do you want to develop on ?.... so, you need to master a language :)

sirmak
I'd start with C (a tiny core) and Scheme, aiming at replacing the Scheme parts with the language itself later.
Jay
I suggest you not to try, use existing languages and frameworks for all your job, I highly suggest you to try static typed (high performance) languages on linux platform that uses JVM like Java and Scala. Cheers
sirmak
@sirmak: I did :-) for several years... I have written large programs in Java, Prolog, ML, C, Pascal... But performance is not the only concern.
Jay
Jay, for example Hibernate is only an orm framework and it's 800.000 Lines Of Code, if a developer can write 30.000-50.000 tested LOC annualy, it took 10 years to write; can I say "I wan to write a web app, but before this, I'll write my own orm that will be better than hibernate" ?. Architecting a language is pointless in your case, read the history of C# and it's author Anders for example. Languge development need years of experience in this field, a group of really smart professional developers and a big company behind it. Writing a small one for yourself is pointless, sorry
sirmak
+3  A: 

well, that's a pretty big task !

have you thought of everything which comprises only a compiler ? how vast the knowledge you have to learn (grammar, machine code, platform convention, file format, ...) ? let alone some very simple things like operator precedence, variable scope, ...

a compiler is not for the faint-hearted. if you never did that, writing an interpreter for a very simple language (like a very simplified pascal) may already take a great amount of time.

if you can afford doing it, do it, because that's a lot of fun and you will learn a lot by doing it. but do not think your language will be more than a toy before some years. and even then, it will surely miss a lot of features found in many other common languages.

Adrien Plisson
"how vast the knowledge you have to learn (grammar, machine code, platform convention, file format, ...)" -- I've written three compilers in my like (one as undergrad, two later). I like compilers -- they're one of the nicest possible software to write. And I would of course not write the full compiler (either generate Gimple or C, or maybe code for the LLVM -- and I'd use a *very* simple syntax, Lisp-like)
Jay
i agree with you, a compiler is a nice piece of software. provided with those informations, it will not be that hard for you to achieve your goal. it will however still require a significant amount of time.
Adrien Plisson
+1  A: 

There is a haskell tutorial where you write a scheme in what they claim is 48 hrs. I want to say Why's potion took about two months but he wrote an interpretor and JIT compiler for it. So I would say if you know what you are doing it would take a week to a month or two depending on time and talent for a first useful release. Writing a grammar in antlr will take you longer to learn the tools than it will to write the grammar if you make it simple enough.

stonemetal
THANK YOU! That helped a lot already.
Jay
I would also like to note in the other direction D was in development for 10 years before it hit 1.0
stonemetal
+1  A: 

I would say between 3 and 5 man/year depending on the complexity of the language and the optimizations of the compiler.

If this is a personal project I would recommend going for a .NET language so that you can skip at least the assembly generation an let that part to the JIT. That will take out a great deal of effort while letting you center on the characteristics of the language itself.

It's not THAT difficult to write a compiler. I know it sounds like a pretty big task and indeed is one of the most complicated things to do in programming as it requires you to know a lot about the architecture, optimization and some nasty stuff but at the end is just like any other business, once you get into it and start to learn it just gets easier.

Jorge Córdoba
@Jorge: I won't do assembly generation, of course! :-) I'd generate code for a VM like LLVM or other.
Jay
A: 

Come on, the best person to answer this question is you yourself! You know your programming abilities and the specific language you have in mind.

In general, I'd say it takes something between a week and a decade.

A: 

Consider getting your feet wet by writing several DSLs (domain-specific languages). You could potentially leverage an existing Language Workbench to get productive quickly. Alternately you could write the DSL in a language that supports compiler extensibility and use the existing IDEs for the core language.

TrueWill
A: 

About a decade (and counting).

BCS
I don't think that counts as a decade. :-) D was "minimaly useful" long before being 5 years old...
Jay
It might well have been minimally useful for v0.01, but no minimally useful language will ever be as good as a really useful one no mater how tailored it is to your needs.
BCS