HNHacker News
TopNewBestAskShowJobs

detrino

482 karma · joined July 15, 2013

chris@detrino.org
submissionscomments
detrino··on DisplayPort and 4K
I think you misunderstand me. I am saying that on Linux text at normal PPI is pretty much as good (to me) as text at high PPI because it has sub pixel rendering and strong hinting that Mac OS X lacks,
detrino··on DisplayPort and 4K
OSX has had sub pixel rendering disabled by default since Mojave. It also never had the strong hinting that you can find on Linux and Windows which makes text significantly sharper at the cost of differing from the shape as specified by the font.
detrino··on DisplayPort and 4K
Do you use Mac OS X?

When using Windows or Linux I don't find much benefit in text rendering on a 4k display.

But as Mac OS X has no sub pixel rendering or grid fitting text looks terrible without a high ppi display.

detrino··on Schwab Removes U.S. Stock, ETF and Options Commissions
You can still get 2% interest on that buy buying treasury ETFs, or 1.56% currently by asking them to open a preferred deposit account for you, which is essentially a savings account with a high interest rate. You dont have to keep it in cash.
detrino··on Schwab Removes U.S. Stock, ETF and Options Commissions
If you have bank of america you can link your bofa and merrill accounts. They even give you bonuses on your credit cards of +25/50/75% cash back for balances over 25/50/100k in assets between both.
detrino··on Show HN: Array with Constant Time Access and Fast Insertion and Deletion
Depends what you consider a Rope.

Does it require constant time concat?

Does it require immutability?

Does it require a balancing scheme based on the fib sequence?

Does it require that the tree is binary?

My tree is an attempt to be as fast as possible with log everything operations and no pointer/reference stability.

detrino··on Show HN: Array with Constant Time Access and Fast Insertion and Deletion
Re benchmarking vs other data structures: Here is a B+Tree based sequence container I made: https://github.com/det/segmented_tree

Basically, it has O(log n) everything like a binary search tree you suggested but also very good constant factors.

By default, leaves hold 1024/sizeof(T) elements and branches hold 47 elements, so it can access up to 13,289,344 8 byte elements with only 4 levels.

detrino··on Linux kernel coding style
If you enforce the use of clang-format then this is not an issue as it will indent the code correctly.
detrino··on ‘Abusing’ the C switch statement – beauty is in the eye of the beholder
It's impressive that clang generates the same assembly for both versions: https://godbolt.org/g/yLh1EF

Note that the assembly for process_message2 calls each function only once even though some appear twice in the body.

detrino··on Short intro to C++ for Rust developers: Ownership and Borrowing
Returning a stack allocated value is a move in C++11/14. It is also true that in many circumstances a compiler may optimize that move away using RVO/NRVO.

Consider this example: http://ideone.com/T872Oj

In F1 the compiler can NRVO away the move.

In F2 it cannot.

Both will fail to compile if you delete the move constructor.

detrino··on Finger Trees: A Simple General-Purpose Data Structure (2006)
I would expect B-trees to outperform binary trees even in a persistent data structure. The necessity of binary trees comes when you need stable iterators/references.
detrino··on The Clockwise/Spiral Rule of C declarations
std::array does not exist because it is easier to read. It exists because C arrays behave strangely. Two examples: decay to pointer and no value semantics.
detrino··on A bit of background on compilers exploiting signed overflow
Your loop:

    void TestSigned(int min, int max, int step) {
      for (int i = max; i >= min; i -= step) F(i);
    }
Becomes this with unsigned:

    void TestUnsigned(unsigned min, unsigned max, unsigned step) {
      while (true) {
        F(max);
        if (max < min + step) break;
        max -= step;
      }
    }
Now if I want to transform my loop to operate on pointers or iterators, the transformation is trivial:

    void TestUnsigned(unsigned *min, unsigned *max, unsigned step) {
      while (true) {
        F(*max);
        if (max < min + step) break;
        max -= step;
      }
    }
Quick: Do the same for yours.
detrino··on A Brief Glance at How Various Text Editors Manage Their Textual Data (2015)
I've written a Data Structure[1] for C++ to handle this problem. It uses counted B+Trees internally and is a drop in replacement for C++14's std::vector.

[1] https://github.com/det/segmented_tree

detrino··on Why you should always buy the men’s version of almost anything
They cherry picked a retailer that was out of stock and listing an old price on the pink scooter.
detrino··on Why you should always buy the men’s version of almost anything
Note that the pink scooter has a grayed-out "Add to cart" button. They are sold out of the pink version so you can't even buy it on target.com (Where the screenshot appears to be from). The old price is completely irrelevant when comparing to what the red version now sells for. Note also that walmart.com which has inventory of both colors sells them each for $24.96, which is about the same price that target.com is selling the red version for. The author of this article knows this and is being intentionally misleading.
detrino··on Do Bilingual People Have a Cognitive Advantage?
Nothing in particular, just admitting the possibility.
detrino··on Cryptographically timestamping all your Git commits automatically
I've looked into this and it seems you are correct, thanks for the explanation.
detrino··on Do Bilingual People Have a Cognitive Advantage?
Who is assuming anything? People are conducting science and the evidence doesn't support an advantage for this particular function. Also, not only do I not think it is not absurd to consider that maybe a second language does not offer any significant advantages, I also think it's a possibility that learning more languages than one could be harmful overall. To assume anything else without supporting evidence is showing a bias.
detrino··on The Fall and Rise of SVG
Because bitmaps target a specific resolution they can be tweaked so that features are aligned to pixel boundaries resulting in less anti-aliasing.

Truetype fonts are an example of a vector format that can still look sharp at arbitrary resolutions because they can include hinting programs that align the control points to pixel boundaries. This is why fonts tend to look sharper on Windows and Linux than MacOS X. Linux and Windows default to strong hinting, and MacOS X uses only slight hinting, preferring accurate shapes to sharpness.

detrino··on Cryptographically timestamping all your Git commits automatically
> Git was not designed for security

Can you elaborate on this? While it's true that SHA-1 is now broken, my understanding is that git's reason for using SHA-1 was to ensure the integrity of the entire history.

detrino··on Ask HN: Do you like code pairing interviews? I hate them
A more common complaint is about whiteboard coding. Having a laptop connected to a projector is exactly what many people say they would prefer.
detrino··on Ask HN: Who wants to be hired? (December 2015)
Location: Las Vegas, Nevada

Remote: Yes

Willing to relocate: Yes

Technologies: C++, C#, C, Python, Git, Subversion, Linux, Windows

Github: http://github.com/det

Email: chris@detrino.org

detrino··on CHIP Vs. Pi Zero: Which Sub-$10 Computer Is Better?
You can not order anything on that page. Besides, there is absolutely reason for doubt when the BoM is estimated to be more than $9.
detrino··on Vertical Finger Trees
Finger trees don't provide O(1) insertion, just O(1) prepend and append.
detrino··on D 2.069.0 released, compiler automatically ported from C++ to D
> Compared to Rust? I doubt that. Like I said, Rust lets you dance near the line.

Your problem is that you are trying to imagine what happens in the real world rather than just looking at it.

> This is from experience in various large C++ codebases. I'm not saying people use refcounting a lot, I'm saying it gets used more than Rust.

I count 56 imports of Arc and 37 of Rc in servo, would you wager the equivalent parts of chromium or firefox use more ref-counting?

> Not really. Aside from non-lexical borrows and a couple other nice-to-have things (but not necessary), the borrow checker is pretty precise for what it tries to prove.

The problem is that the borrow checker does not look at the function as a whole. You are a slave to the borrow checker, you can only consider other things when it has been satisfied, even if its trivially safe from a whole-function view. Some simple things aren't even expressible at all without non-lexical borrows, no matter what gymnastics you try.

> It sort of does. If you try to introduce borrows and listen to the suggestions the compiler gives you, and eventually end up nowhere, it's probably not possible to do it that way.

That sounds like a terrible workflow that I don't think Rust programmers use in the real world. I think they usually use shared ownership because they know they have shared ownership, not because they gave up on the borrow checker. Any instance of actually resorting to reference counting because of the inability to make the borrow checker happy actually counts against Rust, not for it.

> in practice IMO the things Rust makes you feel safe to do is a superset of what C++ lets you feel safe to do

People routinely do safe things in C++ that would be impossible to express in safe Rust code. You need to let go if this untruth.

> if we're going to talk about "all possible things C++ theoretically allows you to do", then you should include unsafe -- you were comparing "safe Rust" with "all C++", which is unfair here, since the entities to be compared for what you're theoretically allowed to do are "all Rust" and "all C++".

I focused on safe Rust because your argument was that safe Rust is just as powerful as C++, just proved safe statically. This is far from the truth and you refuse to accept the correction. Most people in the Rust community would probably say they accept the loss in power because they prefer absolute safety. This is a very defensive position. It's impressive just how little power Rust gives up in comparison to languages like C#/Java. But to pretend that you actually have more power in Rust due to psychological effects is just zealotry and doesn't reflect how people use C++ in the real world.

> Examples?

Any abstraction that uses dynamic checking that would be considered a bug to actually trigger. Some examples include borrowing a RefCell, random access of iterators, sequential access of certain kinds of iterator adaptors, etc.

detrino··on D 2.069.0 released, compiler automatically ported from C++ to D
Your comment has the structure of a well reasoned argument, but it's predicated on falsehoods.

Most large C++ projects do not unnecessarily use reference counting.

Most C++ programmers do not fear using references or pointers because of invalidation.

The Rust compiler does not tell you when it's impossible to satisfy your problem using borrows. In fact it often has false positives requiring borrow gymnastics because it is too primitive.

And your last line is a complete reversal of your previous attitude: Suddenly you are focusing on theory while ignoring that in practice you can not usually break out `unsafe` to solve your borrow problems. In fact it's Rust, not C++, that is more likely to reach for more heavyweight abstractions than necessary because it's not practical to litter unsafe throughout your codebase.

detrino··on D 2.069.0 released, compiler automatically ported from C++ to D
> it's an equivalent set of principles to what you would do in C++ to keep your pointers safe.

The things you can prove statically with the borrow checker are a subset of the things that wont trigger UB in C++.

detrino··on Why Go Was the Right Choice for CockroachDB
There is a clear bias.

When talking about Java:

> JVM garbage collection is notoriously expensive.

> Java’s known performance issues made it unappealing.

> However, in our past experience, we ported a large system from Java to Go, which greatly decreased its memory footprint and garbage collection overhead.

When talking about Go:

> What remains to be seen, of course, is how all of this Go code will perform.

Yet: The JVM's GC is superior to Go's, Java tends to outperform Go, and a large memory footprint is a necessary evil for getting good performance out of any GC.

detrino··on Efficient Image Resizing with ImageMagick
Lanczos-2 is pretty much identical to Catmull-Rom, and Lanczos-3+ are all sharper than Catmull-Rom, but at the cost of ringing artifacts.
Page 1 of 9Next →