LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-02-2006, 03:24 PM   #1
Trizon
Member
 
Registered: Apr 2005
Distribution: Source Mage GNU Linux
Posts: 43

Rep: Reputation: 15
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!

Last edited by Trizon; 12-02-2006 at 03:25 PM.
 
Old 12-02-2006, 03:29 PM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
Well, first you need to program. A lot. By that time, the answers to the questions you asked will become evident.
 
Old 12-02-2006, 03:32 PM   #3
introuble
Member
 
Registered: Apr 2004
Distribution: Debian -unstable
Posts: 700

Rep: Reputation: 31
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).
 
Old 12-02-2006, 10:29 PM   #4
95se
Member
 
Registered: Apr 2002
Location: Windsor, ON, CA
Distribution: Ubuntu
Posts: 740

Rep: Reputation: 32
Buy http://www.amazon.com/Compilers-Prin.../dp/0201100886
 
Old 12-02-2006, 11:04 PM   #5
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
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.
 
Old 12-03-2006, 01:18 AM   #6
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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
 
Old 12-03-2006, 11:30 AM   #7
Trizon
Member
 
Registered: Apr 2005
Distribution: Source Mage GNU Linux
Posts: 43

Original Poster
Rep: Reputation: 15
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.
 
Old 12-03-2006, 09:06 PM   #8
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
"Let's Build a Compiler"

http://compilers.iecc.com/crenshaw/
 
Old 12-03-2006, 09:10 PM   #9
vargadanis
Member
 
Registered: Sep 2006
Posts: 248

Rep: Reputation: 30
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.
 
Old 12-04-2006, 08:55 AM   #10
95se
Member
 
Registered: Apr 2002
Location: Windsor, ON, CA
Distribution: Ubuntu
Posts: 740

Rep: Reputation: 32
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
 
Old 12-04-2006, 09:05 AM   #11
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
I also recommend you write a simple text parsing application first and familiarize yourself with the concepts. Rome wasn't built in a day.
 
Old 12-04-2006, 10:19 AM   #12
Trizon
Member
 
Registered: Apr 2005
Distribution: Source Mage GNU Linux
Posts: 43

Original Poster
Rep: Reputation: 15
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.
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.
 
Old 12-04-2006, 10:21 AM   #13
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
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.
 
Old 12-04-2006, 10:21 AM   #14
vargadanis
Member
 
Registered: Sep 2006
Posts: 248

Rep: Reputation: 30
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. (^_^)
 
Old 12-04-2006, 11:12 AM   #15
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 735

Rep: Reputation: 76
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
which programming language is used to do tcp/ip programming?? gajaykrishnan Linux - Networking 9 12-21-2012 05:16 AM
How does one create a language? mhelliwell Programming 3 03-14-2005 02:37 AM
D Programming Language XsuX Programming 7 11-17-2004 08:55 PM
programming language killi Programming 17 06-10-2003 05:24 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration