Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-27-2017, 03:08 PM   #1
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3171Reputation: 3171Reputation: 3171Reputation: 3171Reputation: 3171Reputation: 3171Reputation: 3171Reputation: 3171Reputation: 3171Reputation: 3171Reputation: 3171
OpEd: "Build, Beg, Borrow, or Steal?"

When you were in school ... at least (koff, koff) when I was in school ... you had to do a lot of stupid things. Such as, "implement a linked list." Or, "build a fully-functional B-tree implementation from scratch."

Today, I still see far too many intrepid programmers trying to be Christopher Columbus: sailing away as though they were embarking on a voyage to an unknown world. Fully prepared to start with a blank text-editor screen and an empty directory.

"Okay, school's out!"

Today, no matter what it is that you are setting out to do, "it has already been done (to death)." Therefore, your project should be seen as a continuous re-play of this decision: "Build, Beg, Borrow, or Steal?"

Fortunately, you don't have to beg, you don't have to borrow, and it's perfectly okay (hey, I'm not speaking literally here ...) to steal. There is a vast amount of "contributed code" that is readily available for whatever programming language you are using. For instance, at this particular moment, Perl's CPAN library contains 122496 Uploads, 35981 Distributions, 194527 Modules, 13336 Uploaders, and by the time you read this there will probably be more. Complete applications can be found at places like GitHub. "Web frameworks" abound at every possible level of sophistication. Elegant pre-existing solutions exist to almost every conceivable obstacle, in every language.

Thus, the first step in any project ... and, at every turn thereafter ... should be: research.
Originally Posted by Sage Wisdom:

Actum Ne Agas: "Do Not Do A Thing Already Done"
"Stuck in existing-application hell, but tasked to create a new feature?" You can still go to these resources for source-code examples of good ideas.

- - -
And, in the same vein, when you think that you have to "write a bash script" in order to implement "a new command," think again. If you take a look at the source-code of most of "the scripts that you know and love," you will discover that most of them are not "bash scripts!" They're programs written in some high-level programming language or another, prefixed by a #!shebang line which causes bash to silently invoke the specified language to carry it out.

This, of course, means that we have come full-circle: if we don't have to use bash's primitive built-in scripting language to actually construct our new script, we can leverage(!) great quantities of existing software to let us get the job done ... quickly.

- - -
Therefore, "now that school's out," re-arrange your mindset to presume that, "whatever-it-is that you are faced with now, you are not the first." (Nor will you be the last.) You should begin – not with "coding" but – with research. Thousands of generous people have created things for you, and they don't mind in the slightest if you "steal" what they did.

Whatever you do: "Don't ... start ... from ... scratch."
Old 12-27-2017, 04:42 PM   #2
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 4,838
Blog Entries: 6

Rep: Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667
Originally Posted by sundialsvcs View Post
Thus, the first step in any project ... and, at every turn thereafter ... should be: research.
To the degree that you seem to emphasize research to mean search for existing code, I disagree with this premise as a general rule to be followed (although I think there may be a special use case for it*).

The first rule should always be to understand the problem at hand, and then to model both the problem and potential solution(s) - even when it seems trivial. Doing both of these things may involve research, but that should be the search for knowledge and understanding, not code!

If you don't understand the problem then you won't be able to make good use of the code others have written to solve it. In fact, as happens very often and is repeatedly demonstrated in fora such as this, by looking for available code solutions too early you can end up spending vastly more time (your own and other's) troubleshooting code you do not understand and which may not, in the end, be appropriate to your real problem! This is the very seed from which X-Y problems often sprout!

On the other hand, once you understand both the problem and one or more potential solution models, only then are you prepared to look for available code. You can then evaluate the applicability of a given piece of code to your problem by determining whether or not it fits the model, or whether either model or code can be adapted to make a good fit.

Once you have a working model, you have already eliminated a fair number of lines of useless or inappropriate code you would have otherwise written, or borrowed (i.e. most problems become simpler). Without it, you can never really know the full effect of any code and today's quick solution often becomes tomorrow's obscure problem.

*Special case: When you tend to use a limited tool set for most problems (perl for example), you will expect to become very familiar with the language AND with the libs, modules and contributed code base available for that language. You may then more quickly go to the code search phase for many use cases, primarily because you come to more quickly see the models by virtue of close familiarity with the tool set.
Old 12-27-2017, 09:09 PM   #3
Mill J
Registered: Feb 2017
Location: Sweet
Distribution: Void, LFS, Haiku, Quirky on Rpi and many others
Posts: 883
Blog Entries: 2

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
Well for a beginner my advice is always Do Not Just Learn how to program, figure out how it works and you'll learn in the process.

But yes you do have a point, every programmer should have/has his favorite functions that he uses cross-application so he doesn't reinvent the wheel. But a programmer HAS to know exactly what's going on in that code he just copied.

return 0;


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux People need to build a new "old-lady Mint-OS".. "Mint Julep"... Cosmicb Linux - Newbie 21 08-29-2016 06:14 PM
[SOLVED] X: "loading extension glx" "no screens found" "fatal server error" (w/ nvidia driver) Geremia Slackware 7 12-29-2014 12:00 PM
[SOLVED] "net rpc" "failed to connect to ipc$ share on" or "unable to find a suitable server" larieu Linux - General 0 11-09-2014 01:45 AM
[SOLVED] What is the difference of "make-kpkg" and "make"(in kernel build) kleio.ming Linux - Kernel 4 07-18-2012 08:15 PM
perl install error: Can't locate object method "new" via package "Module::Build::Vers powah Linux - Software 0 10-24-2006 02:57 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:03 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration