Jump to content

How are programming languages even created?

Go to solution Solved by Paralectic,

You make a compiler, and a compiler does the work to "translate" an existing programming language to a lower one, to assembly or whatever to being able to do anything with it.

 

If you would make your own language, you'll need your own compiler and I have no idea on how to create one.

I'm not interested in creating my own programming language, but it has always perplexed me how programming languages are even developed in the first place. As far as I know, Assembly was the first programming language (1949!), aside from straight up binary ones and zeros. I'm confused - if a computer can only really understand the ones and zeros and needs code written in a programming language that humans understand to be compiled, how was Assembly even created in the first place? I know that before the late 1960s computers didn't really have screens and used physical switches, lights and punch cards for humans to tell them what to do, and to give their answers, so maybe Assembly was created using these switches or punch cards, but I don't know - that's why I'm asking.

 

Furthermore, how were more modern programming languages like C#, C++ or Python created? Do they develop them by typing endless strings of ones and zeros or by using other programming languages?

I have no signature. There is nothing to see here. Move along.

Link to comment
https://linustechtips.com/topic/590237-how-are-programming-languages-even-created/
Share on other sites

Link to post
Share on other sites

You make a compiler, and a compiler does the work to "translate" an existing programming language to a lower one, to assembly or whatever to being able to do anything with it.

 

If you would make your own language, you'll need your own compiler and I have no idea on how to create one.

Link to post
Share on other sites

1 minute ago, Paralectic said:

You make a compiler, and a compiler does the work to "translate" an existing programming language to a lower one, to assembly or whatever to being able to do anything with it.

 

If you would make your own language, you'll need your own compiler and I have no idea on how to create one.

Oh, I see. It took me a few seconds to understand what you meant, but I've got an idea, I think. You make the compiler in the lower programming language, and you make the compiler understand the newer, higher language... right? So Assembly was created by pretty much lying out strings of ones and zeros, if this is the case.

I have no signature. There is nothing to see here. Move along.

Link to post
Share on other sites

1 minute ago, LOLZpersonok said:

Oh, I see. It took me a few seconds to understand what you meant, but I've got an idea, I think. You make the compiler in the lower programming language, and you make the compiler understand the newer, higher language... right? So Assembly was created by pretty much lying out strings of ones and zeros, if this is the case.

I don't know how compilers are made or in what language but I understand that they translate any language into a lower one like assembly.

Link to post
Share on other sites

1 minute ago, Paralectic said:

I don't know how compilers are made or in what language but I understand that they translate any language into a lower one like assembly.

I don't really need to know how a compiler is made, because I think I've gotten my answer. Thanks.

I have no signature. There is nothing to see here. Move along.

Link to post
Share on other sites

Assembly is basically the english version of machine code (the ones and zeros).

Any line of code in assembly can be translated into machine code by just using a translation table ie.

 

"sub R1, R2" translates into "0101101010010101001" (just made that up) so no logic required.

 

So you compile your language of choice into assembly which is then translated into the binary machine code.

Link to post
Share on other sites

*Warning* I may be completely out to lunch on this as I have never created a language, compiler, or even researched the subject. (But it is definitely on the to do list as I need a way of bridging 3 different shading languages for game development.)

 

I would imagine you would start with defining the semantics of the language. This would be things like the memory model, atomic data types, how concurrency is handled, OO or something else etc. After that you would define the syntax of your language. From there it would be creating a compiler or interpreter in another language that actually exists (so far the new language would be purely pen and paper) to translate the new language into the compiler native language or straight to something like assembly. Bam one programming language. 

CPU: Intel i7 - 5820k @ 4.5GHz, Cooler: Corsair H80i, Motherboard: MSI X99S Gaming 7, RAM: Corsair Vengeance LPX 32GB DDR4 2666MHz CL16,

GPU: ASUS GTX 980 Strix, Case: Corsair 900D, PSU: Corsair AX860i 860W, Keyboard: Logitech G19, Mouse: Corsair M95, Storage: Intel 730 Series 480GB SSD, WD 1.5TB Black

Display: BenQ XL2730Z 2560x1440 144Hz

Link to post
Share on other sites

1 minute ago, AlexTheRose said:

Yeah, this is not how you begin creating a programming language. It’s one of the steps, I’ll give you that, but it doesn’t really shed a whole lot of light on the whole perspective of creating a language from the ground up.

 

I have designed a Turing-complete language and even went so far as to write an assembler/compiler for it, so I think I know what I’m gonna go on about here.

 

 

Arguably, you will not spend the majority of your time building the compiler for your language. To make a decent language, you have to know a lot about context-free language design, which is something you can learn by going to university for Computer Science or something for probably years on end, or you could wing it like I did reading reference material and hanging out with developers all day every day. You need to decide between strong or weak typing (or both), the overall grammar of the language, whether you want it compiled or interpreted, whether to use AOT or JIT if you decide to go compiled, and many more minor properties of your language before you even start.

 

After that, you need to write a specification for the language! This is something you can do in Word, but if you want to be more professional about it you can do it in LaTeX. This is the last revision of the specification for my language – as simple as the language is the spec is 55 pages long. Specifications for big-time languages such as C or C++ are much longer. Once your specification is mature—as in, you have to let it simmer for a couple months with no additions—then it is time to write a preliminary compiler for it.

 

 

I hope that gives you a better perspective of what it means to make a programming language. It is certainly no easy task.

Yeah thank.

'never said it was anything near being easy.

Link to post
Share on other sites

5 minutes ago, Paralectic said:

Yeah thank.

'never said it was anything near being easy.

Fortunately I have no desire to make a programming language. Now making video games? That's a whole other thing which I am very interested in doing, and is arguably more difficult.

I have no signature. There is nothing to see here. Move along.

Link to post
Share on other sites

On 2016-05-02 at 4:12 AM, AlexTheRose said:

What could be interpreted as “making video games” varies wildly, and without context there’s really no telling what you mean by it definitively. My best guess is that you’re talking about something along the lines of Unity3D, which is piss easy compared to trying to write an LLVM compiler, or worse yet from scratch.

 

If you were designing an entire engine from the ground up though, that’s a different—and definitely more expensive—story.

 

You’d need years to single-handedly do either of these tasks and still do a decent job, in any case – writing a compiler or engine, I mean. So for serious work it’s really neither here nor there.

If I ever do end up doing a video game on my own, I won't be making the engine, no way in hell. Besides, for my current idea I could easily use one of the open source engines or somewhat open source engines because they'd do all I need them to do. But even still, that's a pretty long ways off. I'm just beginning to learn C++ - I'm on my second day. I feel so accomplished right now because I actually made a program that can take a number a user inputs and adds 5 to it, and the adding part was done by me with only a little help. I know, it sounds pretty sad and it's incredibly simple, but it's pretty awesome since I still can't really do anything with C++.

 

I've currently got two ideas for video games: one's pretty much just a racing game, and the other is this over-the-top open-world game with all kinds of stuff. I might be able to do the racing game on my own (because I've got just a few ideas for it, where I've got a ton of ideas for the other), but I'd need lots of help for the open-world game. I'll be going to college and will eventually be taking a straight-up game development course, and hey, if we do a class project (where the whole class is in on it, there will be 64 class mates) I think that game could happen. Unlikely, but it might. This idea is too cool and I'm too in love with it to let it die.

I have no signature. There is nothing to see here. Move along.

Link to post
Share on other sites

 

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to post
Share on other sites

The principle behind programming languages and compilers is dead simple, others have explained it well.

 

You can write a simple compiler basically overnight. I wrote an Assembly decompiler (converts from machine code to Assembly) in Assembly (almost at inception level here, lmao) for Intel 8088 processor overnight, though it's not able to do some things haha. Actually you might be surprised to hear that the C compiler is written with C, the Computerphile video linked above explains that if I remember right :)

 

Creating a modern and cross-platform compiler is a task of monstrous proportions. Your compiler has to be able to compile for different CPU architectures (x86, ARM etc), and even those can have multiple extra instruction sets (SSE3, SSSE3, SSE4.x, AMD's 3DNow!, etc). If there is some existing code that could benefit from those new instruction sets, you recompile that code with a new and upgraded compiler and you're done. Nowdays, JIT compiled languages like C# and Java do this run-time basically, the virtual machines they run in can detect what the processor is and what instructions it has, executing code accordingly, though the machine itself still has to be compiled for new architectures, the JIT compiled code can be portable in most cases.

 

Another important scenario to put things in perspective: imagine you manufacture some new micro-controller or CPU, the developers won't be able to compile their existing code on the new chip without a compiler, so the author company/person either writes one from scratch or implements their new instruction sets to existing awesome compilers and suddenly empower developers to do great things and re-use all (at least most) of their code.

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

×