Jump to content

How would one create a programming language?

Hello,

 

Ive always been fascinated by the concept of programming.

 

Recently, I was thinking about how one would create a programming language.

 

Would he or she have to create his or hers programming language inside another language?

 

For example:

 

Someone would have made Python by using Java

 

I am not wanting to do this, I was just wondering :)

 

Thanks to anyone that can help,

 

- Harry

It seems impossible until it's done.

Link to comment
https://linustechtips.com/topic/310485-how-would-one-create-a-programming-language/
Share on other sites

Link to post
Share on other sites

Hmm.. I have never actually heard of how they do it.. 

I know game engine and some other programs (like for example GIMP) are made with C.. But I am not sure if that is how languages are created too..

 

Usually languages only work in certain programs (for example, HTML on itself is pretty useless, but throw it in something like Chrome, Opera or FireFox and suddenly you have a webpage).

I think it could be done like that.

 

EDIT: sometimes languages are an edited version of another language. Like C#, C++ and many more languages come from C.

Some modified versions of languages might be easier, but maybe you can do less with it.

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to post
Share on other sites

Hmm I thought about this the other day, and it kinda left me beat :P good question though. 

 

I know very little about coding. But do explain if anyone has an answer 

Bleigh!  Ever hear of AC series? 

Link to post
Share on other sites

 

become jonathan blow. 

CPU: Intel 3570 GPUs: Nvidia GTX 660Ti Case: Fractal design Define R4  Storage: 1TB WD Caviar Black & 240GB Hyper X 3k SSD Sound: Custom One Pros Keyboard: Ducky Shine 4 Mouse: Logitech G500

 

Link to post
Share on other sites

well it's kind of complicated, you need a lexical, sintactical and semantical analyzer, you need a symbol table and you need a translator to turnyour high level commands to object code

 

i've got a class talking about this during this semester and a few years back (say 15-20) was one of the main parts of informatics, understand and program all this.

 

answering to your question, you can do it any way, obiously the first high level languages were coded with low level lenguages but if you can write something you can actually understand why write a bunch of comands using hexadecimal?

The best way to measure the quality of a piece of code is "Oh F*** "s per line

Link to post
Share on other sites

It depends. Interpreted programming languages like javascript (not to be confused with java) are just text files which are read by a native program (usually written in something like C++). To make an interpreted language, you just need to write an interpreter which will understand the commands and run the necessary native (C++) commands. This is pretty easy to do, but the performance is reduced as a result.

A lot of languages, such as C++, are compiled from the text directly into the binary representation that is interpreted directly by the processor. To make a language like this, you would write a compiler, usually using assembly (which itself is only a very slight abstraction of binary, and is the lowest level programming language aside from binary AFAIK). You don't really want to make a programming language like this unless you have a big team of people.

There are some languages, though I can't name any off the top of my head, which are compiled into another language. That new code is then fed into a compiler which converts it into native code. This is basically an intermediary between the other two - there's less effort than writing a binary compiler, but also slightly less performance (depending on your optimisations) than a binary compiled language.

HTTP/2 203

Link to post
Share on other sites

There are some languages, though I can't name any off the top of my head, which are compiled into another language. 

 java would be an example of this one, when you build a java program the .class files you get are just the java program tranlated into bytecode which is afterwards interpreted by the java VM

The best way to measure the quality of a piece of code is "Oh F*** "s per line

Link to post
Share on other sites

For new languages, you just need to make a program that outputs an executable file  (for something like C) or some kind of runtime that can execute instructions (in the case of something like python or Java). You can do that with any language, though creating a runtime language using a language that already has a runtime is pretty wasteful.

 

Is it not done through binary coding?

the final file is binary, but no one directly code in binary anymore. Coding in binary is a pain.

Link to post
Share on other sites

For new languages, you just need to make a program that outputs an executable file  (for something like C) or some kind of runtime that can execute instructions (in the case of something like python or Java). You can do that with any language, though creating a runtime language using a language that already has a runtime is pretty wasteful.

 

the final file is binary, but no one directly code in binary anymore. Coding in binary is a pain.

Well I mean whoever wrote the name of the sub forum does... ;)

It Won't Fail Cause of Me.

Link to post
Share on other sites

Well I mean whoever wrote the name of the sub forum does... ;)

 

 

if you call this writing code... yes

.text:00401000                 dec     esi.text:00401001                 push    ebp.text:00401002                 inc     esi

I assembled the forum subtitle into an executable and analysed with IDA (it was faster than converting to hex and manually analyzing).

Link to post
Share on other sites

At University, look for a class called Compiler Design.

This course focuses on you making your own programming language with it's own grammar (usually the professor will give you that, as that is massive amount of work to think about), and in the class you'll learn, using C/C++ or even Java, how to build a compiler for it, and have it execute. Complete with error detection.

It is a very difficult class, and time consuming. So don't have other heavy classes with it, and you'll do fine.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×