HNHacker News
TopNewBestAskShowJobs

Leszek

1,569 karma · joined May 2, 2012

[ my public key: https://keybase.io/leszek; my proof: https://keybase.io/leszek/sigs/3_mY6iFecdFZc6Ow5JJY9sZoaasKcTYHSNihcVgQptw ]
submissionscomments
Leszek··on What Color Is This? Part 2
This video from Captain Disillusion does a great job of explaining both the biological mechanism and the consequences it has on displays:

https://youtu.be/FTKP0Y9MVus

Leszek··on A Handwritten Math Parser in 100 lines of Python
I like Jonathan Blow and all, but he should be careful with trashing academic parsing theory if he thinks that Pratt parsing was only discovered "in the last few years".
Leszek··on A Deep Introduction to JIT Compilers: JITs are not very Just-in-time
> Or could there be a way to alter the execution graph so that once you add in the optimization, you never have to check if it's there?

One of the things V8 does is store "field dependencies" -- a list of optimized code attached to fields that is invalidated if that field is modified in a certain way. The optimized code is known to only access that field in a certain way, thus doesn't need to check it, so this only slows down unoptimized paths (and only on their slow paths too, since even unoptimized code has fast paths for known access patterns thanks to inline caches). Comes with a memory/generality cost though, so this isn't used for every type of check.

Leszek··on Quora goes permanently remote-first
One interesting aspect of this is that they still explicitly expect "synchronous" work, timezones be damned:

> We have initially designated 9am to 3pm Pacific Time as “coordination hours” where most employees will be expected to be available for meetings and impromptu communication, regardless of where they are located. This maps to 6am to 12pm in Hawaii, 12pm to 6pm Eastern Time, 5pm to 11pm in the UK, and 6pm to 12am across most of Europe

I know that I wouldn't work for them from Europe if those were the conditions.

Leszek··on Memory in JavaScript – Beyond Leaks (2019)
One thing the author doesn't discuss is that the Boom objects themselves are also in memory, and also have to be accessed -- and can therefore also be visited not in memory order, and cause cache misses.

Changing this to a "structure of arrays" approach, with the x value inline in the array, reduces the runtime by another order of magnitude:

    const arr_x = new Array(ROWS * COLS).fill(0);

    function doSoA() {
        for (let i = 0; i < ROWS; i++) {
            for (let j = 0; j < COLS; j++) {
                arr_x[i * ROWS + j] = 0;
            }
        }
    }

     Started data Local
    Finished data locality test run in  0.6168  seconds
     Started data Non Local
    Finished data locality test run in  2.6442  seconds
     Started data Non Local Sorted
    Finished data locality test run in  0.7923  seconds
     Started data structure-of-arrays
    Finished data locality test run in  0.0627  seconds
This is a microbenchmark, so that this with a grain of salt of course.
Leszek··on Sat solver on top of regex matcher
Escaping isn't an intrinsic property of all quoted strings (e.g. single quoted strings in bash), but even so one can work around them without backreferences, by searching for anything that's not a quote or a backslash, _or_ any escaped character:

    /"([^"\\]|\\.)*"/
Now double that up with a single quote version if you wish.

What you can't match without backreferences, however, is strings with customisable terminators, e.g. the behaviour in sed that whatever character you use after `s` is the regex terminator (it doesn't have to be `/`), or raw strings in C++.

Leszek··on Reverse Engineering Snapchat: Obfuscation Techniques
I assume OP meant the securing side, not the RE side.
Leszek··on Words that don't translate into English
I guess, and I say this as a native speaker of both languages, agree to disagree ¯\_(ツ)_/¯
Leszek··on Words that don't translate into English
"Uporządkować" can be "sort out" too, though I'd more often translate it as "tidy up"; "zająć się czymś" is roughly "take care of something", maybe you could use "occupy yourself with something" if it's more in the time-wasting sense.

I stand by "sort out", or even just "sort" as a good translation for załatwić, especially in British English, where I would use "sorted" as a single word sentence similar to "załatwione". There's other possible translations too, I could e.g. imagine using "score" when it's specifically about obtaining something physical, or "get it done" if it's about expediency or perseverance; if anything there's too many ways of translating it!

Leszek··on Words that don't translate into English
"Sort out" is a pretty solid translation IMO
Leszek··on Sonic Pi is a code-based music creation and performance tool
There's also a _great_ talk from the creator (Sam Aaron) on Sonic Pi, including live-coding examples and some wonderful insights on how computer science is taught in schools:

https://www.youtube.com/watch?v=OLLwG_SN8oo

Leszek··on Simdjson 0.3: Faster JSON parser
V8 has a hand rolled JSON parser which feeds directly into our object model without any intermediate data structures. This allows us to take advantage of structural knowledge, e.g. we assume that objects in an array have the same shape (and just verify this before falling back to pointer chasing through transition trees).

I keep meaning to look into SIMD for both this and ordinary tokenisation, last time I tried it the bookkeeping overheads and alignment requirements weren't worth the speedup but it's always worth re-evaluating.

Leszek··on Programmers generate every possible melody in MIDI to prevent lawsuits
Is uncompression a derivation?
Leszek··on Programmers generate every possible melody in MIDI to prevent lawsuits
It's actually very relevant, the TL;DR (from memory) is that lawyers (and judges) aren't programmers, and the source of data (referred to as the "colour of the bits") is as important as the actual bits of the data. Thus "I have this bit pattern as part of a bit enumeration" is different, to the legal system, than "I have this bit pattern because I specifically created it".
Leszek··on Python dicts are now ordered
Well, JavaScript Map preserves insertion order when iterating entries, and as of ES2015 (i.e. ES6), for-in also iterates the (string, non-numeric) properties of an object in insertion order.
Leszek··on V8 Release v8.0
Yeah, sorry about that, it's fixed now.
Leszek··on Thousand year-old windmills in Iran (2017)
There's likely an interesting Ship of Theseus debate to be had about whether these are indeed thousand-year-old windmills, and whether it's accurate to consider the windmills build a thousand years ago to be "still standing".
Leszek··on A lighter V8
Bytecode aging actually existed already for other reasons (expiring code caches).
Leszek··on NanoLog – a nanosecond scale logging system for C++
I had thought that, as long as the object in that location is valid (e.g. constructed with placement new and not since destructed, with the `char` as a pointer to the storage), then accessing it through the `char` is valid -- but maybe that's only true for `void*` now that I think about it. Either way, fair enough, placement new probably hasn't happened (haven't read the rest of the code).
Leszek··on NanoLog – a nanosecond scale logging system for C++
You'd think so, but in fact reinterpret_cast from char* (and unsigned char, and std::byte) is explicitly allowed by the type aliasing rules.
Leszek··on Espresso Machine Powered by Tcl/Tk
Though to be fair, full source strings are kept around in memory for lazy compilation anyway (and other lazy computation).
Leszek··on Visualizing and exploring sorting algorithms in two dimensions
Yeah, for someone not used to the code it's tough. The "insider knowledge" is that builtins defined in .tq files (files compiled by the Torque compiler[0]) are added to entries in the Builtins enum, which itself is defined as a giant macro[1] that pulls in a Torque generated macro[2]. In the bootstraper (which sets up the standard library), the Builtins::kArrayPrototypeSort builtin is installed as "sort" onto Array.prototype[3], which means you should grep for "ArrayPrototypeSort", which is defined in the linked .tq file.

[0] https://v8.dev/docs/torque [1] https://cs.chromium.org/chromium/src/v8/src/builtins/builtin... [2] https://cs.chromium.org/chromium/src/out/Debug/gen/v8/torque... [3] https://cs.chromium.org/chromium/src/v8/src/init/bootstrappe...

Leszek··on Visualizing and exploring sorting algorithms in two dimensions
A more detailed look will show that it uses Timsort:

https://cs.chromium.org/chromium/src/v8/third_party/v8/built...

Leszek··on Decades-Old Computer Science Conjecture Solved in Two Pages
> And I thought they had ways to construct hash functions so that all the inputs of the same length have a different output?

That's trivially impossible for fixed-size hashes, by the pigeon hole principle.

Leszek··on Show HN: Ferrum.js – Rust features in JS: traits and advanced iteration
You want a conditional expression in JavaScript ? you could use the ternary operator : you don't have to use it if you don't want to though;
Leszek··on D is being used for autonomous driving research – Audi and Mercedes
"second to none" means "best" ("there is no one it is second to, thus it is first")
Leszek··on [dead]
Maybe it would make more sense to show overdue promises first.
Leszek··on California is cracking down on the gig economy
Germany has similar workers' rights and protection from firing, yet it has a lower unemployment rate.
Leszek··on Clear is better than clever [pdf]
Thank you for mentioning micro- vs macro-readability, I feel that too often people concentrate on the former without considering the latter.
Leszek··on Cameras That Can Spot Shoplifters Even Before They Steal?
Slippery slope arguments slip both ways: https://www.smbc-comics.com/comic/2010-01-02
← PreviousPage 4 of 11Next →