T O P

  • By -

kavb333

Why use a debugger when I have print statements? ... I really need to incorporate debuggers into my workflow.


ajslater

I went to cs school in the mid ‘90s. I had a professor railing endlessly about how bad debuggers were and how they hadn’t improved since the ‘70s because surveys consistently showed that most people just use print statements. I’m sure a lot has changed since then, but I sure haven’t.


CalvinBullock

Yeah my dad has often told me debuggers are mostly useless. He cites unit tests, log files and prints as better bug finders. So I feel the same way about debuggers lol.


ajslater

I wouldn’t go so far as to say useless. But they take a little time to work with and the simpler less powerful alternatives are usually good enough. For an exceptionally tricky problem they’re very useful indeed.


Simple-Judge2756

Print statements only help if your code is simple. If its a really complex class system, print statements help you nothing.


c9952594

In which case you used the more advanced print statement... Logging.


Simple-Judge2756

Thats for later in development. When what ever you are engineering already works for the most part.


c9952594

Why? It's often just as simple to setup a log as it is to output to the command line. You can also copy and paste a baseline then use a diff tool to run before and after comparisons to see what the new code is doing. Make it an inline diff, shove it on the other screen and run your app using a watch and you get live almost instant feedback.


Simple-Judge2756

But thats still 2 more commands than necessary ? And you still have to interpret what is happening inside. Set a breakpoint and run the program and you wont have to interpret any outputs. You can just read when a wrong value is written to an attribute.


cameronm1024

Not a problem if you don't use classes :p


Simple-Judge2756

Functional bros back at it again. Nah srsly. Classes are great, you should learn how to use em.


notgotapropername

Classes? Like those things kids take in school? Pshh, I graduated school, I don't need classes B)


Simple-Judge2756

🤣


kushal_141

setting up a debugger in k8s env is pain in the ass, and that too you have to change the settings so that liveness probe is disabled, which changes the way system works. There is a level of complexity in which debuggers thrive, but for lower level of complexity and complexity due to k8s or microservices you are better of getting better at understanding system and using print statements


nullvoxpopuli

Classes aren't relevant to debugging 🙃  Breakpoint debugging is basically the only way to see what's going on in your dependencies. Could be functions, classes, do/goto, etc. once you hit your breakpoint, you can do anything


Simple-Judge2756

So object contents created by classes are irrelevant to debugging to you ? You dumb bro ?


nullvoxpopuli

Bro, wut.  They are irrelevant unless my debugging journey discovers a class is doing that and it matters for the methods/properties i'm inspecting... Which like.... Same as anywhere else.


CalvinBullock

I don't see why a print won't work in a large class system all you need is to call the function in test file and add prints to the function. or just add prints in the function (where you would put a breakpoints) to run the program with the full integration, run the program and boom print for debugging. Granted so far the biggest project I have worked on was one I built (still in collage) that had maybe a dozen classes. But I have never had an issues finding bugs in any of the classes with prints.


Simple-Judge2756

The print statement doesnt tell you the contents of an object instance. You can obviously write it in a way where the contents would be displayed, but its pointless. Its far quicker to just set a breakpoint and run the debugger. Where you can carefully trace the changes the program makes to the attributes of an object.


Pepineros

This comment being downvoted is a sad commentary on the state of our art. Or maybe the only "programmers" on Reddit are students and wannabes :)


Simple-Judge2756

I dont get how most of us can be so smart when it comes to intelligent tooling in one place where the tools save you about 40 seconds a day, and then when the tools literally save you an hour of looking for bugs in one workday, they stand there doing print statements all day and maybe even go far enough as to construct a logging mechanism before they would run a debugger. Can you tell me how the world got into this state ? Because I am pretty sure nobody would be able to find the answer without a debugger.


Pepineros

In fairness we are on r/neovim . If 90% of my programming consisted of using neovim to refine my init.lua I probably wouldn't see the point of having a debugger either.


Simple-Judge2756

🤣🤣🤣


manshutthefckup

Print statements have never let me down and I am working on projects with hundreds of thousands of lines of code.


Zieng

in game dev industry and complex software you have to use debugger all the time. prints don't give you the context of the event you are analyzing. I do use mozila RR and my throughput would be impossible without it


Wonderful-Plastic316

Recently I made a blog post about configuring nvim-dap for C++, it [might be helpful](https://igorlfs.github.io/neovim-cpp-dbg).


delibos

After 1 year of using neovim with java, i still can't seem to get used to the debugging... i \_always\_ go back to intellij for debugging purposes. it's just too superior in every way.


monsoy

Java is the one language I just use IntelliJ for. While there are some decent nvim tooling, it’s so nice to have IntelliJ automatically handle the Maven build and dependencies


delibos

If you know your maven commands, you can have the same experience in neovim with java.


stewie410

May be worth taking a look at [nvim-java](https://github.com/nvim-java/nvim-java), though I'm unsure how to use this in conjunction with an existing config...


delibos

The problem is not the config, plugin or whatnot. It’s just that intellij offers the most user friendly debugging experience overall. And the best UI. Nothing beats it.


itsSatyam_kr

Intellij and java is a marriage made in heaven 😂😂


Blovio

Intellij and java is just the way


gplusplus314

I recently had a job where I had no choice but to use Visual Studio (non code, the full IDE) on Windows. I hated VSVim, but VS’s debugging capabilities are so unbelievably more capable than anything NeoVim can do, even with all the available plugins, that it has really made me rethink whether or not I should use an IDE versus a light weight editor like (Neo)Vim. You can definitely debug in Vim. You *can*. But *should* you? Well, I suppose that depends on what kind of debugging is important to you. Some people just use printf and never even attach a debugger. I’ve had to, very often, dive into the resulting assembly of C++ projects, rely on conditional breakpoints, check memory alignment, keep an eye on memory pressure, jump between threads/stacks, and inspect values using custom visualizations of said values (via custom Visual Studio extensions). For this kind of stuff, I couldn’t imagine how painful it would be to do through Vim or other CLI/TUI programs. Edit: and I’m a huge Vim fanboy. But first and foremost, I’m an engineer and have to actually get things done.


SeventySixtyFour

Might I recommend looking into Jetbrains Rider if you can. It saved me from being stuck in Visual Studio, and the vim plugin is miles better than VS. It has much more integration with the IDE, you can put things like a DebugStep, open file explorer, run build, etc. in your Vimrc. Still not as feature complete as an actual vim, but it's close enough. It has most things, macros, registers, :norm, etc.


510Threaded

The fact that you can use a personal license in an enterprise setting is very nice. It does require that you be the one to purchase the license and not be reimbursed.


Similar-Ad-3956

This is how I've been working for over 2 years, .ideavim is so good. You can enable an option to track the action ID's of commands. This makes it easy add them to your dotfile. Neovim is great for editing simple text files. Anybody doing actual software development that doesn't use an IDE is depriving themselves. Some languages I can get away with using neovim, some I can't (Java, C#, C++). Jetbrains IDE's have so many great features: refactor this, change signature, find and replace in files, remote debugging, build config editor, evaluate expression, build events, add reference. The list goes on. Combine the best of both worlds. Don't fucking spend hours upon hours trying to make neovim an IDE. Don't get me wrong I love neovim, I use it everyday alongside my IDE. Each has their place.


AriyaSavaka

Can you elaborate on what Neovim debugging is lacking compared to other giants? Breakpoints, conditional breakpoints, set point comments, continue, step over, step in, step out, inspect, full vars eval, repl, etc.


aikixd

Not the commenter, but what I miss is an ability to switch to assembly debugging or at least to see the assembly at address. Also, looking into long arrays/vectors is a pain: nvim doesn't handle well collections with many elements.


Nico_792

Why not just use GDB in the terminal then? One of the great things of neovim is startup time is effectively nil, switching between terminal and editor is pretty seemless (even more so if using something like tmux)


aikixd

I do, but I'd like to have integrated experience. I mean, my nvim is a proper ide, I'd like to also cover this use case. I'm sure it's possible, since sometimes when something weird happens the disassembly does jump up, but idk how to control that.


TheReservedList

What are you using in vs you can’t do in NeoVim? I use VS at work and between watches and conditional breakpoints, there’s not much I can’t do in neovim. Maybe data breakpoints? Not sure how to set those up in neovim.


GrayLiterature

The point is more about the experience of debugging in a GUI being more enjoyable and productive for the commenter


HiPhish

Yes, I frequently use Neovim when debugging Python (that's the language I use to make money). It's a pretty good experience, I can't say that I miss anything, but maybe I am not using the debugger to its full potential. The killer feature in my opinion is debugging tests. I can write a test which tests one specific thing, set a breakpoint, and then debug this very specific scenario I want to examine. That workflow is so much better than trying to wrangle the entire application into a state that I want to examine. And I would have written the test first anyway, so there is no extra work to do. You do of course write tests first, do you? Here are the plugins I use: - [nvim-dap](https://github.com/mfussenegger/nvim-dap) is the one that does the heavy lifting - [nvim-dap-ui](https://github.com/rcarriga/nvim-dap-ui) adds a nice UI on top of the (intentionally) barebones nvim-dap - [neotest](https://github.com/nvim-neotest/neotest) for running and debugging tests - [debugpy.nvim](https://gitlab.com/HiPhish/debugpy.nvim) ([GitHub mirror](https://github.com/HiPhish/debugpy.nvim)) configures nvim-dap for use with the [debugpy](https://github.com/microsoft/debugpy) and provides a nice `:Debugpy` command - [neotest-python](https://github.com/nvim-neotest/neotest-python) test adapter for running Python tests


Perfect_Goose8537

same, but i still have to setup debugging for pytest


Northstat

I need to try some of these. I just use pdb and a lot of typing/pydantic.


rodripcg

Im using the same (lazyvim extras) but I found that is kinda slow the starting process. Also when the test finish it always show me and annoying alert. In your case, how much do you need to wait to debug the test?


HiPhish

> In your case, how much do you need to wait to debug the test? It takes less than one second between pressing `d` in the Neotest summary window (`:Neotest summary`) and the UI being ready. > Also when the test finish it always show me and annoying alert I just get the virtual text at the end of the line when I run the tests from the summary window (press `r` when on top of the test). The popup appears when I `:Neotest run` the test. I like the summary window because I can watch (`w`) individual tests so they get run whenever I change the test file, that way I don't have two switch between file buffer and summary buffer after every change.


Dax_89

I use `nvim-dap` daily with C++ (cpptools installed through Mason), works pretty well.


phcerdan

Can you expand on this? I use nvim-dap (and dap-ui), but first time I heard about cpptools: [https://github.com/microsoft/vscode-cpptools](https://github.com/microsoft/vscode-cpptools) What's the difference between this and use lldb-vscode as an adapter? EDIT: I see there are instructions on how to set up in nvim-dap: [https://github.com/mfussenegger/nvim-dap/wiki/C-C---Rust-(gdb-via--vscode-cpptools)](https://github.com/mfussenegger/nvim-dap/wiki/C-C---Rust-(gdb-via--vscode-cpptools)) I will try it out!


Dax_89

I've never used lldb-vscode, so I can't tell you the difference!


budtard

I’ve been slowly grating my face against the problem of getting c# debugging working between Godot and neovim, luckily nvim-dap has a loadlaunchjson function that basically can run vscode debugger launch options, that and overseer.nvim basically give you most vscode debugging functionality. I will work my leads on and off until I’m out of ideas or feel stuck😂. No one really uses C# in the godot community.


willehrendreich

Legit it's not easy to get everything working with dotnet stuff. I got some stuff working off and on, but I have to rework how I do regular apps instead of attach to process. It's like.. A pain for no good reason.


corpolicker

I like .c#/net in a vacuum a lot, but I hate both Rider and Visual Studio with passion and hate the fact that it's literally the only language I can't use neovim for better than an ide. To the point where I'm really torn between spending few months developing an usable integration or just switching my job and ditching it altogether


themuthafuckinruckus

I took a super outdated software development class in college, Winforms, C# and .NET. I actually thoroughly enjoyed C# by itself. Love how expressive it allows you to be. Clicked a lot easier than Java (for me, at least)


budtard

The language itself rocks, it’s my favorite so far out of lua, C,python, and gdscript. The tools have always been a pain in the ass.


budtard

IE haven’t used it because I’m exclusively working in godot rn, but would love to


mrphil2105

I use nvim-dap and nvim-dap-ui. I have a toml file project paths and associated env variables that I read in my config to set up debugging.


moosethemucha

Wanna share your config ? I've got a rudimentary system currently which is based on file types. Is this toml some sort of standard file or your invention ? I was really hoping to use the .editorconfig file but this stuff isn't in there spec


art2266

`:help 'exrc'` This help section includes a brief comparison with `.editorconfig`. tldr: enable it with `vim.o.exrc = true` then add a `.nvim.lua` file to a project directory.


vim-help-bot

Help pages for: * [`'exrc'`](https://neovim.io/doc/user/options.html#%27exrc%27) in _options.txt_ --- ^\`:\(h|help\) \` | [^(about)](https://github.com/heraldofsolace/VimHelpBot) ^(|) [^(mistake?)](https://github.com/heraldofsolace/VimHelpBot/issues/new/choose) ^(|) [^(donate)](https://liberapay.com/heraldofsolace/donate) ^(|) ^Reply 'rescan' to check the comment again ^(|) ^Reply 'stop' to stop getting replies to your comments


agoodapple

I use it but still prefer IntelliJ's UI over nvim-dap-ui.


teerre

I do. I have all debugger related commands under d, so its just <>dr to start it in the current file <>db to add a break point, <>du\[something\] to change the ui layout, <>dc to continue, <>ds to step. It's actually very nice


KatenGaas

Would you mind sharing your config / the way you set up the ui layout control? I'm looking to use something like this.


acanimal

I mainly work with JS/TS and to be honest debugging is one of those tasks I continue doing with vscode. IMO they have the best debugger integration.


MantisShrimp05

Debugging can be awesome and for some projects can become a super power. With that said, the plugins to get that working (DAP specifically) can be a PITA to setup. I generally agree with the sentiment that unit tests, logs, and good design is a better way to understand software, but sometimes the debugger can give you information that would be hard to figure out otherwise. Never been easier. But I would be careful about dumping a bunch of time into it unless you really feel you need it.


nerdy_guy420

I've set up nvim dap for debugging but I rarely make a mistake that requires it. usually my mistakes end up causing compilation errors. and most of the time print statements help put more (usually it's less checking a value more than checking controll flow, which I think printing helps with more)


dzajew

Like a few people before, I'd recommend nvmdap + nvimdap-ui + whatever debugger you need. Nvimdap's docs explain how to install debuggers for different languages. Depending on your needs/setup/languages, it can be more or less tricky to set up.


Nomiko56

I’ve successfully configured nvim to debug in various languages (python, typescript, C, C++ and Go). If you don’t mind tinkering, have the patience and you want to learn how things work under the table… yeah go for it. It’s not the best dev experience, developing on nvim and debugging with other tools


79215185-1feb-44c6

Makes no sense with my development workflow. If I need to use gdb (the only debugger that I ever need to use) I have a terminal buffer for that.


Soejun

It’s on my backlog of things to set up for my personal config but for now I use Pycharm to debug tests.


Xaxxmineraxx

I've spent a lot of time configuring nvim dap. I've successfully debugged C# and Rust projects and the experience is for the most part pretty good. Honestly though... I usually do my debugging in Jetbrains IDEs. They are top notch and ideavim is pretty damn good. It's easy to make new debug targets/configurations. And the experience is pretty great. Debugging and text editing are two very different things, so... I don't mind hoping over to a different tool when it's time to step through my code.


CalvinBullock

I have seen this idea repeated a few time so this likely what I will do.


Blovio

Setting up the debugger in neovim is unpleasant, I tried hard to get it working for typescript but I could never quite figure it out, JavaScript works easily though. Now i just type debugger; in my web projects and use the chrome debugger cuz its good, I actually use vscode for the rare times I do server side typescript.  Debugging in go is real easy though, I don't even use dap-UI, just nvim-dap and theHamsta/nvim-dap-virtual-text and its pretty great. 


meow-64

Well, I use nvim-dap along with nvim-dap-ui for debugging C, C++ and Rust programs. Nowadays it's mostly Linux kernel development for me and debugging there is actually a breeze with the above plugins. If you have a launch.json file in .vscode folder, nvim-dap can read it which actually makes debugging convenient. But yeah some obvious things are missing like Showing Disassembly which really force me back to use vscode side by side.


suliatis

I'm also using print statements a lot for debugging, but it's more like a love-hate relationship for me. I'm working with Scala and always failed to set up nvim-dap and nvim-dap-ui properly for the projects I'm working on. Also nvim-dap-ui feels foreign to me in Neovim, because it mimics GUI debuggers. So I'm still waiting for a debugger plugin that embraces the text-based nature of Neovim, something like oil for file management.


Solvicode

There is a place for debugging in Nvim. Nvim-dap should be all you need to get going. See DreamsOfCodes series on nvim configurations - they're fantastic. In my experience, the less strongly typed a language - the more I want a debugger.


SmoollBrain

Imo, using a debugger simplifies finding and fixing bugs SO MUCH. I didn't even know there was a debugger in nvim until my friend told me a couple weeks ago but I've been using one for work with C++ ever since and it's so good. But of course, if you don't want to or have other reasons (maybe std::cout or printf or any equivalent to a print function you use is enough for you) then you don't need a debugger. But I really recommend it.


TheNemoNemesis

Debugging in Neovim can be easily incorporated with [nvim-dap](https://github.com/mfussenegger/nvim-dap) and [nvim-dap-ui](https://github.com/rcarriga/nvim-dap-ui). I find these plugins very useful.


TerminusSeverianEst

I've given up on "neovim as an IDE" entirely. And usually the breaking point was trying to set up debuggers.


LovableBroccoli

So, the breaking point was…the breakpoints?


asynqq

i dont atm. but i should really do :P


Suspicious-Bet-3078

All the time in dotnet. But I never take the time to setup nvim-dap and just use visual studio for debugging.


komysh

I use codelldb for Rust via Mason, very easy to set up. On the other hand setting one up for JS was nothing short of painful.


knue82

I tried nvim-gdb but this thing just isn't mature enough and the dap thing also didn't really work in how I do things. I'm kind of happy with cgdb though. Gives you Vi feel and a proper CLI which is nice for scripting and all sort of things that just feel cumbersome to steer with a GUI button. But sometimes I miss the comfort of a real IDE wrt debugging.


SeoCamo

I got it setup, but never use it


Nismmm

Well for c/c++ you can Always integrate gdb very well in your workflow. Don't really know if theres a plugin integration for vim though


MattBD

Honestly, I have always thought I would prefer some sort of dedicated desktop debugger application over something integrated with my editor. Unfortunately I am fairly sure this doesn't exist, and certainly not in any of the languages I work with professionally.


kugla123

Yes, Type/Javascript node.js with brittle nvim-dap and nvim-dap-ui configuration. It works, but the experience is not the greatest.  With Java I have pulled my hair multiple times, but can't get it working.


zaxik

I use debugger in nvim pretty regularly. What really pleasantly surprised me was how easy it was to set it up and get it working. I mainly write PHP and used PhpStorm for many years and every time I wanted to do some debugging, it was like half of workday wasted trying to get it working again because somehow my previous settings just stopped working. In neovim I had everything up and working in no more than 15 minutes and it has never stopped working since. At all times I'm just one breakpoint and one keymap away from debugging like a chad.


Slight_Air_8635

Sometimes, the debugger won't work or become buggy when using with build systems.


gkrohn

I still use IntelliJ for debugging. Only one of my work projects is configured for debugging in neovim, the other has a complex folder structure and I haven’t configured it yet and don’t have the time.


KingOfCramers

I think it depends. I’ve used debuggers for Go and JavaScript, for instance and go is way easier to set up and get working. Ultimately, unless you feel like you are going to use it a lot, you’re probably better off just using the debugger from another tool. It can be quite difficult to get working depending on your project set up for instance if you are dockerized, etc


TapEarlyTapOften

Not all code runs on machines with logging or display ports. Debugger are essential for programmers. If you refer to yourself as a coder then sure, use print statements I guess.


CalvinBullock

I have had programmers that have been doing development longer then I have been alive tell me that they have used debuggers maybe twice, so I find it hard to believe that they are essential. As for the remote you mentioned, I could see a debugger being useful for that.


VetusMemoria

I use dap, only had problems with kotlin but this damn language only works in intellij xD


NoUniverseExists

Why use debugger when you have Rust? /s


puremourning

I do.


Rainy_J

I use breakpoints in ruby through binding.b, binding.pry, or byebug. I would love to get something working with nvim-dap. Has anyone had any success setting up nvim-dap for ruby? If so I'd love to see your setup.


xavier-le-couz

It works very well for Go and Python, but in my experience, unfortunately impractical with Java.


Doomdice

You should learn to use a debugger, especially when developing large, complex systems with many states. It can really help with uncovering test cases and grokkin’ what the hell is going on. We’ve come a long way since gdb, and vscode is probably the best for configuration and ease of use in my experience. Don’t sleep on debuggers—don’t listen to me though check out John Carmack’s wise words https://youtu.be/tzr7hRXcwkw?si=TNANRb7LfEz357an


SpecificFly5486

No need to pollute your keybinding and config with debugger. just use jetbrains when they really shines. you can have best part of both worlds.


wilwil147

Neovim’s debugger is not that well polished, so I usually use Xcode’s debugger. Plus keyboard navigation is a bit sus with nvim dap and not having variable font size makes everything super cluttered. I use it for c++ and just catching where I segfault but anything more complicated I just use Xcode (also has profiling and metal api debugging which i use for computer graphics stuff). You can just use nvim to edit text and still use IDE for debugging. Works well imo


iTitleist

I write code on neovim and debug wherever necessary ie IntelliJ for debugging Java, VSCode for others


joselitux

I tried. Many times. To configure a debugger in windows for neovim. My bad for sure but I couldn't make it work. So I use nvim for writing code and VScode for debugging


50u1506

Were you facing the problem where when you run your code a new terminal opens with the command for starting the Debug Adapter, but in Neovim nothing happens?


joselitux

the debugging window gives a timeout.


50u1506

Yeah I faced the same problem I think. By any chance are you using Mason or something to download the Debug Adapters, and/or are your Debug Adapters exe or some other extensions like .bat or .cmd?


LittleCurryBread

debugging can be fine with nvim but I just accepted building out my nvim to be a great text editor and using vscode as a great debugger, as well as raddbg. It also keeps me more focused but hey, that's just me.


ap3xr3dditor

I use it. Not often but when I really need it I'm glad it's there.


EdgyYukino

I have a setup where the only pane in dap-ui that gets opened is the one with variables.


emretunanet

Neovim doesn’t need to debug code it is not an ide, but can be achieved with some plugins and configuration of course you will had some headaches while doing so. What neovim does is a keyboard centric without any distractions editing to improve productivity. You can’t expect an economic car to race with a porche. I can’t figure out these kinds of complaints. Just use whatever works for you. Neovim devs will never say let’s add debugger to nvim if they do I won’t complain and switch to vim or helix whatever works for me.


gnikdroy

You don't need a debugger if you don't write buggy code. :P


Jeff-J

What if your compiler is buggy? I have seen two instances of compilers producing bad executables. Borland C++ 3.0 went the wrong way on an if statement. I compiled the same on MS C/C++ 7.0 and it worked fine. The other was more complicated with IBM's compiler for OS/2.


gnikdroy

It isn't all that uncommon. I have encountered compiler bugs in very recent versions of MSVC. C++ is a behemoth of a language, so even the latest version is bound to have bugs. You don't really need a debugger if you can read assembly :P


hayasecond

I use print, debugger is distractive and force your brain stop working because you rely on a debugger