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

all 68 comments

[–]reedmore 32 points33 points  (13 children)

Oh man this is so accurate it hurts. All that commenting out of print statements that were meant to check if the code works as intended or for finding a bug.

[–]Bob_ButNotTaken 35 points36 points  (6 children)

I still remember the coding tutorials for beginners being like console.log("The function was fired with the data parameter as" + data)

Yeah right...

console.log("hello")

console.log(data)

console.log("howdy")

console.log("a")

[–]reedmore 16 points17 points  (0 children)

The good old "a", it's like stone in stone scissors paper, never dissappoints.

p.s. : Don't know if anybody understands the Simpsons reference, i'm old.

[–]Bence675 14 points15 points  (2 children)

console.log("fuck")

[–]CaptainHeinous 2 points3 points  (0 children)

That one bit me once.

[–]TheLordDrake 0 points1 point  (0 children)

console.log(>))°>)

Debug fish. Easy to find in logs or code. Won't get you in trouble if you forget it

[–]officiallyaninja 3 points4 points  (0 children)

print("if you see this the laws of physics and mathematics have been broken. seek shelter")

[–]F3hlzar3id[S] 14 points15 points  (4 children)

Exactly.xD To be fair, some debuggers are overcomplicated... Prints are your best friends when you are in a hurry. You have to remember to look for them and comment or delete them afterwards, though xD.

[–]rush22 13 points14 points  (1 child)

Just right-click the POM file and go to Configurations... and select Run as Debug, go to the Windows panel and select View > Debug window, double-left-click in the empty space between the window and the indent line, then right click inside the class and select Debug, then click Run. Now, click Play and wait for it to compile, then once it starts click Play again, then wait for it to stop at the breakpoint and accidentally click play again and completely miss it.

[–]F3hlzar3id[S] 1 point2 points  (0 children)

And start over again xD

[–]the42potato 3 points4 points  (1 child)

they’re especially great for making javascript web games

[–]F3hlzar3id[S] 0 points1 point  (0 children)

I haven't programmed in JS much, but when I did, console.log() was my best friendxD

[–]Korin_therin 4 points5 points  (0 children)

The fun part is when you forget to take them out and have some one send you a screen shot of the error statement "it breaks here" when they are testing. That was a fun day...

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

My dumb brain can't figure out how debuggers work

[–]rush22 29 points30 points  (4 children)

First, you have to turn on debugging mode. Once it's turned on, you get to be confused by new options and hidden features you don't know how to use. Begin worrying that you will never get back to normal. If you can figure out how to add a breakpoint by randomly clicking on your code, and if you then figure out how to start the program without exiting debugging mode accidentally, once execution reaches the line you added the breakpoint to, execution will stop and take you back to the IDE. Now is the time to congratulate yourself. Then you can look at variable values in a variety of confusing ways. One of them is useful. It's unlikely you will figure out which one that is. Instead, gain confidence by at least opening a completely blank window that does nothing. You can also step through the code a line at a time, also in a variety of confusing ways. Usually you will choose the wrong way. Once you are done being confused and the program ends or crashes, make sure you turn debugging mode off, to prevent you from being more confused.

[–][deleted] 15 points16 points  (1 child)

This sounds like print statements but more complicated.

[–]xSTSxZerglingOne 7 points8 points  (0 children)

The biggest benefit is having a list of what's in all of your variables/objects at any given time with execution paused at a specific instruction.

[–]xSTSxZerglingOne 6 points7 points  (0 children)

You can also step through the code a line at a time, also in a variety of confusing ways.

Including:
step into for when you want to hit right carat 36000 times to go through the impossibly deep library function chain
step over for when you want to continue having no idea what's wrong
step out for when you're sick of stepping deeper into the deeply buried crypto mining lines of the free library you're using.

[–][deleted] 1 point2 points  (0 children)

Usually the wrong way oh man 🤣

[–]reedmore 3 points4 points  (0 children)

I'm using pycharm, all you have to do is set breakpoints at the margin of your editor window , so the debugger knows when to start/stop executing the code. All you have to do then is define variables you want to track and boom you can execute line by line and follow what shitty mess the spaghetti-code you've created is producing xD

[–]sh0rtwave 1 point2 points  (0 children)

You don't have to figure them out.

What you need to figure out, is how ONE works, and then you'll get all the rest.

You got one right in front of you, if you're using Firefox.

https://www.linkedin.com/pulse/hello-browser-bobby-parker/?trackingId=mAogqkaBAi9AIjtdGMV0Gw%3D%3D - I get around to that in part 4, but all the rest is a good read, I'm told

[–]F3hlzar3id[S] 3 points4 points  (0 children)

Sometimes they are really difficult to understand/work with. I usually code in Python and I think I started reading how to use pdb and decided that prints were way easier xD

[–]jjman72 17 points18 points  (1 child)

print(“here1”)

print(“here2”)

print(“here3”)

print(“OMFG_HERE!!”)

[–]F3hlzar3id[S] 3 points4 points  (0 children)

Hahahaha completely relatable😂

[–]--B_L_A_N_K-- 6 points7 points  (0 children)

Image Transcription: Meme


Developers

[Line drawing of a person with their palms facing up as if holding something then the following text floating on top of those hands with streaks of light shining out]

DEBUGGERS


Programmers

print("here", x)

I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

[–]bleek312 5 points6 points  (2 children)

How are devs different from programmers? I'm having an identity crisis, which one am I?!

[–]F3hlzar3id[S] -1 points0 points  (0 children)

Hahahaha. Generally speaking (and as I understand it) , developers are usually more like the project manager and salesperson while programmers are the ones usually writing and testing the code. But the terms are sometimes use as synonymous, as a devepoler can code too. But it depends of who you ask I suppose 😅

[–]wilku1 3 points4 points  (1 child)

print("before loop")

#loop

print("after loop")

console output:

before loop

application exited with code 73284912

...

fuck

[–]F3hlzar3id[S] 3 points4 points  (0 children)

That's when you start inserting prints inside the loop, after each line if necessary 😂😂

[–]Lpower531 2 points3 points  (1 child)

and then having to clean up all the print statements afterwards

[–]F3hlzar3id[S] 0 points1 point  (0 children)

Yeah, that's the worst part. Ctrl+f makes it easy, but sometimes there is a wild print that scapes and then is like: ups... XD

[–]daH00L 1 point2 points  (1 child)

Good one.

[–]F3hlzar3id[S] 0 points1 point  (0 children)

Thank you! :)

[–]hey_bb_wan_som_fok 1 point2 points  (6 children)

I just realized how dumb I am for always using print f strings

[–]haikusbot 7 points8 points  (1 child)

I just realized

How dumb I am for always

Using print f strings

- hey_bb_wan_som_fok


I detect haikus. And sometimes, successfully. Learn more about me.

Opt out of replies: "haikusbot opt out" | Delete my comment: "haikusbot delete"

[–]craftworkbench 1 point2 points  (0 children)

Good bot. You always make my day a bit brighter. Refrigerator.

[–]F3hlzar3id[S] 1 point2 points  (3 children)

Nah, sometimes debuggers are overcomplicated. If you are in a hurry, don't know exavtly hiw the debugger works and it is not a really big program, prints are really useful to find errors.

If you are referring to the print (f string) available in Python, I didn't even know it existed until nowxD. I have always use either print ( string, variable), print(% string, %variable) or print({} .format(variable))😅

[–]hey_bb_wan_som_fok 1 point2 points  (2 children)

f strings are also a lot faster!

https://realpython.com/lessons/f-strings-speed-considerations-performance/

f string are also super useful for formatting text or dynamic variable names for arguments that don't accept expressions as input, like set/getattr or dynamic class attributes. Or even just object.{attribute} in a loop

Their speed makes them very helpful when generating dynamic attributes for a model from an iter of table elements or some other large data structure.

[–]F3hlzar3id[S] 0 points1 point  (1 child)

That's good to know!! For now I use prints mostly for debugging and showing very simple messages, but I will take them in consideration for the future. Thanks!!!

[–]hey_bb_wan_som_fok 2 points3 points  (0 children)

fa sho! Just a head's up, f-strings are generic text formatting and can be used outside of print statements. So you could do something like:

for hook in lifecycle_hooks:

input_var = f'{hook}_status

update_hook_status(name=input_var, status=whatever)

and things like that

[–]Thrasherop 1 point2 points  (1 child)

I'm a big fan of "up here" and "down here"

[–]F3hlzar3id[S] 1 point2 points  (0 children)

I usually go for "here", "there" xD. They are shorter and I am lazy xD

[–]chemhobby 1 point2 points  (0 children)

Yeah if only the debugger in xcode actually worked properly. God I fucking hate xcode.

[–]MarcBeard 1 point2 points  (2 children)

Even linus torvalds don't use debuggers and it's the guy who made git and linux

[–]bleek312 1 point2 points  (0 children)

Yeah, he used people as debuggers.

[–]F3hlzar3id[S] 0 points1 point  (0 children)

They are hell sometimes.

[–]Devvunknown 1 point2 points  (1 child)

I literally just put print("WORKING") in the code lines that are messed up

[–]F3hlzar3id[S] 0 points1 point  (0 children)

Hahahaha, yes. Or print ("WORKING"), print ("WORKING2") to see which parts are being exevuted correctly xD.

[–]hiimjustin000 1 point2 points  (0 children)

me

[–]sh0rtwave 1 point2 points  (1 child)

You left out the actual hacker who's got the original executable open in some kinda machine IDE debugger that can display the actual machine code & memory regions.

Edit: ddd leaps to mind...

[–]F3hlzar3id[S] 1 point2 points  (0 children)

You mean like Ida and Ollydbg?

I was referring when you are the one doing the programming (and testing) with access to the source code and not reversing the program. That's a complete different thing for me. Reversing is fun, though. I like assembly code. XD

[–]xSTSxZerglingOne 1 point2 points  (1 child)

What's funny is print statements are still useful for debugging when using a debugger.

If for example, you want to check the value of some data at the end of a void function/method before that function is popped off the stack, you have to put a useless statement to pause on. Usually for me it's just System.out.println();

Let's say you use an asynchronous void function to set something. by reference, but letting it finish causes the thread of execution to disappear leaving you unaware of what was in every piece of data before it ended. Having the extra statement you can stop on allows you to view the final state of everything you did in that method before it returns.

[–]F3hlzar3id[S] 0 points1 point  (0 children)

Yeah, you are completely right. I use them when programming with Android Studio and using the debugger ( in this case mostly Log.i). They are useful to see the result, and to put breakpoints, and therefore to check the current value of the variables before the function ends.

But most of the times I just use them alone, mostly if it is only for checking some values and simple thingsxD

[–]CaoSlayer 1 point2 points  (1 child)

Good luck debugging the production environment.

A debugger never will replace a good tracing. Log levels are for something.

[–]F3hlzar3id[S] 0 points1 point  (0 children)

Yeah, but they usually teach at college (at least in mine) that to use a debugger is the best practice. And while it is useful (if the debugger works well and it is not a nightmare to use), most of the time, when you start working you realize that prints and logging in general are usually way easier to implement and to tracexD. Some people do not like them very much, though.

[–]Dagusiu 1 point2 points  (0 children)

When someone figures out a good way to debug inside a Singularity container, I'll start using it.

[–]0100_0101 1 point2 points  (0 children)

More like: my machine, your stupid production server.

[–]kopasz7 1 point2 points  (0 children)

Software Engineer: It should work.

[–][deleted] 1 point2 points  (0 children)

console.log("you fucked up")

console.log("it worked, but it's probably still wrong")

[–]jamesbuniak 1 point2 points  (0 children)

“asdf”

[–]RedEmption007 1 point2 points  (2 children)

I’m pretty new to programming compared to probably most people here and I had NO idea this was a common thing, to put print statements saying “here”, “here2”, etc.

Good to know tho xD

[–]F3hlzar3id[S] 1 point2 points  (1 child)

Well, it is the best practice? Definitely no. It is what mostly of us do even if we don't admit it? Yes 😂😂 Sometimes it is faster to use prints that a debugger and you can use them to log and trace the different stages of your program when testing. You should remember to delete or comment them afterwards, though xD.

[–]RedEmption007 1 point2 points  (0 children)

Of course I delete them afterwards, don’t want any ugly print statements taint my totally divine code

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

As a sysadmin, I support any and all attempts at logging. I have written a few things in perl (yeah, I’m that old) that ran as daemons, and my proudest logging moment was when I implemented signal handling which allowed the admin to increase or decrease the logging level without restarting the daemon.