Jump to content

Photo

C++ is complicated; so how do I make my own programming language?


  • Please log in to reply
19 replies to this topic

#1 Kivitoe

Kivitoe

    Sponsored by Taco Bell

  • Members
  • Location:Beyond Sagittarius A*

Posted 12 October 2015 - 08:43 PM

I've been TRYING to learn C++, but with it being so hard just to make a simple hello, world! program in it I can just think how much harder it could get in C++ so I want to know how to make my own programming language.

 

Simple Hello, World! program in C++:

#include<iostream>
	using namespace std;

	int main()
	{
		cout << "Hello World!" << end1;
		return 0;
	}

My programming language idea Hello, World program:

startscript{
   
    new(application){
         
         print("Hello World!");
                    }
}

This is the complicated version of that in my language:

include gui_program;

startscript{

    new(application){

         button(text && Print Text; color && default; gravity && center);
             action(print("Hello World!"));
                    }
}
         

Which one is easier for you to understand? It wouldn't be C++ for me so I want to know how to make a programming language, but how?


Edited by Kivitoe, 12 October 2015 - 08:45 PM.


#2 thepsynergist

thepsynergist

    thepsynergist

  • Members
  • Real Name:Jeff Lee
  • Location:California, USA

Posted 12 October 2015 - 08:53 PM

http://lmgtfy.com/?q...raming language



#3 coolgamer012345

coolgamer012345

    🔸

  • Members
  • Location:Indiana, USA

Posted 12 October 2015 - 08:58 PM

Honestly, I would imagine it would much much easier to just learn a language that already exists rather than try to make one that's easier for you to understand, since as far as I know, there's nothing like a program that you could use to make a programming language, so you'd need to already know a coding language to be able to code a compiler/code running program/etc.


  • Beefster and nicklegends like this

#4 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 12 October 2015 - 09:01 PM

If you learn c/c++ you can use that to make a new language! :P
  • ShadowTiger, Magi_Hero, Beefster and 4 others like this

#5 Anarchy_Balsac

Anarchy_Balsac

    Quest Builder

  • Members

Posted 12 October 2015 - 09:02 PM

Let me put it this way, if the work involved in making Winter's Curse is a bit much for you, you may not want to try programming. 

 

Edit - and trying to make your own programming language.  Let's just say that even I don't know how to do that, and I'm well versed in coding.


Edited by Anarchy_Balsac, 12 October 2015 - 09:03 PM.


#6 David

David

    Fallen leaves... adorn my night.

  • Administrators
  • Real Name:David
  • Pronouns:He / Him

Posted 12 October 2015 - 09:04 PM

To be brutally honest, it is considerably easier for you to learn existing languages than to make a new one from scratch. You're in for a lot of work -- probably years of work, at best -- in which most of the time you will be confused. The odds of succeeding are heavily stacked against you, unfortunately. If you are not strongly self motivated to do this, it isn't going to happen. Not only that, but you have to have a substantial understanding of coding to actually make a programming language yourself, and even then it's a tough goal to accomplish. Because of these reasons, I think it's better to stick with existing languages to create whatever it is you are trying to make.

 

If you find yourself getting stuck with C++, I suggest trying to learn another language first. Java, in my opinion, is a great one to start with as it is not overly complicated and actually quite simple, relatively speaking.


  • nicklegends, Mani Kanina, Shane and 3 others like this

#7 Kivitoe

Kivitoe

    Sponsored by Taco Bell

  • Members
  • Location:Beyond Sagittarius A*

Posted 12 October 2015 - 09:21 PM

To be brutally honest, it is considerably easier for you to learn existing languages than to make a new one from scratch. You're in for a lot of work -- probably years of work, at best -- most of which will be you wandering in the desert. The odds of success are heavily stacked against you, unfortunately. If you are not strongly self-motivated to do this, it isn't going to happen. Not only that, but you have to have a substantial understanding of coding to actually make a programming language yourself, and even then it's a tough goal to accomplish. Because of these reasons, I think it's better to stick with existing languages to create whatever it is you are trying to make.
 
If you find yourself getting stuck with C++, I suggest trying to learn another language first. Java, in my opinion, is a great one to start with as it is not overly complicated and actually quite simple, relatively speaking.

Ahh yes Java, my personal favorite. I'm already programming in it though and find it close to English and overall the best programming language.
  • David likes this

#8 Aevin

Aevin

  • Members
  • Pronouns:He / Him
  • Location:Oregon

Posted 12 October 2015 - 09:39 PM

Something else to consider is that if you put in the considerable effort to make your own language, only you would know it and use it. That's not to say people can't invent new programming languages that catch on and become widely used, but the likelihood of that happening is pretty small. Learning something like c++ means you can apply that knowledge to all kinds of things that are typically done in c++. Think of the example of learning a spoken language. Would you rather learn Spanish or make up Kivitoish and be the only speaker?

 

On another note, please stop with replies like the links to Let Me Google That For You. If you don't have a meaningful contribution to the topic, such as responding to the question yourself, then don't post. Another staff member already addressed this here, and if it continues it will become a problem.


  • David and HavoX like this

#9 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 12 October 2015 - 10:28 PM

I know everyone else has been saying it's way more trouble to write a new language than to learn an existing one, but just for fun, here's what you'd have to do:

  • Write down a complete description of the language, its syntax, its reserved words, and all of its features (make sure you have a complete definition BEFORE you start writing the interpreter).
  • Learn an existing language with which to write a compiler/interpreter. C++ is a natural choice, but you could probably get it to work in Java. Or anything, really.
  • Using the existing language, write an interpreter program (probably easier than a compiler?) that will read in a MyScript (insert name here) program and execute native C++ (or Java, or Assembly, etc) functions for all of its system calls. (This is what a Python interpreter does when you open a Python prompt - read in the program one line at a time and follow the instructions as it goes).
Obviously, step 3 is harder than it sounds. But it is certainly possible. Some people with too much free time have developed their own weird languages like Whitespace and Shakespeare and so much more using this basic technique.

Edited by MoscowModder, 12 October 2015 - 10:33 PM.


#10 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 12 October 2015 - 11:06 PM

New language. Such complex... So try Dogescript! Very doge. Much amaze. Wow!

https://github.com/d...ript/dogescript





...well someone had to do it.
  • Magi_Hero, Beefster, Moosh and 6 others like this

#11 Beefster

Beefster

    Human Being

  • Members
  • Real Name:Justin
  • Location:Colorado

Posted 13 October 2015 - 01:00 AM

One does not simply "make" a new programming language. It takes years of programming experience to understand what is needed to make a good compiler. You not only have to understand the language you're using to program the compiler, but you also need to understand the language you compile to. You need to be well versed in computational theory, especially in creating context-free grammars in such a way that they can be processed in linear time. Once you have everything implemented, you not only need to test everything thoroughly, but you ideally will go through and prove the correctness of your compiler.

 

Interpreters are a fair bit easier, but not by much. You still have to do the grammars. And you'll probably want to put the interpreted code into a format that is quick to read, lookup, and execute. The only part you don't have to do is convert the code to machine code.

 

If you want to write a language and have people besides yourself use it, you also need to consider things that would set your language apart from all the rest, which, you guessed it, would require years of programming experience. (to even know what would be nice to have as a language feature.)

 

I would recommend starting by learning an easier language. Try Python or Java. Do those for a few years. Save C++ for when work, school, or performance requires it. (and I might add, you really shouldn't care about performance until you have at least 2 years of programming experience)

(or you can do C++ now, but you're in for a much rougher journey. You might also hit a wall once you have to deal with memory management for the first time.)


Edited by Beefster, 13 October 2015 - 01:02 AM.

  • Timelord and David like this

#12 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 13 October 2015 - 05:21 AM

If you're finding C++ to be a bit too intense, try base C, or Pascal. I suppose there's also VB, although that's an absolute rubbish language.

 

All else aside, if you want to 'make a programming language', you need to learn the machine code for the platform on which you want it to compile. Many other things too, but you'd need to start with x86 or x64 assembly

 

From what I can see, you are simply having trouble learning tokens, and identifiers. Also, Cobol uses definitions that you might like, but it's nothing like C++ otherwise.

 

Your HW C++ programme is actually a bit more than you need, too, as you can use printf to accomplish this.

#include <stdlib.h>
#include <stdio.h>

int main( void ) {
    printf ( "Hello World!\n" );
    system ( "PAUSE" );
    return 0;
}

You seem to want something between a classically structured language, and a markup language.

 

Here are some example language equivalents:

 

Pascal

Program Hello;
Begin
Write( 'Hello World.' );
Readln;
End.

C

#include <stdio.h>

main()
{
    printf( "Hello World" );
}

I think that you would enjoy using Pascal.


Edited by ZoriaRPG, 13 October 2015 - 05:38 AM.

  • HavoX likes this

#13 HavoX

HavoX

    Has more posts in Doomworld than in PureZC

  • Members
  • Real Name:Jon
  • Location:Republic, Missouri

Posted 13 October 2015 - 08:51 AM

Speaking of C, I've been wanting to learn to code in that language, so I got the "C for Dummies (2nd Edition)" book. I'm still reading it and haven't learned/memorized anything yet (yeah, it's a long book), but I did manage to bookmark the most important parts.

 

I agree with the others though; if you want to learn C++, you should at least learn the ones that are easier first.


Edited by HavoX, 13 October 2015 - 08:56 AM.


#14 Anarchy_Balsac

Anarchy_Balsac

    Quest Builder

  • Members

Posted 13 October 2015 - 12:08 PM

If you're finding C++ to be a bit too intense, try base C, or Pascal. I suppose there's also VB, although that's an absolute rubbish language.

 

All else aside, if you want to 'make a programming language', you need to learn the machine code for the platform on which you want it to compile. Many other things too, but you'd need to start with x86 or x64 assembly

 

From what I can see, you are simply having trouble learning tokens, and identifiers. Also, Cobol uses definitions that you might like, but it's nothing like C++ otherwise.

 

Your HW C++ programme is actually a bit more than you need, too, as you can use printf to accomplish this.

 

I prefer cout to printf.



#15 Deedee

Deedee

    Bug Frog Dragon Girl

  • Moderators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 13 October 2015 - 01:31 PM

Wait, wait, wait,...

You know java, the most useful programming language out there...

And yet you want to create a new language because you can't learn C++, which is easier to learn?

What.

No, how....?

 

Please explain.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users