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
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
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).
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/
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.
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.
The way I've always looked at C++ programming is that I am extending the language by creating new types to solve new problems.
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.