But what if I don’t want strict comparison? What if my frontend contains a text field for a numeric input and I wanna manually check against each possible valid input value if (input_val == 1) {…} else if (input_val == 2) {…} else if… without having to convert it first or check that it’s actually a number or fix my frontend?
(I’m sure there are valid use cases for non-strict comparison, I just can’t think of one right now)
If you’re looking for good code, you missed the point of my comment 😄
If I was looking for an enumeration of valid inputs, I’d make it a selection box rather than a text field that’s supposed to contain a number and give the selections reasonable names. If I want an integral quantity, I’d use a number input field.
If I have no control over the frontend, that means I’m writing a backend in JS for a bullshit frontend, and no amount of good coding practice is going to salvage this mess.
I’m also blessedly far away from WebDev now. I work in Data Analytics and if I ever have to do any of this for a living, something has gone very wrong.
Converting texts into numbers or dates still haunts me though - fuck text inputs for numbers and dates.
To be honest, we are fucking up the planet at an exponentially faster rate, so it is natural that mitigation solutions seems exponentially crazier.
There are people that believe that doing these crazy things will actually reverse the damage.
Then there are people like me who not only believe we are fucked but also believe that anything we do now is completely pointless as we are fucked either way so why bother.
Stop. Please stop. Doomerism compounds the problem, it is not a neutral stance.
Has irreparable damage already been done? Yes.
Will it be worse if we don’t do anything as soon as possible? Yes. And each moment that we don’t do the thing, it gets a little bit worse.
But each moment we do do the thing, it gets a little bit better.
The Earth will relatively be 1.5°, likely 2°C hotter, regardless of what actions are now taken. But 2°C hotter is far, far preferable to 4°C.
Everything we do as individuals and societies matters. I understand it feels daunting, and I’m not really advocating for you to drive less or eat less meat, because ultimately these changes won’t be driven by individuals making the choices.
However, please please please support and push, protest, fight for societal changes for us collectively to drive less, eat less meat, and corporate carbon taxation.
However, please please please support and push, protest, fight for societal changes for us collectively to drive less, eat less meat, and corporate carbon taxation.
You may be preaching to the choir. This year in Europe more than 50 percent of the newly bought cars were SUVs. To me that feels that most people do not care, they just want to enjoy themselves as much as possible before total collapse. Protest ? Three states in the USA recently banned protesting. In Europe with far right winning about everywhere will likely go the same direction. It is obvious in the news headlines. Fascism is on the rise and the masses do not seem to care about a burning planet and killing of everything but themselves.
Protest ? Three states in the USA recently banned protesting.
If I’m thinking about the right laws, don’t they more specifically make whoever is running the protest responsible for damages or crimes done by members of the protest if said members cannot be identified?
Well you can only do so much, and a denier will come and fuck everything up. Oil and coal companies will pay billions to keep the propaganda going - that the earth is just fine.
So tired of all that. Remember the CFC issue. World got together to fight it and it worked. I don’t know if we will ever see such cooperation again. If we do, maybe we have a chance.
Other than a uniform collective action as a species we have no hope to turn this around. And since I don’t see that happening anytime soon I would rather stick to my “Doomerism”.
PHP has gotten really good over the past few versions, actually. Lots of really great stuff has been added, it feels like it resembles rust more every release lol
The part that always gets me is when people choose Js for the backend. Like I get that it’s the default thing that works on the frontend, so there’s some rationale why you might not want to transpile to it from another language. On the backend though, there are so many far better option, why would you willingly go with Js, especially given that you’re now forced to do all your IO async.
No I meant having to do async as opposed to having threads like you would in Java for example. In vast majority of cases a thread pool will work just fine, and it makes your code far simpler. Typically, Java web servers will have a single thread that receives the request and then dispatches it to the pool of workers. The JVM is then responsible for doing the scheduling between the threads and ensuring each one gets to do work. You can do async too, but I’ve found threads scale to huge loads in practice.
I moved from primarily ASP.Net Core backends, which is a hell of a great backend framework btw, to NestJS. Not my choice. I do what the people who sign my paychecks ask for.
I cannot begin to fathom why anyone would willingly choose JavaScript for backend. TypeScript helps a lot but there are still so many drawbacks and poor design decisions that make the developer experience incredibly frustrating. Features that are standard in ASP.Net Core, Django, or other common backend frameworks just don’t exist.
Also, don’t get me started on GraphQL. Sure, it has performance advantages for websites of a certain size and scale. But 99% of the websites out there don’t have the challenges that Facebook has. The added complexity and development cost over REST is just not worth it.
Yeah, gql in particular is a problem looking for a solution in most cases. It makes sense for facebook because they have people building frontend apps for their marketplace, and those apps need all kinds of weird combinations of data. However, this isn’t the situation for most apps where you have a fairly well defined set of calls you’re doing.
Server side rendering looks like it could be useful. I imagine SSR could be used for graceful degradation, so what would normally be a single page application could work without Javascript. Though, I’ve never tried SSR, and nobody seems to care about graceful degradation anymore.
No one cares about graceful degradation anymore. But you can sell management on SEO. Page performance is a key aspect of search engine rankings and server-side rendered pages will almost always have a much faster initial load than client-side rendered.
Most pages tend be just documents and fairly simple forms. Making SPAs and then having to worry about SSR is just making a Rube Goldberg machine in most cases. I think something like HTMX is a much better approach in most cases. You keep all your business logic server side, send regular HTML to the client, and you just have a little bit of Js on the frontend that knows how to patch in chunks of HTML in the DOM as needed. Unless you have a highly interactive frontend, this is a much better approach than making a frontend with something like React and adding all the complexity that goes with it.
lemmy.ml
Hot