Click here to Skip to main content
15,895,740 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I know c,c++(OOP) and python (web scrapping and GUI)

I would like to create a simple functional programming language and a complier for the language of my own .

How would I do that.

Suggest me a learning path(resources , book , tutorials) to achieve this.

The learning path should include all the prerequisites I needed to learn.



I have spent of good amount of time researching on the internet and saw a couple of many tutorials on YouTube but still I don't know where to start and what should I know earlier.

The maximum time I can spend is 6-8 months. I am so determined to this and I can spend a maximum 6 hours daily.

What I have tried:

I have spent of good amount of time researching on the internet and saw a couple of many tutorials on YouTube but still I don't know where to start and what should I know earlier.
Posted
Updated 7-Sep-21 19:17pm
Comments
[no name] 7-Sep-21 12:14pm    
Best I found: Writing Compilers and Interpreters; A Software Engineering Approach; by Ronald Mak. The original version used Java; the later edition C++.

Writing a compiler is not a "beginner project" - or at least =, not if you actually want to be able to use it later.

But ... start with an existing language instead of your own - it'll make life a lot simpler for you to work out what you need to do, and a better "feel" for languages in general. Perhaps a simple BASIC dialect?
Start here: write a basic compiler - Google Search[^] - but don't expect this to be a fiv e minute job, it won't be!
 
Share this answer
 
Comments
CPallini 7-Sep-21 2:26am    
5.
Have a look at those 2 links:
Compilers: Principles, Techniques, and Tools - Wikipedia[^]
Apache Ant - Welcome[^]
ANTLR - Wikipedia[^]

As OG said: it is not for beginner.
 
Share this answer
 
v2
Comments
CPallini 7-Sep-21 2:01am    
Why Apache Ant?
Did you possibly mean ANTLR?
Patrice T 7-Sep-21 2:14am    
My bad, thank you.
CPallini 7-Sep-21 2:27am    
5.
Patrice T 7-Sep-21 5:21am    
Thank you
Wirth's book, Compiler Construction[^] (1996), is still a very good introduction.
 
Share this answer
 
Comments
jeron1 7-Sep-21 18:29pm    
From that book;
"The construction of the first compiler for the language Fortran (formula translator) around 1956 was a daring enterprise, whose success was not at all assured. It involved about 18 man years of effort, and therefore figured
among the largest programming projects of the time. "

Not a trivial subject indeed!
I think you are being optimistic. I actually did this once. I wrote my own language, debugger, and then changed everything from byte code interpretation to native machine code execution. That was my full time job and it took me about two years to do all of that. You probably don't need your own debugger but for various reasons I did. Still, that leaves an awful lot of work to do. First you need to define and specify your language. Then you need to make a parser to process the source code. Another major component will be to decide how you want your programs to execute. Do you want an interpreted virtual machine like Java uses or do you want machine code to execute like C compilers use or do you want something in between those, sort of like how the .net languages work?

I think you could find yourself spending six to eight months on just the language design and specification and parser. Then you will figure out how much you learned during that process and decide you could have done it all much better and want to do it all over again. That happened to me and I decided the front end was good enough, despite it flaws, and so I decided to rewrite the back end, the code generation part. That ended up paying off in a big way for me because the execute speed improved dramatically. The thing is, with machines as a fast as they are today, that is probably a very low priority. If performance is that critical there is no good reason what so ever to write your own language. Therefore, decide what your priorities are with this project and focus on that aspect. If I were to do it all over, my priority would be to design the best front end possible. The rest of it will be fairly easy as long as you have a good language design and parser for it.
 
Share this answer
 
Consider learning some languages like C or Java at first. Than you also need some abstract knowledge in computer science.
To be honest: you better invest your efforts in learning C. Read my How to Start the Homework or a Developer Career? to learn from my 20+ years experience in the software development.
 
Share this answer
 
Six to eight months isn't enough time to produce something useful, not when you're starting by asking for background reading material. I've probably spent 2 man-years (4,000 hours) on a C++ static analysis tool[^]. It does many of the things that a compiler does but only produces object code for a simple, virtual stack machine (so that I can check if it properly interpreted the code). It also assumes that the code already compiles, so it omits checks that a true compiler would have to include. But if the time spent on the static analysis portion had instead been spent on generating object code and adding more checks, it could be generating object code by now, but nothing as efficient as that produced by good C++ compilers.
 
Share this answer
 
v2
IMO the best start in the right direction would be this book flex & bison: Levine, John: Kindle Store[^]

By the end of the book you will have fully functional SQL parser (it covers some complex logical calculators too). With few tweaks you can adopt it to your own programming language. It uses Flex/Bison lexer and parser generator (both free GNU license) and utilizes BNF (Backus–Naur form) for grammar rules file.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900