Live data from Hacker News

Wave Function Collapse library in pure C

github.com

21–30 of 87 posts

Re: Wave Function Collapse library in pure C

#21
post #15
post #9

Earlier quoted context omitted.

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.

This is a valid point. I was on the fence between doing .c/.h pair and a single .h. But finally took the inspiration from: https://github.com/nothings/stb .

Overall I think the code in the library is good, this was just the thing that stuck out to me most. Congrats on getting shared on HN.

Re: Wave Function Collapse library in pure C

#22
post #12
post #6

Earlier quoted context omitted.

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?

Yes. It's just an equation. The complexity of quantum system that can be simulate is limited. https://marl0ny.github.io/QM-Simulator-2D/index.html From the above link you can look single slit, double slit, triple slit, step, spike, or load an arbitrary image as a potential and do experiments in 2d box. >This WebGL program simulates the quantum mechanics of a single particle confined in a 2D box, where inside this box…

> btw. Wave function collapse in quantum physics is completely speculative phenomenon. There is only apparent wave function collapse.

To be more precise, the Born rule non-linear adjustment of the wave function to a single real value after a measurement is strictly necessary for QM to match experiments. Whether this should be interpreted as a physical phenomenon of wave function collapse, or as entanglement with the environment (MWI), or as an update of probabilities for hidden variables (Pilot wave) or some other phenomenon is speculative, but the wave function must be "collapsed" to a single real value after a measurement to correctly predict experimental results.

Re: Wave Function Collapse library in pure C

#23
post #16

Earlier quoted context omitted.

You don't need an elaborate build system to add a single .c file to your project

and now you need to add a .h to where ever you need to call those function. This .h will need to know if it got included multiple times, and so isn't just a trivial declaration. It's just easier to have a single .h you include.

>to add a .h to where ever you need to call those function

No, it can be in a single place and you can just #include it.

>This .h will need to know if it got included multiple times, and so isn't just a trivial declaration.

This is the point of using header guards.

>It's just easier to have a single .h you include.

Depending on the build tool it's the same or only marginally easier (you save like 10 characters)

Re: Wave Function Collapse library in pure C

#24
post #12

Earlier quoted context omitted.

Yes. It's just an equation. The complexity of quantum system that can be simulate is limited. https://marl0ny.github.io/QM-Simulator-2D/index.html From the above link you can look single slit, double slit, triple slit, step, spike, or load an arbitrary image as a potential and do experiments in 2d box. >This WebGL program simulates the quantum mechanics of a single particle confined in a 2D box, where inside this box…

> btw. Wave function collapse in quantum physics is completely speculative phenomenon. There is only apparent wave function collapse. To be more precise, the Born rule non-linear adjustment of the wave function to a single real value after a measurement is strictly necessary for QM to match experiments. Whether this should be interpreted as a physical phenomenon of wave function collapse, or as entanglement with the…

Adjustment is just cutting interference terms from equation. Mathematically apparent wave function collapse is caused by quantum decoherence.

Wave-function collapse as a priori process is just speculation. Finding that it actually happens would be new physics.

Re: Wave Function Collapse library in pure C

#25
post #19
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.

This is a sad idom followed in C and C++ libraries that cannot be bothered to learn build tools, dealing with C and C++ as if they were scripting languages.

Have you ever tried using a unity build?

Re: Wave Function Collapse library in pure C

#26
post #2

I wonder why the implementation is all in a header.

It is an atrocious fad imported a few years ago by young programmers coming from script languages, because they don't grasp modularity à la C and adding -lthatlib in a Makefile or a build script seems out of their reach :-(

Re: Wave Function Collapse library in pure C

#27
post #24

Earlier quoted context omitted.

> btw. Wave function collapse in quantum physics is completely speculative phenomenon. There is only apparent wave function collapse. To be more precise, the Born rule non-linear adjustment of the wave function to a single real value after a measurement is strictly necessary for QM to match experiments. Whether this should be interpreted as a physical phenomenon of wave function collapse, or as entanglement with the…

Adjustment is just cutting interference terms from equation. Mathematically apparent wave function collapse is caused by quantum decoherence. Wave-function collapse as a priori process is just speculation. Finding that it actually happens would be new physics.

In which case, where does the Born rule come from?

Re: Wave Function Collapse library in pure C

#28
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?

Sure. We’ve been doing quantum theory with pencil and paper for over a century!

Re: Wave Function Collapse library in pure C

#29
post #20
post #13

Earlier quoted context omitted.

That would be easier if the most popular build systems weren’t terrible

Or I don't know, people actually bothered to learn them.

Learning something doesn't stop it being terrible. One time I ran `cmake`, and forgot to run `sudo -k` beforehand. It reconfigured my system.

Re: Wave Function Collapse library in pure C

#30
post #13
post #9

Earlier quoted context omitted.

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.

That would be easier if the most popular build systems weren’t terrible

If the library is installed separately, the terribleness is about adding "-lfunkylib" to your linker command.

If you embed the source in your project, the terribleness is about adding to your Makefile:

  funkylib.o: funkylib.c
       $(CC) $
Post reply on HN