Live data from Hacker News

Comptime – C# meta-programming with compile-time code generation and evaluation

github.com

1–10 of 71 posts

Re: Comptime – C# meta-programming with compile-time code generation and evaluation

#5
post #2

This seems like the kind of feature that should be built into MSBuild.

It's a lot less ergonomic but there are source generators in C# :

https://devblogs.microsoft.com/dotnet/introducing-c-source-g...

That said, for more complex results, you'd typically load a serialization on start.

I can see the value in this tool, but there must be a fairly limited niche which is too expensive to just have as static and run on start-up and cache, but not so large you'd prefer to just serialize, store and load.

It also needs to be something that is dynamic at compile time but not at runtime.

So it's very niche, but it's an interesting take on the concept, and it looks easier to use than the default source generators.

Re: Comptime – C# meta-programming with compile-time code generation and evaluation

#6
post #5
post #2

This seems like the kind of feature that should be built into MSBuild.

It's a lot less ergonomic but there are source generators in C# : https://devblogs.microsoft.com/dotnet/introducing-c-source-g... That said, for more complex results, you'd typically load a serialization on start. I can see the value in this tool, but there must be a fairly limited niche which is too expensive to just have as static and run on start-up and cache, but not so large you'd prefer to just serialize, store…

Also t4 templates before that for at least a decade

Re: Comptime – C# meta-programming with compile-time code generation and evaluation

#7
post #5
post #2

This seems like the kind of feature that should be built into MSBuild.

It's a lot less ergonomic but there are source generators in C# : https://devblogs.microsoft.com/dotnet/introducing-c-source-g... That said, for more complex results, you'd typically load a serialization on start. I can see the value in this tool, but there must be a fairly limited niche which is too expensive to just have as static and run on start-up and cache, but not so large you'd prefer to just serialize, store…

Not terribly niche. All config that isn’t environment-specific and is used in inner loops or at startup. It’s even got a test for serialised values so can be used to speed your case up:

https://github.com/sebastienros/comptime/blob/main/test/Comp...

But you need to be sure you won’t want to change without compiling.

Re: Comptime – C# meta-programming with compile-time code generation and evaluation

#9
Makes me think of Boo language; Boo was so good at metaprogramming and multi-phasr programming! A very fine .NET language that was so far ahead of the curve, with having the tools of that language be usable at runtime.

Alas many of the docs are offline now. But it had great quasiquotes, which let you write code that gets turned into AST that you can then process. Good macros. A programmable compiler pipeline. So much. Alas, obscured now. https://boo-language.github.io/

Re: Comptime – C# meta-programming with compile-time code generation and evaluation

#10

Makes me think of Boo language; Boo was so good at metaprogramming and multi-phasr programming! A very fine .NET language that was so far ahead of the curve, with having the tools of that language be usable at runtime. Alas many of the docs are offline now. But it had great quasiquotes, which let you write code that gets turned into AST that you can then process. Good macros. A programmable compiler pipeline. So much…

Boo and Nemerle both were really showing what was possible in .NET back in the early days. I still miss the metaprogramming they had, not to mention their pattern matching (which C# has closed the gap on, but is still way, way short.)
Post reply on HN