d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Building A Compiler
Add Reply New Topic New Poll
Member
Posts: 1,358
Joined: Dec 30 2012
Gold: 0.10
Mar 12 2015 10:24pm
Topic.

I think I'm going to start writing a simple C or C++ compiler cus bored.

Anyone have pointers, documentation, or input on how to get started, etc?

Member
Posts: 21,407
Joined: Jun 15 2007
Gold: 120,303.00
Mar 12 2015 11:25pm
look at an open source compiler...

u are gonna be in 4 a tough time my friend..
Member
Posts: 62,215
Joined: Jun 3 2007
Gold: 9,039.20
Mar 13 2015 05:05am
Code
#include <stdio.h>

int main()
{
int n = 28271;
int *dum = &n;

printf("Here's a pointer %p\n", &dum);

return 0;
}
Member
Posts: 37
Joined: Feb 23 2015
Gold: 0.00
Mar 13 2015 05:40am
http://bellard.org/tcc/

also http://bellard.org/otcc/ - this one's source code is only 2 KB and can compile itself

That Bellard guy is a fucking genius btw, i recommend looking at his other projects too (like virtual machine written in javascript, that can run linux...)

This post was edited by valky08 on Mar 13 2015 05:42am
Member
Posts: 62,215
Joined: Jun 3 2007
Gold: 9,039.20
Mar 13 2015 06:44am
You should contribute to Temple OS

http://www.templeos.org/Wb/Doc/Mysteries.html

Terry A. Davis needs your help writing the most schizophrenic operating system possible.
Member
Posts: 1,358
Joined: Dec 30 2012
Gold: 0.10
Mar 14 2015 09:14pm
Quote (dos350 @ Mar 12 2015 09:25pm)
look at an open source compiler...

u are gonna be in 4 a tough time my friend..


Meh. I enjoy a good challenge. Plus, there's a lot to gain from writing a basic, but functional compiler.

Quote (valky08 @ Mar 13 2015 03:40am)
http://bellard.org/tcc/

also http://bellard.org/otcc/ - this one's source code is only 2 KB and can compile itself

That Bellard guy is a fucking genius btw, i recommend looking at his other projects too (like virtual machine written in javascript, that can run linux...)


Thanks. I'll look into his work :)

This post was edited by SelfTaught on Mar 14 2015 09:14pm
Member
Posts: 21,407
Joined: Jun 15 2007
Gold: 120,303.00
Mar 21 2015 12:21am
Quote (SelfTaught @ 15 Mar 2015 13:14)
Meh. I enjoy a good challenge. Plus, there's a lot to gain from writing a basic, but functional compiler.



Thanks. I'll look into his work :)


wats the gain??

this isnt abuse but

u will take years as a 1 man team getting a compiler anywhere near functional compared 2 say gcc
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Mar 21 2015 08:37am
Quote (dos350 @ Mar 21 2015 01:21am)
wats the gain??

this isnt abuse but

u will take years as a 1 man team getting a compiler anywhere near functional compared 2 say gcc


?? it won't take nearly that long, depending on his free time.

There are plenty of guides out there, for starters.

Also, he probably won't be looking to compete with the best compilers....

Lastly, a lot of those well known compilers are only so huge/took so long etc is because they support so much other shit than just "compiling one language to one specific assembler/intermediary". They support multiple instruction sets, have huge optimizers, support for multiple passes, and all kinds of other shit.


If you just want to compile *1* language to *1* instruction set, it shouldn't be too bad.

This post was edited by Eep on Mar 21 2015 08:41am
Member
Posts: 1,358
Joined: Dec 30 2012
Gold: 0.10
Mar 21 2015 04:34pm
Quote (dos350 @ Mar 20 2015 10:21pm)
wats the gain??

this isnt abuse but

u will take years as a 1 man team getting a compiler anywhere near functional compared 2 say gcc


knowledge and a thorough understanding of what's happening behind the scenes.

im writing one just for a learning experience.. not to compete against well known compilers lol. i realize that would be a waste of time.



Go Back To Programming & Development Topic List
Add Reply New Topic New Poll