Code management

Started by
13 comments, last by SiCrane 11 years, 12 months ago
I've been programming for a while, and I know have a rather large collection of scripts, classes, functions, etc. that I find useful in different situations, but I find it difficult to manage them. Does anyone use a code management application, or does one even exist? I haven't found much thus far in my searches. One requirement would be different languages - C++, Java, Python, R...

-Kirk
Advertisement
Describe what you mean by "management". Are you talking about managing versions of them, i.e. using version control software? Or perhaps separating them into standalone libraries that you can quickly re-use?
Good question. Not so much managing versions (in the SVN sense), but more the latter, a tool (database?) where I can collect the routines/libraries I use, and easily access them for later reuse.
Unless you're using Lisp, Smalltalk or one of its descendants, reuse generally isn't practical since very little code actually is reusable.

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.
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++.

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.

[quote name='kirkd' timestamp='1335456993' post='4935111']
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.
[/quote]



OK. I'm not sure I follow you on that one. No. I'm certain I don't.

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.
I see your point. It's a bit of an extreme example, but I do get your point.

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.

This topic is closed to new replies.

Advertisement