What's the current state of the art for module compilation?

monkyyy crazymonkyyy at gmail.com
Tue Dec 1 17:32:36 UTC 2026


On Tuesday, 1 December 2026 at 10:42:45 UTC, user1234 wrote:
> On Wednesday, 25 November 2026 at 00:08:35 UTC, monkyyy wrote:
>> On Tuesday, 24 November 2026 at 23:34:15 UTC, user1234 wrote:
>>> On Tuesday, 24 November 2026 at 15:54:56 UTC, monkyyy wrote:
>>>> On Tuesday, 24 November 2026 at 12:39:39 UTC, user1234 wrote:
>>>>> [...]
>>>>
>>>> Its always been templates *vs* linkers 
>>>> https://forum.dlang.org/post/ikuzqeynqbdxzlyjnrvw@forum.dlang.org
>>>>
>>>> [...]
>>>
>>> Thanks for the additional explanations.
>>>
>>> Do you have an alternative solution ? Depending on how 
>>> realistic it would be I'd be interested to concretly test 
>>> this, not for D but for the my own PL.
>>
>> I dont even have a complete mental model of this.
>>
>> Consider a drawing directed graphs of a physics simulation, a 
>> brick house would be presumably almost entirely in 
>> compression, a suspension bridge would be almost entirely in 
>> tension. Both should make a dag and be easy to reason about 
>> and Im pretty sure they both exist.
>>
>> Its not actually true, but in theory soviets were all push 
>> logistics and america is all pull logistics(this is a huge 
>> myth on the american side) and you get economists going 
>> "capitalism ho"; walmart is fairly pushy until you get to a 
>> warehouse then customers pull and they moderate demand with 
>> sells.
>>
>> Theres a spectrum of acceptable solutions here; but random 
>> systems fail, its awfully hard to fix a brick house with a 
>> steel cable. I couldnt tell you what sorts of subgraphs make 
>> for dysfunctional system.
>>
>> BUT, all push or all pull, will make a dag. So you could keep 
>> doubling down on templates, or have a file that is all 
>> explicit typing.
>>
>>> Do you have an alternative solution ?
>>
>> subsystems? Im optmistic of goose hotloading inside a dlang 
>> game engine(given its 10 mb compiler) I have a ai slop demo of 
>> particles. True hotloading works if you inject something in 
>> the runtime but the goose dev is rust and ai was uninterested 
>> in the suggestion and went with a safe option.
>>
>> My "innate" pattern make templates poke the linker to use the 
>> symbol table in a useful way; `template innate(T,T 
>> data,discrim...){ T innate=data; }` this avoid dual context 
>> issues as a "super global" reference
>>
>> Maybe you could mark a function as hotreloadable and data as 
>> "super global", and when you generate the .o in hotreload 
>> mode, every super global data is opened from cache and the 
>> hotreloadable functions are preped for dlsym?
>
> I see now. I think that you are lost into the static and 
> dynamic languages "schism". You should understand that the time 
> gain on static linking would then be lost during dynamic 
> loading, shouldn't you ?
>
> I mean at some point you have to call something. If that thing 
> is statically linked, it's fast. Othertwise you have to resolve 
> the address during the run-time. Plus, for every each call ? 
> without using an indirection ? Do you want the performances of 
> an interpreted languages while it is statically compiled ? Just 
> "comon". You have python, TS, for that.

Its not that simple, inbetween static and dynamic is at least 2 
types of progressive disclosure

consider:

```
struct onstacklists(T){
   ubyte length;
   T[0] data;
   ref T opIndex(int i){
     assert(i<length);
     return *((&data)+i);
   }
   ...
}
struct somestack(T,int N){
   ubyte[N] data;
   T[] malloc(int length)
   ...
}
struct stackiter(T){
   *onstacklist!T where;
   ...
   popFront(){
     move your onstacklist by the length
```

typeof(data[0]) still gives T, the size of the data isnt known 
its pushed into runtime details

---

```d
struct circle{
   ubyte id=0;
   ...
}
struct rect{
   ubyte id=1;
   ...
}
float area(void* shape){
   switch(shape.id){
     ...
```

"fat structs" may/should have a shared size and encode their type 
in a first/early field this does dynamic dispatch but all area's 
return floats by construction.
---

You can also do hotreloading of void* pointers in an element 
including "opApply" iterators, to get arbitrary behavior. Tho you 
could debate if that belongs on the type.

Runtime mutable behavior, introspection and size at on the table 
without a dynamic language. All that matters for static typing is 
you encode it as an indirection if it has dynamic size and you 
help it know the return types of functions.

Then you start talking about tiny compilers, tinycc is 100kb; you 
can just embed that in your 10 mb d hello world executable and 
compile time vs runtime would get all screwy.

Its only when you know nothing that you need the double 
indirection and heap allocation. You could go quite far using 
only one of these hacks at a time.


More information about the Digitalmars-d mailing list