News for hackers. Stuff that matters.

funnymony

Re:Don't use DISTINCT as a "join-fixer" on Saturday October 21, 2023 @05:45PM (#37970753)
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.

Re:Don't use DISTINCT as a "join-fixer" on Saturday October 21, 2023 @05:16PM (#37970520)
1
Re:Don't use DISTINCT as a "join-fixer" on Saturday October 21, 2023 @06:02AM (#37965484)
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.

Re:Don't use DISTINCT as a "join-fixer" on Saturday October 21, 2023 @04:56AM (#37965208)
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
Re:Sweden reports damage to Baltic Sea cable with Estonia on Wednesday October 18, 2023 @11:06AM (#37929761)
Somewhat relevant. Estonia has a law that financial instutions should have servers located on Estonian soil. (Exactly for this kind of scenario)
Re:Escape analysis hates copy elision (2021) on Saturday October 14, 2023 @04:00PM (#37883768)
This would be like learning everything from books vs learning by experience. (Can’t learn skiing from books. I talk from experience)
Re:Strong typing, a hill I'm willing to die on on Wednesday October 04, 2023 @05:53PM (#37772327)
> 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...

Re:Human ancestors nearly went extinct 900k years ago on Friday September 01, 2023 @10:15AM (#37351122)
Interesting idea. But this would require no intermixing between groups.
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.
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.
Re:Why Checked Exceptions Failed on Saturday July 15, 2023 @06:59PM (#36741682)
:)
Re:Why Checked Exceptions Failed on Saturday July 15, 2023 @03:13PM (#36740004)
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.

Re:Why Checked Exceptions Failed on Saturday July 15, 2023 @10:40AM (#36737205)
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

Re:Why Checked Exceptions Failed on Saturday July 15, 2023 @10:09AM (#36736906)
“bad” might not be the right word. Maybe better “usefulness for current population of developers is very limited”.
Re:Why Checked Exceptions Failed on Saturday July 15, 2023 @09:54AM (#36736779)
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)

Re:Why Checked Exceptions Failed on Saturday July 15, 2023 @09:49AM (#36736733)
> 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.

Re:Why Checked Exceptions Failed on Saturday July 15, 2023 @09:27AM (#36736538)
“I wrote some very good C# code“

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

Re:Behind Europe’s agenda for undersea internet cables on Saturday July 15, 2023 @02:27AM (#36734139)
Possibly there should be emergency scenarios considered. Where government turns off video things (youtube and netflix) in case of major network degradation.
8 to 11 needed changes in application code.
Re:How Coders Can Survive–and Thrive–In a ChatGPT World on Wednesday July 05, 2023 @06:36AM (#36598392)
How do you ensure quality?

Review and testing.

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

Could you elaborate? Why is it so?
Re:Wind-to-Hydrogen Production Reaches Deep Water on Saturday June 10, 2023 @12:07PM (#36271709)
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.

Re:Wind-to-Hydrogen Production Reaches Deep Water on Saturday June 10, 2023 @11:55AM (#36271620)
If you have some time: https://youtu.be/Zklo4Z1SqkE (Sabine Hossenfelder)

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

Why restaurant business is bad for you?
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.

Re:All the arguments against EVs are wrong on Monday May 15, 2023 @05:44PM (#35954910)
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.

Re:All the arguments against EVs are wrong on Sunday May 14, 2023 @01:31PM (#35939638)
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)

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.
Easy fix. Do cgi of the control room.

Older »