6 ms·
SGCL: Real-time garbage collector for C++
- kaladin-jasnah 4y agoI do not mean to detract from the author's work in any way, but how does one maintain a 2180 line file easily? I find these to be very difficult to grep and grok, even if I am the author of the entire file.
- signa11 4y ago''' ... but how does one maintain a 2180 line file easily? I find these to be very difficult to grep and grok, even if I am the author of the entire file. ''' not sure about others, but i am using emacs with various tools f.e. for c++ these days, clangd as lsp-server, for c (long time ago) it was mostly cscope (via xcscope.el iirc) etc. etc.
- rileymat2 4y agoWhen I have a large file, using multiple panes on the same file was a big step forward. It took me far longer than it should have to realize that. Edit: Although 2k lines in file does not quite qualify as large in a lot of the projects. (Not that I like it, I prefer to break them up)
- signaru 4y agoWhen it can't be avoided there were (rare) times that I used #includes to split what would have been one long source file into multiple files. (2k lines is still within my 1 file threshold, but I generally aim for less than 1k lines). Interestingly, C# has partial classes which I have also rarely manually used (automatically generated for forms).
- pjmlp 4y agoNot only forms, nowadays it gets plenty of use via Roslyn code generators.
- pipeline_peak 4y agoThe IDE component that displays the project hierarchy is necessary at this level. Visual studio displays all methods of all classes in the current file with combo boxes making it a lot easier to navigate.
- kaladin-jasnah 4y agoOh, this is a great idea! I have to look into adding this to Emacs.
- Jorengarenar 4y agoNot necessary to use IDE either, there is e.g. Tagbar plugin for Vim
- dataflow 4y agoI was working on a 1.7k LOC file as I read your comment. To be honest I'm not sure I understand the question (how would splitting the file into two change anything in your view?), but one thing that I find helpful in general is my editor's ability to collapse method/class/etc. definitions. That lets me work on the function I want without being distracted by other definitions. Perhaps that's the answer to your question? But that's useful at 200 lines too, not just 2000 lines.
- sakras 4y agoHonestly, 2200 LOC is really not very much. I’ve dealt with 15 kLOC source files before, and have seen upwards of 30 before. I don’t think breaking it up would add much in the way of clarity given the volume of code, at that point splitting it up is just about optimizing compile times. In regards for how to grok and grep code like that, it’s just a skill like any other. I got very good at reading code and forming a mental model of it.
- flohofwoe 4y agoModern text editors and IDEs have plenty of features to better find your way around in large source files. One objective advantage of putting the entire implementation code of a C or C++ library into one source file is that you can entirely get rid of private interface headers (also, as other have said, 2kloc in one file isn't really all that much).
- maxnoe 4y agoThe simulation code we use is a 88kLOC Fortran77 file which is in continuous development since the eighties. And that's just the main file, it uses several libraries for lower level operations.
- aidenn0 4y agoHow does the LGPL get interpreted for a header-only library?
- Kranar 4y agoMakes it behave very similarly to GPL. LGPL requires any derivative to allow a user of that derivative to substitute the LGPL'd portion with a modified version. It's very difficult to perform such a substitution without providing substantial portions of the derivative's source code.
- pebal 4y agoVersion 3 is more liberal.
- jgaa 4y agoThe first question I asked myself when I read the topic-line was: "Why would I want a garbage collector for C++" I'm not saying that it's a bad idea. I'm just curious about why/when garbage collection is better than conventional use of unique_ptr or shared_ptr.
- pebal 4y agoGC can be faster and allocate less memory. tracked_ptr: 279.95ms (151MB) shared_ptr: 1035.07ms (480MB) source: https://godbolt.org/z/jP7ohPehY https://godbolt.org/z/jP7ohPehY
- Kranar 4y agoMakes writing lock free data structures a heck of a lot easier. Entirely eliminates the ABA problem.
- pebal 4y agoThis introduces the tracked smart pointer. This pointer has less overhead than shared_ptr and releases circular data structures.
- pjmlp 4y agoUnreal C++ and C++/CLI have one. When one wants the flexibility of C++ with the productivity of a GC.
- pkolaczk 4y agoWhether GC improves productivity is a strong claim that needs a proof. I have yet to see such a proof. So far my experience has been that (nondeterministic) GC is only a productivity improvement over languages with manual memory management like C, but a productivity degradation over languages with deterministic automatic memory management like C++ and Rust. GC manages only memory, while in the latter case, you get automatic management of resources of any type, which can be a huge productivity boost if you use it to your advantage.
- pjmlp 4y ago
- TheDesolate0 4y ago[dead]
- Rochus 4y agoDid anyone check how it works?