HNHacker News
TopNewBestAskShowJobs

flohofwoe

23,650 karma · joined October 15, 2013

submissionscomments
flohofwoe··on Zig – SPIR-V Backend Progress
Zig's SPIRV support is on the same abstraction level as GPU shading languages (GLSL, MSL, HLSL, WGSL, ...), there's nothing particularly "magic" about turning imperative source code (no matter if Zig or any other language) into a sequence of SPIRV instructions, it's not all that much different from generating x86 or ARM instructions.

The main difference to 'traditional' CPU programming is that you don't write an entire 'application' with a single main function, but instead many small-ish self-contained functions that will run 'per vertex', 'per pixel' or 'per compute invocation' on the GPU.

The Zig toolchain is only concerned about how to compile Zig code into SPIRV blobs, but not about how that code is then 'uploaded' and 'orchestrated' on the GPU, instead this is the job of APIs like Vulkan (e.g. there is no magic integration between CPU- and GPU-side code in the Zig toolchain like in the CUDA toolchain).

SPIRV's specification basically defines what features Zig needs to expose as specialized builtins or language features (e.g. things like `@SpirvType(.sampler);` or `@SpirvType(.{ .image = .{...` or `@extern(*addrspace(.constant)` map directly to SPIRV concepts (the same concepts that dedicated shading languages had to add on top of C or C++).

flohofwoe··on The CEO of Mullvad is the main financer of the Swedish Örebro party
Lol, so Hitler was 'left wing' because he built the Reichsautobahn, got it...
flohofwoe··on The CEO of Mullvad is the main financer of the Swedish Örebro party
Not doing business with a company (for any reason btw) is not 'punishment'. Nobody is taking away anything from the company or any people involved with that company.
flohofwoe··on The CEO of Mullvad is the main financer of the Swedish Örebro party
> Extremely left wing dental care is the best I will give them.

Free dental care is considered "extemely left wing" now? That's just bizarre tbh.

If a country would decide to use tax money to provide health care services for free to everybody that's not much different than using tax money to maintain an infrastructure network that's free to use (like roads), or free police and firefighting services - and I think none of those examples are considered particularly 'left-wing'.

flohofwoe··on The CEO of Mullvad is the main financer of the Swedish Örebro party
Sounds like the logical evolution of left/right-populism into 'absolutist-populism' ;)
flohofwoe··on The CEO of Mullvad is the main financer of the Swedish Örebro party
> in that case we might punch em in the face

Nobody is calling for violence though?

In a free democratic society nobody is forced to do business with anybody they don't agree with, and free speech means they can talk about their decision without fearing repercussion.

flohofwoe··on Dissecting Apple's Sparse Image Format (ASIF)
The article is about disk images though :)

But yeah, while I think the `cstruct` helper function to describe a binary data layout in Python is more elegant than the builtin alternatives, it would have been much less painful to just go with a minimal C command line program (or any other programming language where a struct directly maps to memory). Python and most other scripting languages have been built for manipulating text data, but suck when working with binary data.

flohofwoe··on The last Romans are still around
Maybe in Erdogans dreams ;) (
flohofwoe··on The last Romans are still around
Yeah, but every empire worth its salt needs a good 'garage story' ;) (like the Romans claiming to be descendants of Trojan war refugees)
flohofwoe··on The last Romans are still around
What have the Romans ever done for us?!
flohofwoe··on The last Romans are still around
You could just as well say 1922 because the Ottomans also claimed to be the successor to the Roman Empire, or alternatively 1917, because the Russian Empire did too.

The more realistic alternatives are 'around 480', 1204 or 1453 :)

flohofwoe··on Zig's new bitCast semantics and LLVM back end improvements
It's pretty great in my toy emulator project (https://github.com/floooh/chipz) as 'system bus' where each bit is a 'wire' which is then mapped to chip input/output pins.

The bus-width is a generic parameter and can be below or above 64 bits (depending on the emulated system). With arbitrary-width integers the high level code remains the same no matter what the bus-width is, and from looking at the compiler output, as long as bit operations don't straddle the underlying 64-bit integer boundary, those bit operations are just as efficient as working on a simple 64-bit int.

Also AFAIK LLVM supports arbitrary-width integers since pretty much forever, Zig just 'exposed' them in the language (as later did Clang via _ExtInt(N), which is now deprecated in favour of C23's _BitInt(N)).

The other nice usage (also in emulators) is for chip registers and counters, those often have odd widths (like 5 bits), and writing those as u5 instead of u8 in the code is just nicer since it matches the chip documentation, and when reading the code it's immediately clear that this u5 is a 5-bit counter or register.

flohofwoe··on Bohemia Interactive: Cold War Assault Remastered Source Code on GitHub
IMHO the ARMA3 campaign is quite alright (once you realize how much freedom you have between the missions), also the Contact DLC was pretty great IMHO.

But where ARMA3 really shines is single-player sandbox mods like DUWS-X.

flohofwoe··on The Low-Tech AI of Elden Ring
Such a hierarchcal AI is how most RTS games work, and also the famous Falcon 4 campaign system which could simulate a realistic modern war scenario on the Korean peninsula in realtime down to individual units (although collapsed into higher level 'group AIs' when far away from the player) and all that on a 1998 PC!
flohofwoe··on 8086 Segmented Memory was a good idea
> we also need memory protection / isolation

I seem to remember that memory segments came with a permission system (read-only, read/write, execute) in 'protected mode'. Probably only added in the 286 though (I was always more of an m68k guy at that time).

flohofwoe··on 8086 Segmented Memory was a good idea
It's pretty much the same thing, except that all the memory mapping logic has moved from 'custom memory mapping hardware' into the CPU.
flohofwoe··on 8086 Segmented Memory was a good idea
> Also it's the year ~1980 and we're limited to the technology of the age.

Tbf the Motorola 68000 which was released around the same time (1979) had a proper linear address space with 32-bit address registers (of which 24 bits were wired up).

Also the 8086 was intended as a cheap and temporary stop gap until Intel's "proper" 32-bit CPU architecture was ready for prime time (the doomed iAPX 432).

flohofwoe··on 8086 Segmented Memory was a good idea
It's not all that different from the memory pages we have today, except that the 'segment' addressing has become a lot more complex under the hood (multi-level page tables) and a lot simpler at the surface (by merging the 'segment-' and page-address bits into a single virtual address).

PS: and segmented memory wasn't all that different from the memory banking used before in 8-bit home computers to address more than 64 KBytes, except that the memory mapping hardware was implemented outside the CPU.

flohofwoe··on Deno Desktop
You should try the last few Xcode versions some time. As far as I'm aware there's not a single line of Javascript in it, and all UI is 'native' (whatever that means these days), and the whole experience is such a janky and laggy mess that even VSCode feels slick.

It's trivial to write slow UI application in any tech stack, and just being 'native' really means nothing nowadays.

flohofwoe··on Deno Desktop
Deno also just strips the type annotations when running TS code - at least by default. To get type checking you'll need to run via `deno run --check`, or use the separate `deno check` subcommand. No big deal since type checking and linting usually happens automatically in the IDE during development.
flohofwoe··on Linux eliminates the strncpy API after six years of work, 360 patches
Ok, technically not the programming languages, but their stdlibs. On MSVC at least, opening a file in text mode via fopen will translate CRLF into LF on read, and LF into CRLF on write, which has been a neverending source of confusion since at least the 1990s.
flohofwoe··on Linux eliminates the strncpy API after six years of work, 360 patches
> Apple used CR

Apple hasn't been using CR since the release of OSX (26 years ago). Microsoft could have made the switch at any time too (just as they could have switched to UTF-8 as universal text encoding on Windows), they just choose not to.

In the end it's not the job of programming languages to clean up Microsoft's mess ;)

flohofwoe··on Windows UI evolution: Clicking an unassociated file
This is because back in the 90s GUI development was still driven by hard research, not by "emotions" (e.g. actually sitting very diverse groups of people in front of computers, asking them to perform specific tasks and then analysing where exactly they got stuck or became confused).

IIRC this golden era of GUI research fell apart once people started to call themselves "UX designers".

flohofwoe··on Zigzag Decoding with AVX-512
Now that you mention it... :)

Zig has MultiArrayList in the stdlib which does the SoA transform via comptime:

https://ziglang.org/documentation/master/std/#std.multi_arra...

Zig also sorts struct members by size/alignment, but has two escape hatches ('extern struct' which is for C compatibility, and 'packed struct' which offers an explicit bit-by-bit memory layout).

AFAIK Odin and Jai offer the SoA transform as specialized language features, e.g. in Odin:

https://odin-lang.org/docs/overview/#soa-data-types

I'd still always want such data layout transforms as an explicit language feature though, not the compiler making this decision for me.

flohofwoe··on Linux eliminates the strncpy API after six years of work, 360 patches
> non UTF-8 encoded strings on input/output

UTF-8 on stdin/stdout works perfectly fine (unless you are on Windows of course, which is stuck in in the early 90s when it comes to international text encoding).

> Using LF or CR or CRLF as line terminators

This is also an operating system convention, and it would be better if programming languages wouldn't try to "guess" the correct line endings, since this causes more problems than it solves - but again, this is mostly a Windows specific problem, and it's Microsoft's job to finally bring Windows into the current century.

flohofwoe··on Linux eliminates the strncpy API after six years of work, 360 patches
> But we did get _Generic and VLAs! Party hard.

VLA has been demoted to an optional feature in C11 (good).

IMHO the current main problem is that the C stdlib is stuck in the K&R era and the stdlib APIs haven't even been updated to the language features added in C99 (e.g. make use of struct args and return values). A range struct (ptr/size pair) in the stdlib and new or updated string functions to use such ranges would already go a long way.

flohofwoe··on Zigzag Decoding with AVX-512
Worth mentioning that MeshOptimizer (https://github.com/zeux/meshoptimizer) has become one of a handful 'hidden champion' pillar libraries that probably carries half of the gaming industry.

Basically the curl of asset pipelines ;)

https://github.com/zeux/meshoptimizer/discussions/986

flohofwoe··on Zigzag Decoding with AVX-512
Are there any programming languages which change the data layout beyond naively sorting struct members by alignment? (which at best helps with reducing padding bytes but can be either good or bad for performance, depending on the code which accesses the data).
flohofwoe··on Zigzag Decoding with AVX-512
> 1000x in AVX512+days of thought compared to the naive version written in a python loop

Out of this 1000x speedup you get 100x by just not using python though ;)

Also IIRC the main problem specifically with AVX512 was that mainstream CPUs simply didn't have it, so a smart compiler won't be of much use when the output code only runs on a handful devices.

flohofwoe··on Computed goto for efficient dispatch tables (2012)
FWIW it's possible to get rid of the range check via a __builtin_unreachable in the default case (which of course is essentially injected UB):

https://www.godbolt.org/z/YTcY3E8hx

...it's actually interesting though that the compiler adds the range check on a 'complete' switch over an enum, because the compiler would complain when a case branch is missing (via a warning). E.g. the frontend is smarter than the backend.

← PreviousPage 17 of 34Next →