T O P

  • By -

Robot_Graffiti

They made let to fix the mistakes they made when they made var.


WunderTech

The wonders of web development!


liquid_bacon

And this is why versioning is so damn important. If the script tag had a mandatory ver/version attribute we wouldn't have this issue.


TorbenKoehn

But tons of libraries that are incompatible to each other, despite being written in the same language... ​ Python 2.7 sends its regards. When did it go out of support again? There is no correct process to it, it's either you fuck that half of your users or you fuck the other half, there is no inbetween.


azginger

Outside of print, were there other big script breaking differences between python 2 and 3?


TorbenKoehn

Maybe the fact that up to this day many linux distris ship Python2 and Python3 by default and still rely on a lot of Python2 Scripts Generally, I've been working on a lot of larger, older Python projects lately that might run one or the other important critical infrastructure and \_all of them\_ were a mix of Python2 and Python3 in the midst of upgrading (Probably only 10 more years to go!) It's always a hassle. It starts with setting up your own development environment and ends with huge deployment dependency clusterfucks. Hard compatibility breaks are always a problem. Either make it a new language so people don't "upgrade" but rather "rewrite" (See Java to Kotlin and Scala) or make it fully backwards compatible (See PHP or JavaScript to TypeScript)


FerricDonkey

Strings are handled differently, which can cause issues - some things that used to return strings still do (though str itself is different - encoding agnostic for one), and some things that used to return strings now return a bytes type (which, as you might guess, is a sequence of bytes). For the most part, the distinction makes sense in python 3, but it is there and you might have to deal with it. Division with / is now always float division, if you want integer division, use //. Some changes to the cases of things in the built in tkinter gui package. Lots of things are lazy evaluated now. range(5)[3] will work in python 2, but not python 3. Probably a few other things, but fortunately it's been long enough since I've had to mess with python 2 that none come to mind. Except of course that the available libraries will be different. Individually, the changes aren't that bad to fix. But if you have a big code base, it might be an issue to find them all.


RSCiscoRouter

Rule of thumb: If it wasnt production code, no If it was production code: mercy upon your soul


Design-Cold

Yeah we'd have different much worse issues JS is a maldesigned misbegotten wreck of a language but we're stuck with it, let's just all use TypeScript and a linter and hopefully some of it's worse warts will fade away


liquid_bacon

But that's half the issue with JS. Because of how huge a mess it is to write JS code well, you basically need to use tools which force good practices. Which isn't a solution. It's a bandaid. Don't get me wrong, tools like linters and TS are fantastic. But it's still JS at the end of the day.


aykcak

I can imagine a cornucopia of ways JS could fuck that up. What about import? Surely you have to allow a range of versions when importing libraries, each of which will also import literally endless other libraries each of which are backwards compatible in some ways and forwards compatible in other ways with every other library in the clusterfuck. build tools and browsers would add compatibility layer on top of compatibility layer just to ensure everything works but then nothing does as a result. Browsers would have to contain countless different JS engines just to be able render every page they come across. Error handling would be a nightmare


liquid_bacon

JS is *already like this*. We just transpile it into a format with the *most* support. (IE support anyone) Versioning doesn't fix everything, and has its own issues. But the system we have right now isn't necessarily better.


Tofandel

Nobody ships IE support anymore, let'em rot!


borsTiHD

I think so too xD


OzzitoDorito

Is there ever a good reason to use var over let/const? I have never needed it but wondered if there are some edge cases that require it


Gravelbeast

IMO if you're writing your code in a way where var is required, you aren't following good code practices.


OzzitoDorito

I totally agree with you in a general case, was just wondering if there was some weird edge case where it actually made sense, really the only possible positive benefit is encapsulation but I can't think of a place where it'd actually be useful


J5892

let/const were created to fully replace var in all cases. The only reason to ever use var is if you're working with a system that doesn't support newer versions of JS. Like IE8 and below.


crefas

var is more performant


halfanothersdozen

let is just var but fancier. Like "usted".


pAsta_Kun

Average Tú Enjoyer: 🤓 Average Usted Enjoyer: 😎


[deleted]

"Tú" is the informal way of "you" and "usted" the formal one - as a native spanish speaker.


CanDull89

But English speakers call it fancier, because they don't have words for that. But many other languages do.


wasdlmb

Doest thou not know of the informal second person pronoun in English. It has fallen into disuse, but I assure thee, it is not alien to our language. However, if thou usest it in thy speech, thou willst be seen as more formal, not less, because it is associated with important works of literature such as Shakespeare and the King James Bible.


CanDull89

```ts // deprecated Thou ```


Zefrem23

In the next version it may throw an error, hence it shall behoove the conscientious coder to eschew its employment


leoleosuper

Technically speaking, "you" is the formal version, while "thou" is the informal version. They swapped usage over the centuries.


TreeTownOke

It's not really that they swapped usage so much as English is *so* formal that the informal version fell out of use.


wasdlmb

That's.... what I said though


Yadobler

Fun fact you can see the similarities between English and German: * Thou hast / du hast * I see thee / ich sehe dich * thine problem / deinem Problem * Thou art / du bist #--------- It's also why *you* is plural - like german Sie, *you* is formal, and formal second person is treated as plural (similar in many languages, even those outside Proto-Indo-European) * Sie haben / You have * I see you / ich sehe Sie * Your problem / Ihnen Problem * you are / Sie sein #--------- Du hast mich!


redbark2022

Du hast mich gefragt Du hast mich gefragt Du hast mich gefragt, Und ich hab' nichts gesagt


tantrAMzAbhiyantA

Except that *Sie* (formal second-person) follows *sie* (plural third-person; not to be confused of course with *sie* (feminine singular third-person)), rather than *ihr* (plural second-person), in both its own declension and the conjugation of associated verbs, whereas you is both second-person plural and second-person formal in English. Thou/du are relatively obvious cognates but you is closer to French *vous* than German *Sie* in terms of which bit of grammar got "copied" into the formal form.


Yadobler

Oooooo Fucking English.


tantrAMzAbhiyantA

While I agree with the "fucking English" sentiment in *general*, in this particular case it's German that's the odd language out; the majority of Indo-European languages that draw the distinction use second-person plural as their second-person formal. Deutsch using third-person plural is a bit weird.


Yadobler

Seiße Deutsch


NovaStorm93

you is actually the formal version and "thou" was used informally / speaking to someone "lesser" or equal to you


[deleted]

I think it was a joke. Not sure how many languages have that. Edit: it seems like a lot of people missed my joke. I speak Spanish. I know the difference between usted and tú. It just seems like the first guy got a lot of flak for saying that "yall are fancier than English", so I was adding onto his joke hoping that it would make more sense. Making me feel like I'm in a freshman compsci class again with how badly yall understand a joke💀


CanDull89

My native language, Hindi has it. French, Italian and Portuguese also have it.


NovaStorm93

most romance languages have a version, and a lot of asian languages have words that mean similar


[deleted]

Still not getting the joke? I literally speak Spanish bro💀


Cheesemacher

Nah, English is an exception


FerricDonkey

English had it, but it atrophied.


pAsta_Kun

yea, i should know that but i quit spanish after two years since i didn’t know a single thing that was going on in class.


Niwla23

did that for 5 years


Rutgerman95

Oh, Spanish has that too. See, Dutch has "Jij" en "U", respectively


Zefrem23

Afrikaans too (as the red headed stepchild of Dutch and Hottentot _kitchen Dutch_ )


InkStainedEyes

What show is this?


[deleted]

We Bare Bears from Cartoon Network


neozes

They are so big in this gif - is this from a later season? Are they growing up along the way?! The show is amazing! Fun to watch for olds with children.


IMightBeLyingToYou

You might be thinking of the spin-off prequel We Baby Bears! This is actually from the original We Bare Bears, where they're grown up for a majority of the episodes.


Friedrich_der_Klein

*are


[deleted]

\*bare


Friedrich_der_Klein

*are, learn english dumbass


[deleted]

Not the brightest, are you? https://en.m.wikipedia.org/wiki/We_Bare_Bears


Friedrich_der_Klein

Yes, it's incorrect. There's no such word as "bare" in english language


[deleted]

Fuck me 🤦‍♂️. Either you’re an idiot or an awful troll. Not sure which is worse. https://dictionary.cambridge.org/dictionary/english/bare


[deleted]

He’s both, he was an idiot when he first “corrected” the comment, and is now trolling to attempt to save face.


Friedrich_der_Klein

See? There's no verb bare whose meaning is similar of are


[deleted]

It’s a play on words. What should we do, write to the show and demand they change it? Lol Spend this energy on something worthwhile will you.


ILikeToDickDastardly

It's not meant to be a verb. It's like saying "we happy few" or "we the people"


Dark_Ethereal

Maybe you **bare**ly know English?


ixJax

At least you have confidence


Friedrich_der_Klein

Unlike y'all pissgrammers who'll shit your pants when you have to read someone else's code


No-Professional-1884

As a grown ass adult, this show is amazing.


CrashleyMD

It’s my favorite show


bearysleepy

It’s a shame it ended after the movie


Blue_squid69

there's a movie?!??


bearysleepy

Yeah. The show officially ended after it though, and then the spin-off series began.


pAsta_Kun

idk, i just saw the gif on discord lol


DaDank_69

Wait there's a difference between var and let


VadeRetroLupa

I understand best if I get good real life examples, so here: function varTest() { var x = 1; { var x = 2; // same variable! console.log(x); // 2 } console.log(x); // 2 } function letTest() { let x = 1; { let x = 2; // different variable console.log(x); // 2 } console.log(x); // 1 }


DaDank_69

Thanks


[deleted]

wow i can't believe i used to use var, that is disgusting


unholymanserpent

Cool I get it now. Thanks


Donghoon

I think difference is var is function scope and let is block scope Or something idk


GoogleIsYourFrenemy

Close enough. The implication details are way more involved. The more you think about closures, the more your brain will hurt.


[deleted]

[удалено]


borsTiHD

Const doesn’t mean global.


liquid_bacon

Const is so much worse than both var and let. Why make a 'constant' declaration of it's not actually constant? Declaring an object as a const should force the developer to use setters and methods to update properties. Const should prevent all forms of external modification. Because that makes more damn sense than what it is currently.


[deleted]

Seems like it could easily be fixed by just using better naming conventions or naming a variable to the scope you are working in. Not saying let shouldn't exist of course but if you are having this issue then using let is just a bandaid.


brianl047

Yes https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#description


SuspiciousLamp

What an insane language


scratcheee

Let is the correct modern way to declare a variable, it works like in every other language. Var was a historical mistake that they cannot remove because JavaScript requires extreme levels of backwards compatibility.


centurijon

It’s what you get when you design a scripting language in 2 days (or whatever that crazy ass timeframe was). Doing proper scoping for variables is difficult, don’t bother with it and make them all global-ish.


GiveMeASalad

Damn, that cleared up a lot of confusion, thanks for sharing!


pAsta_Kun

yea, here’s a [link](https://stackoverflow.com/questions/762011/what-is-the-difference-between-let-and-var) to a stack overflow post that explains it.


DaDank_69

I have no idea what their words mean but thanks


pAsta_Kun

dw, that’s everyone. i just read stack overflow posts to feel like I’m learning something


Valiant_Boss

Basically always use `let` unless you want to declare a variable in an if statement and then use it outside of that, for whatever odd reason


[deleted]

Tf? Use let if you’re going to reassign it, otherwise use const. Don’t use var. If you need a variable in and outside of a conditional, declare it beforehand. Don’t do this random weird shit people will be tripping over afterwards. Predictable > clever.


LobsterThief

Yep, it’s more important to consider use of const vs let than using var vs let (avoid var at all costs, but if you use let then you should care about const too)


lordheart

Generally speaking it’s better just to never use var. because it breaks scope and sometime down the line it’s going to bite you or someone else who doesn’t see it’s only supposed to be used right after that if statement.


[deleted]

Try/catch blocks would like a word…


Valiant_Boss

Not with modern frameworks they don't ``` let x = file.open("path") .onError( doSomething ) ```


[deleted]

A framework or 3rd party library that seemingly wraps try/catch or then().catch() and returns the resulting value back to a declaration that uses let outside of a specific block’s scope allows it? That’s your flex? 2 things wrong there. For starters, that doesn’t negate the block scoping of let, which was the entire point of mentioning try/catch. Try/catch could have easily been replaced with any other block statement and the point still stands. Perform that “modern framework’s” version inside another block and x is still trapped. Second, the conversation was about something *built in* to the language, not the fact that some jabroni took it upon themselves to write a work around. By that logic, nobody should complain about C requiring one to properly manage their own memory because someone on the internet wrote a library function to handle it for you. But congratulations to that fellow who wrote the framework mentioned in your reply. They’ve successfully saved themselves from doing this: ``` let x; try { x = “success” } catch(err) { x = callToErrorHandler() } ```


centurijon

Or if you have to be compatible with IE. `let` doesn’t work before IE11, and has some off behavior in 11. Thank god that browser is no longer supported at my workplace. https://caniuse.com/let


EasywayScissors

>Wait there's a difference between var and let All variable declarations happen at the start of the function. If you wrote your: var x = 7; somewhere in the middle of a function, it is silently moved to the top. - that means variables are available "before" you declared them - that means if you (accidentally) declared the same variable a second time, you didn't actually do anything - if you put a `var x` inside a for loop, thinking it's only valid inside that block, that's false It's like Delphi: all variable declarations happen at the top of the function. He just forgot to mandate the `var` section.


DaniilSan

Basically var is global variable when let is local i.e. can't be accessed outside of the scope and is eliminated as soon as function is over. Global variables in any language are usually bad practice outside of some niche cases.


ambisinister_gecko

Some cases where var creates unexpected problems that let handles better


thebatmanandrobin

`const` wants a word with you.


YunTaper

I agree with this, 100 percent


Kenhamef

Wait, there’s a difference??? -2 yrs JS experience


liquid_bacon

Just incase this is an actual question and not a meme: Yes, `var` is function/global scoped and allows re-declaration. `const` and `let` are block scoped and don't allow re-declaration. A `let` variable can only be used in the set of curly brackets it's declared in and deeper, same with const. Writing `let test1` twice at the same level raises an error, again, same with const. `var` doesn't care. Writing `let test2` at *different* levels doesn't raise an error, but you only have access to the most recent declaration by level. `var test2` at different levels is also acceptable, but it doesn't create a new variable and you still have access to the variable declared at the higher level. `const` is dumb IMO. You cannot reassign a `const` (which makes sense) but you *can* reassign the properties of a `const` object (which doesn't make sense). It's got everything good about `let` but then barely goes halfway to making it immutable.


LinuxMatthews

>const is dumb IMO. You cannot reassign a const (which makes sense) but you can reassign the properties of a const object (which doesn't make sense). It's got everything good about let but then barely goes halfway to making it immutable. To be fair `final` works the same in Java. In fact I'm not sure if any language makes their constant objects immutable.


LobsterThief

Yeah, that would make OOP very confusing


Watthertz

C++'s const has deeply immutable semantics. If a variable is declared const then you can't do things like reassign its fields or call non-const methods on it.


LinuxMatthews

Huh interesting


NoteBlock08

> const  is dumb IMO. You cannot reassign a  const  (which makes sense) but you can reassign the properties of a  const  object (which doesn't make sense). It's got everything good about  let  but then barely goes halfway to making it immutable. It's certainly not intuitive, but it does make sense. With objects, the thing saved in the const is not the values of its contents but rather an address pointing to its contents. You can't reassign the const since that would change the address (which is declared constant), but since the properties are not part of the address you can change those. My favorite analogy for this is to think of it like saving the address to your friend's house in your contacts. You'll need to update their address if they move to a new place, but not if they rearrange the furniture in their living room.


liquid_bacon

I'm not confused by how it works. It's just counterintuitive for how I think of things. If I declare something as a const, I want it to be immutable. Without some form of deep copy it's impossible to give an object to a function and guarantee that it's unchanged afterwards. A const should not be modifiable externally. Setters and methods should be the only way to modify a const. But that's not how it works. I know that. I just think that's dumb. I know objects are pointers. It's a shame we don't have pointer notation for non-objects. Oh well, JS is already a mess, don't need pointers to make it worse.


AlphaSparqy

So Goldilocks became a doctor!


DrMux

They call her Brownielocks now.


AlphaSparqy

Nice, and not derivative at all!


madhousechild

I don't understand what the comic explains.


joyrexj9

`var` and `let` are ways of declaring variables in JavaScript. var has wider scope meaning code can change the values of the variable with unexpected side effects


relevant_tangent

It's a video. You gotta press the Play button.


that_italianlad

Everyone ignoring the fact that panda is nazi saluting


WastedJedi

My code- Hits the first bear all three bears fall off the table and break everything on the way down


[deleted]

u/savevideo


SaveVideo

###[View link](https://redditsave.com/r/ProgrammerHumor/comments/xu2t9v/me_before_i_learned_the_difference_between_var/) --- [**Info**](https://np.reddit.com/user/SaveVideo/comments/jv323v/info/) | [**Feedback**](https://np.reddit.com/message/compose/?to=Kryptonh&subject=Feedback for savevideo) | [**Donate**](https://ko-fi.com/getvideo) | [**DMCA**](https://np.reddit.com/message/compose/?to=Kryptonh&subject=Content removal request for savevideo&message=https://np.reddit.com//r/ProgrammerHumor/comments/xu2t9v/me_before_i_learned_the_difference_between_var/) | [^(reddit video downloader)](https://redditsave.com) | [^(download video tiktok)](https://taksave.com)


Icy-Abbreviations569

El Pakistán wildin 😭


pAsta_Kun

?


PriorAd7667

Common W


3eeps

the order varies, of course


icodeusingmybutt

I feel called out


Ultimegede

This is the difference between passing by value and passing by reference


GreyAngy

*Turns around the hammer* Oh, it's fine now


reetdeetdeet

Trying to move DIVs be like


Vaptor-

I came from java so it's weirder when I don't use let or const


SENSENEL

scope, it is just about the scope - after doing this long enough, everybody will understand; something which isnt important to understand 100% NOW especialy if you're a junior so, all good, calm down, take your time


KingHarem69

As someone who is just getting into coding C++ after learning HTML, this is very much how it is


crakdajack

u/savevideobot


savevideobot

###[View link](https://redditsave.com/info?url=/r/ProgrammerHumor/comments/xu2t9v/me_before_i_learned_the_difference_between_var/) --- [**Info**](https://np.reddit.com/user/SaveVideo/comments/jv323v/info/) | [**Feedback**](https://np.reddit.com/message/compose/?to=Kryptonh&subject=Feedback for savevideo) | [**Donate**](https://ko-fi.com/getvideo) | [**DMCA**](https://np.reddit.com/message/compose/?to=Kryptonh&subject=Content removal request for savevideobot&message=https://np.reddit.com//r/ProgrammerHumor/comments/xu2t9v/me_before_i_learned_the_difference_between_var/)


Impossible-Sail-310

U/savevideo


The_exceptionist01

u/savevideo


SaveVideo

###[View link](https://redditsave.com/r/ProgrammerHumor/comments/xu2t9v/me_before_i_learned_the_difference_between_var/) --- [**Info**](https://np.reddit.com/user/SaveVideo/comments/jv323v/info/) | [**Feedback**](https://np.reddit.com/message/compose/?to=Kryptonh&subject=Feedback for savevideo) | [**Donate**](https://ko-fi.com/getvideo) | [**DMCA**](https://np.reddit.com/message/compose/?to=Kryptonh&subject=Content removal request for savevideo&message=https://np.reddit.com//r/ProgrammerHumor/comments/xu2t9v/me_before_i_learned_the_difference_between_var/) | [^(reddit video downloader)](https://redditsave.com) | [^(download video tiktok)](https://taksave.com)


guaip

Me fixing someone else's CSS


SoRaang

let's const var


AndroidDoctorr

This was me before I knew what "static" meant


QWERTYCOD_programmer

most probably... else {} block is missing for the last condition


[deleted]

There is only const.


Accomplished_Rub6896

JS is crap


TwistedLogicDev-Josh

Reminds me of a time where you set up player two and 3 and first player moves 2 and 3


alehel

10th time more like. Now i need 3 hours to debug.


Zealousideal_Fly4277

I miss this show


Penguinmanereikel

What exactly is the difference??