HNHacker News
TopNewBestAskShowJobs

xanathar

344 karma · joined July 8, 2020

submissionscomments
xanathar··on Not Your Grandmother's Textbook Exercise
I think the idea in parent post is: fill the dictionary (I would use a 200 entries array though), iterate over the keys in sorted order summing the values, stop when you are at N/2. The 'iterate over keys in order' part depends heavily on the data structure choice of the dictionary (good for treemaps, bad for hashmaps, best for preallocated array).

Incidentally this falls in the 'sort an then pick the middle' because the original text says nowhere that is must be a n*log(n) sort and what I described here is essentially the same but with counting sort (and a couple redundant steps removed).

xanathar··on Shellfirm: Intercept risky patterns at the command line
Yes, but probably not in the way that makes the program any useful.

Example: I recently executed `git checkout .` (that incidentally would not be caught by this project) on the wrong repo. Oh the pain. But I would have probably confirmed the "captcha" blindly as I really wanted to execute that... just not on that repo.

xanathar··on Ask HN: Should I learn Rust or Go?
What a missed opportunity to title it "Should I Rust Or Should I Go?".
xanathar··on Xor swap trick and add/sub swap trick (2010)
99.9% of the time swaps are done for a reason, usually when sorting or manipulating linked lists pointers, but - for example - comes into play also when you want to transpose a matrix in place, or other similar algorithms.

I guess you can make an argument that the best way to get an array sorted is to have the array already sorted, but that sounds as "the best way to calculate the length of the hypotenuse is to just measure the hypotenuse, and Pythagoras never realized it was a problem upstream".

xanathar··on Things I hate about Rust, redux
Popping in my mind:

- System.Diagnostics.Debug.Assert (on debug builds)

- Envinroment.FailFast (this is precisely what panic! is usually used for)

- void BlowUp() { BlowUp(); }

But, in reality, any unexpected Exception: how would you properly handle an unexpected NRE or index out of bounds? Either swallowing the exception (bad) or aborting.

xanathar··on Don't Write a Programming Language
I can feel the author pain, even though I didn't invent a programming language, I just wrote the interpreter for one (specifically a Lua interpreter written in C# - moonsharp).

Why I did it: in 2013-2014 I was SUPER bored and burned-out, I needed a challenge and I picked that one. Oh, I was wrong.

The GOOD: the challenge has been fun, I learned A LOT. I learned how to use ANTLR, and then I learned that ANTLR was getting in the way and now I'm wary of ever using a parser generator at all, for sure not that one. I learned how to write a recursive descent parser, even if I did it by reversing engineering (i.e. mostly copying) the original rd-parser of puc Lua. And I learned that no matter what I do, what I find the hardest is respecting the correct operator priority in math expressions. I know that shouldn't be the hardest thing, but brains are fun. It also ended up getting used. It was used in the OnePassword client for windows, and it's for sure used in the Shenzen IO and TIS-100 videogames. I'm sure there are many more users using that. It's stuck somewhat in between of "nobody uses it" and "it has enough traction that the community will take it forward and you can forget it even existed", and that, turns out, is not a great place to be.

The BAD: I picked C#, as that's the language I was using at the time and I had an interest in seeing it used in Unity. Big mistake. Don't get me wrong: C# is a great language and if you're planning to base your company on it, I don't see big reasons not to (I wouldn't, probably, but every language has its pros and cons). But C#, and in 2014 to boot, was a mistake for such a project. First, however multiplatform C# became, a lot of development is still Windows only (at least, if you want to target the main frameworks). And second, 2014 is precisely the year when C# started changing radically with the core / standard frameworks. The situation now is probably more stable, but in 2014/2015 it was a mess, and half of the reflection frameworks were broken to say the least.

The UGLY: I just didn't consider how much punches life can hit your face with. I changed job, twice. Changed platform from Windows to MacOS, to Linux, to MacOS again, now I program for multiple platforms in Rust most of the time, and my interest in C# is close to non-existent. Family members passed away, new kids were born, situations changed, and life hit me hard enough. Energy got focused on daily jobs, or on other side projects. Every other side project, by the way, has been met with humongous amounts of guilt, because I'm/was leaving moonsharp users (however few they might be) behind.

So where I'm now? I tried to delegate the project to other people, but I'm not effective at it (maybe they are, but in reality, I'm just absent). I tried to get back active into the project but failed a couple of times and now I fear doing it again and creating expectations. Sometimes I feel like contributing something, but I can't even get a proper dev setup running. I don't remember details well enough to not break something when fixing major bugs, nothing major but usually it goes over the amount of energy that I would like to spend. Sometimes I read some question on MoonSharp, and I try to answer, but more often I read a question and before answering I have a guilt trip because I'm answering to this question and left alone all the others and so I simply avoid this one too.

Most of all, the project is not aligned anymore to my interests, so it feels like a chore.

So, if you are reading this: think twice before making the same mistake. If you want a side project, pick one that is either small, or has a clear end to it.

xanathar··on Jless – a command-line JSON viewer (written in Rust)
Feature suggestion: pressing some hotkey exits and prints the path that could be used in jq to select the node that was selected when the hotkey was pressed.

I'm sure it has a lot of corner cases as a feature, but that would be super-useful as companion tool to jq.

xanathar··on Some mistakes Rust doesn't catch
Linters should be frustatingly non-general. They should alert for the common case and special cases should have a "#[allow(xxx)]" or "#pragma warning disable xxx" (or whatever does that in your language) and, possibly, a comment.

This, incidentally, also helps fellow humans reading the code who'll see that it's all intentional and won't flip with "wtf why does it XOR in an add method?" even if just for a second.

xanathar··on Hello Mac OS X Tiger
Windows 11 also has shadows again, fwiw.
xanathar··on The vagaries of 1990s 32-bit Windows networking
> Anyway: that was the sole significant improvement in networking in Win98 that I am aware of. The other thing 98 could do was drive multiple monitors, if you had the right — that is, from an extremely limited selection — graphics cards.

The selection included all common S3 models, and you just had to have one S3 graphic card to be compatible, and they were already dirt cheap. It was AMAZING.

This was the real killer feature (most of the time I didn't even have one IP address because dial-up internet was expensive).

xanathar··on Google DNS at 010.010.010.010
The main prerequisite is "having a bloatload of money".
xanathar··on 286 vs. 386SX
I had a 286 12MHz and then upgraded to a 386sx 40Mhz (both manufactured by AMD, btw).

It was a HUGE upgrade.

First, 12Mhz to 40Mhz was an amazing upgrade, but that was definitely not the reason why I upgraded.

The real reason was *compatibilityé.

The 286 was compatible with close to nothing by the early 90's. Doom? Sure, runs slow on the 386sx, but on the 286? Does not run at all. And the same goes for all games and programs using one of: 1) 32 bit DOS extenders 2) EMS 3) any amount of XMS more than my 286 could handle 4) >600KB conventional memory, because there's only that much HIMEM.SYS can do 5) Windows 3.0 in 386-enhanced mode

xanathar··on On Apple’s “Expanded Protections for Children” – A Personal Story
I'm also Italian. My dad shared the name and surname with somebody with shady background who incidentally lived close to our house.

He was denied an operation at the bank once, but was quickly able to clarify the issue and unblock it (probably he got lucky).

But he had to have himself removed from the white pages and the ring label (ring label? whatever, il citofono :D) because of violent threats.

xanathar··on QUIC is now RFC 9000
QUIC has been an IETF draft for years and they were definitely accepting contributions and feedback, and a lot of efforts were not driven by Google at all.

As far as orthogonality goes, it seems to be pretty orthogonal to different kind of uses, I'm not sure why you're saying it's not.

On simplicity it's definitely not simple, but given the problems it is trying to solve it's probably as simple as it could be.

xanathar··on QUIC is now RFC 9000
> so many client/server implementations don't implement the datagram extension properly

I'm genuinely interested in what aspects you think are (or were) not implemented properly.

I wrote most of the implementation of quiche's datagram extension and, well, if there's something that can be improved, I'm all for it.

(aside: I think the standard should've considered an option for datagrams to opt-out of congestion control, given that most applications which want to take control over datagram sending probably also want to take control of available bandwidth and control congestion differently - e.g. by dropping encoding bitrate instead of queuing - but it is what it is).

xanathar··on Where the top of the stack is on x86 (2011)
I THINK that the reason is: 8086 inherited it from the 8085 which inherited it from the 8080. The next parent in line would be the 8008, but that has a small call stack in the CPU registers rather than RAM, so the ancestor would be the 8080.

The 8080 had 64KB address space. I bet the rationale was to partition memory so that classic memory usage goes upwards from 0000 to FFFF and the stack goes downwards from FFFF to 0000. This removes the need to define a boundary between the two beforehand.

Of course this is totally speculation on my part, I might be super wrong.

xanathar··on Where the top of the stack is on x86 (2011)
Bonus (?): the stack going down rather than up means that overflowing a stack-allocated buffer will overwrite the contents that are already on the stack (as they have a higher address than the last item in the buffer), likely changing the return address of the function and thus making arbitrary code execution a breeze (see: https://en.wikipedia.org/wiki/Return-to-libc_attack).

Most operating systems and standard libraries have checks and countermeasures to make this a lot harder nowadays, but still.

xanathar··on Sexual Eeling
Considering we're talking about Freud, I'm not sure we can say "sexual reproduction" to be remote from "personal issues".
xanathar··on Making the Monty Hall problem weirder but obvious
If you want to visualize them in "enumeration of cases".

The complete cases for the choices is:

Problem-1:

    1) You pick goat#1, Monty opens goat#2
    2) You pick goat#2, Monty opens goat#1
    3) You pick car, Monty chooses a goat of his liking
Problem-2:

    1) You pick goat#1, Monty opens goat#2
    2) You pick goat#2, Monty opens goat#1
    3) You pick car, Monty opens goat#1
    4) You pick car, Monty opens goat#2
    5) You pick goat#1, Monty opens car
    6) You pick goat#2, Monty opens car
We know Monty didn't pick a car, that reduces it to:

Problem-1:

    1) You pick goat#1, Monty opens goat#2
    2) You pick goat#2, Monty opens goat#1
    3) You pick car, Monty chooses a goat of his liking
Problem-2:

    1) You pick goat#1, Monty opens goat#2
    2) You pick goat#2, Monty opens goat#1
    3) You pick car, Monty opens goat#1
    4) You pick car, Monty opens goat#2
Or, 1/3 for Problem-1, 2/4 (=1/2) for Problem-2
xanathar··on Making the Monty Hall problem weirder but obvious
https://news.ycombinator.com/item?id=24716753

It's a Conditional Probability of non independent events.

xanathar··on Making the Monty Hall problem weirder but obvious
Problem-1: "You pick a door. Then Monty opens a door he knows having the goat. Calculate probability of winning if staying."

Problem-2: "You pick a door. Monty opens a door at random, which just happens to be a goat. Calculate probability of winning if staying."

Both are conditional probability P(A|B) (that is, probability of A happening, under the assumption B has happened).

   - A is probability of picking the correct door at the first try (or switching if you prefer)
   - B is the probability that Monty picked a door with a goat
P(A|B) is defined as: P(A|B) = P(A and B) / P(B)

In both problems P(A) is 1/3.

In Problem-1, P(B) is 1 because Monty knows and it's not a random event and P(A and B) = P(A), so P(A|B) = P(A)*P(B)/P(B) = P(A) = 1/3.

In Problem-2, P(A) is 1/3, P(B) is 2/3, P(A and B) is 1/3 (if you pick a car, Monty is guaranteed to pick a goat), so P(A|B) = 1/3 / 2/3 = 1/2.

xanathar··on Hard to discover tips and apps for macOS
Mind. Blown.

(seriously, this is a game changer for me, thanks!)

xanathar··on Italian Ruby
I will never read "ometti" in the same (sane) way again.
xanathar··on Luau – A fast, small, safe, gradually typed scripting language derived from Lua
I was almost semi-proud of having done my implementation, why did you ruin the party.

Jokes aside, and not to boast about what I did, honestly, but Lua is (in hindsight - I wish I realized before) full of gotchas which are definitely not easy to implement (just one word which still makes my stomach hurt: COROUTINES).

I honestly think there are simpler (and better) languages to target. With hindsight, experience and pain, of course.

xanathar··on Things I wish I’d known about CSS
I know, I retried before and it worked.

But "it works differently every time I try" wouldn't have made a good CSS joke. Oh, wait.

xanathar··on Things I wish I’d known about CSS
Ends up to a page saying "The page you requested does not exist".

...which kinda reflects "things I wish about CSS", so 10/10.

← PreviousPage 3 of 3