HNHacker News
TopNewBestAskShowJobs

legobmw99

609 karma · joined January 10, 2021

submissionscomments
legobmw99··on Beware of Fast-Math
Kahan summation is an example (also described in the top level article) of one such “gotcha”. It involves adding a term that - if floats were algebraic in this sense - would always be zero, so ffast-math often deletes it, but this actually completely removes the accuracy improvement of the algorithm
legobmw99··on Matt Godbolt sold me on Rust by showing me C++
That still has the issue of Quantity{-100} being a-ok as far as the compiler is concerned, but there are other things one can do (as the article alludes to).

My reading of this article wasn't to say that these things are impossible in C++, just that they're not the default or the first thing you try as a beginner is perfectly wrong.

legobmw99··on Matt Godbolt sold me on Rust by showing me C++
Based on the rest of your comment I suspect you're already familiar, but a decent candidate for "Rust with a GC" is OCaml, the language the first Rust compiler was written in.
legobmw99··on Implementing a Struct of Arrays
This is probably the most compelling example of C++ reflection I've seen yet. Deriving a debug printer or stringifying the names of enums is one thing, but this is clearly quite a powerful abstraction one could get 'for free'
legobmw99··on Giving Software Away for Free
It's a bit heavy handed, but the VSCode "Live Server" plugin is the closest I've come. If I set code as the default file association for `.html`, then it's just one extra click to get it open in a browser with a local server.

This isn't going to work for everyone, but if you're dealing with non-tech-savvy but mostly-able-to-use-a-computer users, it can, and it being graphical seems to be less of a hill than if I tell people to run `python -m http.server` in the terminal (because, "what is a terminal"...)

legobmw99··on Migrating away from Rust
I mean, we already have a sort-of answer, because the "Bedrock Edition" of Minecraft is written in C++, and it is indeed less popular on PC (on console, it's the only option, so _overall_ it might win out) and does lack any real modding scene
legobmw99··on PEP 750 – Template Strings
I still think it is a shame that `match` isn't valid as an expression, requiring things like the helper function here that could be a lambda or part of a comprehension otherwise
legobmw99··on Cheating the Reaper in Go
No idea how plug-n-playable it is, but the source seems to be self contained: https://github.com/mcy/mcy.github.io/blob/master/public/js/m...
legobmw99··on 0+0 > 0: C++ thread-local storage performance
Note that MinGW uses libwinpthread, which is known to have slow TLS behavior anyway (I've observed a 100% overhead compared to running the same program under WSL using a linux-native GCC). c.f. https://github.com/msys2/MINGW-packages/discussions/13259
legobmw99··on Resigning as Asahi Linux project lead
I can't find the exact link now (very well might have been a video without a searchable transcript), but I recall someone asking Linus that (specifically re his previous comments on C++), and his answer was something like he saw Rust solving a problem that C genuinely does not. It's controversial, but I do think of C++, Zig, etc as solving the "same problems" as C (perhaps in a much nicer way)
legobmw99··on C is not suited to SIMD (2019)
“strict aliasing” refers to disallowing pointers of different types to alias. In the context of a function that accepts two arrays of floats, for example, it doesn’t apply
legobmw99··on H.R.25 – Repeal income tax and abolish the Internal Revenue Service
Morph into a federal sales tax? This bill literally proposes one
legobmw99··on Obvious things C should do
Some other languages have equivalents (OCaml comes to mind), but usually they’re less necessary
legobmw99··on Ask HN: Programmers who don't use autocomplete/LSP, how do you do it?
I mean, maybe? But if you hover over the function you just completed, the same LSP will also show you the documentation.

This is how I personally use it for discovery, anyway. The other day I was writing some Rust code and needed to remove a prefix from a &str. I tried a few common names after ‘.’ to see what would autocomplete, before finding that Rust calls this idea “trim_start_matches”. I then wanted to know what happens if the prefix wasn’t present, so I just hovered my mouse over it to read. Now, if I was writing Rust a lot, I would end up memorizing this anyway. I’ve never not written Python without a similar tool involved, yet I have a pretty close to encyclopedic knowledge of the standard library.

I feel similarly about go-to-definition. I often use it the first time I’m exploring code, or when I am debugging through some call stack, but I also always do read where I actually end up, and do form a mental map of the codebase. I’m not sure I buy either the contention in this thread that these “crutches” make developers uniformly worse, or that removing them would make all poor developers suddenly more disciplined

legobmw99··on Does Your Code Pass the Turkey Test? (2008)
One of my first ever public projects actually had a bug report that ended up being the Turkish i problem. Didn’t know there were more!
legobmw99··on Show HN: Rust library for numerical integration of real-valued functions
The Fn trait could be used, which prevents mutation, but allows a lot of useful closures. I should note, a motivated user could provide a junk function no matter what the type accepted is
legobmw99··on Show HN: Rust library for numerical integration of real-valued functions
Is there a technical reason to now allow closures as the integrand?
legobmw99··on Show HN: Rust library for numerical integration of real-valued functions
It seems like it is lacking the functionality R's integrate has for handling infinite boundaries, but I suppose you could implement that yourself on the outside.

For what it's worth,

    use integrate::adaptive_quadrature::simpson::adaptive_simpson_method;
    use statrs::distribution::{Continuous, Normal};

    fn dnorm(x: f64) -> f64 {
        Normal::new(0.0, 1.0).unwrap().pdf(x)
    }
    
    fn main() {
        let result = adaptive_simpson_method(dnorm, -100.0, 100.0, 1e-2, 1e-8);
        println!("Result: {:?}", result);
    }
prints Result: Ok(1.000000000053865)

It does seem to be a usability hazard that the function being integrated is defined as a fn, rather than a Fn, as you can't pass closures that capture variables, requiring the weird dnorm definition

legobmw99··on Fair coins tend to land on the side they started: Evidence from 350,757 flips
I’ve seen this attributed to John von Neumann, of all people
legobmw99··on Weird Lexical Syntax
I’d be shocked if jart didn’t know this, but it seems unlikely that an LLM would generate one of these most vexing parses, unless explicitly asked
legobmw99··on 1 in 6 Companies Are Hesitant to Hire Recent College Graduates
I wonder how much of this has to do with Covid interrupting a lot of recent grads’ time in college and forcing a large percentage of their courses to be online for a time

It seems pretty obvious to me that the quality of both teaching and assessment plummeted during this time, so I suspect that it’s even harder than usual to trust things like a transcript to see what an applicant really knows

legobmw99··on Defining Statistical Models in Jax?
The author links to https://arxiv.org/abs/2006.10343, which seems like a good place to start on normalizing flows for Bayes
legobmw99··on Show HN: Compiling C in the browser using WebAssembly
It’s sadly a bit more of a proof of concept than a hackable project. The docker build in the readme did work last time I tried, and there is a demo site at https://jprendes.github.io/emception/, but I’ve failed to modify it in the past to do other things

There is a fork at https://github.com/emception/emception that is trying to make it more production ready, but it looks like that may have stalled

legobmw99··on Show HN: Compiling C in the browser using WebAssembly
If what I want is not an executable but a shared library, does this get me anything?

I currently have a use case that uses a server running an emscripten build (using SMODULARIZE and some exports, I suppose it’s not a true dylib)

legobmw99··on Show HN: Compiling C in the browser using WebAssembly
See: emception

https://github.com/jprendes/emception

legobmw99··on IntelliJ IDEs supports Wayland now
Synergy core (aka synergy 1) just had Wayland support merged this week. “Next year” has finally come to pass
legobmw99··on IntelliJ IDEs supports Wayland now
The closest I’ve found in terms of description is https://github.com/feschber/lan-mouse, but the lack of encryption on the connection has discouraged me from using it.

I’m also a paid Synergy user, and it’s frankly comedic how long Wayland support has been on their road map. I’m not convinced it’s ever coming, which means I’m probably only 1-2 distro updates from being forced to use something else

legobmw99··on Maker of RStudio launches new R and Python IDE
It seems a little odd to me that this is not just… a vscode extension pack?
legobmw99··on Circle C++ with memory safety
I think a challenge to this evolution path is the same as what motivated Sutter’s cpp2: defaults

I think the premise that a lot of experienced programmers can write good C++ is at least somewhat valid. They know to not use raw pointers, which APIs to use for bound checking, whatever. The issue is that new users don’t, and the defaults are bad.

If I have to write #feature on safety in every file, it becomes possible to forget. Opting in vs opting out

legobmw99··on Why not just do simple C++ RAII in C?
extern “C” on everything, if you care about linking compatibility, gets you another chunk of the way there by also disabling overloading etc.
← PreviousPage 3 of 7Next →