Tell me more ×
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.

Lets define "Simple".

  • This is my first language. I have no previous experience
  • I will not dedicate +4 years to learn it properly. I'm a professional software [developer], but as an amateur in this area, I want instant gratification. If the idea shows a future, I could rewrite it.
  • I don't want to do everything from scratch. In fact, if there exists a way to get GO (for example), change its syntax, add some sugar, give some extra functions and leave intact everything else, that would be perfect!
  • From the example of coffescript/scala I think is better to build on top of some rich runtime like .NET/GO so I don't need to rewrite everything. HOWEVER, if is better other way, no problem for the first try!
  • I want it in a week. I need it in a week so it will really take a month. Then it truly takes 3 months. But I don't want to put more that 3 months on this. I could reduce the scope of my language, but I hope the tools will help me a lot...

I want to build a new language. Similar to python, but typed.

I wonder what to build it on top of.

I like the idea of building on top of GO. To get their sane (IMHO) OO paradigm (I plan to do the same, using interfaces, not inheritance), get goroutines and some other stuff. In my naive thinking I imagine that spit another language could help me to debug it more easily.

However, look like everyone is building on top of something like .NET (don't like Java), LLVM or make it own VM.

I read http://createyourproglang.com/ (great!) and the part of the VM look "easy" to me.

So, what I need is the proper criteria and question I need to know in advance to have a fair shot at make this.

share|improve this question
How much is your language design deviating from say... Python? If all you're doing is adding static typing, compiling from your language into (ugly) python source would give you the quickest development time I would think. – Telastyn Sep 22 '12 at 3:10
1  
If it's your first time why worry about compiling it? Just create an interpreter for your language. – Buttons Sep 22 '12 at 5:53
You don't even need a VM. Extend a language. Say, Racket. – SK-logic Sep 22 '12 at 9:37

closed as not a real question by Walter, ChrisF Sep 30 '12 at 20:50

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

2 Answers

up vote 3 down vote accepted

Depends on the nature of the new language (NL) but probably the fastest way to implement an NL is to write a preprocessor written in your favorite existing language (EL) that translates the NL into EL and then use the EL compiler or interpreter to get machine code. It's easier to compile to an EL than directly to machine code and gives you the facilities of the EL such as code optimizer, linker, debugger, library manager and libraries. It's also easier to debug if you can read the code being generated directly. Compilation/interpretation will be a two step process but that doesn't matter - just put it in a script or make file or system() call.

Do you know what a recursive descent parser is? If not learn about it - it's probably easier and faster to write than using one of the many lexers and parse generators out there (the front end of a compiler/interpreter).

You can also implement an NL in an EL interpreter but that probably means you'll have to implement more complex symbol table management and will have to rewrite many of the facilities of the EL. May be more appropriate if the NL doesn't map well to an EL you're familiar with.

A third way is to not write an NL at all, just write library routines that perform the functions you want in an EL. No new syntax.

There are a lot of programming languages out there (see http://en.wikipedia.org/wiki/List_of_programming_languages). It's possible the ideas you have have already been implemented. Remember that the fastest way to write code is to use existing code.

share|improve this answer

What's your favorite language? Let's say it's C#.

If you want to create a new language, define its syntax. Then create the C# program to interpret it. Then add some syntax, and add more to the C# program. Rinse and repeat till you think you have a good enough language.

It'd help you to learn what's a lexer.

The idea will be that you will parse the program in your new language, use a lexer to define what is what, and execute the program.

It's just faster/easier to write this in a language you know. Don't bother learning about a VM's intrinsics (yet).

share|improve this answer
So, your are telling me to build a interpreter? – mamcx Sep 22 '12 at 20:09
Yes, that's the first step to build a language. – Florian Margaine Sep 22 '12 at 20:39
@FlorianMargaine, compilers are much simpler than interpreters. – SK-logic Sep 23 '12 at 10:08
What make them simpler? – mamcx Sep 24 '12 at 18:06
You don't need to learn another language. Unless I'm misunderstanding what's a compiler there. – Florian Margaine Sep 24 '12 at 18:08

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