PDA

Click to See Complete Forum and Search --> : Creating a New Programming Language


alacritous
Oct 2nd, 2004, 09:42 PM
Hello,
I want to create my own programming language. I had absolutely no idea where to post this, so I did here. The thing is, I'm going to do this on my own and this forum is about getting a team, so admins please move it to where you think. (I just couldn't decide where, heh.)

Please don't post about saying that I shouldn't do this because it's too hard. Obviously, I'm going to go very slow, and won't even go near graphic functions and things, at least for a long long time. I'll just do like print, etc, then keep getting more advanced. OK, enough about that, here's my question.

I was wondering if any of you know any good tutorials, resources, or just anything that would help. I've heard of Flex and Bison. It's something that like helps to create parsers and after that you can make your own, etc. Obviously, the whole project will take a while, so right now I'm just gathering resources and then will read them later. You can also post ideas like how I would construct this or something.

Mainly, I just want to know what programming language I will be working with to create this new programming language. I think C/C++ would work, wouldn't it? I don't think I'll go near ASM, and if it's required then I suppose this project won't work out, because I have absolutely no knowledge of ASM.

Alacritous

alacritous
Oct 3rd, 2004, 07:59 PM
Anyone?

Alacritous

wildcat_2000
Oct 4th, 2004, 03:00 AM
this is a typical question, everyone of us has had this thought once going through the programming road.

well. let me get this straight from the beginning. C++/C#/VB/Perl/Java or anything if that does matter WON'T do in programming an op sys.

why? because all of these languages are much too far away, all of these are system dependent. you need to hard code the processor stack and work with registers DIRECTLY.

-> only ASM can do. and believe me, the hard part is NOT to get an op sys working as much as it is STARTING it, and getting your first C:\ prompt. only a very veeeeeeeeeeery few people in the WORLD are able to do it.

good luck ;)

wc.

Merrion
Oct 4th, 2004, 03:40 AM
Nothing mentioned about writing a new operating system (which wouldbe a thankless and pointless task) but rather about writing a new programming language

If this is a learning experience I suggest writing a new language to target the .NET platform - the CLR has a bunch of classes to make this easier and there are quite a few good examples around.

For example there is Ook# (http://bluesorcerer.net/esoteric/ook.html) - a .NET langauge for orang-utans

alacritous
Oct 4th, 2004, 03:40 PM
Originally posted by Merrion
Nothing mentioned about writing a new operating system (which wouldbe a thankless and pointless task) but rather about writing a new programming language

Yeah, heh, at first I thought I was crazy. But I would never consider making an operating system. (although I did, along time ago when I thought VB6 could make one, LOL. At least now, I won't.)

I want to write it in C/C++... and not based upon .NET...

Like you said, it is for just learning... And like I said, I'm only going to get the very basics, like print and maybe variables, etc. I will start from the basics.

So, it's possible in C/C++ right?

Just wondering on ideas. Like where to start?

Thanks,
Alacritous

Merrion
Oct 4th, 2004, 05:34 PM
First you need to define the syntax of your new language.
For this have a read of the works of Chomsky on well formed grammars

Then you define your tokens (keywords, operators etc.) and write a parse and tokeniser.

Then you take your tokenised output and pass it to the compiler. You can create your onw if you wish but there are a number of open source C++ coded compilers.

Then you wonder why you did this in the first place... :D

alacritous
Oct 4th, 2004, 05:49 PM
Thanks! More info is great for google! (What, like 50 pages now? Not quite yet...)

Yeah, I've been (and still :)) looking for articles and resources. I've read stuff about parsers, etc...

Originally posted by Merrion

For this have a read of the works of Chomsky on well formed grammars
Where can I find this?

Originally posted by Merrion

Then you wonder why you did this in the first place... :D
I know you meant it to be a little sarcastic and funny (or not?), but I'll answer serious anyway :D.

Well, before I even posted, I thought about it alot. I knew it would take a very long time, but I kept the "anything is possible" (flying, well...) quote in my head. I just need to follow my goals, etc.

Alacritous

Merrion
Oct 6th, 2004, 03:57 AM
(You would probably do well to buy a book to help in creating your own language - I did it as a module in my university course and after 1 term we had a pretty stupidly basic language written...and I have forgotten much of that.)

OK - Syntaxes.
When you create a new language you need to create the syntax structure. This is a tight definition which specifies what statements are legal and how they fit together.

For example the syntax for an IF branch might look like:

IF_BRANCH ::=
IF logical_expression THEN
statements
[
ELSEIF logical_expression THEN
statements
]*
[
ELSE
statements
]
END IF

Merrion
Oct 6th, 2004, 04:01 AM
This says that an IF statement consists of

The keyword IF
followed by a logical expression
followed by the keyword THEN
followed by statements
Optionally followed by one or more groups of..
(
The keyword ELSEIF
followed by a logical expression
followed by the keyword THEN
followed by statements
)
Optionally followed by one only group of...
(
The keyword ELSE
followed by statements
)
followed by the keyword END IF

wildcat_2000
Oct 7th, 2004, 05:56 AM
alacritous,

please do accept my most sincere excuses! i guess i was just too tired when i posted my message and just don't know what happened in my brains ;) confusing 'language' with 'operating system'... oh heck.

i would still though bring attention to ASM. if you do program your own programming language, you basically have two choices as far as compiling:

1. either you take the 'translation' choice, i.e. everything that you program on your language gets translated to C++ and then compiled as Merrion suggests;

2. you go the hardest/most powerful way: you build your own compiler for your language, based in ASM.

i believe that from the 2nd option you get the most out of it. like serious headakes :). i would even consider targeting your language for special usage: like scientific simulators, or DB-specific programming,...

just suggestions :)

cheers,

wc.

alacritous
Oct 7th, 2004, 03:24 PM
Not like this is a project log or anything, but the "project" will be on hold until I install Linux.

Thanks for your ideas and everything. Since I'm not so well at ASM (truth: I can only print like 1 letter, lol) I'll probably just convert "my language" into C++ and use an open source compiler. I'm still researching some things, but thanks alot!

About the Linux:

It is installed but there are some problems so if you can help me install linux :) go to the LinuxQuestions.org Post (start) (http://www.linuxquestions.org/questions/showthread.php?s=&threadid=239134&perpage=15&pagenumber=1) or the second page, more recent, LinuxQuestions.org Second (http://www.linuxquestions.org/questions/showthread.php?s=&threadid=239134&perpage=15&pagenumber=2).

Alacritous

Merrion
Oct 7th, 2004, 05:38 PM
you go the hardest/most powerful way...


I disagree with this statement - you can not possibly write a better optimising compiler than that written by Intel .. and even the Borland and Microsoft ones are better than you will match.

alacritous
Oct 7th, 2004, 06:10 PM
It seems we all have different ideas...

This is probably sarcasim but, I probably won't make more than 10-15 functions/etc.

Alacritous

alacritous
Oct 12th, 2004, 05:52 PM
I'm still trying to install Linux (some problem or bug or something... going for the Fedora distribution)

But I just had some thoughts...

So, say I use some language (C , C++, VB6) and I scan through my new language, for example the following:

consay("saying a message in the console")

I program the langauge (C, C++, VB6) to look for the words consay and the syntax such as (, ", etc. Then, I write to a text file and translate the code I wrote into C (like printf instead of my consay). Then I pass the text file to an open source C compiler. Whala, my program...

Would this work? Also can I have your ideas?

Alacritous

Halsafar
Oct 16th, 2004, 12:31 PM
Just a little note to all those who believe it is okay to write your own langauge based on c++.

That sounds like someone saying "I'm goona put a new body onto my rusty old car". The car now has a new body, still has the same engine, transmission, tires, axels, shafts, wires.....In the case the car was broken, a new body won't help.

Well C++ aint broken, why fix it?
Why create a new language based off of C++? Then you really didn't create a new language did you.

If you want to create your own language. Assemble is the way to go.
I do not know much about assemble, all I know is that you can code assemble in c++, I aint sure about any other way to compile assemble.

If you want to create your own langauge, start from scratch. If your langauge needs a c++ compiler to run, then it is a c++ language.

See, most all languages have a high-end and a low-end...some have a middle.
VB for example (i'm just guessing here)
high-end --> VB itself
low-end --> C++

all vb code is compiled and used as c++, or least links to c++ libs, and dll's
now for c++
high-end --> C/C++ itself
low-end --> Assemble

C++ code is directly translated into assemble code...You see the structure yet.

now for Assemble
high-end --> Assembly itself
low-end --> This is a hard one to say...But I guess binary, 0-1, voltage ammounts, straight instruction sets to the cpu...

The only thing lower than assemble would be the code on the chips on your motherboard.

alacritous
Oct 16th, 2004, 05:16 PM
I understand...

I'm not trying to make the best programming language. It's just for experimenting and fun. Oh yes, and saying to newbies that are just learning to program, "hey, you can use my language" :). Then after they figure out it only has 20 functions/subs/etc they ditch it.

I think that explains what I'm aiming for.

Alacritous

ice_531
Nov 6th, 2004, 07:10 PM
hey :D


just one question : " Why " :p

Seems rather pointless, it won't help you further your programming knowledge anymore in c++ , c #.net or VB.NET and it will just be time consuming and :hard:


but hey have fun :lol:

alacritous
Nov 6th, 2004, 07:53 PM
Originally posted by ice_531

Seems rather pointless, it won't help you further your programming knowledge anymore


Actually it would. If I transfer the "programming language" I wrote into C, it would be help me understand C, since I am actually learning it now. It just depends on how many commands I do. The more I do, the better I'll know C.

It's kind of like this: you learn better from teaching. Well if I teach the computer my langauge by transfering it from C, I'll learn C better.

Alacritous

ice_531
Nov 6th, 2004, 09:13 PM
Originally posted by alacritous
Actually it would. If I transfer the "programming language" I wrote into C, it would be help me understand C, since I am actually learning it now. It just depends on how many commands I do. The more I do, the better I'll know C.

It's kind of like this: you learn better from teaching. Well if I teach the computer my langauge by transfering it from C, I'll learn C better.

Alacritous


Then the whole point is to learn C better, in which case my other statement stands proven. "it will just be time consuming and useless" ;)

alacritous
Nov 6th, 2004, 09:17 PM
Well whatever. I didn't do it just to learn C better, but owell. I'm going to do it, I guess. I've actually been so busy that I havn't done like anything. Once I get time, it shall start.

Alacritous

ice_531
Nov 6th, 2004, 09:37 PM
I don't mean to discourage you in any way, im just wondering why you want to do it lol


you must be held against your will by russians or something :ehh:

nemaroller
Nov 16th, 2004, 09:16 AM
The most difficult part of creating a programming language is probably going to be building the compiler.

You can lay out your structure and syntax first.

But the most difficult hurdle will be this:

say you have:

Dim I As Number
Target I = 0 To 50
Print "HI"
Run Target


How do you go about converting that to even a low-level language such as C?

You have to keep references, allocate memory from the stack, manage scope, and more... I mean its really going to be a waste of your life no offense.

You want to do something really cool... build a biological computer that uses living cells for memory. Then you can be the first to build a programming language for that computer. Now, that would be something useful and a learning experience.

Arc
Nov 17th, 2004, 01:01 AM
I just read this whole thread and trust me, you are no where near a good enough programmar to even be thinking about creating your own language.

Graduate High School then get a PHD in Computer Science then sit down and think about writing a new language.

alacritous
Nov 17th, 2004, 04:00 PM
All I'm doing is a few subs/functions. I convert "my language" into C and feed it through a C compiler. Very simple.

Now obviously I'm not good enough to actually make a compiler and all that crap in assembly or whatever, I'm fourteen years old!

Alacritous

UnknownX
Nov 21st, 2004, 10:35 PM
a big LOL!!!

sorry but I can't do anything else...

alacritous
Nov 22nd, 2004, 08:18 PM
Yeah and a LOL at all you people discourage me.

You know, you can do anything as long as you put your mind to it. I guess you guys don't realize it. Is there a problem with an interest in not just this, but anything? You guys should be ashamed of yourself.

You know what, maybe if I don't complete the project, but at least I learned a heck of a lot researching about it. I'm young, and I'll admit it, I'm 14, but anyway, I'm still wondering about my career and just want to experiment. I never said I'm an expert programmer looking to invent the next C/C++ or whatever language.

I'll say this right now, I probably won't complete it, because there really is no reason, but it sure was fun researching about it all.
Alacritous

UnknownX
Nov 23rd, 2004, 06:22 PM
Come man! Take it easy!!!

I know, I thought the same things years ago. But let me tell u something: you will loose ur time.

Try to read manuals about C/C++ and try to learn it. Don't waste your time making unnecesary things. Use your time reading things about real programming languages.

But listen, I'm not trying to disturb you, just giving some tips about learning.

If you wanna continue, go ahead. And try to make your best. Some day I was 14 and I was thinking about making programing languages and operative systems, but you know... time teaches you lot of things and one of those: don't loose your time making unnecesary things. Use your time making things that doesn't exist or improve other created by others.

Sorry for my last message, it causes me laught. ;)

Have a nice day!

ice_531
Nov 23rd, 2004, 06:41 PM
lol "Looses time"

:lol:


ie. Wastes time - American ;)

UnknownX
Nov 23rd, 2004, 09:16 PM
Lol! Sorry for my broken english :P

dglienna
Nov 24th, 2004, 09:51 PM
Do you want to help with the l33t transl33tor class for the sandpaper project? it's in VB.

ice_531
Nov 24th, 2004, 10:19 PM
Originally posted by dglienna
Do you want to help with the l33t transl33tor class for the sandpaper project? it's in VB.

No. Don't corrupt his youthful mind with your the frogs nonsense sand materials! :mad:

alacritous
Nov 28th, 2004, 09:19 PM
Originally posted by dglienna
Do you want to help with the l33t transl33tor class for the sandpaper project? it's in VB.

Who, me?