Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a small programming language for beginners

I would like to create my own programming language. Maybe not exactly a programming language from scratch but maybe base it on another language.

I've heard of Yacc. So, I installed Flex and Bison. But I do not understand how to make a compiler with it. I have made the Hello world project in it, but how would I make a compiler in it?

Are there any easy ways of creating a small programming language, I have heard of translating a language as in taking, e.g., Write() and making the computer understand it as Print().

Is this be possible?.

like image 938
Gabe Avatar asked Jul 12 '13 07:07

Gabe


People also ask

What coding language is easiest for beginners?

If you're new to the world of programming, Python is the best coding language to start with. It's a beginner-friendly code with a simplified syntax, using fewer lines than other coding languages, making it easy to read, understand, and use.

Can I create my own programming language?

You can just take a subset of an existing language or come up with a simple variation of it and get started. However, if you have plans for creating your very own programming language, you will have to give it some thought. I think of designing a programming language as divided two phases: The big-picture phase.

Which is the shortest programming language?

The shortest code on average is produced by programs written in Wolfram's Mathematica. The runner-up is Clojure, closely followed by the R language. For comparison, programs written in Python are more than twice the length of equivalent programs in R; programs in C++ are about 4x the length.


1 Answers

You might consider learning to build a compiler from a fabulous 1964 (yes, you read that right) paper META II: A Syntax-Oriented Compiler Writing Language on how to build "meta compilers".

This paper contains, in 10 pages, a compiler writing philosophy, a definition of a virtual compiler instruction set that is easy to implement, a compiler-compiler, and an example compiler built using the compiler-compiler.

I learned initially how to build compilers from this paper back in 1970 odd. It is astonishing how clever and conceptually simple it is.

If there was a paper I'd make every computer science student read, this would be it.

You can get the paper, see a tutorial and an implementation of MetaII in JavaScript here. The guy behind the tutorial is Dr. James Neighbors, source of the term "domain analysis".

like image 109
Ira Baxter Avatar answered Sep 21 '22 06:09

Ira Baxter