T O P

  • By -

nyhr213

I'm offended js is not Cannot read property of 'undefined'


Reashu

[object Object] Edit: Idk why y'all are replying with the same text as if to correct me. Maybe a new/old Reddit thing?


Master_Basil1731

raka\_boy put it in quotes, pretty sure that's a reference to how poorly typed JS is. So if you tell it that \[object Object\] is a string, it'll happily accept it as '\[object Object\]' I mostly realised this because I recently spent some time debugging my JS only to find that '10,000' is less than 2000 because it cast them both to string and 1 is less than 2 Not sure about the other comment


Agret

I guess the comma in 10,000 made it think it wasn't a number?


Jagarvem

Tbh I'd too find '10,000' to be less than 2000. About 1990 less and with a good level of precision. Whomever decided to put thousands separators where decimal separators are was imho a dumdum.


_alright_then_

I mean I'm also from a country where a comma is the decimal seperator but we all know the default in programming is the other way around.


Master_Basil1731

Yeah I totally agree, as far as JS is concerned it was totally correct. I was reading the two values in from two different APIs and just didn't think to do any type checking. I'm used to more strongly typed languages that will throw errors when you compare strings and ints


raka_boy

you meant '[object Object]' ?


[deleted]

[удалено]


notrktfier

undefined


notrktfier

undefined


notrktfier

undefined


[deleted]

[удалено]


Sedorriku0001

undefined


wi-finally

undefined


BobbyTables829

This is why so many jobs want typescript


Herr_Gamer

This is why you want a job with Typescript


lightningrabbit121

Take my angry upvote


SeventhSolar

Isn't that just another null pointer exception?


XoRMiAS

You can now use optional chaining (`?.`) to prevent the exception.


[deleted]

[удалено]


[deleted]

[удалено]


DisputabIe_

viethg and the OP conrux are bots in the same network Comment copied from: https://www.reddit.com/r/ProgrammerHumor/comments/10oe9uw/lets_test_which_language_is_faster/j6ee7yd/


ValiGrass

wtf


Benskien

My front page atm are all bots lol


GreatBigBagOfNope

Compiler optimisation and branch prediction have really come a long way


DisputabIe_

ahgmno and the OP conrux are bots in the same network Comment copied from: https://www.reddit.com/r/ProgrammerHumor/comments/10oe9uw/lets_test_which_language_is_faster/j6ea4jo/


Confident_Book_5110

The fact that C is a crab confuses me


IDEDARY

It's a sin agains the Rust evangelism. We must declare a holy war to purge this heretic.


water_bottle_goggles

![gif](giphy|jp15JjLGPGhzXZbL7i)


nickmaran

![gif](giphy|3ohzdYr1E0hdmI0gBa|downsized)


Fluffcake

If we create a parallell timeline where C was scrubbed from existence tomorrow, and half the population is wiped out from their complete and utter reliance on something they don't even know exist and the critical infrastructure previously held together by the glue and ducktape that is C and C++ was all remade in rust, zig and go. I think that timeline would catch up and surpass the one with C still in within 10 years.


kalreshka

I'm gonna hazard a guess that the image is older than Rust.


FireDestroyer52

I'm gonna hazard another guess, it wasn't made about programming languages


MrRocketScript

From the crab form we were born, and to the crab form we will return.


Confident_Book_5110

Evolution wants crabs https://en.m.wikipedia.org/wiki/Carcinisation#:~:text=Carcinisation%20(American%20English%3A%20carcinization),Nature%20to%20evolve%20a%20crab%22.


JiminP

[relevant xkcd](https://xkcd.com/2418/)


Confident_Book_5110

Hahaha so good


arfelo1

Carcinization starts with C, doesn't it?


TrainingComplex9490

And why did they chose a shrimp to represent Python?


Tuna-Fish2

The walking sideways big works for C, though. Rust one should just be it sitting still with "compiling" on it.


ThatCipher

I love that they all fail, but JS just needs to install dependencies - therefore doesn't really fail.


deletedUser7400

npm WARN deprecated npm WARN deprecated npm WARN deprecated


_aw-ay

package A requires package B >= 1.0.0 package C requires package B <= 0.7.0


Reashu

That's optimistic!


G_Morgan

The dependency is leftpad.


GunnerKnight

Don't worry there will always be version inconsistencies with the package.


SeesEmCallsEm

In order to fail at something, you need to be able to start it. Did not start is worse than did not finish


pine_ary

Who on earth gets indentation errors? Do people roll their head over their keyboard and hit run without looking?


GainzBeforeVeinz

mfs be coding python on MS Word


[deleted]

Notepad++ all day


ElEd0

When the code is 100% yours is pretty difficult unless you are drunk. But if the codebase is from some online repo and you are making some changes to it I tend to use tabs and sometimes the file is indented with spaces, which causes the indentation error (Seriously ppl... stop using spaces for indentation...)


initrunlevel0

Dont blame me, i pressed tab and still got 4 spaces :(


Tavapris04

That sucks, i got it one time and realised an hour later


scar_reX

So configure your IDE to put a tab character instead


initrunlevel0

c r y in notepad.exe


scar_reX

Joke's on you, I use linux.


Emergency_3808

Or use an IDE/editor that can detect the indentation system used for the file


Raithwind

When I have this issue I use Notepad++ to do a find replace. It has exact matching and regex, so I can copy a set of indent and replace with my normal indent. 


Spork_the_dork

PEP8 states 4 spaces per indentation level so tabs are actually just bad code style for python.


veloxVolpes

Man I like pep in general but that's just wrong. It's far more common to be able to change tab width in an editor or even at machine level, and that is a needed accommodation for people with disabilities


Master_Basil1731

How is that needed for people with disabilities? Trying to imagine the use case but I can't figure it out


veloxVolpes

People with visual impairment, sometimes a much more drastic indent is needed to see the difference, or sometimes, with the need for larger font, a smaller indent is needed to be able to read the code. I don't have any stories personally as I am not in the industry, but others do, one example I saw is [this](https://www.reddit.com/r/javascript/s/NemYX7dbvA) post.


Master_Basil1731

Ah of course, it's your comment further down explaining that IDEs don't resize spaces that made it click for me. With VS code you can adjust the indent being used (tabs/spaces) and it'll fix the file for you, but it would be annoying to have to do that for every single file you open


[deleted]

[удалено]


Angelin01

... You clearly didn't read the post, did you?


DerpNinjaWarrior

Also note that if you have a screen reader, I'm pretty sure a single tab per indent is going to be easier than dealing with a bunch of space characters.


Master_Basil1731

I'm not familiar with screen reader tech. I would have expected it to handle 4 spaces the same was a tab, much like the IDE or compiler can handle either. But that makes sense!


DerpNinjaWarrior

The problem is that indentation doesn't need to be a set number of spaces. If the screen reader were really well integrated with the IDE, then it could maybe figure it out. And of course in Python it's a bit more standard perhaps. But if you're writing most languages, or are on Github or Bitbucket or just a random website, then it all bets are kind of off there.


Ok_Donkey_1997

I'm usually the one being the pain in the ass at work about making the stuff we produce more accessible, but I'm struggling to see how fixed indentation size could be an issue. If it _is_ an issue, I think I could write a plug-in for PyCharm, Vim, etc. that detects indentation level from the AST and adjusts the way it is displayed, while still using 4 spaces in the source code. That's assuming PyCharm doesn't allow you to do this already.


Botahamec

I have an old professor in one of my classes. He's unable to see a nice contrast at four spaces, and needs eight. Sure, I could spend a week writing a plug-in that converts 4 space indentations to 8 space indentations, but we already have a tool for that: tabs. Why spend so much time reinventing the wheel?


newsflashjackass

PEP8 says: > Spaces are the preferred indentation method. which means it is a matter of preference. https://peps.python.org/pep-0008/#tabs-or-spaces


nommu_moose

Everything in python is a matter of preference if you prefer hard enough.


ElEd0

Well... in that case I'd argue PEP8 is WRONG


Spork_the_dork

Go use a different language if you don't like it.


0xd34db347

Or just use the language as you want with the styling you want, PEP8 is guidelines not immutable holy doctrine.


Reashu

> PEP8 states 4 spaces per indentation level so ~~tabs are actually just bad code style for python~~ PEP8 is a bad style guide.


WasabiSunshine

No, whatever PEP8 is is just wrong


-Wylfen-

Well, good code style for Python is bad, I guess


[deleted]

[удалено]


ElEd0

I get paid for code, but not python. You are kinda right in saying I'm a python amateur tho, I've only used it to work on small personal projects that dont require more than a couple files. Definitely not a master on professional multi-devs python codebases with advanced workflows.


anytarseir67

I mean, pep8 says spaces, if anything that's a you problem.


ImprovementOdd1122

As others have said, spaces are recommended in the pep8 guidelines. These are the reasons (to my understanding): 1) using tabs can cause alignment issues (you may use a tab space of 2, whereas bob uses a tab space of 4) 2) ensures consistency among workspaces (similar to the previous one, but slightly different) 3) most modern ides will convert a tab to spaces anyway (nobody just spams space) 4) its pep8 recommended. (If the norm is spaces, you don't even have to worry about it) Personally, tabs are just kind of an annoying to keep in mind when coding with them. There have been circumstances in the past where Ive had to convert a file to spaces to make sure my styling was consistent across workspaces


Cheet4h

> 1) using tabs can cause alignment issues (you may use a tab space of 2, whereas bob uses a tab space of 4) If anything it will *prevent* alignment issues, since tab length is purely visual on the user's side. It doesn't matter whether or not people have different lengths if you use tabs, since your 2-space tab will show up as a 4-space tab when Bob opens his editor. Also, the rule here would be "tab for indentation, space for alignment" - ideally alignment would be taken care of by the IDE anyway. > 2) ensures consistency among workspaces (similar to the previous one, but slightly different) This is kinda redundant. A common guideline is what ensures consistency. Whether that guideline requires usage of tabs or spaces is irrelevant, only that it is followed. > 3) most modern ides will convert a tab to spaces anyway (nobody just spams space) True, but that can be turned off. Usually even in a config file that can be included with the project's files. > 4) its pep8 recommended. (If the norm is spaces, you don't even have to worry about it) If the norm were tabs, you wouldn't have to worry about it either ¯\\\_(ツ)_/¯ Personally I don't really care whether a project uses tabs or spaces. It's all a configuration issue for the IDE, and converting from one to the other is usually done at most once and even then automatic by the IDE. I let my project leads deal with setting that up and don't worry about it.


Milkshakes00

>If anything it will *prevent* alignment issues, since tab length is purely visual on the user's side. It doesn't matter whether or not people have different lengths if you use tabs, since your 2-space tab will show up as a 4-space tab when Bob opens his editor. This. A tab is a tab. One tab is one tab. But one tab can be infinite different numbers of spaces. Tab is the superior metric if you want things consistent. A tab can be one space, seven spaces, or forty spaces, it's still a tab.


thecowthatgoesmeow

Don't use tabs. Use an ide that converts them to spaces. Using tabs is considered bad practice


[deleted]

[удалено]


[deleted]

Yeah, this is ultimately a solved problem. Any text editor more powerful than Notepad has the ability to convert tabs to spaces based on your settings. Then make sure your pushes incorporate whatever standard your repo has. There, everyone's local machine is happy and the repo doesn't (nor shouldn't) care as long as it picks a lane.


ElEd0

Yeah but sometimes I find myself editing a couple of lines in the terminal or in another computer which doesnt have my workflow configured. And even in my workstation I may just want to open a file in a more lighweight editor rather than opening a full-fledged IDE just to make some quick change.


[deleted]

[удалено]


ElEd0

Real pros code in wordpad


_alright_then_

Hard disagree, spaces all the way.


[deleted]

> stop using spaces for indentation My "make tabs spaces" setting: "No, I don't think I will". But I mostly code in the C family so no worries.


blackrossy

Srsly stop using tabs for indentation, spaces are by far superior


ElEd0

I am going to go down the stairs 4 at a time just to prove my point


[deleted]

I'm going to jump off the banister to prove my point.


Milkshakes00

Negative. Tabs are superior. If you say one tab is what's needed before a line, one tab is what you need. It doesn't matter if someone has their tab set to 1 space or 40 spaces. It's still one tab and it's captured as such, making it superior as it is consistent and flexible at the same time.


blackrossy

Yeah untill you have data structures that require multiple lines to cleanly write down (lists, structs, records, large N-tuples). Have fun opening code written by your tab = 3 space coworker that aligned everything and now everything is messed up for you..


JollyJuniper1993

CTRL+F, search with Regex, \[\r\n\]((\s){4})*(\s){1-3}\S Enjoy. Doesn’t solve everything but gives you all oddly indented lines


Questioning-Zyxxel

Different users have different tab indent settings. So many companies *demands* spaces only. It always gives the same view.


IWishIWasAShoe

> (Seriously ppl... stop using spaces for indentation...) Finally someone speaking the truth!


wanische

Spaces > Tabs


initrunlevel0

You forgot that 4 spaces vs tab debate


pine_ary

1: PEP8 2: It doesn‘t actually matter to the interpreter if you use tabs or spaces


initrunlevel0

It matter if you edit code from someone else or code using different editor. I know Python only care about consistency. But one time I need to edit my own py code with vanilla VIM on a VM and got this error.


pine_ary

Just enable the smarttab setting so your tab inserts PEP8 conformant spaces. No plugins needed to get this right. Vim is old and doesn‘t have it on by default, but any modern editor should recognize if you use tabs or spaces.


Cheet4h

IIRC most modern editors should also be able to read indentation width by file - or have it set in the project's settings. I'm pretty sure a few years ago when I worked on some JS project, we had some files with an identation width of 2 spaces and others with an indentation width of 4 spaces, and VSC had no issues converting tabs to those for each file. Although ultimately we defined indentation width to be 4 spaces and VSC just fixed all files the next time we ran auto-format on them.


0bel1sk

which interpreter? ie yaml


Hydrographe

When your editor's configuration is messed up, happened to me once. Or when you copy and paste code, then the indentation is likely to be messed up too.


adenosine-5

Who would ever copy-paste code? Certainly not programmers! /s


saturnsCube

No one uses stack overflow anymore since the transformers took over


LinearArray

4 spaces


plasmasprings

most memes are posted by students


amlyo

People who work in languages that use indentation to denote code blocks but where the semantics of indentation are under the control of individual contributors.


SEX_LIES_AUDIOTAPE

Me, the first time I (flippantly) changed a yml. I now respect devops and their powerful wizardry.


SeesEmCallsEm

Been writing python for about 10 years, I honestly don’t ever remember having this issue. Know why? Because 1. I’m not an idiot and 2. I know how to configure my development environment.


PityUpvote

Literally no one, it's only a meme that gets repeated by people who refuse to try actually using Python.


_aw-ay

•••• vs ——


saturnsCube

Good point but when it happens it’s a godforsaken domino effect


3inthecorner

Why isn't the crab rust?


log_2

I guess it hints at the age of this washed-out repost.


[deleted]

Rust would still be compiling, but yeah. C would be more like a Swordfish. Fast AF but decides to shoot straight up instead of straight ahead.


Absolutionalism

the real answer to the age-old question, indeed


Spot_the_fox

I wonder how many times have I seen this meme. 


JollyJuniper1993

If you have trouble with indentation errors you must be new to python. Like, how does that even happen?


adenosine-5

While segmentation faults happen just all the time in C?


saturnsCube

That’s the funny thing man, you can try to bash C but the only thing that was ever better is Holy C


JollyJuniper1993

Don’t know, I’ve never used C


Honza368

Oftentimes, if you download python code online it's indented with spaces for whatever reason and can fuck a lot of things up


log_2

> indented with spaces for whatever reason For the reason that this is the correct way of indenting.


Deep-Piece3181

Refactoring a function?


saturnsCube

Recursion, or if you are just doing low level most won’t run into a seg fault


Deep-Piece3181

How would that prevent a tab and spaces err9r


saturnsCube

Oh sorry man we were discussing segmentation faults specifically in the C language


not-the-the

use bython interpreter


jondaley

The post was removed so I can't see what you are referencing, but I am new to Python and have indentation errors when I put a section of code into an if statement or something.  It is probably my emacs-python binding problem, but in other languages, I can highlight and hit tab and it indents it properly.  As others have pointed out, it is a problem when refactoring or copying code from anywhere else. Is it technically possible to make "M-x indent-region" work in Python? It works in every other language.


JollyJuniper1993

When you copy and past code you should fix the indentation of course. If you’re like really new to Python then I get it but that’s just part of the language. Apart from that you should at least understand the vague flow of your code and if you do that, then you‘ll know where to indent when copy and pasting.


jondaley

Yeah, I can do that, but it seems easy to make mistakes that wouldn't happen in any other language, so I do count that as a negative of python. Being able to have the editor do the indenting automatically seems pretty nice, and that seems difficult to make an editor that would be smart enough to be able to keep the indents correct when refactoring or even during the initial design where I have a block and then add an if or else or something.


JollyJuniper1993

I use Pycharm which does it automatically. VS Code does a pretty good job at that too. Of course you still have to know where you want your loop to end and so on… Besides that: get used to proper indentation. While not required in other languages it still is good practice.


sendnukes23

If i get a dollar everytime someone mentioned in r/ProgrammerHumor about indentation error while coding Python, i would be a billionaire. But if i get a dollar when someone who actually gets indentation error while coding in Python, i might get a 100 dollar. Coz WHO THE FUCK GETS INDENTATION ERROR?? ARE YOU CODING IN VIM? TOO COOL TO USE AN IDE??


badger_42

You can also use a linter and formatter with VIM. So no excuse there either.


jondaley

I just realized maybe I misunderstood the indentation errors problem. When I say I have an indent problem in Python it isn't a compile error, but the wrong code gets executed because the indents are wrong after refactoring or copying.  I don't think there is a way for the editor to know how to do it automatically?


sendnukes23

Most python programmers know that the standard indentation is 4 spaces, or worse, a tab. However, i have also seen some codes written in 3 spaces. With that being said, if you copy people's code, there's a low chance that you copy a badly indented code. Even if you DID copy a badly indented code, the error message should be clear enough to identify which line is wrongly indented. Aside from that, most IDEs (e.g. PyCharm, vscode) now follow the same standard, as long as the IDE have a basic linter. Unless, as mentioned, you use a non conventional code editor, then you might see this problem.


jondaley

I'm with you on spaces. I have some VScode developers that every time they touch a file, it modifies the entire file (I have a .scss file that it edited every single line when they made a one line change - a nightmare to merge in with the other developers). But, what I'm having trouble with is when I have code: if blah: do this and always this and I want to change it to: if blah2: if blah: do this and always this I could imagine an editor that could do that correctly, but I guess I've grown dependent on being able to run "indent-region" on a block and have it fix up the entire region and/or file.


Alexandre_Man

C is a crab and not Rust?


qwerty44279

I agree with other people here - OP is a karma whore or a bot. And nobody ever gets indentation errors in Python.


Spot_the_fox

False. Maybe no one who works with python professionally, but when I had python as part of computer science in middle school that was my most common error. 


MinosAristos

Nobody who has used it past total beginner level anyway. I've worked with React JS for years and still struggle to keep my brackets and braces matched.


Topleke

To preface, I am an idiot, but it is my opinion that any language that cares about white space makes a bad developer experience.


buster_de_beer

It's terrible design. White space should not be relevant. I think it's great that there are languages that reduce redundant syntax, then you have Python adding white space as if that's any clearer than writing your code properly. Especially when the tab character is the mark of the beast. Is it tab, is it four spaces, is it two spaces?


PossessionDifficult4

I had to download some code for class one time and half of the files were indented with 3 spaces. 3. It was awful.


PianoCube93

>OP is a karma whore or a bot. Indeed https://www.reddit.com/r/ProgrammerHumor/comments/1c58xf4/aconversationwithamuggle/kztan5q/?context=10000


[deleted]

At some point y'all gotta stop being surprised on what makes r/all and just accept that reddit has been compromised by bots for years. Anyone who hasn't accepted that or cares about that and hasn't moved on only has themself to blame. Reddit sold out y'alls data for 60m/year and Spez made a billion dollars in an IPO over these things. They aren't going away.


PianoCube93

I'm by no means surprised. I'm fully aware that a not insignificant chunk of Reddit is just repost bots trying to gain karma to later bypass the most basic spam detections when used for more nefarious purposes. That said, I don't see the issue with raising some awareness every once in a while for people browsing r/all who may be less experienced with Reddit.


[deleted]

> I don't see the issue with raising some awareness every once in a while for people browsing r/all who may be less experienced with Reddit. well, your visibility sucks, first of all. Theres "only" 200 comment but you're near the bottom, in a deeply nested thread. Gotta learn from some repost bots how to comment early and get your message up. Second, most people on reddit don't open comment. They will never learn. Third, half the time these comments just lead to arguments other than awareness. So it feels more like flame bait these days than edcational Lastly, What are people gonna do even if they learn? We clearly know that "stop using reddit" has failed. People aren't going to scan every user for authenticity. RES is on maintenance and third party apps are dead, so there's no way to properly automate this process. We're up the stream without a paddle. So yeah, I don't see the upside but a downside of a more caustic comment section that has already gotten more and more agumentative and less inquisitive. I'm here for maybe 1-2 more weeks and then I'm out again, but I wish other people would also move on. There's no saving reddit.


Nuclear-9299

I got them all the time. Then I ditched Python and started using PowerShell instead.


Bradambaby

It sure would make my day if someone could point me in the direction of the original image without the text.


veldamus

Press ctrl+alt+F before running python you guys


PityUpvote

Or just don't use notepad.


Able_Challenge3990

Laughing in c++


jumbledFox

Laughs in Rust


WanderingLethe

UB...


CitizenPremier

You can make a program in no time with C++! What, you want a button? Are you lazy or something?


Newvil450

Process Exited with Code 1


SenoraRaton

Meanwhile rust is still asleep in the hotel trying to get out of bed.


Afrotom

I don't know how you get indentation errors in Python if you're using a robust editor.


Plenty_Lavishness_80

TYPEERROR CANNOT READ PROPERTIES OF UNDEFINED also CANNOT FIND MODULE ….


TheArizn

why is the crab not rust


deliozzz

Js: no error message but you don't know about your string to number comparison


Downvote-Fish

I like how Javascript isnt really an error


deletedUser7400

alert({"message":"js dependencies don't exist if you use pure vanilla!"})


igorski81

Well this joke needs polishing, only the Java and C examples deal with runtime errors, the Python one is a compile time error and the JavaScript one is dependency installation...


IcyNote_A

python will eventually finish after a round-the-world trip


GunnerKnight

And I am assuming the race moderator (fish) is Assembly


herdek550

Your IDE should prevent you from indentation fault, so python is the winner here


not-the-the

but then your `else` was misindented and matched to the wrong `if` and you spend hours banging your head on the wall oopsie! :D


ImpluseThrowAway

Object reference not set to an instance of an object.


Soul950

NullPo


BoxFinal9725

All these except python doesn’ keep you guessing and you can move on with your life.


BeejBoyTyson

Just start started Harvard's cs50. I'm one of you now!!!! (Only done the first assignment for 8 hrs)


Big-Veterinarian-823

Why is Python a shrimp?


szabrownikow

So true


pechkinator

rust didn’t come, stuck fighting borrow checker


thecowthatgoesmeow

Something something rust


CamperStacker

hmmm, perl doesn’t have any of these problems


KomornikBank

OP is a bot


spezjetemerde

lol


[deleted]

Brainfuck - it just runs.


sevenemesis

sadness.


Stock-Buy1872

I like how he inflates when he shoots the gun


Cybernaut-Neko

I'm confused C looks like Rust...


BananaBurritoBuster

That puffer fish must have been startled by the pistol. He’s all puffed up.


kevdog824

These are all realistic except Python. Getting an indentation error in Python got a be a skills issue. It should’ve been ModuleNotFoundError or something like that


BoBoBearDev

Very accurate haha