HN Simulatornew | past | comments | lists | submit | MaulingMonkey's commentslogin

I prefer:

    const size_t n = 10;
    for (size_t i = n; i --> 0;) {
        std::cout << i << "\n";
    }


That's a certain kind of taste... I checked out your home page, game dev, check, and this work of art is worth linking (no irony, I love it):

http://maulingmonkey.com/brainfuck/


That looks like the brainfuck mandelbrot set by Erik Bosman, but the example is missing the header line with the credit. The one I saw came from here:

https://github.com/thaliaarchi/bfcorpus/blob/main/ebosman/ma...

Be sure to check out other files in that directory for how the program is assembled.

(Erik Bosman's mandelbrot set is a personal favorite of mine, very useful for benchmarking brainfuck interpreters)


Cute but wouldn't work with ssize_t :)

VHDL's array/vector syntax actually works a similar way:

-- gives 0, 1, 2, 3:

for i in 0 to 3 loop

-- gives 3, 2, 1, 0:

for i in 3 downto 0 loop

-- Source - https://stackoverflow.com/a/7642026 -- Posted by Kerrek SB -- Retrieved 2026-10-29, License - CC BY-SA 3.0


Does work with ssize_t, just not necessary.


Depends on your definition of "work".

For me it does not work because I'd want to use it with values < 0, but the for loop checks for > 0, so I would have to modify that first.


If you want -3 -2 -1 0 and +3 +2 +1 0 from the same operation, you'll need something more complicated (either some nonsense to give you a signed stride/step value among other things — or perhaps just writing the damn loop twice instead of getting too clever.)

However, if you just want -1 to not iterate down to `std::numeric_limits::min()` — and then invoke undefined behavior by signed integer underflow if `i` happens to be `ssize_t` instead of `size_t` — I'll note that the `i --> 0` will terminate immediately, unlike `i --` as otherwise seen. (unless you feed it `min()` exactly. Then it'll underflow a signed integer before the comparison, so that's still undefined behavior.)


> At this time there is no portable way to produce computed gotos or tail call optimization in compiled machine code from Rust.

Nightly rust now has the `become` keyword:

https://doc.rust-lang.org/std/keyword.become.html

> `feature(explicit_tail_calls)` is currently incomplete and may not work properly.

Works on my machine (tm). At least with toy examples. Including in full optimizationless debug mode, turning `call`s into `jmp`s ensuring `factorial(usize::MAX)` won't stack overflow probably maybe.

https://rust.godbolt.org/z/7xf836E8K

> checked_sub? wrapping_mul? MaulingMonkey, what's wrong with you?

Eliminating debug-mode panic boilerplate.


The final shareware version (2.6) was fairly comparable to the retail version (2.7). This says the shareware version just lacked some sound effects...? https://web.archive.org/web/20091129230733/http://wiki.gible...

However, I believe the first shareware version I had was 1.x (distributed via CD that was packed full of shareware) which was significantly different. I remember mining fuel, which tracks with the above link.

Stars! was one of my very first video game purchases. I remember mailing a money order, and recieving a copy in the mail - I didn't have internet at the time. I'm not sure I even knew the internet existed then, although I would soon after if not.


IDK about "tier 1" but I'll note I've used VS for debugging and profiling Rust binaries. I even wrote a tool to auto-generate a wrapper .sln so I can easily launch from VS: https://github.com/MaulingMonkey/cargo-vs

The main pain point IME was poor debugger visualizers for standard containers and enums. I fixed some of that for the standard containers by writing some natvis files for std: https://github.com/rust-lang/rust/issues?q=state%3Aclosed%20... . Admittedly, they broke a few times. They also weren't automatically included in the pdbs, so I wrote a crate for that: https://github.com/MaulingMonkey/natvis-pdbs . And then someone crated and stabilized #[debugger_visualizer] for rust itself, which can do the same job: https://doc.rust-lang.org/reference/attributes/debugger.html .

(...I should check on enum visualization, but I suspect it's still poor.)


I shelled out for a Steam Machine (SteamOS ≈ Arch Linux.) I do gamedev, and I figured having a test machine was a decent enough excuse for a purchase. It's working suprisingly well for the games I'm actually playing. They're playing better than on my last Windows desktop tower, even, presumably due to a better GPU.

Granted, catalogs vary - anti-cheat and DRM may not play nice, and EvE Online wasn't stable until I switched the renderer from D3D12 to D3D11 (and I haven't tried playing with multiple accounts) - but you might revisit Linux gaming if it's been awhile since you last have.

The enshittification of Windows has finally driven me to the point where Linux compatability is going to start affecting my Steam purchases.


Out of interest, are you doing any dev on the SM? If so, how is it for that?


Only a token test amount so far. The root filesystem is read-only by default, but without the whole Nix ecosystem, which is a little awkward (can't install packages even as root without changing that.) On the other hand, it comes with `distrobox` preinstalled, so it's easy enough to spin up a container and use that (including package installation.)

My raw notes are here: https://github.com/MaulingMonkey/notes/blob/master/programmi...


Worktrees share more git state (remotes, blobs, etc.) and don't require hunting down the repository url to feed to git clone, or a network connection to use said url. While you could get the same benefit from cloning your local repository, you're then in the weird state where `origin` is a local non-bare repository.

If you're setting up long-lived checkouts that you reuse, it doesn't help much (except perhaps saving space or bandwidth) vs multiple clones and some once up-front reconfiguration. On the other hand, if you want something more temporary - and perhaps based on your current HEAD without having to hunt down a commit id to feed a subsequent git clone / git checkout command - worktrees save you some boilerplate (re)configuration.


if it's a my main repo where im regularly doing hotfixes in one folder while i work simultaneously on a feature branch on another I will have multiple long lived checkouts (usually 4).

it makes sense to keep them warm because while cloning a new repo is almost always quick, regenerating the build artefacts from scratch each time is not.


Feature flags are great. Working on a crash / memory corruption in an optional subsystem? Just disable the subsystem to unblock coworkers on the same branch while you track down the cause.

Feature flags are terrible. Working on a crash / memory corruption in an optional subsystem? You disabled it previously for your local build, and you'll lose hours failing to repro despite QA giving excellent repro steps.

(For my own gamedev background, I learned to mute audio by setting volume to 0 instead of by disabling the audio subsystem.)


> If you define another language Rust-Without-Any-Unsafe, then maybe that one is safer than Fil-C.

Just write `#![forbid(unsafe_code)]` at the top of your src/lib.rs, and track crates not using it with `cargo geiger`. You don't need a whole new language, it already provides the tools to wield that hatch shut.

> Rust is less safe because it has a feature for turning off safety

Can I write Fil-C's mmap wrapper in Fil-C?

If no, fair enough, but it's worth noting I can write a safe Rust mmap wrapper in Rust, and I absolutely and frequently need to do that kind of "syscall wrapping" in arenas Fil-C explicitly hasn't handled, by virtue of being explicitly a Linux project.

If yes, that sounds like an escape hatch to Fil-C's memory safety, undermining the claim that Fil-C is fundamentally safer, and you're now at best arguing it's safer as tends to be used.


It should be mentioned that rust's type system has a long-standing known bug compromising memory safety, as made famous by cve-rs. It's perhaps not a big issue for most people but if you are someone that wants the assurances of #![forbid(unsafe_code)] that should probably be on your radar.


Certainly, we should build into our threat model the idea that the implementation of Rust will have bugs that compromise safety until proven otherwise (merely fixing that one aforementioned bug won't alter that calculus). And the same applies to Fil-C: we should assume it has bugs that compromise safety until proven otherwise. Until then, in practice, Rust has much more real-world use that convincingly demonstrates its ability to realistically eliminate memory safety risks.


A known bug with easily accessible proof-of-concept is quite different from a theoretical bug.


No, that's not how this works. The bug being utilized by cve-rs has such roundabout requirements that it's unlikely that anyone has ever triggered it without trying (to be clear, the Rust devs plan to fix it regardless). Meanwhile, here's a memory safety bug that Fil-C fails to catch, not because of a compiler bug, but by design: https://www.reddit.com/r/cpp/comments/1v4nw0k/filc_garbage_i...


I've encountered a few soundness holes in rust-lang in practice, but they've all been fixed before I managed to shoot myself in the foot with any of them:

• `std::mem::uninitialized()`. It's now deprecated in favor of `MaybeUninit`.

• `std::env::set_var(...)`. It's now marked `unsafe`. While I dodged the bullet, these fellows didn't: https://www.geldata.com/blog/c-stdlib-isn-t-threadsafe-and-e...

• `#[no_mangle]`. It's now `#[unsafe(no_mangle)]`.

I don't believe I've constructed cvs-rs's hole by accident. cve-rs's code links to https://github.com/rust-lang/rust/issues/25860 , which is admittedly still open after a decade. Progress appears to still be ongoing though! Related:

• https://github.com/orgs/rust-lang/projects/44/views/1

• https://rust-lang.github.io/rust-project-goals/2025h2/next-s...

> Meanwhile, here's a memory safety bug that Fil-C fails to catch, not because of a compiler bug, but by design: [...]

Thanks for sharing a concrete example of Fil-C's limitations! Disappointing - but not unexpected - to see it underperforming existing sanitizers. I was hoping for better.


> I've encountered a few soundness holes in rust-lang in practice

Indeed, I'm trying to be careful not to claim that merely fixing #25860 at long last would make Rust's implementation suddenly beyond reproach. For that, we would need formal verification (which, so far, has at least been done by Ralf Jung's group for proving the correctness of large swathes of the standard library, but I wouldn't expect that to extend to the compiler anytime soon).


Guidelines | FAQ | Lists | API | Security | DMCA | Apply to YC | Contact

Search: