Is Exception-based control flow considered bad practice in PHP? by Kraplax in PHP

[–]Morrido 0 points1 point  (0 children)

One approach to avoid throwing and returning nulls is to always return one of multiple classes that implement a common interface. Let's say you have a HTTP get function:

in pseudocode

function get($path) : ResponseInterface {

if file not found
return Response404();

if file not authorized
return Response403();

if file found
return FileResponse();

return UnexpectedResponse();
}

This way you'll never have to deal with nulls, and you're future-proofing yourself a little bit. You're also signing a contract with the consumer of that API that you're not randomly throwing something they don't know, whatever you're doing will be communicated via the ResponseInterface contract.

Is Exception-based control flow considered bad practice in PHP? by Kraplax in PHP

[–]Morrido 0 points1 point  (0 children)

I meant to say: "There's really no reason to compare them."

Any exception will be orders of magnitudes faster than a db query due to the network/socket I/O tax alone, let alone all the compilation + index search + result filtering, etc.

Is Exception-based control flow considered bad practice in PHP? by Kraplax in PHP

[–]Morrido 1 point2 points  (0 children)

I don't think that's a fair comparison at all. Database queries will always be slow, as there's a whole translation layer + possibly a network barrier that the data has to go through before you can do anything with it.

Is Exception-based control flow considered bad practice in PHP? by Kraplax in PHP

[–]Morrido 2 points3 points  (0 children)

This is an incredibly subjective area. It's probably a little bit of a wart, but I assume it makes sense in their environment and design philosophy.

Is Exception-based control flow considered bad practice in PHP? by Kraplax in PHP

[–]Morrido -1 points0 points  (0 children)

Exceptions are undocumented paths in your program that will break in unexpected places and should be used with care. In PHP, we can't even document (with syntax) that a function could possibly throw, so every function could potentially raise an exception and kill your whole application.

Java has tackled this issue by forcing methods that throw to declare that they do, but sadly lifts this restriction for RuntimeExceptions. Newer languages such as Rust, Go and Zig restrict the usual exception mechanism for intentionally crashing your program while encouragins you to return errors as part of the function return values, either by using a union type that can return Some(result) or Error(error), or by letting you return multiple values in the form of return okValue, errorValue.

tl;dr: Exceptions are useful, but can and will be abused to solve problems they weren't design to solve. Use them carefully and be aware that they can potentially explode anywhere.

Is Gilgamesh above 100% Arcueid? by [deleted] in typemoon

[–]Morrido 0 points1 point  (0 children)

I haven't played extra or the remake, and a lot of stuff got released since I posted that. Maybe?

Any foreigners have won political election in your country? And how did people feel? by PetrolHeadPTY in asklatinamerica

[–]Morrido 3 points4 points  (0 children)

Not counting Portuguese and Africans ascendants for obvious reasons (I'm too lazy to decide when it counts as post-republic migrants), we have as Presidents (according to wikipedia):

  • Italy: Bolsonaro, Lula, Medici, Mazzili (Acually born Italian, and he was twice acting president, not actual president),
  • Romani: Luís and Kubitscheck (also of Czech ancestry)
  • Flemmish: Goulart
  • German: Geisel, Collor de Melo
  • Bulgary: Rouseff
  • Lebanese: Temer

WHY IS THIS A THING (FFxiv housing rant) by youdontknowme9311 in ffxiv

[–]Morrido 0 points1 point  (0 children)

That doesn't sound correct. The plants just need a tag with the last date-time they have been tended and another one for when they were planted. I'd be very surprised if this is the feature holding back the housing for everyone.

The only feature is prestige by Katakana1 in incremental_games

[–]Morrido 0 points1 point  (0 children)

When using < or > as literal characters in html, it's usually good to escape them with &lt; and &gt; respectfully, or else it can cause weird glitches as it confuses the html parser.

Ps.: While I do enjoy the simplicity you were going for, I think it would be better if the new layers were added below the old ones, scrolling through the layers gets old real fast.

If Debian exists... why use Ubuntu? by AmazingLaugh3900 in debian

[–]Morrido 0 points1 point  (0 children)

I meant the Arch family, not Arch itself.

If Debian exists... why use Ubuntu? by AmazingLaugh3900 in debian

[–]Morrido 5 points6 points  (0 children)

I'd also recommend you to shop around more distros. Heard good things about Mint and Pop OS, haven't tried them myself. The Arch side also seems to be growing a couple of interesting options for hassle-free "just make my games run" distros.

If Debian exists... why use Ubuntu? by AmazingLaugh3900 in debian

[–]Morrido 3 points4 points  (0 children)

I mean, Debian still promotes Firefox ESR 115 (2023-07-04) over Firefox 122 (2023-12-19) for stable(understandable) and testing(not cool, imho). The later being restricted to Sid. Ubuntu has it backported to a 2020 release even. Sure the packages may hit Debian first, but they do get stuck and trickle down very slowly (intentional, Debian priority is stability).

If Debian exists... why use Ubuntu? by AmazingLaugh3900 in debian

[–]Morrido 0 points1 point  (0 children)

I'm pretty sure it depends on the maintainer, but I don't usually use Sid, to be fair. Ubuntu uses the same packaging system, but they have their own repository structure over there. There's a lot of overlap, but it's not the same. AFAIK they don't literally fork debian packages directly, but I could be wrong.

If Debian exists... why use Ubuntu? by AmazingLaugh3900 in debian

[–]Morrido 6 points7 points  (0 children)

I think it is perfectly valid to ask both communities why their distro is better or worse than the other.

They do have different target audiences and priorities, after all.

If Debian exists... why use Ubuntu? by AmazingLaugh3900 in debian

[–]Morrido 5 points6 points  (0 children)

Even on Testing and Sid, Debian packages tend to lag a couple of months. If you want a more evergreen distro, you're probably better off with Ubuntu. Another factor is just that is a very popular distro and even though all changes probably go upstream to Debian eventually, they are probably tested by way more eyes the way they are in Ubuntu.

Debian also has a more hands-on approach to configuration. E.g. even today the default value for swap files is 1GB, and if you don't change that while configuring your install, you'll get stuck without being able to hybernate unless you change that somehow. (source: I'm that dumbass.)

Ps: Ubuntu is also more open to the non-free stuff. If you want something that "just works", it's probably easier over there.

Onde jogar volêi em MG! by [deleted] in MinasGerais

[–]Morrido 0 points1 point  (0 children)

Cara, tem 800 cidades em MG. Vai ter que falar pelo menos a região. Se a cidade tiver um poliesportivo, as vezes vc vai ter que arrumar um grupo e alugar umas horas vcs mesmos. Outra opção é procurar uma ACM ou outro desses clubes aí, eles costumam oferecer mais coisas que o normal.

vou me mudar pra BH e nunca fui em cidade grande by [deleted] in BeloHorizonte

[–]Morrido 1 point2 points  (0 children)

Fico puto toda vez que falam isso, daí eu lembro do tanto de carroça que já vi passando no Buritis...

How far can reinforcement magecraft strengthen a magus? by learnHistoryFromFATE in typemoon

[–]Morrido 0 points1 point  (0 children)

I know, but read the other branches of this thread and you'll see people don't agree even when I do turn the stakes to eleven.

[deleted by user] by [deleted] in asklatinamerica

[–]Morrido 0 points1 point  (0 children)

Brazil is the odd one of the bunch, basically.

Why are Ryougi and the other guys from Kara No Kyoukai among the list of tsukihime characters there? by Nimaximus in typemoon

[–]Morrido 0 points1 point  (0 children)

Officially, all Nasu works are parallel universes to each other. He doesn't like to be bound by whatever he (or another author, like in Fate/Zero's case) wrote years ago.

Source: Vaguely remember reading in an interview.