+ 14

How to create our own programming language and a compiler for it?

I can't understand how people create programming languages and devise compilers for it. I also couldn't understand how people create OS like Windows, Mac, UNIX, DOS and so on. The other thing that is mysterious to me is how people create libraries like OpenGL, OpenCL, OpenCV and so on. The last thing I am unable to figure out is how scientists devise an assembly language and an assembler for a microprocessor. I would really like to learn all of these stuff😊.

18th Feb 2020, 5:15 PM
Yaseen Akbari
Yaseen Akbari - avatar
8 Respuestas
+ 8
A programming language works just like a human language: it has grammar (syntactic rules how you formulate instructions) and vocabulary (keywords and symbols which make up the tools available to the programmer). A program has to strictly follow these rules at all times. A compiler turns these instructions into machine code. Normally this is done by syntactic and semantic analysis, by building up an Abstract Syntax Tree and converting it to machine language that computers understand. https://en.m.wikipedia.org/wiki/Abstract_syntax_tree To write a good compiler you would need to have a good understanding of the hardware too. https://softwareengineering.stackexchange.com/questions/165543/how-to-write-a-very-basic-compiler
18th Feb 2020, 6:37 PM
Tibor Santa
Tibor Santa - avatar
+ 7
Simple: how compilers work and how to create our own programming language?
19th Feb 2020, 2:27 AM
Yaseen Akbari
Yaseen Akbari - avatar
+ 4
I strongly suggest asking those as separate questions so you get more actual answers to your questions instead of responses like "get a CS degree." For the assembly language question, I recommend you get an old DOS emulator and create your own COM assembler. The com file format is as simple as executable files can be and the old instruction sets for 8086 are far simpler than what is supported now so the old technology would be easier to support. Use a hex editor and an x86 instruction set reference to get started. Even if you don't make a complete polished assembler, getting some simple features to work and some trivial little programs generated will teach you the fundamentals of assembly and machine languages. The assembler I wrote is at: http://planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1501&lngWId=7 which includes a screenshot of a running program made with it. Creating your own high level programming language seems more challenging in many ways. I took a university course on it and still found teaching myself to make an assembler easier. http://jlu.myweb.cs.uwindsor.ca/214/a4.html guides you a little on creating a parser from a context-free grammar. Those tools are enough to make a high level language to other high level language translator. This way you can design a new language and translating to a better supported language like Java or c++ gives your new language a path from your custom language's source code to compiled .class, .dll, .exe... executable files.
20th Feb 2020, 4:31 PM
Josh Greig
Josh Greig - avatar
+ 3
Complicated and hard question 🤔
21st Feb 2020, 1:02 AM
Mahsa Ashna
Mahsa Ashna - avatar
+ 2
These questions are very complex to answer. To better understand all this you really need a CS degree. Making a language requires you to make a compiler for it. To make an OS you need to make your own files for it or use the existing ones for it like in the case of linux. The scientist that make and study the microprocessor already know a lot of the old ones and will in most cases innovate on the existing systems than create an entire new system.
19th Feb 2020, 12:55 PM
anup
+ 1
I always thinking about when I will develop my own programming language
20th Feb 2020, 2:44 PM
Emmanuel F Kamara
Emmanuel F Kamara - avatar