Monday, January 19, 2026

Amazon Autos (Beta)

 Amazon.com: Amazon Autos

Amazon.com : pick up truck





.NET C# meta-programming: Comptime (vs LISP)

Watch out LISP based languages, DotNet is coming (50 years later :)

And while in Lisp code is in same format as data, so it is natural to generate code,
other languages need to use tools and tricks to do it. 
Still, that can be useful...

Comptime brings meta-programming capabilities to C#, enabling compile-time code generation and evaluation.

sebastienros/comptime: Comptime brings meta-programming capabilities to C#, enabling compile-time code generation and evaluation. @GitHub

A .NET source generator that executes methods at compile time and serializes their results to C# code. Comptime brings meta-programming capabilities to C#, enabling compile-time code generation and evaluation.

Comptime allows you to mark methods with the [Comptime] attribute to have them executed during compilation. The return values are serialized into C# source code and used at runtime, eliminating the need for runtime computation of values that can be determined at build time.

This meta-programming approach enables developers to shift expensive computations from runtime to compile time, resulting in faster application startup and execution.








Lisp is considered the quintessential language for metaprogramming due to its unique feature of homoiconicity, where the code is represented as the language's primary data structure (lists, or s-expressions). This allows programs to manipulate their own source code as data during compilation or runtime, enabling powerful abstractions and dynamic language extensions. 
Core Concepts
  • Code as Data: In Lisp, source code is written as s-expressions, which are essentially nested lists. This makes the code accessible and manipulable using the same functions and data structures used for regular programming tasks.
  • Macros: Lisp macros are the primary tool for metaprogramming. Unlike simple text-substitution macros (like those in C/C++), Lisp macros operate on the Abstract Syntax Tree (AST) of the code at compile time.
    • How they work: A macro takes unevaluated code (as a list) as input and returns new Lisp code (also as a list). This generated code is then inlined and compiled at the macro's call site, effectively extending the language's syntax and behavior.
    • Power: This capability allows programmers to define domain-specific languages (DSLs) and new control flow constructs (e.g., a when-let macro for conditional binding) without modifying the core compiler.
  • Eval Function: Lisp was the first language to introduce an eval function, which can take a data structure and interpret it as code at runtime, further blurring the line between runtime and compile time. 
Benefits and Challenges
  • Benefits: Lisp metaprogramming fosters incredible flexibility and expressive power, enabling sophisticated code generation and reducing code duplication. This flexibility has been a key factor in Lisp's historical use in Artificial Intelligence (AI) and modern use in cutting-edge fields like quantum computing.
  • Challenges: The power of metaprogramming comes with a trade-off in complexity. Code that heavily uses macros can be difficult for less experienced programmers to understand and debug, particularly concerning scope rules and evaluation order.