LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to create your own programming language? (https://www.linuxquestions.org/questions/programming-9/how-to-create-your-own-programming-language-506918/)

Trizon 12-02-2006 03:24 PM

How to create your own programming language?
 
If someone wanted to create their own programming language, what steps would need to be taken to do it?

Would you need to know a language like C?

It looks like you would need to use LEX & YACC or Flex & Bison?

How is the syntax for the language you are creating usually created?


Any information on this would be appreciated. I am interested in doing this, but I am a very poor C programmer. So I'm trying to determine what I need to study to reach this goal.

Thank you!

tuxdev 12-02-2006 03:29 PM

Well, first you need to program. A lot. By that time, the answers to the questions you asked will become evident.

introuble 12-02-2006 03:32 PM

Somewhat similar to what tuxdev said..

One could argue that if you have the knowledge to create a *usable* programming knowledge, you also know the answer to your question(s).

95se 12-02-2006 10:29 PM

Buy http://www.amazon.com/Compilers-Prin.../dp/0201100886

taylor_venable 12-02-2006 11:04 PM

It depends on what you want to create. If you want to invent a DSL (domain-specific language) from existing material, you can write a macro-based language on top of an existing PL like LISP. If you want to write a new language from scratch, you'll have to do a lot of research first. Here's some books / papers / links to get started: http://lambda-the-ultimate.org/node/492 (LtU is a great aggregating resource for PL design).

As far as writing compilers go, you can do it in any language, not just C. There are books about writing compilers in C, Java, Standard ML, you name it. Lexer and parser generators exist for many languages, in addition to Lex / Yacc for C. Eventually, some language designers decide to write the compiler of a language in the language itself. :)

paulsm4 12-03-2006 01:18 AM

I second 95se's suggestion!

Trizon - if you're genuinely interested in an answer to your question, please beg, borrow or ... well ... just GET a copy of "The Dragon Book". It's absolutely the single best "first step" for understanding "how programming languages work" and how to go about writing your own.

IMHO .. PSM

Trizon 12-03-2006 11:30 AM

Thanks guys, I really appreciate the help!
I have heard about the dragon book, but I had no idea what the real name of it was. Thanks for the link!

You guys have some great suggestions! It has helped clear up some things.

anomie 12-03-2006 09:06 PM

"Let's Build a Compiler"

http://compilers.iecc.com/crenshaw/

vargadanis 12-03-2006 09:10 PM

Hehe... I would code everything in assembly and I would rewrite C with a better syntax and maybe as OO. I dunno if there is any point in creating a new one. There are programming languages for everything now.

95se 12-04-2006 08:55 AM

Quote:

Originally Posted by vargadanis
Hehe... I would code everything in assembly and I would rewrite C with a better syntax and maybe as OO.

Been done, it's called Java :) *ducks under flame retardant wall*


Quote:

Originally Posted by vargadanis
I dunno if there is any point in creating a new one. There are programming languages for everything now.

There will always be new ideas. This could be for a whole new programming language, or just a new application for an existing one. Look at JRuby. They took an existing, great, pretty new (decade old I think), language, Ruby, and created an interpreter for it on the JVM (they're also trying to create a byte code compiler as well). When MS' .Net became popular, lots of people create .Net compilers for all sorts of languages, like lisp (L# http://www.lsharp.org/).

Aside from this, it's just fun creating a language, even a small useless one, and seeing it work. Just like everything else. I'm sure many of us have create a text editor. We didn't do it because we were trying to create something new and useful, but just learning and having fun :)

vharishankar 12-04-2006 09:05 AM

I also recommend you write a simple text parsing application first and familiarize yourself with the concepts. Rome wasn't built in a day. :p

Trizon 12-04-2006 10:19 AM

Quote:

Originally Posted by harishankar
I also recommend you write a simple text parsing application first and familiarize yourself with the concepts. Rome wasn't built in a day. :p

Funny you should say that, because that is exactly what I am planning to do. I've been trying to find information on basic parsing concepts. I thought I might start out with just a two-word text parser like the old text adventure games and expand from there.

Also, 95se was right on, it is all about learning and having fun. Plus, really improve my programming skills.

vharishankar 12-04-2006 10:21 AM

Have fun and enjoy. Programming can be a joy when you aren't under pressure to deliver results. It's the process itself rather than the end result.

Good luck. :)

vargadanis 12-04-2006 10:21 AM

Quote:

Aside from this, it's just fun creating a language, even a small useless one, and seeing it work. Just like everything else. I'm sure many of us have create a text editor. We didn't do it because we were trying to create something new and useful, but just learning and having fun
Hehe... There is the point. (^_^)

makyo 12-04-2006 11:12 AM

Hi.

Languages that are small, little, and mini -- often domain-specific or task-specific -- are discussed in:

Programming Pearls, 2nd, Jon Bentley,

The Practice of Programming, Kernighan and Pike,

The Pragmatic Programmer, Hunt and Thomas

Best wishes ... cheers, makyo


All times are GMT -5. The time now is 02:49 AM.