Code management
#1 Members - Reputation: 499
Posted 26 April 2012 - 08:26 AM
-Kirk
#4 Members - Reputation: 2369
Posted 26 April 2012 - 10:09 AM
For Java, there is Maven. Create POMs for each reusable artefact, keep it in suitable repository.
For C# there is at very least nuget.
C++ is... a mess.
R has CPAN-like project called CRAN.
And so on.
Reuse of small fragments is not practical due to language design - reusing fragments brings in the entire project with it, unless the code was design from scratch to minimize dependency surface.
Hence all of the above projects require you to define code in well-defined contexts which may be reusable.
#6 Members - Reputation: 2369
Posted 26 April 2012 - 10:18 AM
antheus - thanks for the response.
NuGet seems to be most closely with what I'm looking for. Unfortunately, I don't write in C#. It would be nice if there was something like this for C++.
{
std::vector<int> foo;
}Congratulations, you just included entire Linux or Windows kernel, all 50 million lines of it.
#7 Members - Reputation: 499
Posted 26 April 2012 - 10:24 AM
antheus - thanks for the response.
NuGet seems to be most closely with what I'm looking for. Unfortunately, I don't write in C#. It would be nice if there was something like this for C++.{ std::vector<int> foo; }
Congratulations, you just included entire Linux or Windows kernel, all 50 million lines of it.
OK. I'm not sure I follow you on that one. No. I'm certain I don't.
#8 Members - Reputation: 2369
Posted 26 April 2012 - 10:50 AM
OK. I'm not sure I follow you on that one. No. I'm certain I don't.
In theory, definition of vector<> complies with standard, so typing above will work anywhere. While vector itself is very well tested, it's not completely portable.
It includes, for example, std::allocator. Implementation of that allocator may be stateful or stateless, which affects the rest of the code and algorithms.
But how is allocator itself implemented? It might need to make a syscall somewhere or call malloc which does the same. Malloc is not defined, it's provided by OS kernel. And OS kernel needs to manage these blocks. And blocks themself are defined arbitrary by OS writers, so there's a linked list somewhere. And this linked list will be making some special ring-0 calls specific to CPU. And the output of all of this is determined by C++ compiler which generates assembly while itself uses same implementation.
Or, C++ code might be compiled to an OS which has no strict kernel and no virtual memory, so vector's allocator would map directly to DRAM, causing slightly different behavior on edge cases, such being unable to support same handling of invalid memory accesses.
C and C++ do not come with abstraction layer that would allow code to be reliably reusable, it depends on everything, from compiler implementation, OS design, build toolchain and standard library implementation. Standard library works pretty well, but just about any other code is completely bound compiler settings and version of OS kernel. Change any of that and things can break in a million ways, while remaining standard-compliant C or C++ code.
#10 Members - Reputation: 2369
Posted 26 April 2012 - 11:23 AM
I see your point. It's a bit of an extreme example, but I do get your point.
Simpler version is that any real world C++ source depends on implementation of compiler (less so these days) and the OS (down to version) it runs on.
Consider a simple DX example - it implies version of Windows, version of Visual Studio and version of DX. You could copy paste it, but unless you replicate the environment, chances are it won't compile, won't work correctly or will have subtle bugs.
Ideally, all code would seek to minimize external dependencies, but in practice it's too expensive.
Same applies to, say, Python which depends on VM version and implementation (2 vs. 3, CPython, PyPy, Jython, ...) as well as any hidden dependencies, such as native C code used by project. But all of these would be called Python code and snippet might be copyable between them.
#12 Members - Reputation: 499
Posted 26 April 2012 - 11:51 AM
Again, I'm not doing anything monumental here. I would just like to organize the pieces I have a little (lot) better.
#14 Members - Reputation: 499
Posted 26 April 2012 - 01:39 PM
Why not just include a comments section in each script, where you list keywords you think you might like to search by later?
Then you could just use the search built into your OS.
Yeah, I thought of that, too. I was interested in how others manage their code, and hoping for something a bit more elegant.






