Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I write a bunch of C for various projects of mine and i do it in an editor with some C understanding (it varies by which, but the latest combo is Kate with a Clang-based LSP, however i've also used "plain" text editors with barely if at all any understanding like Notepad++ and Geany, both of which give you at best word completion with words they picked up from the buffer without actually knowing what they mean).

I also write Free Pascal using Lazarus, an IDE which actually understands the language at a deep level.

The experience writing the latter is way *WAY* better than the former and my opinion to that isn't "just write more in Free Pascal" but "i want an IDE for C that is at least as good as Lazarus is for Free Pascal".

I want a C IDE that, among others:

1. Can understand the code so that when i, e.g., want to rename the identifier "foo" it doesn't try to rename it as a keyword but knows if it refers to a local variable, global variable or struct member and only update references to that.

2. Can understand the code so that if i use a symbol defined in a header file that the current module doesn't include by itself it can put it in the includes section automatically (or at least ask me to) instead of waiting for the compiler to fail. If there is some conflict (e.g. because the symbol definition depends on macros or whatever) it should be able to understand that.

3. Can understand the code so that it can move structs, functions, etc around in modules and update header files and their uses in other modules automatically.

4. Can understand the code so that it can convert a struct defined in a header file to an opaque struct and vice versa, for the former being able to tell me which existing code would break and offer fixes (e.g. automatically creating accessor functions for the members).

5. Can understand the code so that it can expand macros in place visually, allow me to edit the macros expanded in-place while actually modifying the header file (or wherever the macro is defined) and also quickly tell me where the macro is used in other places.

6. Can understand the code so that it can convert code to functions, expand functions inline (with any local variables being placed at a decent position and any conflicts handled - it can ask for example if it sees the inline code to use "for (i=1; i<10;" and the existing code also has a "int i" if it should reuse the "int i" or replace it with heuristics that provide decent defaults), add/remove arguments (with automatic updates wherever they are used), etc.

7. Can understand the code so that one can create queries like "replace all string literals to non-static functions whose name matches the '^foo_.*$' regex with calls to macro 'TXT' and the same string literal as the parameter to macro".

8. Has a debugger that works with all the basics (breakpoints, step in/through/out, watches, etc) and...

9. The debugger can modify a variable while the program is running.

10. The debugger can make function calls while the program is running.

11. The debugger can modify a function while the program is running (any new calls are done to that function).

12. The debugger can watch data over time and be able to display values in various means like various graph types.

13. The debugger can tell you where (in code) some use-after-free was originally allocated and then where it was freed and where it was used, all with nicely shown arrows, hyperlinks and graphics directly inside the editor instead of you having to manually parse (in your head) some callstack. Similar for other types of errors like accessing invalid pointers, array data out of range (should tell you both the range and the accessed index where that can be statically inferred), etc.

14. The debugger can put conditional breakpoints which:

14a. Can call functions defined in the program.

14b. Can check if the breakpoint comes from a specific callstack (e.g. break if function "foo" is called from "bar" but not from "baz").

14c. Can access local variables and arguments up the callstack (obviously the breakpoint will only break where that is possible).

15. There is a profiler that works and...

16. The profiler can create call-based profiles (think gprof) and statistics-based profiles (think perf).

17. The profiler can record the full callstack instead of just the function name.

18. The profiler can create full call diagrams (see Luke Stackwalker[0] as an example) as well as flamegraphs (see some perl script for perf i don't remember).

19. The profiler can keep track not only where* but also when* a sample was taken so it can create profile timelines. Actually just have it do everything i had a profiler i wrote some time ago for Free Pascal[1], including be able to be instrumented by the running program, filter via thread, call stack depth, etc.

20. The profiler can call functions in the profiled program to create additional profile (e.g. if you want to count how many files are opened or how many rays your raytracer is casting or whatever so you can use the full profiler functionality instead of hacking up your own)

21. There is a static analysis tool that works and...

22. ...works like whatever Xcode's integration with Clang's analyzer is, i do not have much experience with those but i remember using it a couple of times years ago and thinking it was neat. I haven't seen any other graphical integration of a code analysis tool, pretty much every other analyzer feels like compiler warnings++. More of the graphical approach and less of the warnings++ approach please.

23. There is some form of project management / build tool / whatever that the IDE uses and...

24. The IDE can let you setup various "configurations" for build options (including preprocessor defines, which files/objects/libraries are to be included, etc) that can be mixed and matched at will (e.g. a "lightweight" and "full" configuration set could be mixed with a "win32" and "linux" configuration set with the latter relying on the "unix" configuration and none of those would need you to duplicate any information).

25. The IDE can know about libraries, be able to locate them as well as place them in appropriate locations when you are building a library. Libraries should be able to be built as both statically and dynamically linked if that is needed. If a library A relies on another library B and a program uses library A it should not need to also specify library B too - in the exceptional case where that is needed (e.g. there are alternative versions of library B) it should allow that but it should not be necessary.

26. Setting up the above should not need to be done via arcane text files but via a nice GUI that doesn't hate the user - e.g. using a library should not need you to type it's name but allow you to check next to its name in a listbox with checkboxes (with name filtering and categories). It should also know about different system libraries for the same thing (e.g. OpenGL in Windows, Linux and Mac is accessed via different ways). This should be configurable, not hardcoded - a custom library should also be able to use that functionality. Note that all of this can be stored in text files (e.g. for easier VCS support) but not needed.

27. More of a #26b but i think it deserves its own point: in addition the IDE should have deep knowledge of what a library offers and like #2 if it knows a symbol being offered by a library it should automatically add it to your project's requirements.

28. Again more of a #27b but also a #2b: it should be able to clean up any unused stuff (either automatic or explicitly). In total i should, e.g, be able to use OpenGL by typing "gl", pressing the auto-complete key (ctrl+space or whatever) and have the IDE suggest all the "gl" prefixed functions like "glClear", then once i select "glClear" (or whatever), the IDE adds the #include <GL/gl.h> header and the libgl library in the dependencies. If i press Ctrl-Z to undo that, the header files and library dependencies (if added) will be removed. If i press Ctrl+S to save or some other key to cleanup the project (depending on the configuration), any unused headers and libraries should be removed.

I could write for more but basically i'd like an IDE (i haven't touched topics like VCS support and how i'd like to be able to see and use different version of the code from inside the IDE - like e.g. go back in time to a different function while the debugger is running - or anything that has to do with GUIs) that is smart and helps me get rid of all the manual drudge,

(also FWIW little of the above is provided by Lazarus and i'd also like Lazarus to do all that where it makes sense but it still does more than pretty much any C IDE i've used)

[0] https://lukestackwalker.sourceforge.net/

[1] http://runtimeterror.com/tools/fpwprof/



Your list got long so I did not read it all.

I wrote some simple C a while ago and my go to IDE (which ostensibly says it supports C/C++ out of the box) wasn’t working, and since this was just a dabble, I was really not interested in fighting the IDE.

And, mind, I haven’t touched C in 20 years.

So I fired up Xcode. And, boy, that was easy. For my silly thing, I fat fingered and left thumbed my way to success.

No doubt Xcode has its critics and limits, but for my 3 hour project, I got to focus on my code and not the IDE.

I have another, more substantial pure C, not Mac specific, project I’m thinking of starting, and I’ll go with Xcode until it fails me.


>No doubt Xcode has its critics and limits, but for my 3 hour project, I got to focus on my code and not the IDE.

XCode has to carry a lot on its shoulders these days - C, c++, objective c, SWIFT and a lot of GUI editors, so it's impressive for what it is.

But it can easily support simple c/c++ projects, I've actually developed apps there and then ran them on linux, sometimes with the odd #ifdef to make it compiles on linux, but the dev experience on XCode is better for me than anything I can get on linux.


https://projects.eclipse.org/projects/tools.cdt

Really. I'm not kidding. It's all there. Not for everybody but /clearly/ very much for you. (Unless you move the incredibly complex goalpost you've set up here).

It has a learning curve to configure and to use but if the above 28 is what you want as you say you /can/ have them all.

All of them. For real. Working. It's on you now.

29. vim or emacs keybindings if you want that.


All of them? Including things like the modify a function while the application is running, either directly or using an old version from VCS and things like know all the available libraries, the symbols they export and what header files to include to use them and then be able to do that "type gl, press ctrl+space (or whatever), have glClear (or whatever) show up and have the IDE automatically add #include <GL/gl.h> at the top and 'libgl' as a required library on Linux, 'opengl32' on Windows and 'OpenGL framework' on Mac OS X with Ctrl+Z undoing all that stuff"?

If so i'd be impressed - and TBH ~17 years ago i did use Eclipse CDE and found it superior for C and even C++ code compared to what i saw people praise MSVC for (though MSVC's debugger was better than the GDB front-end functionality Eclipse CDE provided), so i don't think it is unlikely. I do remember it having some neat integration with Trac back then too. I mainly stopped using it because the computer i had at the time struggled to run both Eclipse and Mozilla at the same time :-P. But ~17 years ago i always praised it with the only annoyance (resource usage aside) being that weird "workspace" approach, but that was minor.

I didn't think much about it because it seemed to have fallen out of fashion since then so i thought it is just limping along.

I think i'll be trying it out then :-) perhaps it is time to go back to Eclipse CDT if that is the case.

EDIT: eh, tried it, not impressed. First of all Eclipse crashes or hangs almost every time i try to edit the settings.

Then i tried to make a test library, "librola" (random name) to be used by a program "rolathing". First i made the library using the managed C project with the "Linux GCC" toolchain that was already available. Typed some methods "int rola_init" (dummy, sets some static initialized variable to 1), "int rola_gimme" (returns 42) and "void rola_shutdown" (sets the initialized variable to 0).

1. I forgot to mention it in the above but Lazarus and other IDEs already have this anyway and it seems Eclipse CDT also has it, except it doesn't work: i tried to have the IDE generate the bodies for these functions in a C file (that didn't exist yet) using the "Implement methods" command that seemed the most appropriate (and i couldn't find anything else anyway) but that didn't work. I thought it was because there wasn't a C file so i made an empty one with the same name as the header file but again it didn't work - even after adding an #include in the C file for the header file it didn't seem to match the two. So i typed these by hand even though i believe it should either use the C file with the same name as the H file (a common use) or at least ask me.

2. I made a C program with managed C project and added a new "main.c" file to it. I typed "rol" and pressed ctrl+space to see any suggestions and there were none, so it basically failed #2 and #28 above. I typed the code manually, used printf to print out the return value of "rola_gimme" and even after saving there were no errors or warnings at all even though the C file had no include files at all.

3. Tried to compile and as expected, it failed. There were no quick-fixes or anything else i could do from inside the IDE - there was an "info" message that i should include stdio.h to get the printf definition but the IDE wouldn't help there by adding it itself, i had to manually type the code. And TBH most likely that message came from the compiler and the IDE was oblivious to it anyway. Obviously no message about which file to include to get the rola_init, rola_gimme and rola_shutdown definitions, let alone doing those for me.

I lost interest at that point because it not only was unstable but also failed at the first thing i tried that would show the IDE really understood the source code. Note that this whole "automatically add header files" isn't even something i came up with, i remember a trial version of C++ Builder i tried years ago to do that and while i didn't check to see if it only does it for the header files that come with it or also for your own libraries, the latter would be an obvious thing to do anyway as the library was already part of the workspace and thus known to the IDE - and Eclipse didn't do either anyway.

But just in case, i tried to at least try the debugger so i thought to add the reference manually - which i did but Eclipse crashed every time i pressed the "Apply and close" button. However restarting it seemed to have the setting applied anyway so i could at least try the debugger. And at the end i couldn't figure out how to convince Eclipse to use the shared library project next to the program project, no matter what i tried (i'm sure there is a way but IMO all i should have to do is, as i wrote in #26, check the library's name in a listbox with all the available libraries - and FWIW there was such a thing but it did absolutely nothing, Eclipse only started realizing there is a library somewhere when i started adding in paths, etc, manually but i failed to make it build).

So at least i wrote a "int foo() { return 42; }" (in more than one line :-P) in main.c and then have an endless loop in "main" and run the program under the debugger. The program wrote a bunch of "42"s in the stdout so i put a breakpoint in "return 42;" and modified it to "return 48;" - then continued and... nothing happened, it kept outputing "42". I tried to rebuild the "current source file" and even "rebuild all" but it didn't change, i had to restart the program, thus failing (as far as i can tell) #11.

On a semi-positive side i made a "int lala(int x, int y) { return x*y; }" and the debugger was able to run this function, but then when i tried it with something a little more practical like implementing a very simple strlen "int lala(char* s){ int l = 0; for (;*s;++s,++l); return l; }" it failed with some weird errors.

So, eh, i don't think Eclipse CDT is it :-P.


Well I missed that. No you can't modify running code in C and hope it's going to end well unless your C program is carefully designed to allow that.

You'll have to set paths on the installation or project so it knows where the relevant libraries and headers are. You won't configure it all correctly in the first week.

If you do give it a go, use a makefile project. If you're using something else to build, just have the call to that in the Makefile and nothing much else. Maybe it does cmake etc now? Haven't tried. I only use it occasionally nowadays. Brilliant for any refactor.


Check my edit, i did try things and didn't work out as i described in my post.


You have to want it to succeed and do some work to make it function the way you want. It does work if you care to put some time into it when you're /learning/ how it all works. I did, works great for me but isn't my nirvana. Just another useful tool.

>So, eh, i don't think Eclipse CDT is it :-P.

Don't confuse, "I didn't get it to work first time with very little effort" "does not work" Also note that like any complex tool, once you've worked it out, which takes time, you don't have to do that again. Like the people who say vi is garbage because you can't quit.

If you don't spend the time and give up early, that's fine too and shows you how much you do or don't want these things and /any/ answer there is by definition correct.

Edit: Editing a post above a response with wholly new info is a pain, don't do that. Just hit reply.


> Don't confuse, "I didn't get it to work first time with very little effort" "does not work" Also note that like any complex tool, once you've worked it out, which takes time, you don't have to do that again.

I don't confuse the two, the program didn't do what i explicitly wrote in my post. If you think it can do what i asked, please explain how, because right now from what i can see it fails to do what i want from it. I didn't try everything i mentioned because it failed at pretty much everything i tried from the very first thing, so it didn't give me any confidence to keep on trying.

Also you seem to misunderstand something important even from my initial post: almost everything i wrote can be done by stringing together various tools and/or have various workaround, even the "modify code while it runs" could be done by using one of the libraries or tools mentioned elsewhere.

But the point is having the IDE actually do all that in a single place and with good UX (for example i didn't mentioned the part about checking a library's name in a listbox of libraries in a project's settings for fun, i mentioned because i expect at least that sort of user experience and convenience for the user! Eclipse CDE fails at that part because it needs all filling all sorts of forms in various places to see the library - my requirement wont be met by ignoring the requirement, the entire point of it was to request good user experience).

It is all about having a good user experience, if the program fails at that, it fails at the core of what i asked.

> Edit: Editing a post above a response with wholly new info is a pain, don't do that. Just hit reply.

When i edited the post there wasn't any reply, you replied while i was typing the edit.


>It is all about having a good user experience, if the program fails at that, it fails at the core of what i asked.

You don't want what you said you wanted because you won't do the work to get it. It's not even that much work tbh. That's fine. It does work for me and the "user experience" is fine. I'm not associated with the project, nor pushing anything. You can pretend it's because I'm so much smarter or this is my con or something else to explain that but I doubt these lines of reasoning.

Best.


> You don't want what you said you wanted because you won't do the work to get it.

I do want what i wrote i want, but the program doesn't provide what i want though, that is my point.


> 9. The debugger can modify a variable while the program is running.

> 11. The debugger can modify a function while the program is running (any new calls are done to that function).

Another words: hot code reloading / swapping [1].

And I would add:

> You record a failure once, then debug the recording, deterministically, as many times as you want. The same execution is replayed every time. [2]

[1] e.g. https://github.com/ddovod/jet-live, https://github.com/crosire/blink, https://github.com/ziglang/zig/issues/68

[2] https://rr-project.org/


> Another words: hot code reloading / swapping [1].

Indeed, though without the use of external libraries, be for C and integrated seamlessly into the IDE - and it needs to work on Linux since that is what i'm using :-) (i've used MSVC's edit-and-run or whatever is called at the past though it was kinda finicky if it worked or not).


You seem to know what you want. Have you actively looked for an IDE to use with C? Why don't you think any of the available options is better than your current setup?


I don't know of any IDE that provides even half of what i want TBH.

On Linux (which is my main OS these days) pretty much all options involve a text editor with some plugin/addon to somehow understand C plus the ability to call a makefile or some other command. Of all those Kate (KDE's "advanced" text editor) with an LSP plugin and a Clang-based LSP seems to be good enough.

Though it is really more of a "least bad" than "actually good" situation.


> I don't know of any IDE that provides even half of what i want TBH.

> On Linux (which is my main OS these days) pretty much all options involve a text editor

You obviously haven't looked hard enough. CLion fulfills a decent amount of what you're looking for. https://www.jetbrains.com/clion/

A lot more limited, but still much more capable as an IDE than text editors is KDevelop, for example your request here :

> (i haven't touched topics like VCS support and how i'd like to be able to see and use different version of the code from inside the IDE - like e.g. go back in time to a different function while the debugger is running - or anything that has to do with GUIs)

https://kdevelop.org/features/

> An especially useful feature is the Annotate border, which shows who last changed a line and when. Showing the diff which introduced this change is just one click away!

Also example snippet of the debugging integration :

> You can also hover the mouse over a symbol in your code, e.g. a variable; KDevelop will then show the current value of that symbol and offer to stop the program during execution the next time this variable's value changes.

https://docs.kde.org/trunk5/en/kdevelop/kdevelop/debugging-p...


> You obviously haven't looked hard enough. CLion fulfills a decent amount of what you're looking for. https://www.jetbrains.com/clion/

CLion has the problem of being a proprietary program that requires online validation, which is a big hard no for me.

Also IMO the fact that you point out KDevelop being able to show a per-line commit and the current value of a variable, both being among the minimum you can expect from an IDE tell me you didn't read what i wrote that i wanted, so by extension i doubt CLion also does anything close to what i wrote.

I don't "just" expect "some" debugger integration or "some" VCS integration, i explicitly wrote things like the debugger being able to call a function in the running program or modify a function while the program is called or being able to replace the current function with an older version of the function taken out of VCS. Among a ton of other things.

What you show KDevelop to do aren't anything special, even non-IDE "programmers' text editors" can do them.


You can still try CLion (the trial version) and see if it’s what you’re after. You don’t have to use it but IMHO complaining so much about there not being a decent IDE without even trying the proprietary ones isn’t very fruitful. CLion is what Borland was back in the 90s.


The thing is even if CLion does what i want (TBH i doubt it[0]), i wouldn't use it anyway so i don't see a reason to spend money on it. Note that my issue wasn't so much that it was proprietary (though it is an issue[0]) but that it requires an internet connection to function.

After all i still have and can use Borland C++ 5, Delphi 2 and C++ Builder 1 to this day without requiring any sort of connection or having Borland's permission to use the software i bought. I can't do the same with CLion.

[0] CLion relies a lot more than Borland on external tools like GCC, CMake, GDB, etc meaning that not only it most likely does not provide all the integrated functionality i mentioned but there is also a very high chance it will stop working at some point as its dependencies are changing so you do need to rely on JetBrains to keep it up to date without having access to the source code.


Have you looked at KDevelop? I mean, the underlying tech is still the same, but I find it more pleasant to work with.


Yes, though i don't remember why i decided against KDevelop, i remember installing it at least a couple of times, finding some annoyance and removing it. I do remember liking QtCreator more but that was in comparison to KDevelop.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: