Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

fsif posted:

Recently collaborated with a developer that used no semicolons. It was fine. Code readability is exactly the same.

semicolonless javascript is fine except when it's not. the problem is there are edge cases and they suck - like https://stackoverflow.com/questions/2846283/what-are-the-rules-for-javascripts-automatic-semicolon-insertion-asi. i don't want to have to learn these rules when people can just put the loving semicolons where they ought to go.

Adbot
ADBOT LOVES YOU

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Doom Mathematic posted:

For loops have named parts, and one of them is the "afterthought"? I had no clue.
I haven't seen this either, so I asked chatgpt about it.

In a for loop, there are three conditions - these are referred to as initialization, condition, and afterthought. Do we know who or which standard started calling the third condition "the afterthought"?

chatgpt 4 posted:

It is difficult to pinpoint a specific individual or standard that started referring to the third part of a for loop as "the afterthought." The term "afterthought" is a colloquialism that has been used by some programmers to describe the third part of a for loop, which is often referred to as the "update" or "increment" statement. This term likely arose informally within the programming community as a way to describe the role of the third part in a for loop, which typically involves updating the loop control variable.

The use of the term "afterthought" might not be widespread or universally recognized. In formal documentation and programming literature, the three parts of a for loop are usually referred to as the "initialization," "condition," and "update" or "increment" statements.

That's true, it's not universally recognized. I see it on the mdn website's definition of a for loop - are there any programming language standards that refer to the "update" statement as "afterthought"?

chatgpt 4 posted:

After searching through various programming language documentation and standards, it appears that none of them officially refer to the "update" statement as "afterthought." MDN (Mozilla Developer Network) is a valuable resource for web developers, but it is not an official language standard.

The term "afterthought" might be used informally in some resources or among programmers, but it is not part of any official language specification or standard. The official terms for the three parts of a for loop in most programming languages are "initialization," "condition," and "update" or "increment."

For example, the ECMAScript (JavaScript) standard, C++ standard, and Python's PEP documents, which outline the specifications and standards for their respective languages, do not use the term "afterthought." They all consistently use "update," "increment," or similar terms to describe the third part of a for loop.

I'm seeing "afterthought" crop up on websites teaching new programmers how to use for loops, and I do see some recent stackoverflow stuff referring to afterthought, but it's not as if this name comes from any official standard.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

teen phone cutie posted:

I've handwritten types by looking at the API docs at any job i've been to.

e: not saying it's the most efficient, but it gets the job done

i've used handwritten types in any codebase i've worked in but i did my own pilot project at work with swagger and it really saved a lot of time generating the client code with swagger codegen.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

huhu posted:

Today I learned if you pass an excessively large number to setInterval in JavaScript, it'll just start executing the callback function hundreds of times a second. That took way too long to troubleshoot.
setinterval takes a 32-bit signed int as argument for delay in the v8 engine:
https://stackoverflow.com/questions/12633405/what-is-the-maximum-delay-for-setinterval

Bruegels Fuckbooks fucked around with this message at 22:08 on Oct 23, 2023

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

some kinda jackal posted:

Can someone explain to me, as you would a child, what a Tuple is good for? I think this is a failure of imagination because every tutorial or video I’ve seen I kind of feel like I, throwing around my entire two weeks of non-real-world programming experience, would probably use something else. One thing I see cited a lot is if I want to return multiple things from a function, at which point I instinctively just want to declare a type and have my func return that type. I guess if I don’t know exactly what I’m returning? Or is this one of those “there are eight different ways to do everything, just use whatever fits your style” type of situation?

100% a failure of imagination, yeah.

Tuple is for lazy people who don't want to make a special return value class.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Rob Filter posted:

How do you profile javascript code? Sampling seems straightforward, but I'm not sure how to do instrumental / structural profiling. Are there libraries that let you do things similarly to QueryPerformanceCounter windows stuff?

the libraries that do it right are just using performance.mark() and performance.measure() https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark.

If you just need a current high resolution timestamp you can do performance.now().

Performance api in js is closest thing to QueryPerformanceCounter.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

smackfu posted:

TIL that Typescript doesn’t follow semver, because basically every release has changes that someone would consider breaking. And 5.0 was just a major release, no more or less breaking than any other.

So what’s the best way to specify it as a dependency? Just say “>4.7” or whatever minimum sounds good?

unfortunately because ts doesn't support semver, you can't actually know whether or not a TS version will work unless you actually verify that your build works and unit tests pass with any given version of typescript. so if you're releasing a library written in typescript intended for public consumption, specifying, say, >4.7 may result in the new typescript version causing people's projects to break if they include your library.

I would suggest specifying both a minimum and maximum typescript version, and only updating the maximum version when you've actually run the build with newest typescript version to verify that it actually works - e.g. process would look something like this:
https://github.com/mswjs/msw/issues/1376#issuecomment-1229267340. A lot of libraries don't do this and just go with >4.7, and it does work, but past a certain size project, especially if you're using newer ts features, you're almost guaranteed SOMETHING non-obvious will break in the new typescript version, and it's much easier to figure out what went on that way rather than the completely random errors you will see from the people using bleeding edge typescript versions.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Harriet Carker posted:

I started a new job recently. The most senior frontend guy is vehemently opposed to TypeScript for reasons I don't quite understand (understanding these reasons is obviously step 1). He put up a ton of resistance when I mentioned introducing it, claiming it's too full of quirks. I don't feel like rocking the boat too much since I'm new but curious if anyone had heard any particularly convincing reasons to not use TS in a modern React app. I've been using it for about 5 years and going back to plain JS feels awful so far.

I am a big typescript fan but it's a chore to take an existing js codebase, gently caress with the build process to make it compile typescript, track down definitions for all the 3rd party libraries, and actually convert it to ts so it's beneficial. That poo poo doesn't happen on its own.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

go play outside Skyler posted:

As another poster said, don't use JS Date object to parse a date. It's better to use something like moment or whatever the new hotness is.

don't use moment in new code. https://momentjs.com/docs/#/-project-status/

it's funny because there were all these years of "don't use raw dates, use moment", and now it's luxon. oh well.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

biznatchio posted:

In general yes... until someone does new Date('September 11, 2001') with the crazy expectation that it will act the same as new Date('2001-09-11').

The standard Javascript Date object is fundamentally flawed. The only advisable way to use it is delete globalThis.Date.

Date.parse in particular is hella hosed up. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse#examples

Some highlights:
1. Non standard date strings were allowed to be implementation specific, so there's no guarantee they work the same between any browser.
2. There's no parameter for the expected format of the date string, or region of the date string, so it's up to the browser implementation to guess from the content of the string which date format it is - which is great when it tries to parse a string like 9-11-2001, which could easily parse as December 9, 2001 in some parts of the world.

Adbot
ADBOT LOVES YOU

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Combat Pretzel posted:

I am returning undefined nilly-willy in all my projects whenever something's not found or available.
From the ecma2015 spec, undefined means "has not been assigned a value", and null means "absence of a value." Returning undefined in this instance doesn't match the intended meaning of undefined from language specification, which might annoy people who care about things like that.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply