HNHacker News
TopNewBestAskShowJobs

fwsgonzo

1,688 karma · joined June 6, 2017

submissionscomments
fwsgonzo··on Ask HN: Please stop hosting engineering blogs on medium
I see. Guess I'm moving away from Medium then.
fwsgonzo··on Ask HN: Please stop hosting engineering blogs on medium
I disable all that. Does it not work? https://medium.com/p/b429b91850a5
fwsgonzo··on How to avoid one C++ foot gun
I think I would be using std::unique_ptr here instead of the manual memory management, which as you can see sometimes fails spectacularly. I've had codebases myself ~10 years ago where I didn't really know how to use them properly, and I eventually completely gave up on them. The code was just too unreliable. These days, writing C++ is just like writing Python to me. The language is rarely the problem as long as I keep on the happy path with RAII.

I did see your issue immediately, though, and I could remember having the same issue with my own code. I remember assigning Shaders into a shader manager. They were already dead.

These days I prefer to in-place construct most things, unless there's a particular reason for assignment.

fwsgonzo··on 'The stakes could not be higher': world is on edge of climate abyss, UN warns
Same here. The winters are just sporadic snow and rain now. Also live quite far north. I am worried about AMOC slowdown though.
fwsgonzo··on RISC-V support in Android just got a big setback
I completely agree. Not that everything has to be relaxed, but at least the things that made it impossible to decode RISC-V when C is enabled. The amount of code needed to detect when and how instructions are laid out is much larger than it should be.
fwsgonzo··on How to improve the RISC-V specification
I honestly think the very readable specification has been a boon for RISC-V and possibly part of the reason why people continue to find it easy to pick up. If you are unsure about something in the spec, there's also a multitude of RISC-V emulators out there, probably several in your favorite language already.
fwsgonzo··on Leaving Rust gamedev after 3 years
I see some of those things could perhaps be solved by implementing parts of the game in a sandbox. I know that's work: I'm doing it myself. But all the work with the host-guest boundary (let's not call it bindings, please), is worth it in the end.

I have a C++ game client, a C++ game server, and a shared C++ game script that is transferred to all clients, running in a RISC-V emulator. That means the script will fundamentally execute the same way on all clients, and the server. I have no idea what everyone else is doing. This is what I'm doing now, and the more fleshed out it's becoming, the more I actually like it this way. I don't think I could easily "go back" to other solutions.

fwsgonzo··on Show HN: Comprehensive inter-process communication (IPC) toolkit in modern C++
I tried to migrate to capn-proto but it just doesn't build on MinGW so I have no choice but to wait. Like you say, it gets worse the more I wait. But, if the APIs are somewhat sane, they should hopefully also be somewhat similar: Able to switch case on oneofs, movable data structures etc.

I don't like that protobuf has recently started linking with abseil, which despite being a good framework, I can't use it if it doesn't build absolutely everywhere I need it to. So, maybe I'll be forced over to CapnProto one of these days?

fwsgonzo··on [dead]
I really hope you're not saying modern web-pages are enjoying to use because they look good? Because they are anything but. Instead they're often cumbersome and spend my resources on pointless cruft.

HN is one of the few web-pages that get straight to the point, and could not be any more well designed.

fwsgonzo··on Fast Virtual Functions: Hacking the VTable for Fun and Profit
80% of the code is drivers, which having written many myself, doesn't always need the latest OOP features. Abstractions suck in C for sure, but it's OK.

Meanwhile, the Windows XP codebase had 45M LOC in 2011.

Truly big codebases need to be written in sane languages, mostly OOP ones. That excludes C, Zig and Rust.

fwsgonzo··on Building a hypervisor, 1: KVM Introduction
You don't have to start in 16-bit mode. If you want you could be starting in long mode even, although probably better to start in 32-bit mode without paging enabled.
fwsgonzo··on TCC RISC-V Compiler Runs in the Web Browser (Thanks to Zig Compiler)
As usual, comment out all the error handling code. Also my experience with WASM.
fwsgonzo··on Tell HN: Ambi Climate is closing down. Now I have 5 worthless units
I agree. There is actually a storm coming here tonight, reaching 50m/s gusts. Power is likely to go out, and I have to pre-warm the fireplace in case. Power will likely come back fairly soon, but Internet is not treated the same way. If it goes out, I don't expect it to come back fast.
fwsgonzo··on Ask HN: How often are you using Stack Overflow these days?
Once you become proficient at something, it's likely you don't need basic questions answered, and that leaves advanced to hard problems.

For me SO is still very important. It has people like Peter Cordes that answer my complicated questions about the inner workings of modern CPUs, inline assembly and other esoterica. You can also find Mark Adler answering questions about CRC computations, polynomials and so on!

Eg. https://stackoverflow.com/questions/69830626/unable-to-get-t...

fwsgonzo··on New GitHub Copilot research finds 'downward pressure on code quality'
I recently tried Copilot out of curiosity and this is my experience too: It helps me getting started, which for me is 99% of the challenge. I know how to solve problems, even complex ones, but for some reason getting started is just so extremely hard, sometimes.

Copilot lets me get started, even if it's wrong sometimes. There have been times where I have been surprised by how it took something I wrote for a server, and presented the correct client-side implementation.

I've used it a few times to describe a problem and let it handle the solution. It's not very good, but I wonder if one should place more blame on PEBCAK and put more time into problem-description. I gave it a few more paragraphs to describe the problem, and eventually I could take it from there. It was still wrong, but enough to get me started. Immensely helpful that way.

Another aspect that I'm wondering about is if it will be able to do more with better documented code. Anyone have experience with that? I've started to write more doxygen comments, and hoping to see if there's a slow shift to more accurate predictions.

fwsgonzo··on WASI 0.2.0 and Why It Matters
I have had the same experience compiling for WASM. It's always a bunch of commenting out code that doesn't compile. Thankfully we have other things backend side. I'm guessing people writing Rust are having a better time with WASM.

As far as WASM going away: Sadly, I think browsers are just going to make up a larger and larger share of what computers do.

fwsgonzo··on C Is the Greenest Programming Language
https://old.reddit.com/r/rust/comments/bhtuah/production_dep...

"Because Rust" and safety, of course. I wonder if programming on Windows just sucks in general, and all these are Windows trading shops. Do you even have all the tools you need to write large programs on Windows? Valgrind, libfuzzer, etc. etc.

fwsgonzo··on C Is the Greenest Programming Language
One of the strengths of C++ is just that, that the more information you can provide, the better opportunities for optimizations. If you're saying that Rust adds more information than C++, then sure, it would be possible for it to optimize better. But is that the case right now?
fwsgonzo··on C Is the Greenest Programming Language
It really shouldn't. Rust has internal sanity checks where C/C++ doesn't. C++ also has better abstractions often leading to better whole-program performance than C. In C you would have to obsess about each little thing to keep up. It's a red flag for the whole article.
fwsgonzo··on Out of bounds memory access in V8 in Google Chrome prior to 120.0.6099.224
I wonder if any of these are avoided by disabling JIT, which I have done. And also, just how much of the codebase is JIT related? I also don't think C++ is always the problem. This is a complex language run-time, and there's all sorts of issues that can be language and language run-time related, regardless of it being written in Rust or C++, that manifest as out-of-bounds errors.

I couldn't find any information about work-arounds.

fwsgonzo··on Tell HN: GitHub no longer readable without JavaScript
I've given up disabling JS for my most visited pages, but you can still disable JIT if you want to drop a million LOC of attack surface. The slow-down is barely noticeable. At least not on the sites I visit, including GitHub. I still use NoScript, of course.
fwsgonzo··on Free Godot engine port for Nintendo Switch
Unsurprisingly, no plugins. Just plain-old GDScript, but embedding a faster scripting solution into the C++ codebase is not too hard for serious work.
fwsgonzo··on RISC-Y Business: Raging against the reduced machine
Cool, I still recognize the Instruction union as he based it on mine (libriscv). It's interesting to see how it has mutated across two implementations. Anyway, this is overflowing with cool ideas.

I do see one minor nitpick though. The inlined host call needs to also use an "m" operand, otherwise the compiler could optimize out the actual data (making it a dead-store).

    asm volatile("scall" : "+r"(a0) : "r"(a1), "r"(a7));
to

    asm volatile("scall" : "+r"(a0) : "r"(a1), "m"(*a1), "r"(a7));
Usually, we want to cast a1 here to a fixed or variable-length array in order to inform the compiler of the size of the data, but here the size is known. I believe it's enough with a deref. If not, cast it like so:

    *(uintptr_t(*)[13]) a1
fwsgonzo··on Games don't need venture capitalism
Indeed, if you play Harvest Moon, it's quite interesting just how much Stardew Valley copies.
fwsgonzo··on Post-mortem for last week's incident at Kagi
It wasn't that long ago that I had heard about Kagi the first time. Now I use it every day, and the fact that I can pin cppreference.com to the top is just such a boon.
fwsgonzo··on Ask HN: Laid-off from Big tech, found new job and still very unhappy
What the other commenter said, you need to step back and think logically here. Technically everyone is missing out on something, but we're not stressed out about all of it. It would be too much. Personally, I am working on interesting things mostly alone. That said, just like you, the most fun I had was working in a startup that did cool shit, and now that it's over I miss it.
fwsgonzo··on Fast RISC-V-based scripting back end for game engines
That's definitely a cool project, but I'm only interested in interpreting right now. I am sharing programs with clients, as I wrote in another thread. Not interested in producing or linking native code. I already have a binary translation mode, and I could probably expand it to avoid the interpreter loop to save 2ns, but I just don't have a need. Right now, everything is perfect for my use case.

It's cool that you can inline sandboxed functions like that. I'm curious about how you arbitrarily select and call functions though? A string-lookup kind of thing?

fwsgonzo··on Fast RISC-V-based scripting back end for game engines
No, as the author of TinyKVM, the overheads of entering and leaving KVM is not the same order of magnitude as SFI. TinyKVM requires 2-3 microseconds to enter and leave, which is the lowest I ever managed to get while it still being robust and dependable sandbox. For some, that might seem really low, but keep in mind that libriscv which is the backbone of RVScript has 3 nanoseconds overhead.
fwsgonzo··on Fast RISC-V-based scripting back end for game engines
There's also latencies for arguments into and out from the emulators. I'm not sure the custom signal handling alone can account for that.

I agree that it could as well have been MIPS or ARM.

fwsgonzo··on Fast RISC-V-based scripting back end for game engines
Binary translated libriscv vs LuaJIT: https://gist.github.com/fwsGonzo/9132f0ef7d3f009baa5b222eedf...

Interpreted libriscv vs LuaJIT: https://gist.github.com/fwsGonzo/1af5b2a9b4f38c1f3d3074d78ac...

libriscv vs. Luau: https://gist.github.com/fwsGonzo/5ac8f4d8ca84e97b0c527aec76a...

wasmtime: https://medium.com/@fwsgonzo/using-c-as-a-scripting-language...

You're probably right that things can be improved. But my implementation has the aforementioned latencies right now.

For the benchmarks I did my best writing good Lua, but I am not a pro. Call overhead is also subtracted out of every benchmark after call overhead is measured. So that extra overhead is a permanent feature of these implementations. I also noticed that most of my script functions have at least ~3-4 arguments, which seems like it would be quite costly. Just look at the 8x arg benchmark and divide by 2, I guess. Another 100ns right there. Baseline 150ns on a micro benchmark is going to become at least a microsecond in prod when everything is random and semi-cold.

← PreviousPage 5 of 21Next →