Readit News logoReadit News
znkr commented on God created the real numbers   ethanheilman.com/x/34/ind... · Posted by u/Bogdanp
zamalek · 16 hours ago
When I truly grokked complex numbers, I felt as though real numbers were a lie - though I would now say that it was a convenient omission. There are many things that are more naturally described using complex numbers - waves (which much of reality boils down to) immediately come to mind. Even if something does align better with real numbers, it's still just x+0i. Maybe I'll change my mind ~when~ if I finally grok quaternions.
znkr · 4 hours ago
> Even if something does align better with real numbers, it's still just x+0i

Beware, it’s not always useful to work in complex numbers, you sometimes want to do something different for reals and complex numbers. The prime example here is complex analysis. Defining differentiation is based on limits, on the complex plane there are a lot more directions to approach a limit vs just two on the real line. This has some interesting implications. For example, any function differentiable on the complex plane is infinitely differentiable.

znkr commented on I'm working on implementing a programming language all my own   eli.li/to-the-surprise-of... · Posted by u/ingve
austin-cheney · 12 hours ago
I love that you are using colon for the assignment operator. This is absolutely correct. Most languages use the equal sign as the assignment operator in most contexts and then the colon in limited contexts. This comes from Fortan and its just wrong. The equal sign should be reserved for comparisons, because that is what it means in mathematics.
znkr · 5 hours ago
> The equal sign should be reserved for comparisons, because that is what it means in mathematics.

This is touching on a pet peeve of mine: Mathematics and programming are similar in many aspects, but this is not one of them. In mathematics = is not a comparison, but a statement.

More generally, mathematics is about tautologies, that is statements that are always true. In programming, a comparison is evaluated to either true or false.

That doesn’t mean that there’s no room for conditionals in mathematics (one example is piecewise function definitions). But it’s not the same. Heck, even the definition of “function” is different between mathematics and programming.

znkr commented on Modern C++ – RAII   green7ea.github.io/modern... · Posted by u/green7ea
pjmlp · 3 months ago
One caveat though, you need to pair those with static analysis tooling, if you want to ensure developers don't forget to make use of them.
znkr · 3 months ago
I agree, this is a real benefit of RAII compared to defer. That said, there are disadvantages of making the resource freeing part invisible. Not having to debug destructors that do network IO (e.g. closing a buffered writer that writes to the other side of the world) or expensive computation (e.g. buffered IO writing to a compressor) is a define plus. Don’t get me started on error handling…
znkr commented on Modern C++ – RAII   green7ea.github.io/modern... · Posted by u/green7ea
motorest · 3 months ago
> This seems like an extremely low bar.

Is it, though? Most mainstream languages fail to support anything resembling RAII, at least as first-class support. Do you actually have an example of a language that does a better job at resource management than C++?

znkr · 3 months ago
When I switched from C++ to a bunch of other languages, I missed RAII initially. However, I quickly learned that other languages just do it differently and often even better (ever had to check an error when closing a resource?). Nowadays, I think that RAII is a solution to a C++ problem and other languages have a better solution for resource management (try-with-resources in Java, defer in Go, with in Python).
znkr commented on Modern C++ – RAII   green7ea.github.io/modern... · Posted by u/green7ea
90s_dev · 3 months ago
Why don't we just use shared_ptr most of the time? Is it really that inefficient?
znkr · 3 months ago
It’s mostly fine, until you run into memory leaks due to circles or because some part of your program holds onto the root of some large shared pointer graph and you have no idea which part. If you take it very far, like some code bases I worked with did, you discover that everything needs to be shared pointer now, because most lifetimes are no longer explicit but implicitly defined by the life time of the shared pointer that holds it.
znkr commented on Modern C++ – RAII   green7ea.github.io/modern... · Posted by u/green7ea
kjuulh · 3 months ago
I am by no means a C++ expert, a noob rather. It might be possible to make this generic, but it seems quite easy to forget a small detail here, and then be kneecapped because you forgot one of the overloads. So that in very few amount of edge cases your abstraction isn't actually cleaned up.

Better than nothing, and might be the most preferred way of doing things in C++, but it does seem dangerous to me. ;)

znkr · 3 months ago
I used to program a lot in C++ but switched to a number of different programming languages since then. Everything in C++ is this way and it’s hard to understand that things don’t have to be this way when you’re in the trenches of C++.
znkr commented on Safety in an unsafe world   lwn.net/Articles/995814/... · Posted by u/signa11
smallstepforman · 9 months ago
Nice article. Any project rewritten from scratch (version 3 here) by the same experienced engineers will inevitably be better/more robust/more performant than the previous versions. During our career growth as craftsmen, we build using tools we understand, and get a certain output. As we learn more about various other tools (techniques), we have a wider understanding and will make it better again.

Having read about their journey, I can see they use 77 mutexes and a hierarchy chart for locking to prevent deadlocks. How quaint. I keep on harping about the Actor programming model to deaf ears, but I guess the apprentices need more stumbling around before achieving true enlightenment.

Version #4, perhaps?

Any guru want to share what path to take after Actors? I’m ready…

znkr · 9 months ago
Not a guru, but my take is that the actor model is one method of architecting a system to separate synchronization from other concerns. There are other ways to do that, often specific to a particular problem and with more or less separation. As always, there are many tradeoffs involved.
znkr commented on Show HN: Go Plan9 Memo   pehringer.info/go_plan9_m... · Posted by u/pehringer
cmovq · 10 months ago
> However, (as far as I can tell) Go’s compiler does not utilizes simd

Can someone confirm this? Not even for straightforward copies?

znkr · 10 months ago
Go has a couple of SIMD uses. Copies is one of them.
znkr commented on C++ proposal: There are exactly 8 bits in a byte   open-std.org/jtc1/sc22/wg... · Posted by u/Twirrim
Iwan-Zotow · 10 months ago
In a char, not in a byte. Byte != char

u/znkr

KarmaCake day82July 21, 2022View Original