Remix.run Logo
shortrounddev2 5 days ago

OCaml is a great language without great tooling. Desperately needs a good LSP implementation to run breakpoints and other debugging tools on VSCode or other LSP-aware IDEs. I know there ARE tools available but there isn't great support for them and they don't work well

debugnik 5 days ago | parent | next [-]

LSP isn't the protocol that interfaces with debuggers, that'd be DAP. You're right that OCaml debugging is kinda clunky at the moment.

OCaml does have an okay LSP implementation though, and it's getting better; certainly more stable than F#'s in my experience, since that comparison is coming up a lot in this comment section.

StopDisinfo910 4 days ago | parent [-]

What’s clunky about the Ocaml debugger?

Ocaml has been shipping with an actual fully functional reverse debugger for ages.

Is the issue mostly integration with the debugging ui of VS Code?

anentropic 4 days ago | parent [-]

it was clunky AF last time I tried to use it https://discuss.ocaml.org/t/debug-ocaml-code/10867/18

and yeah integrating to VS Code debugging UI would be ideal

I really like OCaml, so I hope the community can continue to improve the UX of these features

StopDisinfo910 4 days ago | parent [-]

> it was clunky AF last time I tried to use it https://discuss.ocaml.org/t/debug-ocaml-code/10867/18

Yes, I see what you mean now. You encountered a bug around system thread and dune didn’t properly pass your artifacts. That’s indeed annoying.

I deeply dislike dune myself and never use it. I just use the Ocaml toolchain like I would a good old C one which might explain our different experiences.

nukifw 5 days ago | parent | prev | next [-]

Indeed, efforts should be made in terms of DAP (https://microsoft.github.io/debug-adapter-protocol//), extending the following experimentation: https://lambdafoo.com/posts/2024-03-25-ocaml-debugging-with-.... However, I find the assertion about tooling a bit exaggerated, don't you?

lambda_foo 3 days ago | parent [-]

Using DAP with VSCode and OCaml's bytecode debugger (https://github.com/hackwaly/ocamlearlybird) works reasonably well already. My blog post above can be modified to work with VSCode, but I'm primarily an Emacs user. The main issue with Emacs and DAP is the DAP modes are not very polished.

The missing piece for OCaml is debugging native code, the compiler doesn't emit enough DWARF information and debuggers like LLDB or GDB, need to be modified to understand OCaml's DWARF information. Even there DAP with LLDB/GDB works, it's just the debugger doesn't have enough information to work well. You end up working with debugging assembly or C (if it's parts of the runtime). I've written up a PR documenting native debugging here https://github.com/ocaml/ocaml/pull/13747.

dismalaf 5 days ago | parent | prev [-]

?? OCaml has had a completion engine for as long as I can remember (definitely over a decade) and it powers their LSP these days. I do know however that the community focuses mostly on Vim and Emacs.