If the intention of coding in Python is to get stuff done quickly, it seems a bit silly to handcuff yourself by avoiding one of the biggest time-savers.
If the intention of coding in Python is to get stuff done quickly, it seems a bit silly to handcuff yourself by avoiding one of the biggest time-savers.
x = 1
print(x)
y = 2
print(x, y)
And then instead of just running it, I'd have them step through the code, line by line, and observe both the console output and the debugger variable display.Some developers seem to think that using a debugger is a sign of weakness, or that it leads you to write bad code. I see it differently: the debugger is one of the best tools not only for debugging, but also to help you understand a complex codebase that you are jumping into.
Even the concept of the "print line" debugging into a lot file seems kind of foreign to them sometimes.
They instead rely on running the code, changing something, running it again, etc.
I am a big fan of reading through the code. That is almost always enough for me to find the issue and point it out to them assuming I understand the input and output context well enough. But if that doesn't work, add a debug point and fire it up. Not using a debugger seems like a massive waste of time in a situation like this. So much so that I have started asking "did you debug this" or "have you watched this happen in a debugger" before I will help out much. If they say "no" because they don't know how, I will teach them to do so.
Never met this term before - IIUC, SQL tracing is MS-specific? If I may ask, in what kind of situations would you use it?
Basically, it is just a journal of all queries (really ANYTHING going on in the db but for developers it is useful to limit to queries) and typically filtered by database and by keyword (e.g. table or stored procedure name).
You can set up a trace to track long-running queries on a production server (DBA might do this) or on a dev server a developer might use it to capture SQL run from their code (e.g. a complex stored procedure with a lot of input params) so you don't have to try to assemble the SQL using a debugger, for example.
A good example might be "I am doing everything right in code, but the data set is coming back empty" so you profile it and realize the SQL is being called with an empty string and not a null, or whatever. When reviewing the code you thought "it will be a null". That kind of thing.
Totally agree.
In the first week of programming, students should be allowed only use the debugger (no direct runs) in every course/collage around the world. I saw firsthand how many courses/collages students struggle with logic because debugging was never introduced, and they were unaware of how to step through each line.
Another mistake that new programmers make is writing 30 lines of code and then run and lost why bugs occurring. As a rule of thumb, they should debug/run the program every 7 new lines of code.
I was a print-line debugger for years.
Really? I have never encountered that in the last 18 years in any of the 8 or 9 places I've worked.
I've worked with many know-it-alls who both knew it all and didn't. With arrogant and humble developers. No one ever said that.
https://news.ycombinator.com/item?id=29387515
(See the last reply in that thread.)
https://news.ycombinator.com/item?id=19829435
https://www.javacodegeeks.com/2013/05/debuggers-are-for-lose...
I should consider myself lucky
I strongly believe there's a balance to be struck between getting started quickly and understanding how your code is run. Especially if it's an interpreted language like Python.
If you do understand opening a terminal in your project's repository and executing `python3 ./mypythonfile` then this should be prioritized. Even for noobs.
So many of my tools over the years have stuck with their simple command line initiation rather than wrapping into GUIs or other alternatives. Being able quickly write “python [whatever you are doing]” is awesome.
I want them to realise that code is just text files, same with html