Commits

Anonymous committed 228aaee

Moved lib/docbook/xml , lib/docbook/essays etc. under lib/docbook/4.

Comments (0)

Files changed (57)

 
 include include.mak
 include rules.mak
-include deps.mak
 
 make-dirs: $(T2_DIRS_DEST) 
 
 DOCBOOK4_INSTALLED_CSS_DIRS = $(foreach doc,$(DOCBOOK4_DOCS),$(T2_DEST)/$(call get,DOCBOOK4_DIRS_MAP,$(doc))/docbook-css)
 DOCMAKE_STYLE_CSS = $(DOCMAKE_XSLT_PATH)/style.css
 
-DOCBOOK4_BASE_DIR = lib/docbook
+DOCBOOK4_BASE_DIR = lib/docbook/4
 DOCBOOK4_RENDERED_DIR = $(DOCBOOK4_BASE_DIR)/rendered
 DOCBOOK4_ALL_IN_ONE_XHTML_DIR = $(DOCBOOK4_BASE_DIR)/essays
 
 $(MOJOLICIOUS_LECTURE_SLIDE1): t2/lecture/Perl/Lightning/Mojolicious/mojolicious.asciidoc.txt
 	asciidoc -o $@ $<
 
-lib/docbook/xml/Spark-Pre-Birth-of-a-Modern-Lisp.xml: t2/open-source/projects/Spark/mission/Spark-Pre-Birth-of-a-Modern-Lisp.txt
+$(DOCBOOK4_BASE_DIR)/xml/Spark-Pre-Birth-of-a-Modern-Lisp.xml: t2/open-source/projects/Spark/mission/Spark-Pre-Birth-of-a-Modern-Lisp.txt
 	asciidoc --backend=docbook -o $@ $<
 
 t2/humour/TheEnemy/The-Enemy-rev5.html.wml: lib/htmls/The-Enemy-rev5.html-part
 
 DOCBOOK5_DOCS += $(FICTION_DOCS)
 
-# DOCBOOK4_BASE_DIR = lib/docbook
+# DOCBOOK4_BASE_DIR = lib/docbook/4
 # DOCBOOK4_ALL_IN_ONE_XHTML_DIR = $(DOCBOOK4_BASE_DIR)/essays
 # DOCBOOK4_SOURCES_DIR = $(DOCBOOK4_BASE_DIR)/xml
 # DOCBOOK4_FO_DIR = $(DOCBOOK4_BASE_DIR)/fo

deps.mak

-# Extra dependencies
-
-$(T2_DEST)/philosophy/case-for-file-swapping/revision-3/index.html :  lib/docbook/rendered/case-for-file-swapping-rev3.html
-
-$(T2_DEST)/philosophy/computers/education/introductory-language/index.html :  lib/docbook/rendered/introductory-language.html
-
-$(T2_DEST)/philosophy/computers/high-quality-software/index.html :  lib/docbook/rendered/what-makes-software-high-quality.html
-
-$(T2_DEST)/philosophy/computers/high-quality-software/rev2/index.html :  lib/docbook/rendered/what-makes-software-high-quality-rev2.html
-
-$(T2_DEST)/philosophy/computers/optimizing-code-for-speed/index.html :  lib/htmls/from-mediawiki/processed/Optimizing_Code_For_Speed-rev1.html
-
-$(T2_DEST)/philosophy/computers/software-management/end-of-it-slavery/index.html :  lib/docbook/rendered/end-of-it-slavery.html
-
-$(T2_DEST)/philosophy/computers/software-management/perfect-workplace/perfect-it-workplace.xhtml :  lib/docbook/rendered/perfect-it-workplace.html
-
-$(T2_DEST)/philosophy/politics/drug-legalisation/index.html :  lib/docbook/rendered/case-for-drug-legalisation.html
-
-$(T2_DEST)/philosophy/psychology/hypomanias/content.html :  lib/docbook/rendered/dealing-with-hypomanias.html
-

lib/docbook/4/from-mediawiki/optimizing-code-for-speed.docbook.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
+<book>
+<bookinfo><title/><legalnotice><para>Permission to use, copy, modify and distribute this document under the GNU Free Documentation License (GFDL).</para></legalnotice></bookinfo><article id="Untiteled">
+<title>Untiteled</title>
+<para>
+
+</para>
+<para>
+This work is licensed under the:
+</para>
+<orderedlist numeration="arabic"><listitem>
+<para>
+<ulink url="http://creativecommons.org/licenses/by/2.5/"><citetitle>The Creative Commons' Attribution License version 2.5</citetitle></ulink> - or at your option any higher version.
+</para>
+</listitem>
+<listitem>
+<para>
+<ulink url="http://www.gnu.org/copyleft/fdl.html"><citetitle>The GNU Free Documentation License</citetitle></ulink> version 1.2 - or at your option any higher version.
+</para>
+</listitem>
+</orderedlist>
+<para>
+Please keep it this way. If you don't like either or both licenses - feel free to fork it and have a different derived license. (While properly accepting the terms of either license as starting points).
+</para>
+<para>
+Authors: User:Shlomif.
+</para>
+<section><title>Other Resources</title>
+<itemizedlist mark="opencircle"><listitem>
+<para>
+Optimizing Code for Speed/Outline
+</para>
+</listitem>
+</itemizedlist>
+
+</section>
+<section><title>Introduction</title>
+<para>
+Optimization of code is the term that was applied to a process in which a code is tuned to be better in some respects: either speed, memory consumption, Input/Output (disk read and writes or network reads and writes), etc. In Mathematics, Optimization means a process in which one finds the values with the best performance. In Computing where programs are very complex, usually optimizing for speed in the mathematical sense is impossible. Instead the term has come to mean just advancing in the direction of better performance in one or more respects.
+</para>
+<para>
+This document will focus on optimizing code to run faster. However, as you will see later, doing this may involve having to optimize the code in a different aspect. Furthermore, often when programmers are trying to optimize one aspect of a program, they are doing so in order to increase speed.
+</para>
+<section><title>In which programs is optimization required?</title>
+<para>
+There are several type of programs in which optimization is required. One type of them is real time programs. Despite common mis-conception, these are not necessarily programs that need to be very fast. Instead real time programs are programs that must respond to certain events within a certain time limit that was dedicated to the event. So for example, if the user presses a keyboard key while inside a word processor window, it should display the character relatively promptly. A 5 seconds delay will be unacceptable and as such a word processor is a kind of application that has some real-time constraints.
+</para>
+<para>
+Some parts of real-time systems may need optimization. However, once the time falls below the required delay, no other optimization is necessary. (At least not until testing proves it is again exceeding the limit.)
+</para>
+<para>
+Other programs that require optimization are programs that cannot be fast enough. Examples for such programs are Artificial Intelligence programs, games, multimedia programs, virtual machines and interpreters for programming languages, or any type of publicly available library or module whose use "in the wild" may necessitate it to be very fast.
+</para>
+<para>
+And naturally another type of programs are programs that are too slow or perceived to be too slow. While programs of some problem domains are very slow due to the complexity of the calculations involved, that is usually not the case, and nothing prevents a program from being fast. Such programs that are considered too slow should be optimized to make them run faster.
+</para>
+
+</section>
+<section><title>When to optimize?</title>
+<para>
+The rule of the thumb is that one should optimize if the program is not fast enough compared to the desired speed. A common misconception is that if a program is not fast enough now, it will run faster as hardware gets faster. However that is not always the case.
+</para>
+<para>
+If your program is slow, it is usually because the code is not optimized (such as due to the fact it uses sub-optimal algorithms). While better hardware will usually improve performance, it does not guarantee a noticeable speed increase. Furthermore the progress in hardware speed has allowed programmers to write more wasteful code (see <ulink url="http://www.paulgraham.com/hundred.html"><citetitle>Paul Graham's "The Hundred Years Language" essay</citetitle></ulink>), but some programs are still excessively slow.
+</para>
+<para>
+When writing a program on a modern hardware, one should make it fast enough already. Some people have claimed that we have already reached the end of Moore's First Law in regards to uni-core processors, and we cannot expect single-processed single-threaded program to run faster. In any case, even if the program runs well on a high-end platform, it may still need to run on older hardware.
+</para>
+<para>
+We've all seen the fact that while computers got faster, software has often become slower to run unless the hardware is upgraded. The so-called "Gates' Law" claims that commercial programs decrease in speed by half every 18 months, due to various reasons. It is well known that the various versions of the DOS operating system ran adequately on a PC XT's and 286's and that a Intel 386 was a "lean and mean DOS machine" as a certain journalist claimed back then. On the other hand, Microsoft Windows 3.0 and Microsoft Windows 3.1 already required a fast 486 computer to be ran comfortably, while Windows 95 was barely usable there and needed a Pentium computer. Windows XP already ran slowly on a Pentium machine and required a high end Pentium III or Pentium 4 computer. Windows Vista requires even more hardware resources than Windows XP, up to the point that many computers in use today cannot run it comfortably.
+</para>
+<para>
+Now, while software simulations that run directly against the CPU and memory (and possibly hard-disk) are still running much faster than before, the responsiveness of the system itself does not seem to improve much.
+</para>
+
+</section>
+<section><title>When not to optimize?</title>
+<para>
+One should not optimize when the program in question runs fast enough. However, if it also has to run adequately on slower hardware, handle a greater load, or work well with fewer resources at its disposal, then the program might need to be optimized further based on such requirements.
+</para>
+<section><title>Optimization vs. Modularity and Readability</title>
+<para>
+Optimization may have a bad influence on such code-quality factors as modularity and readability. Consider for example, what the developers of <ulink url="http://gmplib.org/"><citetitle>GMP (GNU Multi-precision)</citetitle></ulink>, wrote in <ulink url="http://gmplib.org/manual/Introduction-to-GMP.html#Introduction-to-GMP"><citetitle>their manual</citetitle></ulink>:
+</para>
+<para>
+The speed of GMP is achieved by using fullwords as the basic arithmetic type, by using sophisticated algorithms, by including carefully optimized assembly code for the most common inner loops for many different CPUs, and <para>
+<emphasis role="bold">by a general emphasis on speed (as opposed to simplicity or elegance</emphasis>).</para>
+
+</para>
+<para>
+Also consider that short functions and methods are considered preferable over longer methods, to allow for greater code re-use, testing, and self-documentation. (See the <ulink url="http://c2.com/cgi/wiki?ExtractMethod"><citetitle>"Extract Method" refactoring pattern</citetitle></ulink>). However, function or method calls are considered a relatively costly operation, and so this extra code-quality, will probably make the program slower. 
+</para>
+<para>
+Therefore, it's not hard to imagine that a developer who wishes to save some extra cycles will merge a function that gets used only once or a few times into its caller code (or incorporating its code using a macro, or a preprocessing stage if possible), and therefore making the code less modular.
+</para>
+<para>
+Similarly, highly optimized code may also become much more unreadable. For example, the C Preprocessor's macros are notorious for making code that uses them unreadable. I heard <ulink url="http://www.mail-archive.com/linux-il@cs.huji.ac.il/msg15826.html"><citetitle>some complaints</citetitle></ulink> that mentioned that OpenSSL's code, which is based on the preprocessor macros, identically named static functions and lots of code-generation is very hard to understand and follow due to these facts.
+</para>
+<para>
+Similar complaints are constantly voiced against perl5's XS, its interface for creating subroutines in ANSI C and other lower-level languages. The API was designed to be as efficient and fast as possible and, as a result, is hard to learn, understand and follow.
+</para>
+
+</section>
+
+</section>
+
+</section>
+<section><title>Strategy for Optimization</title>
+<para>
+The first thing you need to do before optimizing is make sure that your code has many automated tests with a good test coverage. Optimizing the code (or any other kind of modification) may break something, and the automated tests will catch that.
+</para>
+<para>
+The next thing you need to do is to make sure your code is modular. Duplicate code and other properties that make a code non-modular can prevent a clear analysis of the code's bottlenecks by profiling it.
+</para>
+<para>
+Afterwards, it is important to profile your code using a good software profiler. Profiling will help show which code does not take a lot of time to run and therefore it would be best not to invest a lot of optimization effort in it. One should start by optimizing the most time-consuming tasks first. 
+</para>
+<para>
+It takes some expertise to knowing how to properly analyze the results given by the profiler, and seeing what needs to be optimized. For example, some IO-intensive routines may appear to consume a lot of time, while in fact that time cannot be effectively eliminated because the amount of IO is minimal (while still being relatively time consuming). I feel that discussing this aspect of profiling further is orthogonal to the mission of this article, so I'm not going to cover it here.
+</para>
+<para>
+Finally, it is a good idea that someone will review the code and and give general remarks on speed bottlenecks found there. To quote Eric Raymond from <ulink url="http://www.catb.org/~esr/writings/cathedral-bazaar/"><citetitle>"The Cathedral and the Bazaar"</citetitle></ulink> "Given enough eyeballs, all bugs become shallow".
+</para>
+
+</section>
+<section><title>Order of Complexity Optimizations</title>
+<section><title>What is order of complexity?</title>
+<para>
+Generally, an algorithm has an asymptotic comptutational complexity. Assuming the input is of size N, we can say that the algorithm will finish at O(N), O(N^2), O(N^3), O(N*log(N)) etc. This means that it is a certain mathematical expression of the size of the input, and the algorithm finishes between two factors of it.
+</para>
+<para>
+Generally, the smaller the order of complexity of the program's underlying algorithm, the faster the it will run and the better it will scale as the input gets larger. Thus, we should often seek more efficient algorithms in order to reduce the order of complexity. 
+</para>
+
+</section>
+<section><title>Some examples for reducing Order of Complexity</title>
+<section><title>Lookup</title>
+<para>
+Let's suppose we're looking for a certain item in a collection of <emphasis role="bold">N</emphasis> items. A naïve algorithm for looking for such an item would be to go over all the items one after the other, and see if they match this item. Then we can stop when we found this item, or declare that it wasn't found if we did not find it.
+</para>
+<para>
+This is called a linear search, and has an average (and worst-case) complexity of O(N). Now, if we're going to do such a naïve lookup many times, then it will cost us O(N) every time. And this is usually unacceptable.
+</para>
+<para>
+A better idea would be to use a more efficient lookup. For example, a Binary search is O(log(N)). It assumes we keep the existing items in a sorted array, or in a balanced tree. A wikipedia:Hash table is a heuristic that with a good design of its underlying parameters provides an <emphasis role="bold">average</emphasis> O(1) lookup, but often O(log(N)) is good enough.
+</para>
+<section><title>Case study for Lookup - the Freecell Solver States Collection</title>
+<para>
+<ulink url="http://fc-solve.berlios.de/"><citetitle>Freecell Solver</citetitle></ulink> is a library written in ANSI C that solves deals of FreeCell and similar "full-knowledge" Solitaire games. Freecell Solver used traditional Game artificial intelligence heuristics from the beginning such as Depth First Search and Best First Search. As a result, there was a need to maintain a collection of the previously encountered board positions (or "states") so they won't be checked twice.
+</para>
+<para>
+The very first version of the solver (written in Perl) used a linear search over an array. That proved to be too slow to be effective to solve even the most elementary deals. Afterwards, the program was re-implemented in C, and used a sorted array, with a "sort margin" that was sorted using ANSI C's <ulink url="http://www.cplusplus.com/reference/clibrary/cstdlib/qsort.html"><citetitle>qsort's function</citetitle></ulink>, which performs the Quick Sort algorithm at an average complexity of O(N*log(N)), giving the program an average lookup of O(log(N)) and an accumulated addition of between O(N*log(N)) and O(N^2). 
+</para>
+<para>
+Later versions made optional use of two Balanced Binary Trees libraries: <ulink url="http://www.stanford.edu/~blp/avl/"><citetitle>libavl</citetitle></ulink> and <ulink url="http://libredblack.sourceforge.net/"><citetitle>libredblack</citetitle></ulink>, which have a maximal O(log(N)) lookup and insertion and an accumulative O(N*log(N)) run-time. Sometimes later, a custom hash table was coded, whose run-time was even somewhat faster than the balanced binary trees, and had an <emphasis role="bold">average</emphasis> run-time of O(N). This hash was later further optimized using micro-optimizations.
+</para>
+
+</section>
+
+</section>
+<section><title>Counting Sort instead of Comparison-Based Sort</title>
+<para>
+Normal comparison-based sort algorithms such as Quick Sort, Merge Sort or Heap Sort run at O(N*log(N)). This is much better than naïve comparison-based algorithms such as "Insertion Sort", or "Bubble Sort" which run at O(N^2). However, we can improve upon O(N*log(N)) too, in some cases.
+</para>
+<para>
+One of them is if the keys in question are, or can be mapped to integers in a certain range. In this case, we can use an algorithm such as "Counting Sort", to sort at a time of roughly O(N). We can also try using "Radix sort" along with counting sort, if we have more than one such "digit" in the radix (as long as their number remain constant).
+</para>
+<para>
+On the other hand, sometimes using Insertion Sort is preferable over Merge Sort or Quick Sort, if the number of elements being sorted is very small, as the latter algorithms have a lot of overhead.
+</para>
+
+</section>
+<section><title>Joel Spolsky's Schlemiel the Painter's Syndrome</title>
+<para>
+In his <ulink url="http://www.joelonsoftware.com/articles/fog0000000319.html"><citetitle>article "Back to Basics"</citetitle></ulink>, Joel Spolsky illustrates a common (and unnecessary) pattern that increases the complexity of programs. Essentially, when one does in C:<programlisting>  char string[1000];</programlisting><programlisting>  strcpy (string, "One ");</programlisting><programlisting>  strcat (string, "Two ");</programlisting><programlisting>  strcat (string, "Three ");</programlisting><programlisting>  strcat (string, "Four ");</programlisting><programlisting>  .</programlisting><programlisting>  .</programlisting><programlisting>  .</programlisting>
+</para>
+<para>
+And so forth, then the strcat calls will keep starting from the beginning of the string and seek the (increasing) end times and again. As a result, the complexity of appending N strings each with a limited length, becomes O(N^2) instead of O(N). 
+</para>
+<para>
+Eliminating such problematic mis-implementations in the code can yield a substantial speed-increase.
+</para>
+
+</section>
+
+</section>
+<section><title>Note about Order-of-Complexity Reduction</title>
+<para>
+It should be noted that some algorithms with a proven lower Big-O notation than equivalent ones, are either too complicated to be effectively implemented or have a huge runtime factor that will make them impractical for most reasonable data-sets, or both. For example, there's an algorithm for finding the Median (= middle element) of an array in linear (O(N)) time, that was discovered in the nineties, but it's very complex and is a very "big" linear time (with a huge factor), that an efficient O(N*Log(N)) sorting would normally be more efficient. That and we are very often interested in the Median for optimizing sorting, and so it would make sense not to use this algorithm in the first place.
+</para>
+
+</section>
+
+</section>
+<section><title>Factor Optimizations</title>
+<section><title>What are Factor Optimizations?</title>
+<para>
+Factor Optimizations are the opposite of order of complexity optimizations: they don't change the overall complexity of the algorithm, but rather make it run faster by a certain factor. As an extreme (but not so unrealistic) example, I may increase the formula for calculating the time that my program runs from 5 seconds times N^2 (where N is the length of the input) to 1 second times N^2. One can see that we increase the optimization by a certain factor, and still don't handle potential scalability problems.
+</para>
+
+</section>
+<section><title>The Motivation for Factor Optimizations</title>
+<para>
+Are factor optimizations worth-your-time? Some people don't seem to think so. For example Eric Raymond has <ulink url="http://catb.org/esr/writings/taoup/html/ch12s01.html"><citetitle>this to say in "The Art of Unix Programming"</citetitle></ulink>:
+</para>
+<para>
+<para>
+
+</para>
+<para>
+One is the exponential effect of Moore's Law — the smartest, cheapest, and often fastest way to collect performance gains is to wait a few months for your target hardware to become more capable. Given the cost ratio between hardware and programmer time, there are almost always better things to do with your time than to optimize a working system.
+</para>
+<para>
+
+</para>
+<para>
+We can get mathematically specific about this. It is almost never worth doing optimizations that reduce resource use by merely a constant factor; it's smarter to concentrate effort on cases in which you can reduce average-case running time or space use from O(n^2) to O(n) or O(n log n),[112] or similarly reduce from a higher order. Linear performance gains tend to be rapidly swamped by Moore's Law.[113]</para>
+
+</para>
+<para>
+Randall Hyde presents an opposing view in <ulink url="http://www.onlamp.com/pub/a/onlamp/2004/05/06/writegreatcode.html"><citetitle>his OnLAMP.com feature, "Why Learning Assembly Language is Still a Good Idea"</citetitle></ulink>:
+</para>
+<para>
+<para>
+Most of the time you can achieve very good performance boosts by simply improving the implementation of an existing algorithm. A computer scientist may argue that a constant improvement in performance isn't as good as, say, going from an algorithm with O(n^2) performance to one with O(n lg n) performance, but the truth is that most of the time a constant factor of two or three times improvement, applied throughout a piece of software, can make the difference between a practical application and one that is simply too slow to comfortably use. And it is exactly this type of optimization with which most modern programmers have little experience.</para>
+
+</para>
+<para>
+So which viewpoint is correct? I tend to think that Raymond is wrong, while Hyde is correct. The factors in which your program is running are still important, and can make a world of difference. Some factor optimizations may yield huge benefits and will make you and your users happier.
+</para>
+<para>
+Raymond is also misled because one cannot expect their end-users to upgrade their machines. Furthermore, it seems that we've <ulink url="http://www.gotw.ca/publications/concurrency-ddj.htm"><citetitle>hit the end of the linear CPU speed increase</citetitle></ulink> for Semiconductor-based CPUs, and that we cannot expect a linear code to become faster with new hardware. Highly parallelized code may become faster, but parallelization is not always possible, or desirable.
+</para>
+<para>
+<ulink url="http://www.mail-archive.com/linux-il@cs.huji.ac.il/msg27751.html"><citetitle>Another illustrative story</citetitle></ulink> about why it's not a good idea to depend on Moore's law to speed up your code was posted by Gilboa Davara to the Linux-IL mailing list. Quoting from there while editing for coherency:
+</para>
+<para>
+<para>
+
+</para>
+<para>
+A couple of years ago I worked for a medical software development company. I was working on the database development side. (We had our own proprietary object oriented database)
+</para>
+<para>
+
+</para>
+<para>
+Our database was pretty cool; it could handle an hospital level load on a dual Pentium Pro machine. (Which was a far cry from most big iron machines that were used back then.)
+</para>
+<para>
+
+</para>
+<para>
+Our medical software side used PowerBuilder (and later VB) to developthe medical applications. To put it mildly, the medical application itself, was by far, slower andheavier then the medical databased that it was built upon. While 50 clients could run easily on a Pentium I 90 MHz with 32MB of RAM , the medical application ran like shit on a Pentium I 166 MHz with 64MB of RAM machine!
+</para>
+<para>
+
+</para>
+<para>
+And every-time we pointed this anomaly to the med team, they claimedthat "new machines are bound, new CPUs; by the time we are out, CPUpower won't be an issue."
+</para>
+<para>
+
+</para>
+<para>
+You know what, that med software now runs slower than a dead dog on a top-level Pentium 3 / Pentium 4 / Athlon machine… nothing has changed.</para>
+
+</para>
+
+</section>
+<section><title>Examples for Factor Optimizations</title>
+<section><title>Managing Pointers to Structs Instead of the Structs Themselves</title>
+<para>
+If we have a collection of many C/C++-structs (structures that contain an adjacent number of elements of possibly different data types), then swapping two such structs (say for re-ordering or sorting) will require a lot of memory access. On the other hand if we manage pointers to such structures, with permanent addresses, then swapping two 32-bit or 64-bit pointers will be relatively cheap.
+</para>
+<para>
+The first ANSI C release (0.2.0) of Freecell Solver allocated a direct array of large C-structs, and then sorted them and binary searched them. In the 0.4.0 release, an array of pointers to individually-malloc()-ed structs was implemented instead, which resulted in a huge boost of speed. This taught me a valuable lesson on how to make a smart use of pointers as an optimization tool.
+</para>
+
+</section>
+<section><title>Reducing Memory Consumption</title>
+<para>
+The more memory an application, or its individual elements consumes, the more cache misses it has, the more page swapping it requires, and it becomes more probable for data to require more than one cache line. As a result, reducing the size of a program can often lead to speed benefits.
+</para>
+<para>
+As <ulink url="http://www.mail-archive.com/linux-il@cs.huji.ac.il/msg07076.html"><citetitle>documented in a post to Linux-IL</citetitle></ulink>, when Freecell Solver was converted from representing cards as 32-bit values, and converted to representing them using 8-bit octets, it became much faster. This is likely due to less swapping, due to less cache misses, and because more cards could fit in the Pentium's 32-byte cache row.
+</para>
+<para>
+<ulink url="http://lwn.net/Articles/82495/"><citetitle>The "Cost of Inline Functions" LWN.net story</citetitle></ulink> is also illustrative. When one function in the Linux kernel was un-inlined, it made the kernel somewhat faster. The reason was that all of the inlined instances of it occupied a (relatively) large amount of memory per-instance, and as a result, the kernel was larger, and there were more cache misses.
+</para>
+<section><title>Note about the Memory-Speed Tradeoff</title>
+<para>
+After reading what was written here, you may think this contradicts the common Memory-Speed Trade-off "truism". The Memory/Speed Trade-off has its origins in theoretical computer science, where it is shown that for certain tasks, one can reduce the run-time's asymptotic complexity by increasing the asymptotic amount of memory used (and vice versa). For example, we can sometimes reduce the asymptotic run-time from O(N^2) to O(N) by increasing the memory from O(1) to O(N). 
+</para>
+<para>
+This is all nice and true, but it doesn't contradict the fact that given the architecture of contemporary computer hardware and operating systems, the less memory a program uses (while the logic of the algorithm remains the same) - the faster it will probably run. It's not an asymptotic trade-off, but rather a gain-gain situation.
+</para>
+
+</section>
+
+</section>
+<section><title>Parallelization</title>
+<para>
+By parallelizing a task, one can split it into several lines-of-executions (processes, threads, tasks on different computers in the cluster, etc.) that each will run in parallel. As a result, the complete task itself will hopefully finish faster. A good example for parallelization is performing the same time-consuming operation on a lot of inputs. If we assign different processes subsets of the inputs, then they will likely finish it faster.
+</para>
+<para>
+Lately, parallelization has become especially attractive for making code run faster due to the advancement of multi-core CPUs. However, it should be noted that parallelization is still limited by some factors such as locking, serialization and de-serialization of the inter-process data, context-switching, CPU and operating system-constraints, and the fact that often the number of tasks will exceed the number of available processors. Most importantly, Amdahl's law rules that the serial part of the task (by definition) cannot be parallelized, and so limits the amount of gain from the parallelization.
+</para>
+
+</section>
+<section><title>Putting the Most Important struct Members First</title>
+<para>
+In the Linux kernel the order of the struct members is ordered so the most important members fit within the Pentium architecture's 32-byte cache line size. This way, access to the struct in general is sped up because all of its members remain in the cache line most of the time and can be accessed more quickly.
+</para>
+
+</section>
+<section><title>Copy-on-write</title>
+<para>
+Another useful optimization is known as copy-on-write. A good example for this is when implementing a virtual machine for a programming language, and where we assign a variable to another one. While we can duplicate the contents of the variable each time, it would be cheaper to just increase the reference count, and wait for one of the variables to change before they are separated.
+</para>
+<para>
+If the contents of the copies are significant, then copy-on-write can yield significant savings in time.
+</para>
+
+</section>
+<section><title>Caching</title>
+<para>
+If we perform many costly queries, then caching commonly-issued queries along with the results we got in memory is likely to increase the overall performance of the program. Caching is implemented in all kinds of software - from operating system kernels that hold recently-accessed file-system entries in cache, to database servers that keep caches of the various stages of the queries given to them.
+</para>
+<para>
+There's a variation on caching called Memoization, in which we never relieve of our results. It can be demonstrated that by memoizing the naïve (tree-recursive) Fibonacci-number calculation, one can actually reduce its complexity from an exponential one to a linear one.
+</para>
+<para>
+One should note that caching or memoization cannot be done in many cases, for example, if the queries have most kinds of side-effects.
+</para>
+
+</section>
+<section><title>Avoiding Copying Altogether</title>
+<para>
+<ulink url="http://tech.groups.yahoo.com/group/hackers-il/message/2517"><citetitle>This Hackers-IL Post</citetitle></ulink> gave the case for avoiding unnecessary copying of objects in order to increase performance. Calling copy constructors excessively can have a negative impact on performance, and reducing the number of calls to a minimum can improve performance. Just copying a large contiguous area in memory, several times, may have a negative effect on performance and eliminating it, may also turn out to be beneficial.
+</para>
+
+</section>
+<section><title>Inline Functions</title>
+<para>
+Despite what was said earlier, in the context of reducing memory consumption, inlining functions in languages such as C or C++ can often have a positive effect on performance. Function calls are costly operations, and have a lot of overhead, and avoiding the function call by inserting the code in-place whenever the function is used, can increase performance. Inline functions become more and more beneficial the shorter they are, and if the memory occupied by the in-place calls is smaller than the memory used without inlining.
+</para>
+<para>
+If you are unsure whether inlining a certain function has a positive or negative effect, then benchmark and see.
+</para>
+
+</section>
+<section><title>The Schwartzian Transform</title>
+<para>
+The Schwartzian transform is a way to optimize certain kinds of comparison-based sort operations. If the keys of the function that we want to compare take a lot of time to calculate (such as if they require access to the hard-disk), then we can first prepare an equivalent array with pairs of the inputs and their keys, then sort the pairs based on the keys, and finally filter only the original inputs from the pairs.
+</para>
+<para>
+It should be noted that the Schwartzian transform actually reduced the order of complexity of the number of times the keys are calculated from O(N*log(N)) to O(N). However, the overall order of complexity of the sort remains O(N*log(N)). 
+</para>
+
+</section>
+
+</section>
+<section><title>Call for a Catalog of Optimizations</title>
+<para>
+I believe it would be a good idea to concentrate all the known optimizations in one place, in a similar fashion to the <ulink url="http://www.refactoring.com/catalog/"><citetitle>Catalog of Refactorings</citetitle></ulink> and the Portland Pattern Repository. This would be a list that people can read for completeness, and to realize where their code can be improved, and for general inspiration, and to facilitate communication.
+</para>
+<para>
+I'm not aware of a similar effort as of the time of this writing, and it will be useful. This section only covered a very small subset of the possible optimization strategies, just to give a taste of them, and did not aim to be comprehensive.
+</para>
+
+</section>
+
+</section>
+<section><title>Optimization by Changing the Dependencies</title>
+<para>
+Often the original choice of programming languages, or libraries can affect the execution speed, because they are not very optimized, too bloated, or otherwise too slow. Moving to a different programming language or library, including possibly replacing third-party code with your own, may have a positive effect on one's program's speed.
+</para>
+<para>
+For example, if you're doing a lot of number-crunching code in dynamic, P-code languages such as Perl, Python or Ruby (at least without utilizing such APIs as <ulink url="http://pdl.perl.org/"><citetitle>PDL</citetitle></ulink> or <ulink url="http://www.scipy.org/"><citetitle>SciPy</citetitle></ulink>) or otherwise your code involves many loops and conditionals, then you can expect it to run slower than if it was written in C or Assembler.
+</para>
+<para>
+Similarly, I found that GLib's balanced binary trees performed more poorly than those of libavl and libredblack, and that its hash performed more poorly than my own custom hash (which was since then optimized further). As a result, eliminating a dependency on GLib's data structures may improve the performance of the program.
+</para>
+
+</section>
+<section><title>Optimizing by Reducing Feature-Set</title>
+<para>
+"There ain't no such thing as a free lunch". The more features your program has, the more code is required to implement them, which in turn consumes more memory, and slows things down. Furthermore, it requires more conditionals and often even loops, which also require extra processing. Thus, by removing features from one's application, one can have faster code.
+</para>
+<para>
+For example, in <ulink url="http://www.joelonsoftware.com/articles/APIWar.html"><citetitle>"How Microsoft Lost the API War"</citetitle></ulink>, Joel Spolsky tells that Microsoft has gone to great lengths to maintain bug-to-bug (binary) backward compatibility for their Windows-line of operating system. As a result, buggy software that relied on API quirks that got changed, often could still work in later versions of Windows, because Microsoft made sure that Windows supplied them with a similar environment. As a result of maintaining all of this backward compatibility, there was more code in Microsoft's products, which may have contributed to the common and notorious perception that they became slower with each release.
+</para>
+<section><title>Optimizing by Compromising on Security</title>
+<para>
+I can go further than that, and claim that one can often optimize one's code by compromising on its security. The less sanity checks, input checks, etc. a code has - the faster it will run. For example, a code that does not have a lot of checking for the failure (and graceful handling) of dynamic memory allocation calls (in languages such as C without managed programming) such as <literal>malloc()</literal>, will run faster. (Until and if it runs out of memory and then crashes.)
+</para>
+<para>
+I read somewhere that <ulink url="http://tech.groups.yahoo.com/group/hackers-il/message/1688"><citetitle>programmers complained that checking and handling errors in their programs made them have to write about 4 times more code</citetitle></ulink>, which makes sense. All this code slows the program down when everything runs as expected.
+</para>
+<para>
+Note that "Here be dragons". It's probably never a good idea to compromise on security in order to increase speed. But I've mentioned it here for completeness sake.
+</para>
+
+</section>
+
+</section>
+<section><title>Conclusion</title>
+<para>
+When I mentioned this article to some people on IRC (while it was still incomplete), someone said that "The first rule of optimization is 'Don't!'". I think such attitude is harmful. While I agree that "premature optimization is the root of all evil", sometimes one's code is just too slow and needs to be optimized. And if your code is what <ulink url="http://www.joelonsoftware.com/articles/FiveWorlds.html"><citetitle>Joel Spolsky calls "Shrinkwrap"</citetitle></ulink> (i.e: code that is sold or otherwise distributed and made available for public consumption) then you can often not make assumptions on how fast it needs to be, and the faster it is - the better.
+</para>
+<para>
+Speed and optimizing other resources are one important factor <ulink url="http://www.shlomifish.org/philosophy/computers/high-quality-software/"><citetitle>in the general, abstract quality of programs</citetitle></ulink>. If your program is slow, it is likely going to make your users frustrated and unhappy, which will be a failure in your mission as a software developer. So it is important that your program is fast enough, if not very much so.
+</para>
+<para>
+My aim in this document was to explain the "why"'s, "what"'s and to a lesser extent "how"'s of optimization. I hope I was successful, and that people who read it will be more willing to optimize their software and more clueful in how to do so. 
+</para>
+
+</section>
+<section><title>Thanks</title>
+<para>
+I'd like to thank Daan for expressing a lot of interest in this article, and for his constant encouragement and input. Limbic_Region has given me some useful input for this article by email. Several people have made some contributions to this article: Jguk, Dallas1278 and the IPs 84.27.42.81, 85.146.243.13, 203.196.46.108, 70.176.53.73, and 213.129.10.120 . I'd also like to thanks all the originators of the sources that I quoted in the article.
+</para>
+<para>
+Category:Computing (Category:Computing)
+</para>
+</section>
+</article>
+</book>

lib/docbook/4/style/human-hacking-field-guide/background-image.png

Added
New image

lib/docbook/4/style/human-hacking-field-guide/background-shlomif.png

Added
New image

lib/docbook/4/style/human-hacking-field-guide/bottom-shlomif.png

Added
New image

lib/docbook/4/style/human-hacking-field-guide/hhfg-bg-bottom.png

Added
New image

lib/docbook/4/style/human-hacking-field-guide/hhfg-bg-middle.png

Added
New image

lib/docbook/4/style/human-hacking-field-guide/hhfg-bg-top.png

Added
New image

lib/docbook/4/style/human-hacking-field-guide/style.css

+a:hover { background-color : palegreen; }
+body 
+{ 
+    background:url(hhfg-bg-middle.png) #E5F0FA repeat-y top center;
+    color:black;
+    margin:0px;
+    padding:0px;
+    font-family: Sans-Serif;
+}
+.ads_top
+{
+    padding-top: 20px;
+    background: url(hhfg-bg-top.png) no-repeat center top #E5F0FA;
+    height: 180px;
+}
+.navfooter
+{
+    background: url(hhfg-bg-bottom.png) no-repeat center top #E5F0FA;
+    height: 180px;
+}
+.navheader hr
+{
+    display: none;
+}
+.itemizedlist ul.centralized 
+{ 
+    text-align: center; 
+    list-style-type : none;
+    font-size: large;
+}
+.section, .toc, .title, .author, table, p, hr, .titlepage div
+{
+    margin-left:auto;
+    margin-right:auto;
+    width:760px;
+}
+hr
+{
+    margin-top: 1em;
+    margin-bottom: 1em;
+}
+h1, h2
+{
+    margin-bottom: 1em;
+}
+.toc dl
+{
+    margin-top: 0;
+    padding-top: 0;
+    margin-bottom: 0;
+    padding-bottom: 0;
+}
+.center
+{
+    text-align: center;
+    margin-left: auto;
+    margin-right: auto;
+}
+

lib/docbook/4/style/human-hacking-field-guide/top-shlomif.png

Added
New image

lib/docbook/4/xml/case-for-drug-legalisation.xml

+<?xml version='1.0' encoding="utf-8"?>
+<?xml-stylesheet href="docbook-css/driver.css" type="text/css"?>
+
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+"/usr/share/sgml/docbook/xml-dtd-4.1.2/docbookx.dtd"[
+]>
+
+<article id="index">
+    <articleinfo>
+        <title>The Case for Drug Legalisation</title>
+        <authorgroup>
+            <author>
+                <firstname>Shlomi</firstname>
+                <surname>Fish</surname>
+                <affiliation>
+                    <address>
+                        <email>shlomif@shlomifish.org</email>
+                    </address>
+                </affiliation>
+            </author>
+         </authorgroup>
+         <copyright>
+             <year>2006</year>
+            <holder>Shlomi Fish</holder>
+        </copyright>
+      <legalnotice id="main_legal_notice">
+            <para>
+<!--Creative Commons License-->
+This work is licensed under the <ulink url="http://creativecommons.org/licenses/by/2.5/">Creative Commons Attribution 2.5 Licence</ulink> (or at your option a greater version of it).
+		<!--/Creative Commons License--><!-- <rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+		<Work rdf:about="">
+			<license rdf:resource="http://creativecommons.org/licenses/by/2.5/" />
+	<dc:title>The Case for File Swapping</dc:title>
+	<dc:date>2005</dc:date>
+	<dc:description>An essay that explains why Internet File Swapping (using Peer-to-Peer networks, etc.) is not only moral and ethical, but also should be legal, and cannot be banned. Discusses other issues.</dc:description>
+	<dc:creator><Agent><dc:title>Shlomi Fish</dc:title></Agent></dc:creator>
+	<dc:rights><Agent><dc:title>Shlomi Fish</dc:title></Agent></dc:rights>
+	<dc:type rdf:resource="http://purl.org/dc/dcmitype/Text" />
+		</Work>
+		<License rdf:about="http://creativecommons.org/licenses/by/2.5/"><permits rdf:resource="http://web.resource.org/cc/Reproduction"/><permits rdf:resource="http://web.resource.org/cc/Distribution"/><requires rdf:resource="http://web.resource.org/cc/Notice"/><requires rdf:resource="http://web.resource.org/cc/Attribution"/><permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/></License></rdf:RDF> -->                
+            </para>
+        </legalnotice>
+
+        <revhistory>
+            <revision>
+                <revnumber>1801</revnumber>
+                <date>29 February 2008</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Fixed some typos, added the "What you can do about it?"
+                    section and added the "Links" section.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1548</revnumber>
+                <date>28 July 2006</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Finished the first published version.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1518</revnumber>
+                <date>14 October 2005</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Forked the text from a previous document, and starting to 
+                    adapt it.
+                </revremark>
+            </revision>
+        </revhistory>
+    </articleinfo>
+
+<section id="introduction">
+    <title>Introduction</title>
+    <para>
+        Many people take the prohibition on the currently illegal narcotics
+        (e.g: Marijuana, Cocaine, Heroine) for granted. They believe that
+        just because the drugs are physically harmful, they should be banned.
+        Yet, this is very far from the fact. While drugs can be harmful, there 
+        is no good reason to make them illegal. In fact, the prohibition on
+        drugs causes so many undesirable side-effects, that they
+        <emphasis role="bold">must</emphasis> be made legal.
+    </para>
+    <para>
+        If this sounds fantastic to you - read on, I'm sure you'll find out 
+        that I know what I'm saying.
+    </para>
+    <para>
+        The war on drugs has been supported by both the left and right political
+        camps, and has only been rejected by Libertarians and various other
+        minority groups who hold this view. As a result, most people who
+        believe they should choose between left, right or middle, think drug
+        prohibition is acceptable on everybody. But this is not the case. The
+        prohibition on drugs is very harmful to the public and individual 
+        well-being and must be eradicated as soon as possible.
+    </para>
+</section>
+
+
+<section id="morality">
+    <title>The Morality of Drug Abuse</title>
+    <para>
+        A person has a basic right to harm himself, as long as he does not harm
+        others in the process. That's because everyone of us is the owner of 
+        his mind, body and property, and is solely responsible for their use
+        and abuse. 
+    </para>
+    <para>
+        All arguments that do not favour that, like that a person thus 
+        contributes less to society, and becomes a burden on it are pretty
+        silly. That's because a person is never obliged to contribute to
+        society ("First, do not harm"), and the society at large is not
+        obliged to support its members. (It would be Socialistic to claim
+        otherwise.)
+    </para>
+    <para>
+        Thus, a person must be allowed by law to consume drugs. I'm not saying
+        it is desirable if a person exercises this right. I'm just saying that
+        a person should be allowed to do so, just as he is allowed to smoke,
+        drink alocholic beverages, deteriorate in personal hygiene, give away
+        money for no good reason, act stupidly, etc. These are all harmful
+        activities, yet perfectly legitimate.
+    </para>
+</section>
+
+<section id="biology">
+    <title>The Biology of Drug Use</title>
+    <para>
+        Drugs are not as harmful as many people think. Most drug users
+        are perfectly healthy people who just happen to have a drug problem,
+        just like people who smoke, or are alcholics, or are
+        addicted to caffeine have a drug problem. Otherwise, they are able
+        to function properly and be good citizens. There are no recorded 
+        deaths from Marijuana in the U.S. The amount of deaths for Cocaine
+        is 20 per 100,000 (4 if we take into account such factors as its 
+        reduced quality), and the deaths from Heroin are 400 per 100,000 (or
+        80 if we take these factors into account). This is compared to 150
+        deaths per 100,000 from Alcohol and 650 from Tobacco. Taking the
+        numbers into account, in the U.S. there used to be 390,000 deaths 
+        per year from Tobacco, 150,000 from Alcohol and only 400 from Heroin
+        and 200 from Cocaine (and none from Marijuana).
+        (<ulink url="http://www.cato.org/pubs/pas/pa121.html">Source</ulink>.)
+    </para>
+    <para>
+        Thus, legalising drugs, which would potentially make them more 
+        common, will not be a hazard to the global health status of the
+        population.
+    </para>
+</section>
+
+<section id="bio_psychology">
+    <title>The Bio-Psychology of Drug Use</title>
+    <para>
+        The mere act of consuming illegal narcotics, usually does not cause
+        one to commits crimes. While drugs affect the mind, a large
+        increase in drug consumption by itself will not cause a large 
+        increase in the number of crimes committed.
+    </para>
+    <para>
+        Note that criminal activity is often related to drug use due to its
+        present illegal nature and the fact drug users steal in order to
+        acquire drugs. (or other drug related crimes.) However, this is not
+        a direct result of the bio-psychological effects of the drugs
+        themselves.
+    </para>
+</section>
+
+<section id="arguments_for">
+    <title>Arguments for Drug Legalisation</title>
+    <section id="arguments_for__inflation_of_crime">
+        <title>The Prohibition on Drugs Causes an Inflation of Crime</title>
+        <para>
+            As drugs are illegal, they are being marketed by outlaws, who
+            charge an inflated price for them. Much more inflated that the
+            amount it requires to grow, manufacture and distribute them.
+            As a result, there is a growing black market for the distribution
+            of drugs and drug users eventually need to commit crimes like
+            theft and robbery to support their habits.
+        </para>
+        <para>
+            The average crime rate in the U.S increased twice fold due to the
+            prohibition on Alcohol. Once the prohibition was lifted, it
+            decreased back to its original state. It is expected that
+            drug-induced crimes cause a similar increase, due to the similar
+            nature of this prohibition.
+        </para>
+        <para>
+            In this analysis one should also include the very "crimes" of drug
+            use, trafficing, and sale, as well as crimes caused due to the
+            criminal nature of some drug dealers. Drug trafficing is also a
+            huge source of income for Organised crime.
+        </para>
+        <para>
+            All of this crime can be eliminated in a swift blow by legalising
+            drugs. When drugs will become legal, they will be produced,
+            distributed and sold by local legitimate entities, who will be
+            subject to Capitalistic market constraints. Their prices will
+            drop to a minimum, allowing everybody to buy them at the
+            needed quantities. Criminals will no longer be able to make a 
+            decent living from selling them in the black market (as there will
+            be none.).
+        </para>
+    </section>
+    <section id="arguments_for__not_helping">
+        <title>The War on Drugs does not Help to Fight them</title>
+        <para>
+            Law enforcement organisations attempt to stop drug trade by
+            catching drug shipments, and drug dealers. However, any shipment
+            or dealer that is caught, has only one effect: a temporary increase
+            in the price of drugs at the location to which they were intended. 
+            Most drug shipments and transactions are never stopped, and it is
+            a pointless struggle to try to stop them.
+        </para>
+    </section>
+    <section id="arguments_for__quality_decrease">
+        <title>The Prohibition on Drugs Lowers the
+            Quality of Drugs</title>
+        <para>
+            Illegal drugs are not sold in the free market and as a result the
+            sold good is subject to the whims of the local outlaw manufacturer 
+            or distributor. As a result, they often have reduced quality, which
+            can cause a lot of unnecessary health side-effects on their users,
+            including many deaths.
+        </para>
+        <para>
+            During the prohibition on alcohol it was observed that the quality
+            of alcoholic beverages has heavily decreased, and the same thing 
+            happens now with the currently illegal drugs.
+        </para>
+    </section>
+    <section id="arguments_for__causes_proliferation">
+        <title>The Prohibition on Drugs Causes Proliferation of 
+        Drugs' Use</title>
+        <para>
+            People who become heavy drug users often need to find a way to
+            finance their habit. As a result, they often become drug dealers
+            themselves, and try to push drugs onto other people,
+            including children.
+        </para>
+        <para>
+            Making drugs legal will stop this vicious cycle. The price of
+            drugs will drop to free market levels, and people will not need
+            to become drug dealers themselves to finance their habit.
+        </para>
+    </section>
+    <section id="arguments_for__lower_sectors_progress">
+        <title>Slowdown of the Progress of Lower Sectors</title>
+        <para>
+            Drug dealing in a society where drugs are criminalised is
+            a way to make a lot of money. As a result, young people among 
+            the poor find selling drugs an easy way to earn their living
+            and escape the more demanding path of working in an honest job.
+        </para>
+        <para>
+            This causes a bad effect on the societies in poor neighbourhoods, 
+            who turn to drug dealing instead of advancing their rank in the
+            honest world. Making drugs legal will kill this easy way out, and
+            force the young people of the poor to struggle for a honest living
+            and gradually advance their personal and collective financial
+            status.
+        </para>
+    </section>
+    <section id="arguments_for__unholy_enemy">
+        <title>Drug Users Serve as the "Unholy Enemy" of Society</title>
+        <para>
+            There is a common pattern in history of "unholy enemies" - 
+            groups of people who are presented by leaders to be of such
+            evil nature that the general populace should be willing to
+            sacrifice their lives, freedom or well-being to fight them.
+            These have been the Jews in Nazi Germany, and the Kafirs in 
+            Islam. In modern society, drug users now serve as an unholy
+            enemy for which the government can undermine
+            <ulink url="http://en.wikipedia.org/wiki/Liberalism">Liberalism</ulink>
+            and gradually repress the people.
+        </para>
+        <para>
+            Yet, drug users are no such enemy - they do not pose a threat
+            to society. Plus, they are people in need of help, not in need of
+            being hunted and prosecuted.
+        </para>
+        <para>
+            The legalisation of drugs will put a stop to the irrational
+            trend to make drug users an unholy enemy and for the
+            government to undermine the individual rights of the citizens.
+            There is no good reason to undermine individual rights, much less
+            one that is useless and pointless as trying to "win" the war on
+            drugs.
+        </para>
+    </section>
+    <section id="arguments_for__abusive_behaviour">
+        <title>The Prohibition Causes an Abusive Behaviour among
+        the Users</title>
+        <para>
+            Since drugs are illegal and using them can jail a person,
+            drug users usually exhibit abusive behaviours: they lie, steal,
+            and become dishonest and suspicious. This is not an effect of the
+            drug itself - it's a result of the psychological and legal
+            situation in which they are present. By legalising drugs, one can
+            be sure that drug users will be able to openly admit their
+            problems, and seek help.
+        </para>
+    </section>
+    <section id="arguments_for__legit_uses">
+        <title>Prevention of Legitimate Uses</title>
+        <para>
+            The prohibition of illegal drugs prevents some legitimate uses
+            of the plants from which they are made. The most prominent examples
+            are paper that can be made out of Hemp, but is now made out of
+            cut-down trees instead (which is certainly not good for the
+            environment), and the various medical uses of Marijuana.
+        </para>
+    </section>
+    <section id="arguments_for__jailing_people">
+        <title>Strain on Society due to People in Jail</title>
+        <para>
+            The prohibition on drugs puts many people in Jail - there
+            are over 1 million prisoners for drug offences in the United
+            States. There are even more if we consider drug-induced offences
+            such as drug-induced theft.
+        </para>
+        <para>
+            These prisoners are a large strain on society which needs to 
+            support them. They also prevent more serious criminals from
+            being jailed, which undermines the punishment and
+            rehabilitation system of the government.
+        </para>
+        <para>
+            The legalisation of drugs will free the prisons from false
+            criminals, and restore justice. And the lawful people will no
+            longer need to support hundreds of thousands of jailed drug users 
+            and dealers.
+        </para>
+    </section>
+</section>
+<section id="summary">
+    <title>Summary</title>
+    <para>
+        The prohibition against Drugs is the real drug problem. It is a war
+        against the people, that consumes lives, money, and property. It has
+        no good reason. History tells us that all the past prohibitions on
+        narcotics failed miserably. The current prohibition on drugs is no
+        different.
+    </para>
+</section>
+<section id="what_you_can_do_about_it">
+    <title>What You can do about it?</title>
+    <para>
+        Here is a list of things you can do to help the cause of fighting
+        for drug legalisation:
+    </para>
+    <orderedlist>
+        <listitem>
+            <para>
+                <emphasis role="bold">Educate people about it</emphasis>:
+                write something pro drug legalistation online, in blogs,
+                mailing lists, newsgroups, web forums; write your school
+                report about it; publish articles about it in newspapers,
+                tell about it to your friends, etc.
+            </para>
+            <para>
+                Note that you should feel free to link to this article, or
+                even quote its text, as long as you give attribution. (See
+                <ulink url="http://creativecommons.org/licenses/by/2.5/">its
+                    open-content, Creative Commons, licence for more 
+                    information.</ulink>
+            </para>
+        </listitem>
+        <listitem>
+            <para>
+                <emphasis role="bold">Contact Your Government</emphasis> -
+                write to your representatives and government, and tell them
+                why the prohibition on drugs is harmful and not justified. If
+                possible, vote for representatives that support the 
+                legalisation of drugs.
+            </para>
+        </listitem>
+        <listitem>
+            <para>
+                <emphasis role="bold">Don't work against the cause</emphasis>
+                - if you're a drug-enforcing policeman, then switch to a
+                different department, or quit. If you're an agent of the
+                <ulink url="http://en.wikipedia.org/wiki/Drug_Enforcement_Administration">Drug 
+                    Enforcement Administration (DEA)</ulink> or a similar 
+                organisation - then quit.
+            </para>
+        </listitem>
+        <listitem>
+            <para>
+                Last, but not least - <emphasis role="bold">don't use illegal 
+                    narcotics</emphasis>. They
+                have numerous bad medical effects, and using them reduces
+                your credibility as someone who can speak against their 
+                prohibition. 
+            </para>
+        </listitem>
+    </orderedlist>
+
+    <para>
+        By acting and propagating the understanding that drugs should 
+        be legalised, we can eventually create a strong, vibrant
+        movement against the prohibition on drugs, that can eventually
+        abolish it completely.
+    </para>
+</section>
+
+<section id="links">
+    <title>Links</title>
+    <itemizedlist>
+        <listitem>
+            <para>
+                <ulink url="http://www.cato.org/pubs/pas/pa121.html">James 
+                    Ostrowski's "Thinking about Drug Legalization"</ulink> is an 
+                excellent and detailed article about the problems of drug 
+                prohibition.
+            </para>
+        </listitem>
+        <listitem>
+            <para>
+                The Wikipedia has an 
+                <ulink url="http://en.wikipedia.org/wiki/Prohibition_(drugs)">article 
+                    
+                    written on the Prohibition on drugs</ulink> from a hopefully 
+                Neutral Point of View.
+            </para>
+        </listitem>
+        <listitem>
+            <para>
+                The web site 
+                <ulink url="http://www.drugwarfacts.org/">"Drug 
+                    War Facts"</ulink> was recommended to me by a 
+                libertarian correspondant. I didn't fully read it yet.
+            </para> 
+        </listitem>
+        <listitem>
+            <para>
+                <ulink url="http://www.druglibrary.org/schaffer/">The Schaffer
+                    Library of Drug Policy</ulink> is a comprehensive site for
+                support of the legalisation of drugs. It contains a 
+                <ulink url="http://www.druglibrary.org/schaffer/dea/">copy of 
+                    the Drug Enforcement Administration (DEA) site, with 
+                    comments</ulink> and especially a step-by-step
+                <ulink url="http://www.druglibrary.org/schaffer/dea/pubs/legaliz/claims.htm">rebuttal of their "Speaking Out against Drug Legalisation" 
+                    document</ulink>.
+            </para>
+        </listitem>
+    </itemizedlist>
+</section>
+</article>    <!-- End of the article -->
+

lib/docbook/4/xml/case-for-file-swapping-rev3.xml

+<?xml version='1.0' ?>
+<?xml-stylesheet href="docbook-css/driver.css" type="text/css"?>
+
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+"/usr/share/sgml/docbook/xml-dtd-4.1.2/docbookx.dtd"[
+]>
+<!-- -->
+<!-- $Id$ -->
+<!-- -->
+<!-- $Log$ -->
+<!-- -->
+<!-- General reminders: -->
+
+<article id="index">
+    <articleinfo>
+        <title>The Case for File Swapping</title>
+        <authorgroup>
+            <author>
+                <firstname>Shlomi</firstname>
+                <surname>Fish</surname>
+                <affiliation>
+                    <address>
+                        <email>shlomif@shlomifish.org</email>
+                    </address>
+                </affiliation>
+            </author>
+         </authorgroup>
+         <copyright>
+             <year>2004</year>
+            <holder>Shlomi Fish</holder>
+        </copyright>
+      <legalnotice id="main_legal_notice">
+            <!-- Ci vis pacem -->
+            <para>
+<!--Creative Commons License-->
+This work is licensed under the <ulink url="http://creativecommons.org/licenses/by/2.5/">Creative Commons Attribution 2.5 License</ulink> (or at your option a greater version of it).
+		<!--/Creative Commons License--><!-- <rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+		<Work rdf:about="">
+			<license rdf:resource="http://creativecommons.org/licenses/by/2.5/" />
+	<dc:title>The Case for File Swapping</dc:title>
+	<dc:date>2005</dc:date>
+	<dc:description>An essay that explains why Internet File Swapping (using Peer-to-Peer networks, etc.) is not only moral and ethical, but also should be legal, and cannot be banned. Discusses other issues.</dc:description>
+	<dc:creator><Agent><dc:title>Shlomi Fish</dc:title></Agent></dc:creator>
+	<dc:rights><Agent><dc:title>Shlomi Fish</dc:title></Agent></dc:rights>
+	<dc:type rdf:resource="http://purl.org/dc/dcmitype/Text" />
+		</Work>
+		<License rdf:about="http://creativecommons.org/licenses/by/2.5/"><permits rdf:resource="http://web.resource.org/cc/Reproduction"/><permits rdf:resource="http://web.resource.org/cc/Distribution"/><requires rdf:resource="http://web.resource.org/cc/Notice"/><requires rdf:resource="http://web.resource.org/cc/Attribution"/><permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/></License></rdf:RDF> -->                
+            </para>
+        </legalnotice>
+
+        <revhistory>
+            <revision>
+                <revnumber>1417</revnumber>
+                <date>14 October 2005</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Forked the text from a previous document, and starting to 
+                    adapt it. Tagged as CC-by 2.5
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1422</revnumber>
+                <date>21 October 2005</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Added a rudimentary introduction and the entire terminology
+                    section.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1426</revnumber>
+                <date>21 October 2005</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Added a "Why File Swapping should be Legal?" Section.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1427</revnumber>
+                <date>21 October 2005</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Wrote the "About this Document" section.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1428</revnumber>
+                <date>22 October 2005</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Wrote the "Refuting Common Arguments" section.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1429</revnumber>
+                <date>22 October 2005</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Added two more examples for why file-sharing does
+                    not hurt media sales.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1431</revnumber>
+                <date>22 October 2005</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Added the "more legal uses" section.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1432</revnumber>
+                <date>22 October 2005</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Added the "Reflections on Online Stores".
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1434</revnumber>
+                <date>22 October 2005</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Added the "Conclusions".
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1435</revnumber>
+                <date>22 October 2005</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Added the "Other Important Copyrights Issues".
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1436</revnumber>
+                <date>22 October 2005</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Added the "more links" sub-section.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1438</revnumber>
+                <date>22 October 2005</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Went over the article and corrected many problems.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1446</revnumber>
+                <date>06 November 2005</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Added the "Can File Swapping Really be Stopped?" Section.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1447</revnumber>
+                <date>06 November 2005</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Added the "How you can Help" Section.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1452</revnumber>
+                <date>10 November 2005</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Fixed a grammatical problem courtesy of t1ber from
+                    kuro5hin.org.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1601</revnumber>
+                <date>18 August 2006</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Added a footnote about the benevolent felons, a note
+                    about "stealing from the rich and giving to the poor",
+                    a note about "The Golden Rule", an entire setion about
+                    "The Inernet as an Alternative Medium of Distribution",
+                    a section about the historical perspective of copyright
+                    law, some links and some corrections. Second Revision.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1604</revnumber>
+                <date>28 August 2006</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Fixed a typo ("who" &rarr; "which").
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1618</revnumber>
+                <date>19 November 2006</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Fixed a grammatical problem pointed by a correspondant.
+                </revremark>
+            </revision>
+            <revision>
+                <revnumber>1773</revnumber>
+                <date>20 May 2007</date>
+                <authorinitials>shlomif</authorinitials>
+                <revremark>
+                    Corrected some errors (such as spelling, phrasing or
+                    grammatical); added more discussion of why copying an
+                    artwork is moral; added the merchandise way of making
+                    profit, the "Pirates of the Carriben" anecdote, "Don't
+                    Download this song", and DRM and the Sony rootkit.
+                </revremark>
+            </revision>
+        </revhistory>
+    </articleinfo>
+
+<section id="introduction">
+    <title>Introduction</title>
+    <para>
+        The purpose of this article is to explain why Internet file 
+        swapping (of media such as music files, video files, etc.) is moral,
+        ethical and should be legal. Plus, people who share files on the
+        Internet or download them, must not be prosecuted.
+    </para>
+    <!-- TODO : write more things in the introduction. (?) -->
+</section>
+
+
+<section id="misleading_terms">
+    <title>Debunking Some Misleading Terms</title>
+    <para>
+        The Human Language is primarily a tool of thought, and only afterward
+        a tool of communication. As such, mutations in the meaning of words
+        can affect clear thinking about issues. The issue of file swapping
+        is no exception. Before we continue, allow me to explain about the
+        improper validity or application of some terms.
+    </para>
+    <section id="term_intellectual_property">
+        <title>"Intellectual Property"</title>
+        <para>
+            As noted by Richard Stallman, <ulink url="http://www.linux.com/archive/feature/39915">the term Intellectual property is a 
+                seductive mirage</ulink>. Patents, Copyrights, and Trademarks
+            are not equivalent to property, not even "intellectual" one.
+            Furthermore, they shouldn't be grouped together as they are
+            intended for different purposes and do different things. (And are
+            treated differently according to law).
+        </para>
+        <para>
+            Some people claim that since a copyrighted work is "intellectual
+            property", then copying it is equivalent to "stealing". But that
+            is not the case here.
+        </para>
+    </section>
+    <section id="term_stealing_theft">
+        <title>"Stealing" or "Theft"</title>
+        <para>
+            Copyright apologists like to say that copying a work that is 
+            copyrighted and was published to the public, is equivalent to 
+            "stealing" or "theft". However, stealing involves taking tangible
+            property without permission, and depriving the owner of one less
+            instance of it. On the other hand, with a public work, we can
+            make an unlimited number of copies, while not harming the original,
+            and while respecting the exclusive rights of the author for his 
+            work. This is because we just copy it - we don't claim it is ours.
+        </para>
+        <para>
+            Accusing people who share or duplicate media non-commercially of
+            "stealing" obscures two other forms of media-related crimes that
+            are in fact stealing:
+        </para>
+        <orderedlist>
+            <listitem>
+                <para>
+                    If someone has somehow gained access to my private 
+                    files and used it to prepare his own copies (or worse
+                    delete the originals), then he has performed stealing.
+                    Not of "Intellectual Property" but of actual property, 
+                    because the files are private and I do not wish them
+                    to be inspected by someone else. And privacy must be
+                    respected.
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    If someone has made an inclusive work of someone's 
+                    else's work, and claimed it was his, then it may be
+                    called "stealing" of copyrights.
+                </para>
+            </listitem>
+        </orderedlist>
+        <para>
+            But copying a work that was released for public consumption, can
+            never be considered "stealing". Instead it is merely "copying",
+            "swapping", "sharing", etc.
+        </para>
+    </section>
+    <section id="piracy">
+        <title>"Piracy"</title>
+        <para>
+            The term "Piracy" is very common for the action of copying files,
+            either for money or free of charge. One thing that should be noted
+            about it is that the original pirates were sea-faring robbers, who
+            took hold of ships, stole the goods, killed the people who 
+            were on board, and burned the ships. It would be a bit of a 
+            stretch to label a 10-years-old child who duplicated a 
+            CD of Music or several copyrighted files to his friend, after such 
+            villains.
+        </para>
+        <para>
+            I personally believe that the term "Piracy" in its applied context
+            is quite harmless and is cognitively sound. However, I will not
+            use the term here below.
+        </para>
+    </section>
+    <section id="crime">
+        <title>"Crime"</title>
+        <para>
+            If one violates the letter of the law of my country did he commit
+            a crime? Not necessarily. A crime is an action that is globally
+            accepted to be unethical, according to well-defined, absolute
+            Ethics.
+        </para>
+        <para>
+            People who hid saved Jews during the Nazi regime, violated the
+            law that took place in their lands. But can you call them 
+            "criminals" with a honest face? Not at all - they were very noble
+            people, who did something almost everyone would agree was an
+            ethical action.
+        </para>
+        <para>
+            Now, were people who bought Alcoholic beverages during
+            <ulink url="http://en.wikipedia.org/wiki/Prohibition#United_States">the 
+                time the U.S.A. had alcoholic prohibition</ulink> criminals?
+            Again no. The Law at this point was completely irrational, and so
+            the American Government could not have prevented such 
+            violations, and it was a regulation that the public could not 
+            withstand.
+            <footnote id="benevolent_felons">
+                <para>
+                    One correspondant to this article complained that I 
+                    shouldn't have given these two examples, because one cannot
+                    compare downloading files to the highly moral acts of the
+                    people who hid Jews during the Nazi reign, and because the
+                    Prohibition on alcohol was a starting point to the
+                    American mafia.
+                </para>
+                <para>
+                    However, this is the <ulink url="http://en.wikipedia.org/wiki/Style_over_substance_fallacy">style over substance fallacy</ulink>, where one
+                    criticises the style of a writing instead of what it says.
+                    My point was to bring two cases where people were acting
+                    illegally yet were acting either ethically or just
+                    morally, and that the Law was not on Ethics' side in this
+                    case.
+                </para>
+            </footnote>
+        </para>
+        <para>
+            Similarly one cannot argue that people who violate laws that
+            prohibit the non-commercial duplication of digital works are
+            criminals. Just because the law is there does not necessarily 
+            make it a right law or a beneficial law. One can argue that these 
+            people are felons (or "Avaryanim" in Hebrew), but that's 
+            not the same thing as a criminal.
+        </para>
+        <para>
+            Many times in history, acts of civil disobedience proved to be
+            beneficial in the long run. The classical example for it is the
+            American Revolution, but there are many other examples.
+        </para>
+    </section>
+    <section id="terms_conclusion">
+        <title>Conclusion</title>
+        <para>
+            In one IRC conversation I had with supporters of actions against
+            file sharers, I realised that while I gave a lot of arguments for
+            my stance, they had nothing better to do than to repeat the same 
+            mantras of: "You're stealing someone else's (intellectual) property
+            so you are a criminal." or "You're violating the law so you are 
+            a criminal.", etc. It was obvious that their cognition was
+            contaminated with the mis-interpretations of these terms, which
+            caused their thoughts and speech to be mutilated as well.
+        </para>
+        <para>
+            Thus, it is high time one eliminates all the mis-applications of 
+            these terms from his or her vocabulary, because they prevent
+            clear thinking and growth on the matter.
+        </para>
+    </section>
+</section>
+
+
+<section id="why_file_swapping_should_be_legal">
+    <title>Why File Swapping should be Legal?</title>
+    <para>
+        So why should file swapping be legal? Let's examine the reasons one 
+        by one.
+    </para>
+    <section id="why_should_be_legal_not_a_crime">
+        <title>It is not a Crime</title>
+        <para>
+            The primary reason why file swapping should be legal is because
+            it's not a crime, at least not an ethical one. Sites or services 
+            that point to where to download the content are just referencing
+            the presence of the information. Referencing or linking is 
+            <emphasis role="bold">never</emphasis> a crime. It's like
+            instructions on actions like how to prepare bombs, where to find
+            illegal drugs,
+            how to cheat various systems, or where to find stolen goods.
+            By itself this information is not a crime to know, because it's
+            protected speech. So does pointing to a copyrighted resource.
+        </para>
+        <para>
+            So now we're left with the question whether sharing a copyrighted
+            work (or downloading it) is an objectively criminal action. The
+            answer is again "no". It's not a crime since the originator of
+            a copyrighted work that was made public cannot prevent
+            non-commercial copies from being made and distributed. As of today,
+            many countries passed such laws, but these laws are unethical.
+            Sharing of copyrighted work is common-place, and many of the 
+            people who do it (including many children) do not feel they're
+            doing something wrong, or feel guilty about it. So it is ethical,
+            and moral and should be legal.
+        </para>
+        <para>
+            Note that selling copies commercially (as in stores of pirated 
+            media), can be prohibited by the copyright holder. But
+            non-commercial copying (from friend to friend, or via
+            Peer-to-Peer services) cannot.
+        </para>
+        <para>
+            Several respondants to early versions of this article, claimed
+            that I should <emphasis role="bold">prove</emphasis> that copying 
+            or receiving a copy of an artwork that was released to the public
+            is ethical and moral. Well, I'd like to ask those critics "Why it
+            is not moral?". And they'll probably have no answer.
+        </para>
+        <para>
+            According to <ulink url="http://www.shlomifish.org/philosophy/obj-oss/obj-oss/two_levels_of_morality.html">the definition of Ethics and Morality
+                that I accept</ulink> (presented there as "Constitutionalitty and 
+            Beneficiality), then file sharing is ethical, because it does
+            not involve an initiatory force, threat of force or fraud against
+            one's property, which as I demonstrated here does not include
+            the so-called "intellectual property". Moreover, it is also moral
+            or at least ammoral, because it does not harm or prevent the
+            filling of human biological needs.
+        </para>
+        <para>
+            Copyrights are not an absolute "nature-given" right like the rights
+            for life and freedom. Instead, they are a state-enacted monopoly
+            that is meant to protect the originators of artworks from
+            abuse by commercial distributers. However, due to the computers
+            and Internet revolutions, it makes no sense to try and prevent
+            non-commercial digital distribution of them.
+        </para>
+    </section>
+    <section id="why_should_be_legal_other_ways_to_make_money">
+        <title>There are other ways to make money</title>
+        <para>
+            There are many other ways in which originators of media can make 
+            money even if they allow free distribution. First of all, they can
+            regulate the commercial use of the works. That way, commercial
+            entities (such as Music stores, online music download services, 
+            D.J.'s in charge-for-entrance parties and commercial radio 
+            stations) must pay them royalties. 
+        </para>
+        <para>
+            Another financial option is to restrict derivation of
+            the work. That way, persons who wish to build upon the work
+            or include substantial parts of it in their own must consult the
+            originator.
+        </para>
+        <para>
+            Another option (of less substance) is to require attribution for
+            the originator. That way, people who wish to build upon a work
+            without crediting the originator must purchase permission from
+            him.
+        </para>
+        <para>
+            These three methods together give enough options for an artist
+            to make money off his art, without restricting non-commercial
+            copying.
+        </para>
+        <para>
+            This is naturally excluding live performances of artists of
+            various sorts, like Rock concerts, that are also a huge potential
+            source of revenue, as well as sales of Merchandise. <ulink 
+                url="http://www.strategy-business.com/press/16635507/9095">The Grateful
+                Dead made more money on merchandise than they ever did on 
+                selling records</ulink>.
+        </para>
+    </section>
+    <section id="why_should_be_legal_not_hurt_media_sales">
+        <title>File Sharing Does not Hurt Media Sales</title>
+        <para>
+            Many people erroneously believe that file sharing hurts media
+            sales. However, there is a lot of evidence to the contrary:
+        </para>
+        <orderedlist>
+            <listitem>
+                <para>
+                    <ulink url="http://it.slashdot.org/article.pl?sid=05/07/13/2317247&amp;tid=141&amp;tid=218">Legal Music Downloads Increase in 2005</ulink>
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <ulink url="http://slashdot.org/article.pl?sid=04/01/04/0049249">Slashdot Article about CD-R's and MP3s not hurting record sales in Australia</ulink>
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <ulink url="http://195.128.176.201/Article.jpg">CD Sales in Israel went up by 15% in 2004.</ulink>
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    <ulink url="http://www.washingtonpost.com/wp-dyn/content/article/2005/03/26/AR2005032600104.html">Success of the single "No Meaning No" by
+                        Chuck D and the Fine Arts Militia</ulink> that was
+                    released under a liberal 
+                    <ulink url="http://www.creativecommons.org/">Creative 
+                        Commons</ulink> license, that allows free distribution.
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    The U.S. band
+                    <ulink url="http://en.wikipedia.org/wiki/Wilco">Wilco</ulink>
+                    released their album <ulink url="http://en.wikipedia.org/wiki/Yankee_Hotel_Foxtrot">"Yankee
+                        Hotel Foxtrot"</ulink> as mp3's online
+                    after their record label demanded they remix their songs.
+                    After a different record label decided to distribute their
+                    songs instead, and distributed the album, it became their
+                    best-selling album, selling over 500,000 copies.
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    The Movie "Pirates of the Carribean" 
+                    <ulink url="http://opendotdotdot.blogspot.com/2006/07/pirates-redeeming-pirates.html">was 
+                        heavily "pirated"</ulink>, yet also had
+                    very successful sales and was incredibly profitable.
+                </para>
+            </listitem>
+            <listitem>
+                <para>
+                    Some new artists that published albums and singles 
+                    in recent years, have proven to be very successful
+                    commercially, despite the fact that their songs are commonly
+                    available for download on the Internet, via Peer-to-Peer
+                    networks or otherwise.
+                </para>
+            </listitem>
+            <!--
+            TODO: 
+                - Add Slashdot article about growth in sales of a certain 
+                record label.
+            -->
+        </orderedlist>
+    </section>
+
+    <section id="why_should_be_legal_witch_hunt">
+        <title>Media Organisations hunt File Sharers and Prosecute Them</title>
+        <!--
+        TODO: Add links.
+        -->
+        <para>
+            You've probably all heard stories of the Media organisations' 
+            witch-hunt against file sharers. From suing a female 12-years-old
+            honour student, to a grandpa in his 70's, to a college player of 
+            American Football. They also were closing many online sites.
+            In New Delhi the police gave the media companies an unlimited 
+            warrant to raid the houses of people suspected of media sharing.
+        </para>
+        <para>
+            Lots and lots of "1984"-style terror. And for what? For preventing
+            the supposed loss of sales by a limited private sector of the 
+            industry? For preventing a practically costless operation of 
+            distributing an mp3 that can be done by the "criminals" at the
+            comfort of their homes?
+        </para>
+        <para>
+            In a presentation he gave, Richard M. Stallman (of the Free 
+            Software Foundation and GNU project fame) gave another good reason 
+            why it wasn't unacceptable. He said that when he was a kid in
+            school, his teacher asked the children to share their sweets with 
+            the other  children. And now, suddenly they have to tell them 
+            something like "No, Tommy, don't share your 
+            music/software/videos/etc. It's 
+            illegal!". 
+        </para>
+        <para>
+            What's a child to feel in this case? Sharing is a nice
+            part of living in a friendly society, and there's no reason we
+            should prevent it, or else we ourselves will become more and more
+            selfish.
+        </para>
+    </section>
+
+    
+    <section id="why_should_be_legal_put_into_perspective">
+        <title>Put it into Perspective</title>
+        <!--
+        TODO: Add links.
+        -->
+        <para>
+            Let's put things into perspective. What the media companies do
+            is sell entertainment to people. Entertainment. They don't save
+            lives and the economy does not depend on them, as there are 
+            many other sources of entertainment a consumer can choose
+            instead that are available independently.
+        </para>
+        <para>
+            The worst case (and extremely unlikely) scenario is that no-one
+            pays for online media, and everybody just share and download music
+            from the Internet. Would that be a bad scenario? No, the world
+            will go on. Without people making money off selling media, but
+            nevertheless.
+        </para>
+    </section>  
+</section>
+
+<section id="refuting_common_arguments">
+    <title>Refuting Common Arguments against File Swapping</title>
+    <para>
+        This section aims to refute some common arguments against file
+        swapping.
+    </para>
+    <section id="refuting_common_arguments_domino_effect">
+        <title>The Domino Effect</title>
+        <para>
+            Some people are using "the Domino Effect" as an argument that file
+            swapping should be stopped. What they say is that if the
+            profitability of the Music industry would be harmed, then it will
+            cause an economical chain-reaction that may devastate the rest
+            of the economy, because other dependent industries may be harmed.
+        </para>
+        <para>
+            There are two problems with this argument. The first is that there
+            is no evidence that the profitability of the music industry is
+            harmed due to file swapping, so there is little risk of this
+            happening. The other is that assuming that would happen, it won't
+            be a bad thing. That's because we essentially reduce the money
+            that is transferred to a heavy taxer, and make the public, as a
+            whole, richer. The public in turn, can spend this money on other
+            merchandise, and make other industries as a whole more
+            prosperous. This is similar to reducing income tax, while laying
+            off some government workers.
+        </para>
+    </section>
+
+    <section id="refuting_common_arguments_anarchy">
+        <title>Violating the Law against File Swapping will Cause 
+        Anarchy</title>
+        <para>
+            Some people say that if the law of a country prohibits sharing 
+            files, then this law must be obeyed, because otherwise there
+            will be anarchy. However, one must understand that if certain 
+            laws are irrational, they cannot be practically expected to
+            be obeyed.
+        </para>
+        <para>
+            I also personally don't see how assuming everyone share files 
+            online, the integrity of a country will be harmed. Sharing files
+            does not involve killing people, stealing from them, nor does it
+            involve force, threat of force or fraud.
+        </para>
+        <para>
+            20% of Americans enjoy file swapping, and yet the United States
+            is functioning perfectly fine, and no anarchy is in sight.
+        </para>
+    </section>
+
+    <section id="refuting_common_arguments_disobeying_traffic_laws">
+        <title>Sharing Files is like Disobeying Traffic Laws</title>
+        <para>
+            The comparison of sharing and downloading files to disobeying
+            traffic laws seems to be quite prevalent. But naturally, copying
+            files does not endanger lives, nor is it actually a crime. The
+            worst thing that can happen if one shares works of art, is loss
+            of profit. If you disobey traffic laws, you risk the lives of
+            yourself and of other people. This makes it a difference of Heaven 
+            and Earth in this analogy.
+        </para>
+    </section>
+
+    <section id="stealing_from_the_rich">
+        <title>"Stealing from the Rich and Giving to the Poor" is still 
+            Stealing</title>
+        <para>
+            Some people claim that because the main entities that will
+            supposedly be harmed from making file swapping legal are media
+            conglumerates, and to a lesser extent best-selling artists 
+            who are very rich, and those who would benefit are the poor 
+            everyday people, then this is a case of "stealing from the rich 
+            and giving to the poor.", which is still stealing.
+        </para>
+        <para>
+            One thing that has to be understood about the Robin Hood myth
+            is that Robin Hood supposedly stole from the exploiters and
+            gave to the exploited. Secondly, it's not really true in this
+            case.
+        </para>
+        <para>
+            Copying a copyrighted work is not stealing, because the money
+            that the author can charge for its commercial copying is due
+            to copyright law - a civil (not criminal) contract between the
+            State and the artists, in order to encourage original creation.
+            However, <link linkend="term_stealing_theft">breaking this contract 
+                is not stealing</link>.
+        </para>
+        <para>
+            It should be understood that record labels and other distributors
+            of entertainment and non-technical media should either adapt to
+            the new situation where Internet users can download such files
+            for free and enjoy them, and to a greater extent contribute such
+            media on their own, without much help from them, or simply perish
+            as a no longer necessary establishment, that just gets in the way.
+        </para>
+        <para>
+            This is not about stealing from the rich and giving to the poor.
+            This is about cutting down the middle man.
+        </para>
+    </section>
+
+
+    <section id="golden_rule">
+        <title>The Golden Rule Argument</title>
+        <para>
+            A few people who criticised the article, claimed that by proposing
+            that media will be free to be non-commercially copied, I've been 
+            violating <ulink url="http://en.wikipedia.org/wiki/Ethic_of_reciprocity">the 
+                Golden Rule</ulink> ("Treat others as you wish them to 
+            treat you") as I don't want copyright to be undermined for my own
+            works.
+        </para>
+        <para>
+            However, this results from two confusions. The first is the
+            belief that I too will mind people re-distributing my work. However,
+            I don't have problems with that: all my work is freely 
+            re-distributable and a most of it is also Free Content. The second 
+            confusion is that I completely reject copyrights. However 
+            <link linkend="why_should_be_legal_other_ways_to_make_money">that's
+                not the case as I still accept that some copyright principles
+                are valid.</link>
+        </para>