0

I was planning on learning a way to create my own programming language and I wanted to know what language to write a compiler with. C? C++?

kukac67
  • 298
  • 1
  • 3
  • 12
  • 4
    If you're going to create a compiler for your own programming language, what languages are supported by default on Windows 7 is the least of your problems... Adding language support is way easier than inventing a proper language and writing a proper compiler. – Eran Jul 01 '12 at 06:50
  • 1
    possible duplicate of [Learning to Write a Compiler](http://stackoverflow.com/questions/1669/learning-to-write-a-compiler) – Greg Hewgill Jul 01 '12 at 06:51
  • i know its easy to add language support, but i don't want to install a language until i am more "confident" of my skills since it aleays seems to be hassle... though this is off topic – kukac67 Jul 01 '12 at 06:54
  • 1
    While all recent Windows version include the .NET Framework and thus a C# compiler, the language really only gets powerful and easy to use when you combine it with a good IDE. Undoubtedly Microsoft Visual Studio is the best for C#, but some free IDEs also exist. In other words, having "to install a language" should be the least of your concerns. – Wormbo Jul 01 '12 at 07:08
  • 1
    Wormbo, Visual Studio Express is free as well. – Joey Jul 01 '12 at 07:35
  • For very basic programming you can even use your web browser (pretty much any popular one except Internet Explorer, which is lacking a number of extremely useful features, especially HTML5, coming in Win8 in IE10). You can learn a lot of programming concepts with HTML (most notably HTML5), JavaScript, CSS and DOM. You can make simple games with all that in your browser. You can make a simple language interpreter and compiler with that too. Make a BASIC interpreter. Then make a compiler out of it (generate asm code for it, then assemble). – Alexey Frunze Jul 01 '12 at 07:41

2 Answers2

2

Windows Vista and newer come with the .NET Framework installed by default. That in turn already provides a compiler for the .NET languages (most notably C# and VB.NET). It's the only provided language you could possibly write an efficient compiler in. Other languages are VBScript and JScript (via windows Scripting Host) and batch files, so nothing you'd really want to implement more complicated stuff in.

Depending on the complexity of the language you want to create, a C++ implementation may provide better performance, though. No offense, but you don't quite make the impression that you really know how to implement a compiler for a new language. Greg Hewgill's link should give you some starting points there. The thing is, creating a new (formal) language is anything but a trivial task. Yes, the tools to do it are free, and so is the knowledge. But you should really already have a solid understanding of the programming language you want to write the compiler or interpreter in before even attempting to do it.

Joey
  • 344,408
  • 85
  • 689
  • 683
Wormbo
  • 4,978
  • 2
  • 21
  • 41
  • you might be right, im not TOO familiar with making a compiler and such, but as I stated I am tryig to learn. Ive already learn things such as what steps a compiler takes (lexical analysis, parsing, etc.) and i hope i learn more. I do have a better understanding of C/C++ than C# but if that's what it takes than I am willing to learn. Thanks for your answer. :) – kukac67 Jul 01 '12 at 07:11
  • There's also JavaScript in the same `cscript.exe` as VBScript. There's also PowerShell. – Alexey Frunze Jul 01 '12 at 07:35
  • But Powershell isn't installed by default, is it? – Wormbo Jul 01 '12 at 07:42
  • 1
    [`You do not have to download Windows PowerShell 2.0 if you have Windows 7 because it is already installed. Unfortunately, it is kind of hidden. To launch Windows PowerShell, you can use the Search Programs and Files dialog box. All that you have to do is type the word PowerShell and press Enter`](http://blogs.technet.com/b/heyscriptingguy/archive/2011/01/07/how-do-i-install-powershell-on-windows-7-and-other-questions.aspx) -- right from the horse's mouth. – Alexey Frunze Jul 01 '12 at 08:15
  • There won't be any performance advantage in using C++ instead of a managed language for implementing a compiler. Tree- and graph- related algorithms are equally efficient in both worlds, unlike the numeric stuff. – SK-logic Jul 01 '12 at 09:24
  • Does this 'default' .NET installation really include a compiler? – user207421 Jul 02 '12 at 09:56
  • @EJP, yes, it does, `csc.exe` and `vbc.exe` are a part of .NET runtime. You will find them in your $WINDOWS/Microsoft.NET/Framework/$version/ – SK-logic Jul 02 '12 at 11:11
-1

I suggest you use C#; DLR is great for this purpose.

Mehrdad
  • 2,054
  • 3
  • 20
  • 34