2,550 karma · joined Nov 22, 2016 (10y ago) · 1,259 submissions
comment 3w ago · link · parent
Spoiler: The <> combines lists as cross joins (for-loop within another for-loop). The lambda maps to new lists ['z', 'a'] and ['z', 'b'] (strings are just char arrays). It then computes the various combinations to recombine them so ['z', 'z'], ['z', 'b'], ['a', 'z'], ['a', 'b']. Note it's not all permutations since you don't have ['z', 'a'] even though that's actually one of the "base" arrays we got from the lambda. It took me a long time to really internalize that and it's still probably not a function I'd reach for.
It is kind of cool, though, that you can do `(,) <$> lista <
> listb` and you get a nested for loop.comment 1mo ago · link · parent
Don't do weird crap with lifetimes to try and convince the compiler that what you're doing is ok, just throw Rc/Arc on it and be done with it.
The Rc/Arc advice also applies to C++ IMO, though you use different constructs, std::shared obviously, but there is a strong argument to be made for a std::shared_st or something which is single threaded.
It would not surprise me if this advice comes from experience with C++ where there is no Rc so reference counting is very expensive. Even so, you can greatly reduce the expense by passing things by ref where lifetimes are simple which is the vast majority of the time.
comment 1mo ago · link · parent
Most importantly, imagine a timeline where no one has invented any programming language beyond assembly. I think an LLM would have difficulties implementing complex programs in assembly without a bunch of supporting libraries.
Sure, the LLM might be able to make the libraries eventually (will it actually know them all without ANY domain knowledge from a human?) but it would take a lot of time and money to do that. And really, you’re still creating libraries, the only question is if you share them or not.
Another thing is that human written code can be much better than what the AI would write. For example, saw it basically duplicate the same complex operation three slightly different ways instead of just abstracting that away in a function.
comment 2mo ago · link · parent
However, that would clearly make your phone look suspicious from forensic analysis. To counteract that, you have two hidden volumes leaving you with three total systems: your insecure system (first password), the honeypot volume for “clever” actors to find, and then the truly secure volume.
I think one honeypot would be ideal. It needs to be convincing and have data that seems sensitive which would take a lot of effort. Put your nude photos there or something.
comment 2mo ago · link · parent
It’s obvious why you want to inline memcpy, but the specialization is more interesting. For example, I’ve seen the compiler optimize a memcpy with a static number of bytes and then use SIMD registers to do the copying with no loop at all. It can even be smart enough to take advantage of memory alignment for this.
comment 3mo ago · link · parent
Optional homework is often a disaster. At best, students would do it right before an exam and the goal of education is not to just pass exams. They’d probably still get a lower score than if they did the homework when they were supposed to.
What I think is better is to have a due date, but just make the maximum 10% each day it is late. So after 2 days, the highest score you could receive would be 80%.
I liked that system because it gave some flexibility with deadlines while still encouraging you to turn things in on time.
comment 3mo ago · link · parent
comment 5mo ago · link · parent
comment 5mo ago · link · parent
comment 7mo ago · link · parent
Jupyter also has a janky execution model. It doesn’t track dependencies so you have to be very careful in how you separate cells from one another and just running the whole notebook every time seems kind of pointless vs just writing a pure Python script.
comment 8mo ago · link · parent
comment 9mo ago · link · parent
Basic microeconomics is just that: basic and thus an oversimplification.
comment 9mo ago · link · parent
Hell, even if you’re not moving things around explicitly, don’t forget that vectors resize themselves. If you use Box, then these resizes will be less painful with large objects.
comment 10mo ago · link · parent
I deliberately avoid full vibe coding since I think doing so will rust my skills as a programmer. It also really doesn’t save much time in my experience. Once I have a design in mind, implementation is not the hard part.
comment 10mo ago · link · parent
comment 11mo ago · link · parent
I actually sped up a script the other day that had been written in bash by 200x by moving it over to Python and rewriting the regexes so they could run on whole files all at once instead of line by line. Performance problems are most often from poorly written code in my experience, not a slow language.
comment 1y ago · link · parent
comment 1y ago · link · parent
comment 1y ago · link · parent