HNHacker News
TopNewBestAskShowJobs

Const-me

6,400 karma · joined March 2, 2015

meet.hn/city/42.4303762,18.6988104/Tivat

http://const.me/

submissionscomments
Const-me··on The low-tech brilliance of Iranian design
Based on the title, I expected the article to be about this: https://en.wikipedia.org/wiki/HESA_Shahed_136
Const-me··on Why does C have the best file API
Indeed, but these normal APIs have runtime costs for bounds checking. For some use cases, unsafe can be better. For instance, last time I used a memory-mapped file was for a large immutable Bloom filter. I knew the file should be exactly 4GB, validated that in the constructor, then when testing 12 bits from random location of the mapped file on each query, I opted for unsafe codes.
Const-me··on Why does C have the best file API
I think C# standard library is better. You can do same unsafe code as in C, SafeBuffer.AcquirePointer method then directly access the memory. Or you can do safer and slightly slower by calling Read or Write methods of MemoryMappedViewAccessor.

All these methods are in the standard library, i.e. they work on all platforms. The C code is specific to POSIX; Windows supports memory mapped files too but the APIs are quite different.

Const-me··on You Just Need Postgres
> no variable-length columns

Both varchar and varbinary columns work fine there. Blobs are indeed missing.

> data loss on restart

That’s OK, collections in memory do as well yet we use them pretty much everywhere.

> Unlogged tables skip write-ahead logging

I don’t want any disk I/O for my memory tables.

Another thing, aren’t PostgreSQL tables without write-ahead logging cause consistency bugs after restart when normal tables are current due to the logging, unlogged tables are old?

Const-me··on You Just Need Postgres
I like engine=memory tables. Compared to data structures found in programming languages, memory tables are more powerful: arbitrary columns, indices. The DB server solves concurrency with transactions and row-level locks; need B-tree primary key which is not the default for memory engine but easy enough to do at table creation.

I think they save quite an amount of software complexity, delegating these problems to the DB server.

Const-me··on You Just Need Postgres
I like the article, but why PostgreSQL specifically? I have recently needed some of these features in a server, MariaDB did the job reasonably well.
Const-me··on Ggml.ai joins Hugging Face to ensure the long-term progress of Local AI
> very small percentage of people to use the torrent over the direct download

BitTorrent protocol is IMO better for downloading large files. When I want to download something which exceeds couple GB, and I see two links direct download and BitTorrent, I always click on the torrent.

On paper, HTTP supports range requests to resume partial downloads. IME, it seems modern web browsers neglected to implement it properly. They won’t resume after browser is reopened, or the computer is restarted. Command-line HTTP clients like wget are more reliable, however many web servers these days require some session cookies or one-time query string tokens, and it’s hard to pass that stuff from browser to command-line.

I live in Montenegro, CDN connectivity is not great here. Only a few of them like steam and GOG saturate my 300 megabit/sec download link. Others are much slower, e.g. windows updates download at about 100 megabit/sec. BitTorrent protocol almost always delivers the 300 megabit/sec bandwidth.

Const-me··on AVX2 is slower than SSE2-4.x under Windows ARM emulation
You’re welcome. Sadly, I don’t know how to observe ARM assembly produced by Prism.

And one more thing.

If you test on an AMD processor, you will probably see much less profit from FMA. Not because it’s slower, but because SSE4 version will runs much faster.

On Intel processors like your Tiger Lake, all 3 operations addition, multiplication and FMA compete for the same execution units. On AMD processors however, multiplication and FMA do as well but addition is independent, e.g. on Zen4 multiplication and FMA run on execution units FP0 or FP1 while addition runs on execution units FP2 or FP3. This way replacing multiply/add combo with FMA on AMD doesn’t substantially improve throughput in FLOPs. The only win is L1i cache and instruction decoder.

Const-me··on AVX2 is slower than SSE2-4.x under Windows ARM emulation
> AVX2 level includes FMA (fast multiply-add)

FMA acronym is not fast multiply add, it’s fused multiply add. Fused means the instruction computes the entire a * b + c expression using twice as many mantissa bits, only then rounds the number to the precision of the arguments.

It might be the Prism emulator failed to translate FMA instructions into a pair of two FMLA instructions (equally fused ARM64 equivalent), instead it did some emulation of that fused behaviour, which in turn what degraded the performance of the AVX2 emulation.

Const-me··on JavaScript-heavy approaches are not compatible with long-term performance goals
> but nobody is using it! What does that say?

It’s impossible to replace JS with WebAssembly because all state-mutating functions (DOM tree manipulation and events, WebGL rendering, all other IO) is unavailable to WebAssembly. They expect people to do all that using JavaScript glue.

Pretty sure if WebAssembly were designed to replace JS instead of merely supplementing it, we would have little JS left on the web.

Const-me··on I fixed Windows native development
> What if you have two different project with different requirements at the same time?

Install multiple versions of Windows SDK. They co-exist just fine; new versions don’t replace old ones. When I was an independent contractor, I had 4 versions of visual studio and 10 versions of windows SDK all installed at once, different projects used different ones.

Const-me··on Android’s desktop interface leaks
> run games through a Proton-like shim even on Windows

Already happening, to an extent. Specifically, modern Intel GPUs do not support DirectX 9 in hardware, yet legacy apps run fine. The readme.txt they ship with the drivers contains a paragraph which starts with the following text: “SOFTWARE: dxvk The zlib/libpng License” DXVK is a library which implements Direct3D on top of Vulkan, and an important component of SteamOS.

Const-me··on The lost art of XML
> It was never the right choice for API payloads and config files

Partially agree about API payloads; when I design my APIs I typically use binary formats.

However, IME XML is actually great for config files.

Comments are crucial for config files. Once the complexity of the config grows, a hierarchy of nested nodes becomes handy, two fixed levels of hierarchy found in old Windows ini files, and modern Linux config files, is less than ideal, too many sections. Attributes make documents easier to work with due to better use of horizontal screen space: auto-formatted JSON only has single key=value per line, XML with attributes have multiple which reduces vertical scrolling.

Const-me··on Are You YES AI or No AI?
Software developers might be majority here in HN comments, but definitely a small minority across general population. A lot of people are negatively affected by AI: computer hardware is expensive because AI companies bought all memory, Windows 11 is crap because Microsoft reworked their operating system into AI-driven trojan horse, many people lost jobs because AI companies convinced top management of their employers’ people will be replaced with computers any day now, etc.
Const-me··on All your OpenCodes belong to us
I have a hypothesis why issues like that are so widespread. That AI infrastructure is mostly developed by large companies; their business model is selling software as a service at scale. Hence containers, micro-services, TCP/IP in between. That approach is reasonable for data centres because these made of multiple servers i.e. need networking, and they have private virtual networks just to connect servers so the security consequences aren’t too bad.

If they were designing these infrastructure pieces primarily for consumer use, they would have used named pipes, Unix domain sockets, or some other local-only IPC method instead of TCP/IP.

Const-me··on How to wrangle non-deterministic AI outputs into conventional software? (2025)
> you can get a performance improvement by calculating A, B, and C in parallel, then adding together whichever two finish first

Technically possible, but I think unlikely to happen in practice.

On the higher level, these large models are sequential and there’s nothing to parallelize. The inference is a continuous chain of data dependencies between temporary tensors which makes it impossible to compute different steps in parallel.

On the lower level, each step is a computationally expensive operation on a large tensor/matrix. These tensors are often millions of numbers, the problem is very parallelizable, and the tactics to do that efficiently are well researched because matrix linear algebra is in wide use for decades. However, it’s both complicated and slow to implement fine grained parallelism like “adding together whichever two finish first” on modern GPUs. Just too much synchronization, when total count of active threads is many thousands, too expensive. Instead, operations like matrix multiplications are often assigning 1 thread per output element or fixed count of output elements, and reduction like softmax or vector dot product are using a series of exponentially decreasing reduction steps, i.e. order is deterministic.

However, that order may change with even minor update of any parts of the software, including opaque pieces at the low level like GPU drivers and firmware. Library developers are updating GPU kernels, drivers, firmware and OS kernels collectively implementing scheduler which assigns work to cores, both may affect order of these arithmetic operations.

Const-me··on OneDrive just deleted all of my files
> if they are stored unpowered for a couple of years, then you clearly aren't doing regular backups

I am doing regular backups yet I have a few backup disks unpowered for years. They are older, progressively smaller backup HDDs I keep for extra redundancy.

Every 2-4 years I am getting a larger backup drive, and clone my previous backup drive to the new one. This way when the backup drive fails (happened around 2013 because I was unfortunate to get notoriously unreliable 3TB Seagate), I don’t lose much data if at all because most of the new stuff is still on the computers, and the old stuff is left on these older backup drives.

Const-me··on OneDrive just deleted all of my files
Flash drives are less than ideal for backups. I think when they are stored cold i.e. unpowered, flash memory only retains data for a couple of years. Spinning hard drives are way more reliable for the use case.
Const-me··on OneDrive just deleted all of my files
> keeps on nudging me to use Onedrive

At least on Windows 10, you only have to decline once, here’s how. Ctrl+Shift+Esc to launch task manager, “Startup” tab, right click on “Microsoft OneDrive”, select “Disable” from the context menu, then either reboot, or log out and log in.

Const-me··on Rust--: Rust without the borrow checker
> How large is large?

About the same size as amount of physical memory. For Word 97, minimum system requirement was 8MB RAM. That’s not just for the word, also the entire OS.

> Loading and saving a few GiB from my SSD is pretty fast

Indeed, that’s one of the reasons why modern word processors stopped doing complicated tricks like the ones I described, and instead serialize complete documents.

> a special file format and use virtual memory

That’s not the brightest idea: inflates disk bandwidth by at least a factor of 2. A modern example of software which routinely handles datasets much larger than physical memory is database engines (large ones, not embedded). They avoid virtual memory as much as possible because IO amplification leads to unpredictable latency.

> Saddling some guy on an underpowered Chromebook

The guy will be fine. The program might allocate a large buffer on startup but will only use the small initial slice because chromebooks don’t come with particularly large screens. Linux kernel does not automatically commit allocated memory.

Const-me··on Why users cannot create Issues directly
> to know "what is clearly a bug" 100% of the time in projects you don't own

Owning a project is counter-productive for QA. If it’s your project, you know where to click and where to not click.

OTOH, you don’t need to know anything about a project to conclude that a crash with access violation, or hang with 100% CPU usage, are clearly bugs.

Const-me··on Rust--: Rust without the borrow checker
> What if you don't know ahead of time how big that monitor is that you are displaying stuff on?

Use a reasonable upper estimate?

> ad-hoc re-implementation of virtual memory?

If you rely on actual virtual memory instead of specially designed file format, saving large files will become prohibitively slow. On each save you have to stream the entire document from page file to actual memory, serialize the document, produce the entire file, then replace. And then when resuming editing after the save, you probably have to load the visible portion back from disk.

Const-me··on Rust--: Rust without the borrow checker
It’s technically possible to do, just very complicated and hard. Quite often, prohibitively so.

Still, the main idea is despite the input files are arbitrarily large, you don’t need an entire file in memory because displays aren’t remotely large enough to render a megabyte of text. Technically, you can only load a visible portion of the input file, and stream from/to disk when user scrolls. Furthermore, if you own the file format, you can design it in a way which allowing editing without overwriting the entire file: mark deleted portions without moving subsequent content, write inserts to the end of files, maybe organize the file as a B+ tree, etc.

That’s how software like Word 97 supported editing of documents much larger than available memory. As you can imagine, the complexity of such file format, and the software handling them, was overwhelming. Which is why software developers stopped doing things like that as soon as computers gained enough memory to keep entire documents, and instead serialize them into sane formats like zipped XMLs in case of modern MS office.

Const-me··on Loss32: Let's Build a Win32/Linux
I did forget to mention something important. Since about Vista, Microsoft tends to replace or supplement C WinAPI with IUnknown based object-oriented ones. Note IUnknown doesn’t necessarily imply COM; for example, Direct3D is not COM: no IDispatch, IPC, registration or type libraries.

IUnknown-based ABIs exposing methods of objects without any symbols exported from DLLs. Virtual method tables are internal implementation details, not public symbols. By testing SDK-defined magic numbers like SDKVersion argument of D3D11CreateDevice factory function, the DLL implementing the factory function may create very different objects for programs built against different versions of Windows SDK.

Const-me··on Loss32: Let's Build a Win32/Linux
> versioned symbols are a thing on Windows

There’re quite a few mechanics they use for that. The oldest one, call a special API function on startup like InitCommonControlsEx, and another API functions will DLL resolve differently or behave differently. A similar tactic, require an SDK defined magic number as a parameter to some initialization functions, different magic numbers switching symbols from the same library; examples are WSAStartup and MFStartup.

Around Win2k they did side by side assemblies or WinSxS. Include a special XML manifest into embedded resource of your EXE, and you can request specific version of a dependent API DLL. The OS now keeps multiple versions internally.

Then there’re compatibility mechanics, both OS builtin and user controllable (right click on EXE or LNK, compatibility tab). The compatibility mode is yet another way to control versions of DLLs used by the application.

Pretty sure there’s more and I forgot something.

Const-me··on Comptime – C# meta-programming with compile-time code generation and evaluation
> there are source generators

Last time I tried them discovered source generators in the current .NET 10 SDK are broken beyond repair, because Microsoft does not support dependencies between source generators.

Want to auto-generate COM proxies or similar? Impossible because library import and export are implemented with another source generators. Want to generate something JSON serializable? Impossible because in modern .NET JSON serializer is implemented with another source generator. Generate regular expressions? Another SDK provided source generator, as long as you want good runtime performance.

Const-me··on I'm returning my Framework 16
A new keyboard for X1 Carbon 7th gen is available on e-bay for the price of $50-100.

A faulty keyboard is IMO not a good reason to replace a whole computer.

Const-me··on Full Unicode Search at 50× ICU Speed with AVX‑512
> it cannot be faster than normalization alone

Modern processors are generally computing stuff way faster than they can load and store bytes from main memory.

The code which does on the fly normalization only needs to normalize a small window. If you’re careful, you can even keep that window in registers, which have single CPU cycle access latency and ridiculously high throughput like 500GB/sec. Even if you have to store and reload, on-the-fly normalization is likely to handle tiny windows which fit in the in-core L1D cache. The access cost for L1D is like ~5 cycles of latency, and equally high throughput because many modern processors can load two 64-bytes vectors and store one vector each and every cycle.

Const-me··on Closures as Win32 Window Procedures
> I'm genuinely surprised Microsoft's attitude towards "wndprocs don't have a context pointer"

They designed windows classes to be reusable, and assumed many developers going to reuse windows classes across windows.

Consider the following use case. Programmer creates a window class for a custom control, registers the class. Designs a dialog template with multiple of these custom controls in a single dialog. Then creates the dialog by calling DialogBoxW or similar.

These custom controls are created automatically multiple at once, hard to provide context pointers for each control.

Const-me··on Isn't WSL2 just a VM?
I find WSL 1 incredibly useful. C++ and .NET compiler toolchains, ssh and scp clients, and many other command-line Linux tools are working flawlessly for me despite the fake emulated kernel lacking some of the APIs. When I develop anything related to Linux be it embedded or servers, I use WSL1 a lot.

I find WSL2 pretty much useless. When I want Linux inside a VM I use VMware which is just better. VMware has tree of snapshots to rollback disk state, hardware accelerated 3D graphics (limited though, I think only GL is there no Vulkan, but it’s better than nothing), can attach complete USB devices to the guest OS, can setup proper virtual networks with multiple VMs, and the GUI to do all that is decent, no command line required.

← PreviousPage 2 of 34Next →