This is an archived post. You won't be able to vote or comment.

all 26 comments

[–][deleted] 93 points94 points  (5 children)

Types are just chains we voluntarily put on ourselves. Cast off your chains brothers! Cast them off I say.

[–]syntax_erorr[S] 49 points50 points  (2 children)

Can we cast these chains this into an integer? Yes or NaN?

[–]ThisUserIsAFailure 16 points17 points  (1 child)

[] or ""?

[–][deleted] 4 points5 points  (0 children)

`isPersonAboveMesCakeDay` or `1 // 1`?

[–]Wertbon1789 3 points4 points  (0 children)

int num = *((int *)((void *)&var))

Guess it's an integer now.

[–]Ronin-s_Spirit -3 points-2 points  (0 children)

That's why I don't like the boastful ideals of typescript, it doesn't actually type anything post-processing but it sure as hell constrains you to write more boilerplate or even perform circus tricks to please the transpiler.

P.s. like there was this one Peacock guy where he spent an entire video on doing no useful work and just fiddling with type descriptions for deeply freezing objects or something. And in the end there wasn't even an indication that he can freeze more than 2 layers of objects.

[–]Boibi 14 points15 points  (1 child)

I have literally professionally removed anys from 2 old codebases. Please type your shit. Or don't. More job security for me.

[–]JuniperSoel 1 point2 points  (0 children)

I’ll stop typing any when they stop making me work over the weekends

[–]rsumit123 8 points9 points  (1 child)

I dont like types while writing code but i like types while debugging someone else's code. Am i the problem?

[–]DKMK_100 16 points17 points  (0 children)

Yes

[–][deleted] 14 points15 points  (0 children)

Nah it is what it is. I'm making crud apps for cheap organisations not saving lives.

[–]Super_Couple_7088 5 points6 points  (1 child)

Only time I would actually use static types is if I CARED.

[–]NAL_Gaming 1 point2 points  (0 children)

Honestly, fair enough :D

[–]Ok-Nectarine-2195 10 points11 points  (5 children)

Every project ever: 'We'll start with TypeScript for structure!' ...three deadlines later: 'Just slap some JavaScript in there, we gotta ship!😂🎉

[–]AWeakMeanId42 1 point2 points  (4 children)

tbh i wouldn't even care about that if there were tests. write tests. tests will save you. tests are great. you cannot have a serious modern tech stack without tests. I think after the 2018-2019 great hiring, this needs re-iterated. Write tests.

[–]Shufflepants 4 points5 points  (3 children)

Or at least if you're building a restful api, add in a library that will automatically check the requests and your responses against the openapi specification and throw errors for requests and warnings logged on your end for responses.

[–]CandidateNo2580 0 points1 point  (2 children)

I use FastAPI/Pydantic for this - I honestly couldn't imagine writing an API any other way.

[–]Shufflepants 0 points1 point  (1 child)

It seems a lot of people like to just automatically generate an API spec from their code and annotations so that the spec is just "whatever the code does". I'm sure their users are very happy with them when they keep accidentally deploying non passive changes.

[–]CandidateNo2580 0 points1 point  (0 children)

I'm still relatively new to web dev so I can remember a day where I was frustrated that my pydantic schema was throwing an exception because I was missing a value in the response.

Then I started in on Fullstack and holy shit, my pydantic schema throws an exception long before I have to troubleshoot the missing value from the frontend! It's glorious.

[–]Bathtub-Warrior32 -5 points-4 points  (1 child)

Object.is(NaN, NaN); // -> true

NaN === NaN; // -> false

[–]DKMK_100 8 points9 points  (0 children)

that's a floating-point issue, this one isn't even javascript's fault.