views:

193

answers:

7
+1  Q: 

Sub Language C#

Hi All

I was just wondering, is it at all possible to create sort of like a "Sub-language" in C# OR C++? or would a better term be "Extension"? And can somebody please provide links/resources?

Much appreciated! :)

thanks jason

A: 

It all depends on what you consider a "sub-language".

You could create just about anything you want if you're willing to put the time and effort into learning how to utilize the DLR (Dynamic Language Runtime).

Justin Niessner
+10  A: 

I think maybe the phrase you are looking for is Domain Specific Language?

One example is Boo for .net

Book on Boo: http://www.manning.com/rahien/

Link on building DSLs for .Net

Kevin
A: 

Can you be more specific? You can build your own dynamic languages on the DLR. Also here.

jeffamaphone
A: 

For simplicities sake I'm making my contribution 'your-very-own-scriptlanguage'. If you are not concerned about pre-compiled code but instead want something compiled in runtime, you could look into making your own script language and write a parser for it so you can execute it in runtime.

Jonas B
A: 

Well, .net is a multi-language platform. You would need to write a compiler of course, and you can write that compiler in any language, including C#. I've started a series about writing a brainf**k compiler in C#.

A compiler doesn't have to be Languague-to-IL, you can also write a compiler that compiles Language-To-C# and then uses the C# compiler (Some people call those compilers pre-processors). You just need to be sure that whatever you do can be translated to C# (or C++ if that's what you want to do). Then you can just define your keywords and language tokens.

Just keep in mind that creating new, insular programming languages can be a maintenance debt in the future and often is a sign of too much "Not invented here"-syndrome.

Michael Stum
+2  A: 

The way I've always looked at C++ programming is that I am extending the language by creating new types to solve new problems.

anon
A: 

I've used Irony to implement a DSL and it worked out great. Keep in mind it's still very much a WIP and you'll probably find it pretty nice to work with.

Ron Warholic