HNHacker News
TopNewBestAskShowJobs

funnymony

96 karma · joined October 8, 2022

submissionscomments
funnymony··on Don't use DISTINCT as a "join-fixer"
These examples reminded me one more issue: change in column selection, might change number of rows, which means column addition/removal is so much riskier afair.

> Not if distinct is the default.

If that works for you, great, but let’s agree to disagree here.

funnymony··on Don't use DISTINCT as a "join-fixer"
1
funnymony··on Don't use DISTINCT as a "join-fixer"
Performance implication exist, but it is secondary.

Primary reason: distinct on every select shows either lack of knowledge of schema, in particular which columns make rows unique, or unfortunate schema design. (Apart from niche cases, schema should be somewhat normal. I.e. column parent_name belongs in the table parent, not in the table student)

Select a from x where myuniquekey=1; —- guaranted to return 1 or zero rows, if myuiniquekey is actually unique.

Select a from x join y on x.parent_id = y.y_id —- guaranteed to return same amount of rows as exist in y, never more, never duplicates y rows. (N-to-1 relation)

If distinct is used in any of above, then question “why?” naturally arises.

In more severe case, leads to bugs:

Select distinct student.student_name, parent.parent_name from student join parent on student.parent_id = parent.parent_id —- silently discards rows, where by accident student/parent name combo matches several times.

Technically sql allows comparing unrelated columns (colour=last_name), but for vast majority of cases, when joining, one of the side should be joined using it’s unique key, and other side should be using it’s foreign key, which ensures that duplicates don’t appear randomly, and thus distinct is not needed.

funnymony··on Don't use DISTINCT as a "join-fixer"
Its a matter of your eyes being used to this.

If for ten years you always indented the code this way

    Void F()
    {    Foo();
         Bar();
         Baz();}
Then following snippet will seem hard to parse mentally:

    Void F()
    {
         Foo();
         Bar();
         Baz();
    }
And vice versa
funnymony··on Sweden reports damage to Baltic Sea cable with Estonia
Somewhat relevant. Estonia has a law that financial instutions should have servers located on Estonian soil. (Exactly for this kind of scenario)
funnymony··on Escape analysis hates copy elision (2021)
Link to exact section: https://dlang.org/spec/function.html#scope-parameters
funnymony··on John Carmack and Rich Sutton partner to accelerate development of AGI
This would be like learning everything from books vs learning by experience. (Can’t learn skiing from books. I talk from experience)
funnymony··on Strong static typing, a hill I'm willing to die on
> deserialization is validation

I saw similar, catchy phrase: “parse, don’t validate”.

https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-va...

funnymony··on Modern genetic data suggests pre-humans were a group of only 1,280 individuals
Interesting idea. But this would require no intermixing between groups.
funnymony··on How to Roman Republic 101, Part IIIb: Imperium
Problem is that despots want power, whatever system you have you will get despots wanting to be at the top, and doing what is necessary to get there. Democracy at least moves them around a bit.
funnymony··on JWST spots giant black holes all over the early universe
I’ve read something like: there are bunch of observations of extremely dense masses in various suroundings. Talented people can find explanations other than black holes in each case. But that feels adhoc, and black hole fits quite nicely for whole class of observations. Current consensus is that b holes exist.
funnymony··on Why checked exceptions failed
:)
funnymony··on Why checked exceptions failed
On its own, seeing ‘SQLException‘ in method signature, does not provide you with information: “this is part of bigger transaction, and you have ability and responsibility to retry or rollback”.

That will be part of lib documentation, which should be read & understood regardless of existence of checked exception.

funnymony··on Why checked exceptions failed
Yes, grep and nuclear reactor controller, and your gui grep are applications.

They all use library for file reading.

As author of file reading library you don’t know how critical is the failure to open a file or how it should be handled. My point was that You know those things only at application level.

So it feels a bit misguided to decide at library level which failures are important. (I.e. which are checked vs which are unchecked)

> But as API authors how can we make sure

First thought: documentation. (which is required for both, checked and unchecked exceptions).

But overall, it’s not library author’s responsibility or ability to “ensure”. You can’t force correct handling of exception. At best one can make it a bit more annoying to ignore, and convenient to do the right thing.

My view:

- all exceptions should be unchecked

- assume all code throws

- if “log and exit/continue” is not enough and you need to know exact exception types, dig into the docs.

- read docs during lib version upgrades

funnymony··on Why checked exceptions failed
“bad” might not be the right word. Maybe better “usefulness for current population of developers is very limited”.
funnymony··on Why checked exceptions failed
Any chance you have a code/pseudo code example of this?

My naive take on this would be “just use raii/closable”. (But easily and likely, I misunderstood)

funnymony··on Why checked exceptions failed
> important failure that can't be dismissed

But importance of the failure is determined completely by the program, not the library.

Grep fails to open a file for reading -> message the user and exit

Nuclear reactor controller fails to read important a file -> initiate reactor shutdown or something.

If file read is critical, you have to handle failure no matter what the interface is. Because you know that disk can fail.

funnymony··on Why checked exceptions failed
“I wrote some very good C# code“

We all do.. its always that other guy who is at fault :)

funnymony··on Europe’s agenda for undersea internet cables
Possibly there should be emergency scenarios considered. Where government turns off video things (youtube and netflix) in case of major network degradation.
funnymony··on If PEP 703 is accepted, Meta can commit three engineer-years to no-GIL CPython
8 to 11 needed changes in application code.
funnymony··on Tips for programmers to stay ahead of generative AI
How do you ensure quality?

Review and testing.

Reviewing is easier when there is less code (i.e. libraries are in use)

funnymony··on Shifting views about psychedelic drugs require a new category for them
Could you elaborate? Why is it so?
funnymony··on Wind-to-hydrogen production reaches deep water
Storing hydrogen is not the same as storing oil.

Over time, hydrogen damages the tank. (Which is undesirable combo with “explosive gas when mixed with air”)

I would like some breakthrough in material sciences here.

funnymony··on Wind-to-hydrogen production reaches deep water
If you have some time: https://youtu.be/Zklo4Z1SqkE (Sabine Hossenfelder)

If I remember video correctly, summary would be: not yet

funnymony··on A Swedish startup’s bid to build a green rival to AWS
Why restaurant business is bad for you?
funnymony··on NYC skyscrapers sit vacant
Mega yacht costs bazilions.

Yes, lot of people would not reject idea of having it, but at the same time actual demand (i.e. actual number of people who would think price is worth it, is quite lower compared to spagetti which is much cheaper but has many more buyers)

All in all. high price does not necessarily mean huge demand.

funnymony··on All the arguments against EVs are wrong
I must concede: 1000x increase in driver count is too far fetched.

Though if forever growth is assumed, and goal post is moved to co2 total instead of per km, then some options exist to eat up that 1000x saving: Owning more than one vehicle per person, buying new automobile more frequently, moving to bigger, better and powerfuler cars.

funnymony··on All the arguments against EVs are wrong
Lets say EV cut co2 emissions by factor of 100x for each km traveled.

Lets say number of cars in total follows exponential progression, 5% growth per year.

It follows that after 100 years due to growth co2 gets back to original level. (Log100/log1.05=94)

EVs are required bandaid, but degrowth will come eventually. (Possibly due to climate change supply will decrease and so will consumption)

funnymony··on Parts for stolen Hyundais and Kias are so scarce the cars are being totaled
You should not reveal that you know the code and especially the content of neighbour’s safe. Your physical surroundings might be safe, but internet is not.
funnymony··on Why is it so hard to pull off a lunar landing?
Easy fix. Do cgi of the control room.
Page 1 of 3Next →