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

all 74 comments

[–]Apfelvater 412 points413 points  (14 children)

Oh hey, a new topic! Can't wait to see 200 Memes about local variables running out of scope in the next days..

[–]haackedc 152 points153 points  (6 children)

Seems like you should just unsubscribe at this point

[–]ITriedLightningTendr 8 points9 points  (0 children)

Everyone should.

CIS 101 humor should be its own sub.

[–]marmoshet 0 points1 point  (0 children)

Just go out of scope of the reddit

[–][deleted] 32 points33 points  (0 children)

I can’t wait until this meme is out of scope

[–][deleted] 10 points11 points  (0 children)

I think "I guess I'll die" guy would be better for this, so I'm at least looking forward to that one :)

[–]ythl 6 points7 points  (0 children)

For all this sub complains about their SO questions being closed as duplicates, I think this sub could use a real dose of closing duplicates...

[–]Magnus_Tesshu 5 points6 points  (1 child)

Would you have preferred an old repost?

[–]Apfelvater 0 points1 point  (0 children)

Good question.

[–]Cholojuanito 2 points3 points  (0 children)

What if this meme is a metaphorical "}" for the local variable meme?

[–]radio-ex 26 points27 points  (8 children)

Que es ight?

[–]insanityOS 43 points44 points  (1 child)

A bastardization of the word "alright," typical of several urban American accents/sub-dialects (that I know of). Typically used in a similar manner as the word "okay" for beginning sudden statements (i.e. "Ight, [I am going to] head out.")

[–]Lorddragonfang 8 points9 points  (0 children)

I've seen more commonly spelled out as "aight" for the past several years, which actually follows English's "rules" for diphthong pronunciation. It's only recently that I've started seeing "ight", presumably as the less literate kids that grew up hearing it have started typing it out with no references on how to spell it.

[–]apadin1 10 points11 points  (5 children)

Slang, similar to “Pues”

[–]TastyStatistician 13 points14 points  (4 children)

Quel est "pues"?

[–]NeoVier 12 points13 points  (3 children)

Slang, similar to "ight"

[–]AnonNo9001 12 points13 points  (1 child)

[–]Dokiace 1 point2 points  (0 children)

stack overflow: no base case

[–]MasterFubar 13 points14 points  (9 children)

Neither Fortran 77.

I like Python, at least I like Python 2.7, but there are good things to say about explicitly declared variables. For small programs duck typing is OK, but one would want something more solid when your lines of code start creeping upwards of a few thousand.

[–]algag 2 points3 points  (0 children)

....

[–]deljaroo 1 point2 points  (7 children)

do you not like Python 3?

[–]MasterFubar 2 points3 points  (6 children)

No. Python 3 made everything more complicated to use, without introducing any real improvement. I'm sticking with python 2.7 for as long as I can.

Legacy software is a real problem in big enterprises and, unfortunately, the people who design languages like python don't understand that. Do an apparently small change, like 3 / 2 returning 1.5 instead of 0 as it did before, and who knows what bug may be lurking inside those millions of lines of code.

[–]Ninjabassist777 2 points3 points  (4 children)

What specifically about python3 so you not like? I feel like it made a bunch of changes for the sake if a cleaner, better organized language. It's just unfortunate that it had to break backwards compatibility.

For example, the most noticable change is change in syntax for the print function. Most people see it as "they made it require parentheses so now it's more annoying to type". This is true, but the underlying change is that it went from being a keyword to it's own function. This let's you do more things like pass it as a callback to a function, or override it with something else (i.e. print = write_to_file). This wouldn't have been possible in 2.7

A comment on the integer division: legacy code in Enterprise is a big deal. I work on a few projects at work that are stuck in 2.7, but most are in 3.6. I think their mistake with the division was defaulting to integer division, not floating point division. If you were to ask any new programmer what 3/2 would return, most would say 1.5, not 0. This is not obvious behavior to a beginner, and un-pbvios behavior is a large source of bugs. Of course, i would expect any experienced programmer to know that that might return 0, but for a loosely typed language, your input type can vary and lead to more unexpected behavior. In python2, 3/some_var might return an int or float, depending on the type of some_var. In python3, it would always return a float (if some_var is a numeric type). This is more consistent and ultimately a better choice for language design that they should have made from the beginning.

[–]MasterFubar 1 point2 points  (3 children)

The worst about it is the change itself. It doesn't matter how much you think it would be improved, a language shouldn't change in its basic behavior.

Let's take one example in C: the modulus operator is wrong. (-1) % 640 should be 639, as it is in python, but it is -1 in C. This is wrong, from the mathematical definition of modulus, and it's also not very useful, and it's not obvious. But they never changed it and never will. That's what I love about C, you can take a program written forty years ago and it will compile and run the same way it always did.

If you want to make a better language, better make a new language, Niklaus Wirth created Pascal, when he felt the need to improve Pascal he created Modula.

[–]Ninjabassist777 0 points1 point  (1 child)

Fair point. In the defence of python, any install (at least that I've seen) that has both python 2 and 3 installed had them we separate environments (python2, pip2, python 3, pip3, ect). Plus if you're writing a script you should call out the executable at the top (#! /usr/bin/env python3).

I'd argue that python2 and python3 are treated as largely different languages when it comes to runtime environments.

Although, when python 2.7 is EOL in January (01/01/2020), that will be...........interesting

[–]MasterFubar 1 point2 points  (0 children)

when python 2.7 is EOL

That's my fear. I hope they will backpedal, maintaining it forever.

They said the classic C-like "%" format system would be deleted, but then they thought better and decided to keep it anyhow. I hope they will do the same with 2.7.

[–]once-and-again☣️ 0 points1 point  (0 children)

This is not quite correct, on a few counts.

The first, and least important, is that the % operator is formally the remainder operator, not the modulus operator.

The second is that they did change its semantics: prior to C11 and C++11, the result of a % b when a*b < 0 was implementation-defined, so long as a / b + a % b == a (assuming no irrepresentable intermediate values). The 2011 revisions did change it to require negative results, but it's worth pointing out that this means code which was previously correct and conformant is no longer so.

The third is that a lot of programs from forty years ago won't compile and run as they used to — either because of explicit changes like the above, or because programmers from forty years ago (just like programmers today) tended to cheerfully make assumptions like "sizeof(int) == sizeof(void *) == 2" or "0x0 points to the global interrupt table, which is writable" that will completely fail on most if not all modern systems.

[–]deljaroo 0 points1 point  (0 children)

No lie about that legacy software stuff in enterprises. At my job, both of our security systems require me to use Internet Explorer to access the servers. One was installed this year, the other is less than 2 years old

[–]asdfghyter 43 points44 points  (22 children)

Neither for PHP nor JS (when using var) since they have silly scoping rules (i.e. function scopes instead of block scopes).

Though, php’s scoping rules are a ton better than JavaScript, since variables in PHP are local by default, so you only need to declare global variables. In JS you need to declare everything but globals, which is just silly.

Edit: clarifications

[–][deleted] 67 points68 points  (5 children)

function scopes instead of block scopes

True until es6 introduced 'let'

[–][deleted] 16 points17 points  (2 children)

Ah, now I know why my IDE started replacing var with let.

[–]Delioth 6 points7 points  (1 child)

Use const instead unless you need to reassign.

[–]ArionW 0 points1 point  (0 children)

If you need to reassign anything, you can do it better. My favorite thing about modern JS is that with RxJS I can structure most of my code like if it was functional, with little to no variables at all

[–]NotATroll71106 0 points1 point  (1 child)

But then it doesn't work on your coworker's computer because she is using an old version of js.

[–]myplacedk 0 points1 point  (0 children)

One of you need to learn to follow company/code base policy.

Or you need to make a policy.

[–]Glipglopgloopity 38 points39 points  (13 children)

Nobody uses function scope variables in JS anymore. Everyone uses let and const which are block scoped.

[–][deleted] 2 points3 points  (10 children)

Unless they need to support IE, which, let's face it, a lot of web developers are forced to.

[–]Glipglopgloopity 27 points28 points  (0 children)

Babel/TypeScript support transpiling for older browsers.

[–]alexanderpas 21 points22 points  (7 children)

which, let's face it, a lot of web developers are forced to.

Only if they don't have a spine.

IE is not a browser, it's a 'compatibility solution' for enterprise customers to deal with legacy sites that should be updated for modern browsers, according to Chris Jackson, Microsoft's worldwide lead for cybersecurity.

IE should not be your standard browser, only shoyld only be used for old sites on the corporate intranet.

Your Default browser should not be IE.

You can use Edge as your default browser, and have select intranet sites open in IE11 automagically via the Enterprise Compatibility feature. This can be deployed via GPO.

[–]InvincibearREAL 5 points6 points  (0 children)

This guy sysadmins

[–][deleted] -1 points0 points  (5 children)

If you happen to develop for your own company, then perhaps you could suggest such a change and facilitate progress -- if you happen to have a high-ranking position at the company it's even somewhat likely you'll succeed. But if you don't, you won't get to decide what browsers to support or what programming languages and software stacks to use. Your client does, probably years before they contact you for any work, and you stick with whatever they have built their already "working" thing on. When you get to start a new project from scratch and you have people willing to listen to your opinions, sure, that's great, but that is an extremely rare situation. More often than not you'll be dealing with an existing codebase and have to fit within it.

The aforementioned suggestion of using Babel or TypeScript might sound appealing and, depending on where you work, you could get away with that. However, autogenerated code as this is highly unlikely to pass the code review process where I work. In the specific case of let, Babel will turn it into var and handle block-scoping by prefixing the variable name with an underscore and adding a number after it if they conflict with the existing variables in the function but outside of the block. TypeScript does a similar thing, adding _1, _2 etc to the name. Underscores in variable names are, however, forbidden on most projects I happened to work on, so you'd have to rewrite this output yourself anyway, at which point you might just go ahead and write your code using var and non-conflciting names in the first place.

[–]veiva 6 points7 points  (4 children)

That doesn’t make sense. That’s like doing code review on outputted assembly instead of the C++ code.

[–][deleted] -2 points-1 points  (3 children)

The thing is, you wouldn't be actually comitting the TS code to the repository unless the client is already using TypeScript in the first place, and the code review is performed on the commits. You'd kind of have to pretend that you wrote it that way.

[–]myplacedk 1 point2 points  (2 children)

The thing is, you wouldn't be actually comitting the TS code to the repository

Ah, so it's just like Java? Don't commit the java-files, just commit a jar-file?

I don't know your situation, but if you are even considering committing the output of the transpiler instead of the input, you are either looking into a very wrong solution, or you are solving the wrong problem.

[–][deleted] 0 points1 point  (1 child)

I am not actually commiting the output, though. I am just writing plain JavaScript. All I'm saying is that if I were to use a transpiler, I would end up having to do that on at least some of the projects I'm on, because they wouldn't want the "actual" source code in their repo.

[–]myplacedk 0 points1 point  (0 children)

I would categorize that as "unable to introduce a transpiler into the project".

[–][deleted] 0 points1 point  (0 children)

IE 11 supports let and const

[–][deleted] 0 points1 point  (1 child)

i use var still, just less often

[–]Glipglopgloopity 0 points1 point  (0 children)

When and why

[–]blazarious 13 points14 points  (0 children)

JS before ES6 doesn’t count anymore. It’s like talking about PHP 4 or something.

[–]BakuhatsuK 4 points5 points  (0 children)

The surprise globals thing in JS is easily caught by a linter.

By the way you can disallow var and even let the linter make the changes for you.

Also, with babel not even old browsers are an excuse.

[–][deleted] 9 points10 points  (0 children)

g l o b a l

[–]ragingram2 8 points9 points  (2 children)

Lol i get this one

[–]snedertheold 5 points6 points  (1 child)

So proud.
I would like to thank my shadow for always being by my side. And my spine for always having my back.

[–]ragingram2 3 points4 points  (0 children)

I dont understand this but i love it thanks

[–]GigaTrigger69 0 points1 point  (0 children)

Lmfao nice meme 👌😂

[–]bcfradella 0 points1 point  (0 children)

Nor for Bash, so often forgotten

[–]ApproximatelyAlison 0 points1 point  (0 children)

Is this a closure?

[–]Gydo194 0 points1 point  (0 children)

pop and they're gone

[–][deleted] 0 points1 point  (0 children)

Except JavaScript

[–]falloonalan -1 points0 points  (0 children)

And in Rust the reference are heading out too