Jump to content

  • Log In with Google      Sign In   
  • Create Account

Code management


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
14 replies to this topic

#1 kirkd   Members   -  Reputation: 505

Like
0Likes
Like

Posted 26 April 2012 - 08:26 AM

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

Sponsor:

#2 rip-off   Moderators   -  Reputation: 8726

Like
0Likes
Like

Posted 26 April 2012 - 09:35 AM

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?

#3 kirkd   Members   -  Reputation: 505

Like
0Likes
Like

Posted 26 April 2012 - 10:02 AM

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.

#4 Antheus   Members   -  Reputation: 2397

Like
0Likes
Like

Posted 26 April 2012 - 10:09 AM

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.

#5 kirkd   Members   -  Reputation: 505

Like
0Likes
Like

Posted 26 April 2012 - 10:16 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++.

#6 Antheus   Members   -  Reputation: 2397

Like
-3Likes
Like

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 kirkd   Members   -  Reputation: 505

Like
0Likes
Like

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 Antheus   Members   -  Reputation: 2397

Like
0Likes
Like

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.

#9 kirkd   Members   -  Reputation: 505

Like
0Likes
Like

Posted 26 April 2012 - 10:53 AM

I see your point. It's a bit of an extreme example, but I do get your point.

#10 Antheus   Members   -  Reputation: 2397

Like
0Likes
Like

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.

#11 rip-off   Moderators   -  Reputation: 8726

Like
4Likes
Like

Posted 26 April 2012 - 11:41 AM

Antheus, I'm not convinced your hyperbolic arguments are helpful here. Reusing code (in particular low level code like C++) has challenges, but it is not quite the Everest you are making it out to be.

Tone it down.

#12 kirkd   Members   -  Reputation: 505

Like
0Likes
Like

Posted 26 April 2012 - 11:51 AM

I'm really looking for something smaller scale. I have a couple of dozen C++ classes I wrote that I use regularly (custom exception handler, parameter file parsing, data file clean up, etc.), a large number of Python scripts that do a whole variety of things, and a few R scripts that I use for general data mining, chart generation etc. The issue I run into, is that when I start a project, I find myslef doing many of these things over and over and I find myself looking through my directory tree to find the script I wrote that did this last time, trying to remember where I saved it. I'm just looking for something that will conveniently organize the classes/scripts/etc., and maybe give me the ability to more simply find the ones I've already written. Maybe searchable keywords - that sort of thing.

Again, I'm not doing anything monumental here. I would just like to organize the pieces I have a little (lot) better.

#13 mrbastard   Members   -  Reputation: 1573

Like
0Likes
Like

Posted 26 April 2012 - 12:38 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.


#14 kirkd   Members   -  Reputation: 505

Like
0Likes
Like

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.

#15 SiCrane   Moderators   -  Reputation: 9668

Like
0Likes
Like

Posted 26 April 2012 - 03:59 PM

You could try putting code you reuse in a personal wiki. Almost all such software has search functionality and versioning. Some also have tagging.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS