Live data from Hacker News

Writing a winning 4K intro in Rust

codeslow.com

21–30 of 94 posts

Re: Writing a winning 4K intro in Rust

#21
post #18

How do they view the use of libraries in this competition? Do the libraries count toward your 4K?

Its only the output binary size that matters. If the libraries are in there then it counts. Where it gets a bit funny is graphics libraries and gpu features. You wouldn't include vulkan in your size but you get a bunch of features that weren't available on older hardware.

Re: Writing a winning 4K intro in Rust

#22
post #7

TIL: about the Demoscene[1], "an international computer art subculture focused on producing demos: self-contained, sometimes extremely small, computer programs that produce audio-visual presentations. The purpose of a demo is to show off programming, visual art, and musical skills. Demos and other demoscene productions are shared at festivals known as demoparties, voted on by those who attend, and released online." […

I'm surprised someone on HN since 2012 would learn about the demoscene today! Then again, it's true that the demoscene "keeps to itself", it's always been quite the bubble. I'm not sure how that community could do some outreach, but I believe a lot more people would find it interesting.

Something something lucky 10,000

Re: Writing a winning 4K intro in Rust

#24
post #6
post #5

Kinda surprised about iterators not getting optimized so well. Even in higher-level languages, this is a commonly utilized optimization opportunity - e.g. the C# compiler will replace a foreach-loop over an array with an identical (but faster) for-loop.

Compiler optimizers are full of surprises going both ways: good and bad. And details like this can probably change from version to version and get affected by compiling options. I would also expect that performance is higher priority than code size, generally, so missed opportunities like this might go unnoticed and unaddressed a long time if they don't show up on performance benchmarks.

The classic example of surprising optimization is perhaps matrix multiplication in Fortran:

At some point in history, when you wrote the straightforward, primitive three-nested-loops version of matrix multiplication your code ran much faster than when you tried to implement one of the more sophisticated algorithms.

That was because the Fortran compiler recognised the primitive version and replaced it with a special purpose highly optimized matrix multiplication. The compiler couldn't do that with the more sophisticated approaches.

Re: Writing a winning 4K intro in Rust

#26

I learned programming on the TRS80, and didn’t know about the demo scene until I was already too busy with other parts of my life; I think I first saw a demo on the Amiga. I always feel like I missed out on something transcendental. I think I would have leaned a huge amount. Instead I had to settle with hacking NewDOS/80 binaries. I have a huge amount of technical respect for the people who do this stuff.

It's never too late! Demoscene competitions happen all year round, around the globe. Some of the competitions are super focused and aren't a ton of work to do. The competitions (called "parties" in the scene) are a great way to spend a weekend with a bunch of like-minded nerds from many different disciplines: programming, graphics, music, ANSI/ASCII art, retrocomputing, etc.

Re: Writing a winning 4K intro in Rust

#27
post #18

How do they view the use of libraries in this competition? Do the libraries count toward your 4K?

Basically it has to run on a fairly clean Windows machine. The competition will usually publish the specifications of the machine ahead of time and what's on it. What you enter has to fit entirely within the bounds of the competition, but can use anything else on the machine if it's available. So you could enter say, a 4kb entry, and use a bunch of Windows .dlls for icons or something as artwork, but you couldn't enter a 4kb executable and 100MB of libraries and other stuff.

For some languages where this is really hard to achieve, they'll carve out a separate category for a language if they think there will be enough entries. e.g. a Java category where the entry fits with the space limit, but can use any other library in the default Java classpath, even though that's very very big. Likewise for different operating systems (Linux, MacOS competitions).

There's been a fantastic resurgence in retrohardware and a category called "old school/skool" for entries that have to run in MS-DOS -- which can be ultra hard as you have to code up a lot more of the runtime libraries like music, graphics rendering pipelines, etc.

Re: Writing a winning 4K intro in Rust

#28
That intro was very cool! Does anyone have pointers for a fullstack web dev who is interested in the demoscene (or computer generated art in general)?

I've actually played around a bit with rust [1] (I understand it probably isn't ideal for demoscence), but I haven't really done any graphics programming before. I get the feeling it is a pretty deep rabbit hole.

[1] https://github.com/dwaltrip/advent-of-code-2019-rust

Re: Writing a winning 4K intro in Rust

#29

Looks nifty. Seems to only compile on Win though: $ xargo run For more information about this error, try `rustc --explain E0463`. error: could not compile `winapi`. Still, probably good for interest/learning from. :)

Hm so it's leveraging the Windows API. I thought demos were supposed to be bare-metal.

Re: Writing a winning 4K intro in Rust

#30
post #29

Looks nifty. Seems to only compile on Win though: $ xargo run For more information about this error, try `rustc --explain E0463`. error: could not compile `winapi`. Still, probably good for interest/learning from. :)

Hm so it's leveraging the Windows API. I thought demos were supposed to be bare-metal.

The only way to achieve those kind of graphics in 4k is leveraging the Windows platform api. That is, unless you can drive a gpu and a soundcard from bare metal in 4k, while implementing the drivers and stuff for the hardware.
Post reply on HN