Live data from Hacker News

Wave Function Collapse library in pure C

github.com

1–10 of 87 posts

Re: Wave Function Collapse library in pure C

#3
post #2

I wonder why the implementation is all in a header.

This is a typical idiom frequently seen in modern C and C++ codes. As https://github.com/krychu/wfc#how-to-use-the-library says, you need to define a macro in a C file in order to "expand" the actual code there.

Having the code in the header gives a bit more flexibility considering the file layout. IMHO this is an awkward consequence of the missing de-facto-standard in C/C++ build systems.

Re: Wave Function Collapse library in pure C

#6

I feel like the algorithm is maybe poorly named. At first I thought this was a tool to help with computational quantum physics.

Very naive question but is it even possible to do quantum experiments with code on a regular computer? Anyone knows if it's been tried?

Re: Wave Function Collapse library in pure C

#7
post #6

I feel like the algorithm is maybe poorly named. At first I thought this was a tool to help with computational quantum physics.

Very naive question but is it even possible to do quantum experiments with code on a regular computer? Anyone knows if it's been tried?

You can simulate quantum dynamics but the number of bits required is exponential with respect to the number of qubits simulated. So basically you can simulate really simple quantum systems but it becomes pretty much intractable when the system you are simulating has many parts.

Re: Wave Function Collapse library in pure C

#8
post #3
post #2

I wonder why the implementation is all in a header.

This is a typical idiom frequently seen in modern C and C++ codes. As https://github.com/krychu/wfc#how-to-use-the-library says, you need to define a macro in a C file in order to "expand" the actual code there. Having the code in the header gives a bit more flexibility considering the file layout. IMHO this is an awkward consequence of the missing de-facto-standard in C/C++ build systems.

How is it more flexible exactly?

I hate this idiom every time I come across it. I like to look at the header file to see the interface and important documentation, and this just obscures it. Depending on your compiler it can make debugging a huge pain as well.

Re: Wave Function Collapse library in pure C

#9
post #3

Earlier quoted context omitted.

This is a typical idiom frequently seen in modern C and C++ codes. As https://github.com/krychu/wfc#how-to-use-the-library says, you need to define a macro in a C file in order to "expand" the actual code there. Having the code in the header gives a bit more flexibility considering the file layout. IMHO this is an awkward consequence of the missing de-facto-standard in C/C++ build systems.

How is it more flexible exactly? I hate this idiom every time I come across it. I like to look at the header file to see the interface and important documentation, and this just obscures it. Depending on your compiler it can make debugging a huge pain as well.

It does seem that 'modern' idioms tend to just be doing the same thing in a more obfuscated manner. Just a .c/.h pair would have been easier to add to your source.

Re: Wave Function Collapse library in pure C

#10

I feel like the algorithm is maybe poorly named. At first I thought this was a tool to help with computational quantum physics.

Wave Function Collapse is actually the same (or essentially identical) as Model Synthesis[1]. IMO that is a better name.

[1]https://paulmerrell.org/model-synthesis/

Post reply on HN