Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@OmerFlame see, unrefined scares me.
With null at least, we know that there's certainly nothing there but undefined is just too inconclusive to me. -
theuser47814y@Ranchonyx Undefined might be the closest thing you can get to nothing in JS because a null value can be coerced to the number 0 (for example if you do null + 1).
In truth though, I believe there is no nothing value in JS. Anything can be converted to a boolean. -
@Ranchonyx undefined means that there was never meant to be anything there. In this case it's stupid because an exception means that something happened, and there should be an object describing it.
-
kamen69254yThere was some lengthy explanation as for why to use undefined instead of null by someone involved in TypeScript, but I can't find it (I'm only finding this: https://github.com/Microsoft/...), although I also feel like null is a bit more explicit. Something that is only declared (but not initialised) will equal undefined in a strict comparison (and I'm a proponent for strict comparisons whenever possible).
This is yet another instance of "JavaScript allows me to do stupid shit, hence I must do stupid shit". Well, you are allowed to jump off a bridge, but will you? -
@kamen undefined is used in typescript for optional things because javascript will leave an unassigned parameter on undefined and this allows assigning optional parameters to optionals. Basically since javascript will produce undefined a lot but null almost never it's better to use undefined if you want to use only one of them.
-
theuser47814y@kamen I agree. I would also suggest treating null values as something you that goes between client and server.
-
after i had a good giggle i had to explain that to my so. that was not as much fun.
-
kamen69254y@firecracker It's like asking for everyone to start using Betamax when VHS was all over the place, only that with browsers there hasn't been a proper alternative. There is Wasm, but its use is limited IMO.
-
@kamen WASM works really well and its startup overhead will become negligible once the standard glue JS is cached in every browser, but there aren't many languages that are high level, single threaded and have a tiny executable size (which is essential on the web).
-
To statically link WASM with something like Qt would be to have the user load over 100mb, which you can only do _after_ your app diid something remarkable, in order to prevent losing customers.
-
theuser47814y@Lor-inc I guess you would have to cache the lib files of whatever HTML and CSS alternative you're gonna use and create some kind of "first setup" loading view for the users.
Unless you've got layers upon layers of frameworks, you can create something meaningful in HTML and CSS with almost zero loading times from a user perspective. -
@theuser Now that you mentioned, I think HTML and CSS are excellent GUI building tools, so there's also the option of creating an interface between the DOM/CSSOM and WASM, which would allow to skip the GUI framework.
-
People be bitching about javascript when C lets you define true as false and vice versa.
-
@hashedram That isn't a problem. It isn't up to the language to prevent you from doing stupid shit, as long as it makes sure you know you're doing stupid shit. JS text-number arithmetic and truthyness is considered bad because it isn't obvious that your variable happens to be text.
-
@Lor-inc what a really long way to say "I'm gonna cherry pick".
As with C, JavaScript is obvious if you know what you're doing. -
@hashedram You're not supposed to care about types in JS, but because the defaults for casting are stupid you still have to.
I love how JS lets you throw absolutely nothing.
rant
throw nothing
javascript