5 ms·
But it shouldn't require a full compilation. The ultimate result, given the slow compile times of c++, is that you cannot know in your editor if your code is c
by amiga_500 7y ago
But it shouldn't require a full compilation.
The ultimate result, given the slow compile times of c++, is that you cannot know in your editor if your code is correct.
- saagarjha 7y agoThe IDEs I have used, or IDE-ified editors, run compilation ("indexing", or whatever) in the background to make this work.
- still_grokking 7y agoMaybe you want to share which IDEs you've been using? It sounds like a wonder if there is one that can handle C++ in a way comparable to, say, IntelliJ for Java, or VSCode for TypeScript. My experience is frankly more that the usual IDEs I know of can't even handle syntax coloring 100% correct when it comes to C++…
- saagarjha 7y agoXcode for well-structured (read: Xcode) projects. Sublime Text with clangd for random editing (not an IDE, but it gets good autocompletion and syntax checking from it).
- amiga_500 7y agoThis is problematic on large code bases. Huge mistakes were made on C++ design.
- saagarjha 7y agoHow large are we talking about? I've been able to use these tools on codebases such as WebKit and LLVM…
- amiga_500 7y agoLLVM has 2.5 million lines of code, but I think it also depends upon the number of templated methods etc, not just LOC. I'm surprised you haven't seen this point made many times. It would be a full-time job on the internet asking people why they have code completion issues with C++ IDEs.
- saagarjha 7y agoNo, I know what you're talking about; this is an issue in general if you'd not using tooling that's aware of the ins and outs of C++. The point is that the IDEs I have used essentially run the compiler on the file, so they can actually understand what the templates are doing and get through them.
- Too 7y agoTemplates can inherently not be understood. It's duck typing 3 degrees of freedom with 3 unknowns. You need concepts which adds 1 known into the equation, (the final missing degree of freedom is the dreaded ctrl-click-into-an-interface-instead-of-the-concrete-class which is hard to avoid). Tell me one IDE that will give any meaningful information about buzz in the example below: template<typename T> void foo(T bar) { bar.buzz(); } Other than that, finding foo<T> is usually easy, i've had good experience with qtcreator or clangd, you just have to be very very sure that your include paths are correct, qtcreator is good in that it uses CMakeLists as project-files so all this is done automaticaly.
- shadowgovt 7y agoI completely forgot about this aspect of C++. I remember being surprised the first time I tried compiling a C++ library on my workstation and found I couldn't do so because my workstation ran out of memory. The library was Panda3D; I can't remember what kind of workstation I was running on at the time. It turns out if you use enough layers of templates, the compiler has to carry around an awful lot of state to figure out what program it should actually output. This is another downside to a 1400 page language specification; whether the user can hold most of it in their head or use a reliable, safe subset to avoid sharp edges, the compiler and tools still have to be aware of all of the layers of complexity in both the code a developer is writing and often whatever tricks and quirks developers chose to usein the libraries the developers code is depending on.