- 0 Posts
- 15 Comments
ugo@feddit.itto
Technology@lemmy.world•VPN company Mullvad reminds users it will no longer use OpenVPNEnglish
13·6 months agodeleted by creator
ugo@feddit.itto
Piracy: ꜱᴀɪʟ ᴛʜᴇ ʜɪɢʜ ꜱᴇᴀꜱ@lemmy.dbzer0.com•Can’t pay, won’t pay: impoverished streaming services are driving viewers back to piracyEnglish
48·6 months agodeleted by creator
ugo@feddit.itto
Technology@lemmy.world•Scientists Discover That Feeding AI Models 10% 4Chan Trash Actually Makes Them Better BehavedEnglish
2·8 months agodeleted by creator
ugo@feddit.itto
Technology@lemmy.world•Scientists Discover That Feeding AI Models 10% 4Chan Trash Actually Makes Them Better BehavedEnglish
3·8 months agodeleted by creator
ugo@feddit.itto
Technology@lemmy.world•Microsoft Gives European Union Users More Control: Uninstall Edge, Store, and Say Goodbye to Bing PromptsEnglish
41·8 months agodeleted by creator
ugo@feddit.itto
Technology@lemmy.world•Microsoft Gives European Union Users More Control: Uninstall Edge, Store, and Say Goodbye to Bing PromptsEnglish
18·8 months agodeleted by creator
ugo@feddit.itto
Technology@lemmy.world•Microsoft Gives European Union Users More Control: Uninstall Edge, Store, and Say Goodbye to Bing PromptsEnglish
131·8 months agodeleted by creator
ugo@feddit.itto
Piracy: ꜱᴀɪʟ ᴛʜᴇ ʜɪɢʜ ꜱᴇᴀꜱ@lemmy.dbzer0.com•What database do streaming site IDs come from?English
11·1 year agoTMDB — themoviedb (dot) com
ugo@feddit.itto
Technology@lemmy.world•Privacy advocates demo Babel Street's "Locate X" software, which can track people at abortion clinics without a warrant and has been bought by multiple law enforcement agenciesEnglish
10·1 year agoThat’s not enough, a better idea is to, somehow, poison the location data. Otherwise by disabling location tracking you still leak the information that you are going to a clinic.
Still more readable than APL
ugo@feddit.itto
Technology@beehaw.org•New Windows AI feature records everything you’ve done on your PC
4·2 years agoif you’re using windows and expect any privacy at all […] throw that notion out the window
Correct. And the same is true even if you are using linux, macOS, android, or a butterfly to manipulate bits to send a message through the internet.
Because if your message ends up on the screen of a windows user, it’s also going to be eaten by AI.
And forget the notion of “anything you post on the internet is forever”, this is also true for private and encrypted comms now. At least as long as they can be decrypted by your recipient, if they use windows.
You want privacy and use linux? Well, that’s no longer enough. You now also need to make sure that none of your communications include a (current or future) windows user as they get spyware by default in their system.
Well maybe not quite by default, yet
Since my previous example didn’t really have return value, I am changing it slightly. So if I’m reading your suggestion of “rewriting that in 3 lines and a single nested scope followed by a single return”, I think you mean it like this?
int retval = 0; // precondition checks: if (!p1) retval = -ERROR1; if (p2) retval = -ERROR2; if (!p3 && p4) retval = -ERROR3; // business logic: if (p1 && !p2 && (p3 || !p4)) { retval = 42; } // or perhaps would you prefer the business logic check be like this? if (retval != -ERROR1 && retval != -ERROR2 && retval != -ERROR3) { retval = 42; } // or perhaps you'd split the business logic predicate like this? (Assuming the predicates only have a value of 0 or 1) int ok = p1; ok &= !p2; ok &= p3 || !p4; if (ok) { retval = 42; } return retval;as opposed to this?
// precondition checks: if(!p1) return -ERROR1; if(p2) return -ERROR2; if(!p3 && p4) return -ERROR3; // business logic: return 42;Using a retval has the exact problem that you want to avoid: at the point where we do
return retval, we have no idea howretvalwas manipulated, or if it was set multiple times by different branches. It’s mutable state inside the function, so any line from when the variable is defined to whenreturn retvalis hit must now be examined to know whyretvalhas the value that it has.Not to mention that the business logic then needs to be guarded with some predicate, because we can’t early return. And if you need to add another precondition check, you need to add another (but inverted) predicate to the business logic check.
You also mentioned resource leaks, and I find that a more compelling argument for having only a single return. Readability and understandability (both of which directly correlate to maintainability) are undeniably better with early returns. But if you hit an early return after you have allocated resources, you have a resource leak.
Still, there are better solutions to the resource leak problem than to clobber your functions into an unreadable mess. Here’s a couple options I can think of.
- Don’t: allow early returns only before allocating resources via a code standard. Allows many of the benfits of early returns, but could be confusing due to using both early returns and a retval in the business logic
- If your language supports it, use RAII
- If your language supports it, use
defer - You can always write a cleanup function
Example of option 1
// precondition checks if(!p1) return -ERROR1; if(p2) return -ERROR2; if(!p3 && p4) return -ERROR3; void* pResource = allocResource(); int retval = 0; // ... // some business logic, no return allowed // ... freeResource(pResource); return retval; // no leaksExample of option 2
// same precondition checks with early returns, won't repeat them for brevity auto Resource = allocResource(); // ... // some business logic, return allowed, the destructor of Resource will be called when it goes out of scope, freeing the resources. No leaks // ... return 42;Example of option 3
// precondition checks void* pResource = allocResource(); defer freeResource(pResource); // ... // some business logic, return allowed, deferred statements will be executed before return. No leaks // ... return 42;Example of option 4
int freeAndReturn(void* pResource, const int retval) { freeResource(pResource); return retval; } int doWork() { // precondition checks void* pResource = allocResource(); // ... // some business logic, return allowed only in the same form as the following line // ... return freeAndReturn(pResource, 42); }
Bad advice. Early return is way easier to parse and comprehend.
if (p1) { if(!p2) { if(p3 || !p4) { *pOut = 10; } } }vs
if(!p1) return; if(p2) return; if(!p3 && p4) return; *pOut = 10;Early out makes the error conditions explicit, which is what one is interested in 90% of the time. After the last if you know that all of the above conditions are false, so you don’t need to keep them in your head.
And this is just a silly example with 3 predicates, imagine how a full function with lots of state looks. You would need to keep the entire decision tree in your head at all times. That’s the opposite of maintainable.
ugo@feddit.itto
Piracy: ꜱᴀɪʟ ᴛʜᴇ ʜɪɢʜ ꜱᴇᴀꜱ@lemmy.dbzer0.com•Streaming Pirates Are Hollywood’s New Villains - Illegal subscription services that steal films or TV shows bring in $2 billion a year in ads and subscriber fees.English
49·2 years agoNot so fast now! High resolution video only available on edge on windows
If this was cpp, clang-tidy would tell you “do not use else after return”
I don’t know how null works in swift, but assuming it coerces to bool I’d write
if (a) return a; return b;
ugo@feddit.itto
Technology@lemmy.world•Why Bother With uBlock Being Blocked In Chrome? Now Is The Best Time To Switch To FirefoxEnglish
4·2 years agoUsed discord on Firefox within the last week, no issues detected.
Disable all your plugins and check if this still happens, a few months ago I ran into an issue where every tab would load for a good few seconds before actually opening, even super lightweight stuff. Turned out to be caused by an addon that was umantained because the maintainer passed away.
Don’t remember which addon it was, but I can try and remember / search if you are interested.
ugo@feddit.itto
Technology@lemmy.world•Why Bother With uBlock Being Blocked In Chrome? Now Is The Best Time To Switch To FirefoxEnglish
13·2 years agoWhere do you live where banking sites don’t follow industry standards, even for web development?
I’ve never had a problem with a website outright not working on Firefox, although in some cases features are restricted which usually just require a user agent change (like huddles on slack).
Do you have concrete examples of websites that outright don’t work on Firefox?
ugo@feddit.itto
Technology@lemmy.world•Why Bother With uBlock Being Blocked In Chrome? Now Is The Best Time To Switch To FirefoxEnglish
4·2 years agoBoth work flawlessly for me. In fact, discord on Firefox works much better than the standalone app specifically for calls.
Sounds to me like something is broken or misconfigured on your system.

deleted by creator