template hiding suggestion !

Walter Bright newshound1 at digitalmars.com
Sun Apr 20 13:42:02 PDT 2008


Edward Diener wrote:
 > There are a few, obviously misguided and benighted souls such as 
yours  truly, who actually believe that one should be able to write 
software and sell it on the market, and that to do so one has the actual 
right of not having to distribute the source code, which one created 
from the biblical sweat of one's brow ( or ache of one's fingers, or 
thought of one's mind ).

I have slowly come to the realization that making the source code 
available is *not* incompatible with maintaining one's intellectual 
property rights. Making the source code available is not the same thing 
as making it free for any use. The only reason to hide your source from 
your customers is if you've got trade secrets in there (or if your 
license prevents it). Otherwise, the source code being available is good 
for business as it shows you aren't distributing malware, it serves as a 
great advertisement for the quality of your work, it shows you have 
confidence in your product, it protects against some disaster causing 
you to lose your backup copies (!), customers can often help you fix 
errors, etc.

Sure, some people will pirate it. But if they make money off of doing 
so, they are wide open to a big lawsuit. A real company won't take the 
risk. If it's some hobbyist dinking around, well, so what?

I can tell you I'm getting sick and tired of closed source apps. For 
example, I attempted to install a major software company's crapware app. 
While it might be a good product underneath, the dammed thing attempts 
to take over my machine, installing things that always run upon startup, 
always "phoning home" over the internet, sending gawd knows what back to 
the parent company, nagging me about "activating" and "registering" it. 
It acts like it's doing me a huge favor by allowing me to use it at all. 
I just don't want to deal with that anymore.

Open source products tend to come with an entirely different attitude - 
much more customer focussed.


 > Doing this in C++ while writing templates is impossible in current 
implementations because the 'export' keyword, which hardly anyone ever 
wanted to implement anyway, except for Daveed Vandevoorde, never 
promises that the separation between template declarations and template 
definitions would enable one only to distribute the template declaration 
without the template definitions. But it was always possible to conceive 
that the template definitions could be "compiled" down into some 
intermediate unreadable format which could become part of the binary 
distribution, ala shared libs, static libs, exes etc.
 >
 > But since no one in C++ ever thought it important enough to protect 
the template source as an intellectual right which should not need to be 
distributed in easily readable form, no on in C++ ever decided it was 
important enough to standardize the idea of some intermediate 
"compilable" form by which template source could be distributed but 
remain unread by the end user.
 >
 > Would it be possible that Mr. Walter Bright is sympathetic to the 
notion that template source should be "compilable" down into some sort 
of unreadable format which enables the D compiler to read it but not 
others to discover its source form ? I realize that the very source code 
which might enable D to do this would itself need to be protected from 
prying eyes so that the format of the "compilable" template source could 
not be  easily reverse engineered. Before someone cries that any format 
can be reverse engineered with enough effort, I want merely to say that 
no doubt .lib and .obj files can be reverse engineered to a certain 
extent but at some highly difficult level few, if any, are going to 
bother. S I see no reason why template source code could not be 
"obfuscated" in a similar way.

The reason that obj files are so effective at hiding the source is that 
they are the proverbial "hamburger" that cannot be easily turned back 
into a cow. This is not so for any conceivable precompiled template 
form. Since templates don't even have semantics before they are 
instantiated, the precompiled form must be in the form of the syntax. It 
must necessarily have more information in it than, say, Java .class 
files do. And Java .class files have proven to be easily decompilable 
back into reasonable source. All it takes is one motivated person to 
crack your precompiled template format, and then everyone can see all of 
them.

This is true even if you encrypt it. Look at what happened to DVD 
encryption.

So frankly, it's a pipe dream to be able to hide template bodies in this 
way.


 > As a user of libraries largely based on templates, whether C++ or D, 
once I have faith in the quality of the library I feel I have no need to 
look at the source code in order to use it successfully and the actual 
template declarations should be enough, from the user's point of view, 
to interact with the library. Unfortunately in C++ and D this is not the 
case due to the way templates are currently implemented. But I think it 
could be the case if D pursued the line of thought that the end user of 
the template code, as opposed to the compiler itself, really has no need 
to interact with the template definition, as opposed to the template 
declaration, in order to use the template successfully.

I understand your concern about this, as I have felt the same way in the 
past. But I believe that thinking is obsolete, and that the advantages 
of making the source code available outweigh the disadvantages.



More information about the Digitalmars-d mailing list