10 Replies - 3583 Views - Last Post: 29 April 2009 - 03:31 PM

#1 musya   User is offline

  • D.I.C Lover
  • member icon

Reputation: 11
  • View blog
  • Posts: 1,012
  • Joined: 25-April 07

Creating Programming Languages

Posted 26 February 2009 - 08:19 PM

Okay we hear about programming languages being made and so forth, but my qestion is this, how do you make a programming language? what would one do to start his own programming language?
Is This A Good Question/Topic? 0
  • +

Replies To: Creating Programming Languages

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6968
  • View blog
  • Posts: 31,958
  • Joined: 10-May 07

Re: Creating Programming Languages

Posted 26 February 2009 - 08:27 PM

View Postmusya, on 26 Feb, 2009 - 09:19 PM, said:

what would one do to start his own programming language?

1st, you would have to have a need, a requirement that another language just simply couldn't fill.

& if you knew why you needed to make a new one, you'd probably know enough about what you're doing to know how to make one :)

The reality of it is, you need to know the ins & outs of memory usage, cpu usage, & all of the low level i/o of the PC.

An interpreted language, such as brainfuck might be simpler to create.

** Edit **

I'm not saying that's a simple language, it's just the 1st interpreted language that came to mind.
Was This Post Helpful? 0
  • +
  • -

#3 musya   User is offline

  • D.I.C Lover
  • member icon

Reputation: 11
  • View blog
  • Posts: 1,012
  • Joined: 25-April 07

Re: Creating Programming Languages

Posted 26 February 2009 - 08:32 PM

So its not such a thing that you can build it from say c++? would you need to go down to assembly? or c? I'm just kinda lost as to how you would give birth to a language for example such as php?
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6968
  • View blog
  • Posts: 31,958
  • Joined: 10-May 07

Re: Creating Programming Languages

Posted 26 February 2009 - 08:37 PM

I wouldn't say that it can't be done in C/C++, but surely you would need to have an understanding of assembler & hardware usage as well.

As per the wiki, PHP was written in C.
Was This Post Helpful? 0
  • +
  • -

#5 ayman_mastermind   User is offline

  • human.setType("geek");
  • member icon

Reputation: 127
  • View blog
  • Posts: 1,860
  • Joined: 12-December 08

Re: Creating Programming Languages

Posted 28 February 2009 - 11:52 AM

I stumbled upon this tutorial that shows how to make your own scripting language under linux, actually C and C++ play a major role in it, http://ubuntuforums....ad.php?t=351973 hope this helps, good luck ;)
Was This Post Helpful? 0
  • +
  • -

#6 Sadaiy   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 107
  • Joined: 03-October 08

Re: Creating Programming Languages

Posted 08 April 2009 - 06:44 PM

programming languages are simply an abstraction of the von neumann mahcine.. I recommend you create your language from assembly.
Was This Post Helpful? 0
  • +
  • -

#7 timothybrown   User is offline

  • New D.I.C Head
  • member icon

Reputation: -1
  • View blog
  • Posts: 46
  • Joined: 08-April 09

Re: Creating Programming Languages

Posted 20 April 2009 - 08:37 AM

If you are going to create a language, you'll need a lot of knowledge, time, and effort. I've never attempted to do this myself but I heard about some kind of tool, the YACC Parser or something like that helps. I really don't know, I'm a noob when it comes to creating new languages.

However I was really bored one day and I didn't want to write a lick of code so I just opened up Notepad and wrote documentation for a non-existent language... it had syntax similar to C++ and Java, and it looked really cool - but no plans to ever code it. :P
Was This Post Helpful? 0
  • +
  • -

#8 Kiriran   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 60
  • Joined: 11-April 07

Re: Creating Programming Languages

Posted 20 April 2009 - 01:34 PM

View Postmusya, on 26 Feb, 2009 - 07:19 PM, said:

[...] what would one do to start his own programming language?

well you need some background in parsing and code generation. A nice book to start with is "Compiler Construction: Principles and Practice" by Kenneth C. Louden.
And I wouldn't implement the language in assembler. Use whatever language you are comfortable with. At the moment, I'm writing a Scheme interpreter in javascript :P For the first (few) languages, I'd write everything yourself. There are tools (lex/yacc, ANTLR ...) that can generate most of what you need for the lexical analysis and parsing, but there's a lot you learn by doing it by hand. Create diffrent parsers => LL(1), LR(1), LALR(1), SLR(1) and the (k) versions. Also semantic analysis is an important topic and for finishing touches optimize the code (pre calculate results, unroll loops and stuff like that). Then generate the code for your target plattform (CLR, JVM, Parrot, native, your own (bytecode) interpreter)

Good luck
Was This Post Helpful? 0
  • +
  • -

#9 yohoe1101   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 21-April 09

Re: Creating Programming Languages

Posted 22 April 2009 - 12:16 AM

View PostKiriran, on 20 Apr, 2009 - 12:34 PM, said:

well you need some background in parsing and code generation. A nice book to start with is "Compiler Construction: Principles and Practice" by Kenneth C. Louden.


Is the the famed "Dragon Book" ?

I've started reading up on VS2008 DSL features (just started).

I'm interested in possible new classes of programming languages that incorporate something innovative, for instance, how about an "embrionic language" that is sort of like the HAL 9000 when it first boots up and requires a knowledgable programmer to proram it, but remembers everything along the way, collecting statistical data about the cognative approach of its users.

Aaron
Was This Post Helpful? 0
  • +
  • -

#10 333OnlyHalfEvil   User is offline

  • D.I.C Addict

Reputation: 24
  • View blog
  • Posts: 674
  • Joined: 20-March 09

Re: Creating Programming Languages

Posted 27 April 2009 - 01:44 AM

View Postayman_mastermind, on 28 Feb, 2009 - 10:52 AM, said:

I stumbled upon this tutorial that shows how to make your own scripting language under linux, actually C and C++ play a major role in it, http://ubuntuforums....ad.php?t=351973 hope this helps, good luck ;)


scripting languages and programming languages are different.
Was This Post Helpful? 0
  • +
  • -

#11 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: Creating Programming Languages

Posted 29 April 2009 - 03:31 PM

To create a new language you first have to develop the grammar for the language, meaning the syntax. Like in C++ you have:

while (i < 30)
{
	statements...
}



That is an example of the grammar of a language.

Once you have the grammar you need to write a parser. The parser goes over what the programmer has written and checks the syntax to make sure the code the programmer has written is correct (This is partly what intellisence does). The parser passes what it has checked to the compiler. The compiler takes libraries, that are usually written in assembly language, but they could be written in a language like C/C++, then passes them to the code generator which makes creates the .exe file or equivalent like bytecode in Java or IL in C#/VB.NET.

That is a bit simplified but it is how things work in a compiler.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1