Click here to Skip to main content

Welcome to the Lounge


For lazing about and discussing anything in a software developer's life that takes your fancy.
The Lounge is rated PG. If you're about to post something you wouldn't want your kid sister to read then don't post it. No flame wars, no abusive conduct and please don't post ads.

Technical discussions are welcome, but if you need specific help please use the programming forums.

GeneralRe: Nostalgia PinmemberPJ Arends19-Dec-11 21:37 
GeneralRe: Nostalgia PinmemberMike Hankey20-Dec-11 1:41 
GeneralRe: Nostalgia PinmemberMycroft Holmes19-Dec-11 21:56 
GeneralRe: Nostalgia PinmvpAbhinav S19-Dec-11 21:10 
GeneralRe: Nostalgia PinmemberChris C-B19-Dec-11 21:54 
GeneralRe: Nostalgia Pinmemberviaducting19-Dec-11 22:26 
GeneralRe: Nostalgia PinmvpCPallini19-Dec-11 22:03 
GeneralRe: Nostalgia PinmemberJ. Dunlap19-Dec-11 22:35 
Roger Wright wrote:
The question that drove me to post this tidbit is, is there any contemporary language which offers this same functionality, to save its own output as executable (okay, interpretable) code? If so, I think I'd like to learn it, just in case. If not, would somebody please add it to C#, since that's the language I currently enjoy?

There's a number ways you can do something at least similar to that in C#:
  • Mono.Cecil[^] - modify the IL (.NET byte instructions) in assemblies, then write them out to disk and load/run them
  • Expression trees - generate code by building syntax trees (just about any code statement - not just expressions) and dynamically compiling it in memory. Might take a little getting used to because you work with syntax trees rather than code, but it is super fast because it doesn't have to parse anything and it does everything in-memory.
  • CodeDOM - output actual C# code constructs using an object model, then send it to the C# compiler
  • Write code to manually output C# code, then invoke the C# compiler (which is always installed with the .NET framework) and load/run the resulting assemblies
  • Use the DynamicMethod class to output IL directly into memory and compile it

GeneralRe: Nostalgia PinmemberPIEBALDconsult20-Dec-11 4:10 
GeneralRe: Nostalgia PinmemberKythen20-Dec-11 5:12 
GeneralThe Book of Mozilla PinmemberShameel19-Dec-11 19:20 
GeneralRe: The Book of Mozilla [Spoiler alert] PinmvpAbhinav S19-Dec-11 19:39 
GeneralRe: The Book of Mozilla Pinmvpthatraja19-Dec-11 19:43 
GeneralRe: The Book of Mozilla PinprotectorAspDotNetDev19-Dec-11 20:09 
GeneralRe: The Book of Mozilla PinmemberShameel19-Dec-11 20:23 
GeneralRe: The Book of Mozilla PinprotectorAspDotNetDev20-Dec-11 4:07 
GeneralRe: The Book of Mozilla Pinmember_Maxxx_19-Dec-11 20:27 
GeneralRe: The Book of Mozilla PinmemberPaulowniaK19-Dec-11 20:36 
AnswerRe: The Book of Mozilla PinmemberRogelioP / EX DE,HL20-Dec-11 3:31 
GeneralI'm Back Pinmemberwalterhevedeich19-Dec-11 19:06 
GeneralRe: I'm Back Pinmvpthatraja19-Dec-11 21:20 
GeneralA thought about HTML5 PinmemberNajeeb Shaikh19-Dec-11 17:31 
GeneralBusted PinmemberRTek2319-Dec-11 15:55 
GeneralRe: Busted Pinmember_Maxxx_19-Dec-11 17:37 
GeneralRe: Busted PinmemberGarth J Lancaster19-Dec-11 18:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 20 Sep 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid