 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> So your definition of "one-liner" has something to do with the amount of
> characters.
Everyone who thinks a one-liner spans two lines, raise your hand!
You realize you're just picking nits, which is coming across as severely
childish.
> Perhaps because defining a "one-liner" as the number of characters in
> the script is completely arbitrary?
OK. So if it's a two-liner, does that seriously affect the discussion?
> Yes, it's much more likely that he would learn to use the shell's 'for'
> construct more easily than he would learn how to write a makefile.
>
> You write as if there was something wrong with learning how to use
> makefiles. (Well, by now it wouldn't really surprise me.)
Nope. But using someone else's makefile is often problematic.
I'm against (in principle) many technologies that are simple on the surface
and get abused out the whazoo instead of improving the technology.
> The context was that I was saying that if he wanted to compile only one
> of the programs, or only the programs that have a modified source, rather
> than all of them.
Yep. Then it might turn into a *three* line shell script.
>>> Which is BS. You seem to think that you can't create a makefile that
>>> compiles programs without the dependency lists. It's not like you are
>>> forced to provide them.
>
>> I don't remember. Do you have to actually list the programs in the makefile
>> that you want to compile? Is a makefile that compiles 50 programs
>> necessarily larger than one that compiles 5?
>
> Again with length. Nevertheless, with gnu make, this is all you need
> (and you get compiler options as a bonus):
>
> CPPFLAGS=-Wall -O3
> all: program1 program2 program3
OK, so, yes, it looks like you have to list all the programs. Altho I
suspect there's some wildcard you could put after all: to make that easier.
It wasn't about length. It was about simplicity and maintainability.
> (Of course this assumes that there's only one source file for each
> program, and they are named like that,
That was the original premise of the original question, yes.
> (And granted, with a "standard" non-gnu makefile you would need more
> than this.)
Another problem with make (and similar tools that get abused). Instead of
saying "this tool that handles 80% will be really ugly if we modify it to
handle 90%", people go and add the boxes off the side that then get used in
baroque ways.
> Well, the compiler can't look at the source code if you don't tell it
> where it is in the first place.
Ding ding ding!
> That seems rather obvious, and is true for any language.
Incorrectamundo!
> You are making it sound like most other languages
> don't need to be told where the libraries and source files are.)
Generally, other languages don't need to be told where the sources for a
particular library are stored, no.
> You always succeed in putting the most *trivial* and obvious stuff in
> a negative light. "Hey, you need to tell the compiler where the source
> files are if you want to compile the program. Clearly the programming
> language sucks."
Most other languages don't need to know where the source code is for the
libraries they use. They only need to know where the source code is for the
code you're writing.
>> OK. You're just refusing to read what I actually wrote, and refusing to see
>> the fundamental difference in the two tools. I can't tell whether you're
>> doing this intentionally out of ego or what.
>
> You say that you can build dependencies in XNA by specifying files and
> stuff.
No. No no no. I'm saying I can build dependencies in XNA *without*
specifying files and such in the project file. You're just disregarding
that. I already listed what's in a project file for XNA C#. It
conspicuously lacks mention of dependencies of source files on other source
files.
> I think it's you who is deliberately trying to enforce a difference
> that isn't really there.
>>> I wrote an example earlier: Suppose you have written a program that
>>> generates code, and it generates the code from some data files. Obviously
>>> you would want the program to be run if (and only if) some of those data
>>> files change. Exactly which automated tool would you use to do this?
>
>> Well, as I said, the XNA content pipeline does exactly that, precisely 100%
>> word for word that. And yet, oddly enough, I don't manually duplicate the
>> dependency information into a separate file.
>
> If I run such a program from a makefile, where exactly is the duplicated
> information?
There's a list of information that tells your "program that generates code"
which data files to read, right? How does your "program that generates code"
based on data files know what data files to read? I guess if it actually
reads and parses the makefile, it could put the information there without
duplication.
Oh, I see what you're saying. You're thinking of something like YACC, where
the source files are passed on the command line. Yes, you're right, the
makefile can be the sole repository of the list of dependencies, in that case.
But look at the C compiler. You have the list of dependencies in the
makefile for invoking the compiler, and then inside the source code there's
the list of dependencies in the form of #include files.
> Your complaints have now shifted to duplication of file names. Exactly
> where is the duplication in this particular example?
Do you deny that your makefile is going to have a list of files your main C
code includes, and your main C code will also have that list of files?
Isn't the -M option indeed specifically intended to duplicate that
information in two different formats?
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Darren New <dne### [at] san rr com> wrote:
>> Warp wrote:
>>>> No. The programming language is such that it is impossible to figure out by
>>>> looking at the source code what the dependencies are on other source code.
>>> If that were true, then it would be impossible to compile the program.
>>> After all, it's impossible for the compiler to figure out which files are
>>> being included just by looking at the source code.
>>>
>>> I suppose compilers do it by magic, then.
>
>> Here are three C source files. Please compile them and tell me what it
>> prints. Or do you think this code is impossible to compile? Or do you admit
>> that it's impossible to figure out by looking at the source code what the
>> dependencies are on other source code?
>
> So essentially you want the compiler to know what to compile without
> you specifying what to compile.
Nope. I specified that you want to compile "main".
Look at my statement: "It's impossible to figure out from the source code
what other source files it depends on."
You're intentionally misinterpreting exactly what I'm saying, which is why I
put a *trivial* example in a separate post. You're standing here agreeing
that it's impossible to look at the source code and tell what depends on
what, because there's not enough information in the source code to determine
that. And now you're mocking me for pointing it out, in spite of the fact
that other systems don't seem to have this problem, because other systems
don't have bits and pieces of library source code compiled as part of the
process of compiling your own source code.
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> How do you resolve this? That's right: You tell the compiler which files
> it needs to compile.
Nope. You tell the compiler which *object* file goes with the appropriate
*source* file. Either they're all compiled together (in which case you
shouldn't be stupid enough to do that because it won't compile at all), or
one or the other is in a library, at which point you don't need to know
where the source code is or which one was actually used, because it's
already compiled.
Do you really not see the difference between saying "each time I compile
something, I have to pick which source file to compile" and saying "each
time I compile something, I have to pick the right source files that go with
the corresponding libraries of every library I'll eventually link this with"?
> Exactly how is this situation different from your example?
Because the object code of the file in question is used during the
compilation of your source code. Hence, the declarations and definitions are
united in one file, which is checksummed if distributed outside the project
to ensure what version you're using.
Indeed, when I use the C# equivalent of stdio (or any other third-party
library), I don't need any source code I didn't write myself, nor do I need
to specify where to find the libraries. I merely say which version of what
implementation I want.
> an inexistent flaw in C
I'm happy for you that this flaw has never bitten you in the butt. But it's
far from "inexistent." (Incidentally, the word would be "nonexistent".)
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Exactly how is this situation different from your example?
Or, to phrase it a different way, compiling *your* C code can wind up
depending on the quality of the source code provided by every "pre-compiled"
library author whose code you're using. Not only does their library object
code have to work as advertised, but you have to recompile vital pieces of
it every time you compile your code.
I find this to be a disturbingly problematic lack of modularity in large
projects taking advantage of lots of pre-built code. And most other
languages don't really make you care what some third party's coding standard
is, as long as the library runs, because you don't get their source code.
Does that clarify the fundamental problem?
Or, look at it a different way, if you're *really* interested in pursuing
understanding what I'm saying: Why do you #include stdio in your program?
As you said, it's part of the standard. You can't change it without breaking
lots of programs. Also, you can't pick a different function to be called
"printf" without breaking any library that expects "printf" to mean the one
from stdio. (I.e., C's linker has a flat namespace, so if *anyone* includes
stdio, then the symbols from stdio will preclude using that name anywhere
else to mean something different.) So why does one have to recompile
stdio.h every time you compile a program?
I know the *technical* reason, as in "because that's how C works." I'm
asking you to try to understand why working that way is not as good as
simply telling the compiler you're using the standard library and symbols
come from there. You see the fact that you're recompiling bits and pieces of
the standard-mandated standard libraries (that you correctly acknowledge
can't be changed anyway) every single time you compile your program, yes?
And that doesn't sound like a strange idea?
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 1/31/2011 11:18 AM, Warp wrote:
> Patrick Elliott<sel### [at] npgcable com> wrote:
>> A project file is just another name for a MAKE file (at least
>> on Windows).
>
> Not according to Darren.
>
Well. Don't entirely disagree with his argument against headers and the
like either. Been down roads like that before. Only thing *worse* is
having done something like me, where I knew Basic, so got VB, but VB
didn't include the C headers, so even though I could look up, and use,
system calls that where not directly handled by the standard VB
functions, there was no "documentation", as such, in any book, manual,
or help file, for *any* of the flags. The books might tell you what the
flag name was, but they *assumed* you would be doing this in VC++, and
that you would include the headers for that library, and that, thus, the
compiler would take care of figuring out what they flag's value actually
was. :p
Almost as insane as trying, on the Apple IIGS to write working menu in
PASCAL, using a book showing the flags for C, without any mention in
either the PASCAL help files, or the book, that PASCAL would muck with
the numbers, on some way, resulting in the wrong parameters, so nothing
you could do would *ever* work, if you used the values. Interestingly,
**that** book actually told you what the frak the values for the flag
you might use in each system call where, rather than relying on the
headers to do it. Microsoft's various "Blah API Bible" books came as a
nasty shock when I got one. lol
--
void main () {
If Schrödingers_cat is alive or version > 98 {
if version = "Vista" {
call slow_by_half();
call DRM_everything();
}
call functional_code();
}
else
call crash_windows();
}
<A HREF='http://www.daz3d.com/index.php?refid=16130551'>Get 3D Models,
3D Content, and 3D Software at DAZ3D!</A>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Patrick Elliott <sel### [at] npgcable com> wrote:
>> A project file is just another name for a MAKE file (at least
>> on Windows).
>
> Not according to Darren.
Incidentally, it's comments like this that convince me that trying to
explain my point of view to you is usually useless. Given that I wrote an
extensive message detailing why I thought this which you apparently ignored.
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> > How would you enhance the whole makefile process so that it *would*
> > conform to your needs?
> I already gave several examples of this as well.
You mentioned some XML file format used by XNA. You want built-in support
in 'make' for that format?
> >> Are you telling me that the need for duplicating that sort of information is
> >> a *good* idea? Or do you admit that needing that information in two
> >> different places in two different forms is indeed a limitation that it would
> >> be desirable to eliminate?
> >
> > Exactly how would you eliminate the need?
> I've given several examples of how to do this.
By adding built-in support for every single such format in existence to
'make'?
All your examples are of the type "I'm doing a project in [some IDE]
and there are some [IDE-specific] resources and, surprise surprise, the
IDE has support for automatically tracking the dependencies of those
resources". You have not given any *generic* answer to the question, only
very *specific* ones.
> > What happens if you have a custom format which has similar kinds of
> > dependencies? How do you expect it to work then?
> I've given several examples of how to do this.
I don't remember a single one. You just talked about some XML files which
are specific to XNA.
> > You still can't get over the fact that 'make' is a generic tool.
> Oddly enough, so are many of the other build systems that nevertheless don't
> require you to list dependencies in multiple places. Several examples of
> which I have already given.
You seem to be obsessed now with the "dependencies in multiple places"
thing, yet when I ask where exactly is the duplication in the example
I gave, you don't answer.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> Warp wrote:
> > Patrick Elliott <sel### [at] npgcable com> wrote:
> >> A project file is just another name for a MAKE file (at least
> >> on Windows).
> >
> > Not according to Darren.
> Incidentally, it's comments like this that convince me that trying to
> explain my point of view to you is usually useless. Given that I wrote an
> extensive message detailing why I thought this which you apparently ignored.
So what I wrote above is not false, yet it still somehow bad?
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> > Yes, it's much more likely that he would learn to use the shell's 'for'
> > construct more easily than he would learn how to write a makefile.
> >
> > You write as if there was something wrong with learning how to use
> > makefiles. (Well, by now it wouldn't really surprise me.)
> Nope. But using someone else's makefile is often problematic.
Now you are changing your argument once again.
> I'm against (in principle) many technologies that are simple on the surface
> and get abused out the whazoo instead of improving the technology.
And shell scripts, which is what you advokated instead of makefiles,
cannot be abused nor can they be impossible to understand? I don't even
understand your point anymore.
> > The context was that I was saying that if he wanted to compile only one
> > of the programs, or only the programs that have a modified source, rather
> > than all of them.
> Yep. Then it might turn into a *three* line shell script.
From a two-line makefile. The advantage is left to anybody's guess.
> > CPPFLAGS=-Wall -O3
> > all: program1 program2 program3
> OK, so, yes, it looks like you have to list all the programs. Altho I
> suspect there's some wildcard you could put after all: to make that easier.
You can use wildcards if you don't mind going a bit to the cryptic side
of gnu make (and AFAIK it requires one additional line because I think the
wildcard cannot be embedded in the rule):
CPPFLAGS=-Wall -O3
SOURCES=$(wildcard *.cc)
all: $(SOURCES:.cc=)
If you are ok with writing the program's name you want to compile
(ie. "make program3") you could just have the CPPLFAGS (and possibly
LDFLAGS if you need some special linker parameters) line in the makefile
and nothing else, to get the command line options you want.
(All this works because there's a big bunch of implicit rules in gnu make.
I think there was actually a command-line option to list them.)
All things considered, I don't think that this simple case is all that
complicated. (The only complicated thing is figuring this out.)
> > (And granted, with a "standard" non-gnu makefile you would need more
> > than this.)
> Another problem with make (and similar tools that get abused).
I honestly cannot undrestand why you call this "abuse". This is *precisely*
what 'make' has been designed for. How can you "abuse" a tool for a purpose
it was specifically designed for?
> > Well, the compiler can't look at the source code if you don't tell it
> > where it is in the first place.
> Ding ding ding!
Your point being?
> > That seems rather obvious, and is true for any language.
> Incorrectamundo!
So there exists a compiler which indeed can read your mind so that you
don't have to explicitly specify what it needs to compile. Never heard of
such an innovation. Is there a scientific paper somewhere about mind-reading
software?
> > You are making it sound like most other languages
> > don't need to be told where the libraries and source files are.)
> Generally, other languages don't need to be told where the sources for a
> particular library are stored, no.
Bullshit. Specific compilers might have *default* paths for the libraries,
and so does a typical gcc installation in linux. That doesn't mean that
the compiler is not being told where the libraries are.
When I compile a C++ program, I don't need to tell gcc where eg. <iostream>
is located. However, that doesn't mean that nothing is telling. Of course
something is telling it, else it would not be able to find it. Just because
the path has been pre-configured in this linux distro doesn't change the
fact.
You really are desperately trying to find flaws that just aren't there.
> >> OK. You're just refusing to read what I actually wrote, and refusing to see
> >> the fundamental difference in the two tools. I can't tell whether you're
> >> doing this intentionally out of ego or what.
> >
> > You say that you can build dependencies in XNA by specifying files and
> > stuff.
> No. No no no. I'm saying I can build dependencies in XNA *without*
> specifying files and such in the project file. You're just disregarding
> that. I already listed what's in a project file for XNA C#. It
> conspicuously lacks mention of dependencies of source files on other source
> files.
So XNA employs this new marvelous mind-reading technology, as it is able
to know what to include in the project without you having to explicitly
tell it.
How does it work? Does it scan brainwaves?
> Oh, I see what you're saying. You're thinking of something like YACC, where
> the source files are passed on the command line. Yes, you're right, the
> makefile can be the sole repository of the list of dependencies, in that case.
That's one of the most typical ways of building complex projects in unix,
and it's precisely what makefiles are designed for (and is typically why
command-line tools take things as command line parameters or, at worst,
as data it reads from the standard input stream).
> But look at the C compiler. You have the list of dependencies in the
> makefile for invoking the compiler, and then inside the source code there's
> the list of dependencies in the form of #include files.
Which is why you can *automate* the creation of the dependency rules
rather than having to do it by hand. I know you don't like that 'make'
doesn't have built-in support for this kind of automation, but it just
causes a few extra steps to be necessary. I don't think it's such a big
deal.
Most IDEs do this automation out-of-the-box when you have a project in
C or C++ (or Objective-C). It might be a bit easier with those IDEs, but
in principle it's not much different.
The #include file mechanism in itself is useful for other reasons,
especially in C++, which is why it has its advantages.
> > Your complaints have now shifted to duplication of file names. Exactly
> > where is the duplication in this particular example?
> Do you deny that your makefile is going to have a list of files your main C
> code includes, and your main C code will also have that list of files?
> Isn't the -M option indeed specifically intended to duplicate that
> information in two different formats?
I was talking about my example of a code generator creating code from
some input files.
Nevertheless, why should I care if some #include file information is
duplicated, as long as it happens automatically?
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> Warp wrote:
> > How do you resolve this? That's right: You tell the compiler which files
> > it needs to compile.
> Nope. You tell the compiler which *object* file goes with the appropriate
> *source* file.
Yeah, huge difference.
> Either they're all compiled together (in which case you
> shouldn't be stupid enough to do that because it won't compile at all)
Are you saying that it's impossible to have a C# source file with the
same name in two different directories and which implement a class with
the same name?
What does the compiler do? Scan your entire hard drive to see if it
finds clashing class names, and refuses to compile if it does?
> Do you really not see the difference between saying "each time I compile
> something, I have to pick which source file to compile" and saying "each
> time I compile something, I have to pick the right source files that go with
> the corresponding libraries of every library I'll eventually link this with"?
Not really. You have to specify which source files the program is
composed of. The compiler cannot read your mind. Your example of the same
C file being in two different directories is simply bogus. It has nothing
to do with C particularly.
> > Exactly how is this situation different from your example?
> Because the object code of the file in question is used during the
> compilation of your source code. Hence, the declarations and definitions are
> united in one file, which is checksummed if distributed outside the project
> to ensure what version you're using.
> Indeed, when I use the C# equivalent of stdio (or any other third-party
> library), I don't need any source code I didn't write myself, nor do I need
> to specify where to find the libraries. I merely say which version of what
> implementation I want.
And when I write C++, same thing. So what?
> > an inexistent flaw in C
> I'm happy for you that this flaw has never bitten you in the butt. But it's
> far from "inexistent." (Incidentally, the word would be "nonexistent".)
"I have seen the same C file in multiple places, but I have never seen
the same C# file in multiple places, hence C is clearly the inferior
language." Yes, very convincing argumentation.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> Or, look at it a different way, if you're *really* interested in pursuing
> understanding what I'm saying: Why do you #include stdio in your program?
> As you said, it's part of the standard. You can't change it without breaking
> lots of programs. Also, you can't pick a different function to be called
> "printf" without breaking any library that expects "printf" to mean the one
> from stdio. (I.e., C's linker has a flat namespace, so if *anyone* includes
> stdio, then the symbols from stdio will preclude using that name anywhere
> else to mean something different.) So why does one have to recompile
> stdio.h every time you compile a program?
> I know the *technical* reason, as in "because that's how C works." I'm
> asking you to try to understand why working that way is not as good as
> simply telling the compiler you're using the standard library and symbols
> come from there. You see the fact that you're recompiling bits and pieces of
> the standard-mandated standard libraries (that you correctly acknowledge
> can't be changed anyway) every single time you compile your program, yes?
> And that doesn't sound like a strange idea?
Let's take a better example: Every time I want to use std::vector,
I have to #include <vector> in the source file where I want to do so.
Is there any advantage to this?
You could move all standard (non-templated) functions into the core
features of the language rather than them being declared in header files,
and it would still work ok. OTOH, is there a huge disadvantage in having
to include the files other than the trouble of having to write the
#include lines?
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> > So essentially you want the compiler to know what to compile without
> > you specifying what to compile.
> Nope. I specified that you want to compile "main".
If your program consists of one single file named "main", then it could
work.
> Look at my statement: "It's impossible to figure out from the source code
> what other source files it depends on."
> You're intentionally misinterpreting exactly what I'm saying, which is why I
> put a *trivial* example in a separate post. You're standing here agreeing
> that it's impossible to look at the source code and tell what depends on
> what, because there's not enough information in the source code to determine
> that. And now you're mocking me for pointing it out, in spite of the fact
> that other systems don't seem to have this problem, because other systems
> don't have bits and pieces of library source code compiled as part of the
> process of compiling your own source code.
Don't forget the context. You were talking about 'make' requiring overly
complicated steps in order to automatically track the dependencies of
include files in C programs, and how you don't like that. Then, suddenly,
you come up with a "it's impossible to track dependencies by looking at
the source code only" argument. It was clear from the context that you
were talking about C in particular, as if the same (quite trivial) problem
didn't happen in more "advanced" languages.
Of course the argument is stupid. If you don't tell the compiler which
files to compile, it cannot know which files to compile. Seems rather
self-evident. If you have the same file (with possibly different
implementations) in more than one place, you need to tell the compiler
which of those files it needs to use. Again, rather self-evident, and
completely unrelated to a specific programming language.
So what's the point?
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp <war### [at] tag povray org> wrote:
> Invisible <voi### [at] dev null> wrote:
> > The solution, as I just discovered, is to name the files *.cpp rather
> > than *.c++; this apparently enables Make's implicit rules to fire.
> Not a good solution because you are not getting warnings nor
> optimizations.
Btw, if you haven't followed the ensuing flamewar in this thread, let me
repeat a nice trick with gnu make here. If you want to be able to just
write "make programname" and have 'make' compile the program, but you want
it to use some compiler options such as warnings and optimizations, create
a makefile in the directory where the source codes are and put this line
in it (nothing else is needed):
CXXFLAGS=-Wall -O3
Now when you write "make programname", it will give those options to the
compiler.
If you would want a simple "make" to compile all the programs, make the
makefile like this:
CXXFLAGS=-Wall -O3
all: program1 program2 program3
Or if you don't want to always having to add the name of a new program
to the makefile, you can use this instead:
CXXFLAGS=-Wall -O3
SOURCES=$(wildcard *.cpp)
all: $(SOURCES:.cpp=)
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>> The solution, as I just discovered, is to name the files *.cpp rather
>>> than *.c++; this apparently enables Make's implicit rules to fire.
>
>> Not a good solution because you are not getting warnings nor
>> optimizations.
>
> Btw, if you haven't followed the ensuing flamewar in this thread, let me
> repeat a nice trick with gnu make here. If you want to be able to just
> write "make programname" and have 'make' compile the program, but you want
> it to use some compiler options such as warnings and optimizations, create
> a makefile in the directory where the source codes are and put this line
> in it (nothing else is needed):
>
> CXXFLAGS=-Wall -O3
>
> Now when you write "make programname", it will give those options to the
> compiler.
OK. Thanks for the tip.
I'm curious to see if turning on optimisations actually makes any
noticeable performance difference... I guess I'll find out tomorrow.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> I'm curious to see if turning on optimisations actually makes any
> noticeable performance difference... I guess I'll find out tomorrow.
Well, it depends on what those programs are actually doing. If they are
doing some heavy-duty calculations that take seconds or more, then there
usually is a quite drastic difference between using -O3 and not using it.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> You mentioned some XML file format used by XNA. You want built-in support
> in 'make' for that format?
Nope. Go back and read what I wrote about it.
>> I've given several examples of how to do this.
>
> By adding built-in support for every single such format in existence to
> 'make'?
No, go back and read what I wrote about it.
> You have not given any *generic* answer to the question, only
> very *specific* ones.
You skipped over the theoretical strace-based mechanism. You also are
refusing to consider the possibility of generalizing the mechanism. I don't
want to waste time trying to discuss possibilities with someone who won't or
can't look at several examples and deduce a generality from them.
> I don't remember a single one.
Then you're not even reading the answers I take time to write, so ... OK.
I noticed there were a couple of posts where I said "here, instead of a big
long rambling question-and-answer, is a clear summary of why I hold the
stance I do, well organized and cogent, and you seem to have skipped over
all of those.
>> Oddly enough, so are many of the other build systems that nevertheless don't
>> require you to list dependencies in multiple places. Several examples of
>> which I have already given.
>
> You seem to be obsessed now with the "dependencies in multiple places"
> thing, yet when I ask where exactly is the duplication in the example
> I gave, you don't answer.
>
Yet, two questions up, you say
"So you do and don't oppose the idea of using third-party tools to generate
the dependencies."
How does your third party tool generate dependencies? Does it not take those
dependencies out of the input you give to *that* tool and store them in
makefiles?
I already answered this. There's a dependency in the makefile that goes
prog.o : prog.c abc.h def.h
There's a dependency in the C file that goes
prog.c:
#include "abc.h"
#include "def.h"
That's the last time I'll answer that question for you, tho.
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Darren New <dne### [at] san rr com> wrote:
>>> Yes, it's much more likely that he would learn to use the shell's 'for'
>>> construct more easily than he would learn how to write a makefile.
>>>
>>> You write as if there was something wrong with learning how to use
>>> makefiles. (Well, by now it wouldn't really surprise me.)
>
>> Nope. But using someone else's makefile is often problematic.
>
> Now you are changing your argument once again.
My argument is multi-faceted, as is most complex stances. When you only look
at the messages I write that are answers to your specific questions, it
looks like I'm changing what i'm saying, because you're looking through a
pinhole at the entire argument. When I write down in a handful of
paragraphcs a complete and cogent description of my point, you apparently
don't read it, as you never reply, ask about it, and then later claim that I
never gave the examples I used in those posts.
>> I'm against (in principle) many technologies that are simple on the surface
>> and get abused out the whazoo instead of improving the technology.
>
> And shell scripts, which is what you advokated instead of makefiles,
> cannot be abused nor can they be impossible to understand? I don't even
> understand your point anymore.
No, clearly not.
> All things considered, I don't think that this simple case is all that
> complicated. (The only complicated thing is figuring this out.)
I agree. Not sure why you're making such a big thing of me pointing out that
the simple system works fine with shell scripts.
>>> (And granted, with a "standard" non-gnu makefile you would need more
>>> than this.)
>
>> Another problem with make (and similar tools that get abused).
>
> I honestly cannot undrestand why you call this "abuse".
Your reading comprehension is poor. Where did I say what you wrote is an
abuse of make? Answer: I didn't. I said that having a bunch of different
versions is indicitive of a program whose capabilities have been expanded
over time bit by bit without a coherent plan, in such a way that such
extentions tend to get abused.
And in another post, I explained why such a thing gets abused, which answers
the first question you had.
>>> Well, the compiler can't look at the source code if you don't tell it
>>> where it is in the first place.
>
>> Ding ding ding!
>
> Your point being?
>
>>> That seems rather obvious, and is true for any language.
>
>> Incorrectamundo!
>
> So there exists a compiler which indeed can read your mind so that you
> don't have to explicitly specify what it needs to compile.
Nope. It doesn't have to read your mind. Of course it has to know what to
compile. The problem is not that you have to tell the compiler what to
compile. The problem is you have to (in C) compile much more than your own
source code in order to compile your program.
I have no problem telling a C compiler what and where my program is. I just
don't think it's a good idea to have to tell a C compiler where everyone
*else's* source code for libraries that are already compiled is. For some
reason, you insist on ignoring the distinction. I suspect you do so in order
to be able to feel you're still right.
(As far as me bashing, I find it amusing that when I bash a feature in C
that's improved in C++, you don't get upset, but if I bash a feature in C
that is carried over to C++, you justify it out the wazoo.)
>>> You are making it sound like most other languages
>>> don't need to be told where the libraries and source files are.)
>
>> Generally, other languages don't need to be told where the sources for a
>> particular library are stored, no.
>
> Bullshit. Specific compilers might have *default* paths for the libraries,
> and so does a typical gcc installation in linux. That doesn't mean that
> the compiler is not being told where the libraries are.
You don't understand the word "sources" in that sentence? Reading
comprehension, dear.
> You really are desperately trying to find flaws that just aren't there.
You're just ignoring my complaint and tilting at strawmen.
>> No. No no no. I'm saying I can build dependencies in XNA *without*
>> specifying files and such in the project file. You're just disregarding
>> that. I already listed what's in a project file for XNA C#. It
>> conspicuously lacks mention of dependencies of source files on other source
>> files.
>
> So XNA employs this new marvelous mind-reading technology, as it is able
> to know what to include in the project without you having to explicitly
> tell it.
>
> How does it work? Does it scan brainwaves?
No. I already wrote an extensive post describing all the sections of an XNA
project file, as well as the mechanisms whereby the dependencies get
described implicitly. Which you have apparently either not read or disregarded.
>> Oh, I see what you're saying. You're thinking of something like YACC, where
>> the source files are passed on the command line. Yes, you're right, the
>> makefile can be the sole repository of the list of dependencies, in that case.
>
> That's one of the most typical ways of building complex projects in unix,
> and it's precisely what makefiles are designed for (and is typically why
> command-line tools take things as command line parameters or, at worst,
> as data it reads from the standard input stream).
Yep. Of course, if your YACC grammar has something equivalent to an #include
in it, you're back to listing dependencies in multiple places.
>> But look at the C compiler. You have the list of dependencies in the
>> makefile for invoking the compiler, and then inside the source code there's
>> the list of dependencies in the form of #include files.
>
> Which is why you can *automate* the creation of the dependency rules
> rather than having to do it by hand.
The fact that you can automate (in some cases) the copying of dependencies
from one place to another does not mean you're not copying dependencies from
one place to another.
> The #include file mechanism in itself is useful for other reasons,
> especially in C++, which is why it has its advantages.
Yes. In C and C++, #include is useful. It allows a number of things (like
really powerful templates) that would be difficult (but not impossible, as
seen in LISP and Erlang for example) to do in other ways.
>>> Your complaints have now shifted to duplication of file names. Exactly
>>> where is the duplication in this particular example?
>
>> Do you deny that your makefile is going to have a list of files your main C
>> code includes, and your main C code will also have that list of files?
>> Isn't the -M option indeed specifically intended to duplicate that
>> information in two different formats?
>
> I was talking about my example of a code generator creating code from
> some input files.
Right. And in *my* example, which is what I was talking about since you
never gave a specific example, the dependencies are in the data file (like
#includes would be) rather than on the command line.
> Nevertheless, why should I care if some #include file information is
> duplicated, as long as it happens automatically?
Because now you need a third-party tool to automate dependency generation.
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> > All things considered, I don't think that this simple case is all that
> > complicated. (The only complicated thing is figuring this out.)
> I agree. Not sure why you're making such a big thing of me pointing out that
> the simple system works fine with shell scripts.
When talking about a project building system, a shell script is a
significantly more primitive tool than a makefile because shell scripts
are not designed specifically to deal with dependencies and building
projects, while makefiles are. You could say that shells scripts are
(significantly) *more* generic than makefiles. Going to the more primitive
tool is going to the wrong direction. You should go towards the tool that
is more designed for the task at hand.
Your initial argument pro shell scripts is that, according to you, they
are simpler to create for the original task in this thread than a makefile,
which, again according to you, is the "wrong" tool.
The problem is that you didn't know that you can actually implement what
Andrew wanted with just a couple of simple and straightforward lines with
a makefile (at least when using gnu make, which is the default for all
linux distros). You thought that you need to write a lot more. Hence you
mistakenly advocated shell scripts as the "simpler" solution, when they
really aren't. (Just compare your shell script solution to the makefile
examples I posted earlier and consider honestly which one is simpler.)
'make' is not the wrong tool for what he wants to do, unlike what you
claimed. A shell script will not make the whole process any simpler.
Could there be any better tools than gnu make for this task? Well, if
you don't need to track dependencies (as Andrew clearly didn't have to),
then no: gnu make performs the task perfectly with just a couple of simple
lines. I don't think any other tool could make a better job at it.
If he wanted to automatically track all source file dependencies (in his
linux environment), then yes, there could be (and are) better tools for
this, tools which are even more specialized than 'make' and can automate
the process with less magic keywords and commands. However, such tools are
not necessarily included in many standard linux distributions, while gnu
make is (at least if you have installed any compiler, and probably even
regardless). 'make' is more "standard" (in a sense) than those other more
specific tools. In this particular case, however, there would be little
benefit in using those.
It seems to me that you are opposing 'make' just as a matter of principle
rather than as a matter of practicality. You'd rather have him use shell
scripts rather than makefiles, for whatever reason.
> >>> (And granted, with a "standard" non-gnu makefile you would need more
> >>> than this.)
> >
> >> Another problem with make (and similar tools that get abused).
> >
> > I honestly cannot undrestand why you call this "abuse".
> Your reading comprehension is poor. Where did I say what you wrote is an
> abuse of make? Answer: I didn't. I said that having a bunch of different
> versions is indicitive of a program whose capabilities have been expanded
> over time bit by bit without a coherent plan, in such a way that such
> extentions tend to get abused.
I think it's you who didn't understand. What exactly is this 'make'
abuse you are talking about?
gnu make is a pretty standardized tool in linux distros (and many other
unixes). How do you "abuse" a standard tool when using it for its intended
purpose?
> Nope. It doesn't have to read your mind. Of course it has to know what to
> compile.
Well, that was what I said, and you said that was incorrect.
> The problem is not that you have to tell the compiler what to
> compile. The problem is you have to (in C) compile much more than your own
> source code in order to compile your program.
You have odd problems. I haven't encountered such a problem as far as
I remember.
Maybe compilation times would get faster if the source files didn't depend
on gigantic header files? Probably. However, I haven't personally encountered
this as a problem, as I have never had to deal with gigantic projects with
millions of lines of code. (I do understand that it might be a nuisance in
such huge projects, though.)
> I have no problem telling a C compiler what and where my program is. I just
> don't think it's a good idea to have to tell a C compiler where everyone
> *else's* source code for libraries that are already compiled is.
I don't have to tell it either. I don't even remember where exactly eg.
the C++ standard header files are in my OpenSuse system. Probably somewhere
inside /usr/include/something. The compiler is already configured to find
them so I don't have to care.
If I install a new library from a OpenSuse repository, I still don't have
to care where it's installing it. In fact, I don't even *know* where it's
installing them, and I don't need to. They will still work.
If I install a third-party library *locally* somewhere in my home directory
(rather than systemwide), *then* I may need to add a couple of compiler
options to tell the compiler where to find it. However, that seems pretty
obvious. After all, I have installed the library in a nonstandard location.
The compiler cannot guess where if I don't tell it.
Can this scheme sometimes cause *more* problems than when dealing with
C# on Windows using Microsoft's IDE? Probably. It hasn't bothered me too
much so far, though. (Although I would be surprised that if you installed
a C# library in a nonstandard location, you wouldn't have to explicitly
tell the compiler where to find it. Well, unless the library installer
doesn't tell it automatically, but that's just a technicality.)
> (As far as me bashing, I find it amusing that when I bash a feature in C
> that's improved in C++, you don't get upset, but if I bash a feature in C
> that is carried over to C++, you justify it out the wazoo.)
No, I oppose bashing C (and C++) for flaws that it doesn't really have.
> >>> You are making it sound like most other languages
> >>> don't need to be told where the libraries and source files are.)
> >
> >> Generally, other languages don't need to be told where the sources for a
> >> particular library are stored, no.
> >
> > Bullshit. Specific compilers might have *default* paths for the libraries,
> > and so does a typical gcc installation in linux. That doesn't mean that
> > the compiler is not being told where the libraries are.
> You don't understand the word "sources" in that sentence? Reading
> comprehension, dear.
I don't think I have the sources eg. for libc.so installed in this
system, hence I don't have to tell the compiler where they might be.
I don't get your point.
> The fact that you can automate (in some cases) the copying of dependencies
> from one place to another does not mean you're not copying dependencies from
> one place to another.
And I asked why should I care if it happens automatically behind the
scenes.
> > Nevertheless, why should I care if some #include file information is
> > duplicated, as long as it happens automatically?
> Because now you need a third-party tool to automate dependency generation.
If you consider the C preprocessor a "third-party tool".
Even if you do, so what?
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> The problem is that you didn't know that you can actually implement what
> Andrew wanted with just a couple of simple and straightforward lines with
> a makefile
Of course I knew that. Don't be insulting.
>>>>> (And granted, with a "standard" non-gnu makefile you would need more
>>>>> than this.)
>>>> Another problem with make (and similar tools that get abused).
>>> I honestly cannot undrestand why you call this "abuse".
>
>> Your reading comprehension is poor. Where did I say what you wrote is an
>> abuse of make? Answer: I didn't. I said that having a bunch of different
>> versions is indicitive of a program whose capabilities have been expanded
>> over time bit by bit without a coherent plan, in such a way that such
>> extentions tend to get abused.
>
> I think it's you who didn't understand. What exactly is this 'make'
> abuse you are talking about?
If you've never seen abuse of makefiles, then power to you. I think anyone
who has worked on an ugly system knows what I'm talking about. Otherwise, go
look up the "buildroot" system for compiling kernels. I mean, hell,
buildroot was so makefile-abusive that people capable of working on the
linux kernel said "screw this, let's throw it away and start over."
>> The problem is not that you have to tell the compiler what to
>> compile. The problem is you have to (in C) compile much more than your own
>> source code in order to compile your program.
>
> You have odd problems. I haven't encountered such a problem as far as
> I remember.
Well, good for you. The fact that you've not encountered that problem
doesn't mean that the problem isn't real.
> Maybe compilation times would get faster if the source files didn't depend
> on gigantic header files? Probably. However, I haven't personally encountered
> this as a problem, as I have never had to deal with gigantic projects with
> millions of lines of code. (I do understand that it might be a nuisance in
> such huge projects, though.)
Well, let me know when you've taken the source code for an entire toolchain,
kernel, and application stack and cross-compiled it from scratch. Let me
know how easy it is to figure out where everything goes when your makefiles
download from FTP sites other makefiles and then run them thru sed to patch
up the errors in them before invoking them, and then come back and tell me
it isn't a problem.
> If I install a new library from a OpenSuse repository, I still don't have
> to care where it's installing it. In fact, I don't even *know* where it's
> installing them, and I don't need to. They will still work.
Here you're arguing that someone else has already solved the problem for you.
> Can this scheme sometimes cause *more* problems than when dealing with
> C# on Windows using Microsoft's IDE? Probably. It hasn't bothered me too
> much so far, though.
Great. Install compilers for three different versions of Linux for three
different architectures on the same machine. Make sure that you can use all
three different versions of boost you need on each of those three compilers.
Let me know how simple your makefiles are.
(And you're giving *me* shit about not knowing how makefiles work? Really??)
> (Although I would be surprised that if you installed
> a C# library in a nonstandard location, you wouldn't have to explicitly
> tell the compiler where to find it. Well, unless the library installer
> doesn't tell it automatically, but that's just a technicality.)
I could describe how it works, but you're not interested enough to read it.
> No, I oppose bashing C (and C++) for flaws that it doesn't really have.
You mean "flaws you haven't encountered". Good for you. Maybe I've used C
more than you have even.
>> You don't understand the word "sources" in that sentence? Reading
>> comprehension, dear.
>
> I don't think I have the sources eg. for libc.so installed in this
> system, hence I don't have to tell the compiler where they might be.
Um, yes, you do. You have the sources for some of the openssl libraries
installed, don't you?
> I don't get your point.
Yes you do.
>> The fact that you can automate (in some cases) the copying of dependencies
>> from one place to another does not mean you're not copying dependencies from
>> one place to another.
>
> And I asked why should I care if it happens automatically behind the
> scenes.
And I answered this repeatedly, and you picked nits instead about whether
invoking the C preprocessor is invoking the compiler or not.
>> Because now you need a third-party tool to automate dependency generation.
> Even if you do, so what?
I already answered that.
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Darren New <dne### [at] san rr com> wrote:
>> Warp wrote:
>>> How do you resolve this? That's right: You tell the compiler which files
>>> it needs to compile.
>
>> Nope. You tell the compiler which *object* file goes with the appropriate
>> *source* file.
>
> Yeah, huge difference.
And *this* is exactly why these arguments go on for so long.
I can't tell whether you're being a truly masterful troll, or whether your
misplaced egoism has completely blinded you.
I make a comment. You strawman an argument against it. I point out that
you're putting words in my mouth. Instead of saying "OK, I was wrong in my
assertion, I don't see the difference, please explain again why it matters",
you say "I wasn't wrong, because even tho I was *factually* incorrect, it
doesn't make any difference, because there couldn't possibly be any
difference, so I'm really right anyway."
Yes, there *is* a huge difference. I spent an entire post of several dozen
lines long pointing out exactly why there's a difference and the
implications it has for this, simply so you could stop picking nits one
sentence at a time and maybe comprehend what I was trying to say. But you
either didn't read it, or you read it and decided you couldn't pick nits
with it, so you asked the same question again and again, ignoring the answer
each time by equating it to something different and then dismissing the
differences.
And you know, for someone who distinguishes "invoking the compiler
preprocessor" from "invoking the compiler", saying there's no significant
difference between source code and object code just doesn't ring true.
> Are you saying that it's impossible to have a C# source file with the
> same name in two different directories and which implement a class with
> the same name?
I'm saying that if you do, it doesn't matter, because your compilation isn't
looking at that source code.
>> Do you really not see the difference between saying "each time I compile
>> something, I have to pick which source file to compile" and saying "each
>> time I compile something, I have to pick the right source files that go with
>> the corresponding libraries of every library I'll eventually link this with"?
>
> Not really.
OK. Then I'm afraid I can't explain it to you.
> You have to specify which source files the program is
> composed of.
It's not my program. I've never written a crypto library, nor have I written
a video codec. But I've compiled the source code for parts of those
libraries into every C program I've ever written that used them.
> Your example of the same C file being in two different directories is simply bogus.
Why?
> It has nothing to do with C particularly.
It is much more common in C than in other languages, I've found. YMMV, but
that doesn't make me wrong.
>> Indeed, when I use the C# equivalent of stdio (or any other third-party
>> library), I don't need any source code I didn't write myself, nor do I need
>> to specify where to find the libraries. I merely say which version of what
>> implementation I want.
>
> And when I write C++, same thing. So what?
So, when you use boost, you don't need to compile any source code to any
software you didn't write yourself? Sorry, that's just a lie. I've looked at
the boost code. It's mostly source code. And you know what? I've worked on
projects where I've needed two different versions of boost in the same code,
neither version of which was in the repository. It sucks. It's very
difficult to get right.
> "I have seen the same C file in multiple places, but I have never seen
> the same C# file in multiple places, hence C is clearly the inferior
> language." Yes, very convincing argumentation.
It's only unconvincing because it's a straw man you refuse to acknowledge
isn't what I'm arguing.
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Let's take a better example: Every time I want to use std::vector,
> I have to #include <vector> in the source file where I want to do so.
> Is there any advantage to this?
For C++ and templates, yes. Altho (and I know you'll go apeshit over this
comment) C# manages not to need the source code for generics like that.
The problem is, again, that it can be abused. It works great as long as you
put templates and declarations and such in there, and as long as you don't
build entire type systems and programming structures and such via macros[*].
It sucks when someone starts using include files that are order-dependent,
that try to enforce coding conventions, that screw up the syntax of the
language you're coding in, etc. None of which is possible if you're not
including someone else's source code into your own compilation.
> OTOH, is there a huge disadvantage in having
> to include the files other than the trouble of having to write the
> #include lines?
Yes. And I had an entire 50-line post detailing the logical disadvantages of
it. Basically, it discussed the benefits of having every source file
actually generate object code. Perhaps you missed it?
[*] And please think about it for a bit before accusing me of moving the
goalposts to include macros, eh? Try to do the "why would he bring up that
topic" question before just assuming I must be doing it to annoy you or
something.
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Darren New <dne### [at] san rr com> wrote:
>>> So essentially you want the compiler to know what to compile without
>>> you specifying what to compile.
>
>> Nope. I specified that you want to compile "main".
>
> If your program consists of one single file named "main", then it could
> work.
But it doesn't. And in practice, in C, it almost never does. Yet in many
other languages, it does.
> Don't forget the context. You were talking about 'make' requiring overly
> complicated steps in order to automatically track the dependencies of
> include files in C programs, and how you don't like that.
Correct. In part, because you (for example) already have to know where all
the C header files are in order to generate the dependencies to start with.
> Then, suddenly,
> you come up with a "it's impossible to track dependencies by looking at
> the source code only" argument.
That is correct also. But the two are related. If you don't see how they're
related, then I'm sorry, but you apparently have less experience with really
crappy C code than I do.
> It was clear from the context that you
> were talking about C in particular, as if the same (quite trivial) problem
> didn't happen in more "advanced" languages.
And, generally, it doesn't. Really. It just doesn't cause the same sort of
problems. I've never invoked a Java class where I needed to know what order
to put #include headers in to make it compile.
> So what's the point?
That you're a master troll? That you're ignoring everything I'm saying that
conflicts with your view that it just isn't a problem?
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Let's take a better example: Every time I want to use std::vector,
> I have to #include <vector> in the source file where I want to do so.
Or, to phrase it differently:
vector.hpp is a standard file from the standard library. Why the hell are
you compiling it, over and over, every time you compile your program?
Doesn't it strike you as a bit odd that standard libraries that come with
the compiler still get compiled on your CPU over and over?
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New wrote:
> That you're a master troll? That you're ignoring everything I'm saying
> that conflicts with your view that it just isn't a problem?
I'm sorry. There was a possibility I didn't consider. Perhaps when you say
"I don't understand", you really mean "I don't understand and I don't care
to have you explain it, either." I can perfectly understand that, if that's
what you meant. I was caught off-guard, because usually "I don't
understand" in a social environment like this doesn't carry an implicit "so
go away about this" trailer. My apologies if I was misinterpreting you in
this way.
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 01/02/2011 05:16 PM, Warp wrote:
> Invisible<voi### [at] dev null> wrote:
>> I'm curious to see if turning on optimisations actually makes any
>> noticeable performance difference... I guess I'll find out tomorrow.
>
> Well, it depends on what those programs are actually doing. If they are
> doing some heavy-duty calculations that take seconds or more, then there
> usually is a quite drastic difference between using -O3 and not using it.
How about if the program just calls two or three library functions that
do all the work?
Well anyway, I'll find out in just a minute...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>> I'm curious to see if turning on optimisations actually makes any
>>> noticeable performance difference... I guess I'll find out tomorrow.
>>
>> Well, it depends on what those programs are actually doing. If they are
>> doing some heavy-duty calculations that take seconds or more, then there
>> usually is a quite drastic difference between using -O3 and not using it.
>
> How about if the program just calls two or three library functions that
> do all the work?
>
> Well anyway, I'll find out in just a minute...
Conclusion: -O3 = small but measurable performance increase.
(E.g., 27 seconds instead of 30 seconds.)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> How about if the program just calls two or three library functions that
> do all the work?
Well, then it shouldn't make much of a difference (because there usually
aren't different versions of libraries depending on your optimization level).
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> Warp wrote:
> > The problem is that you didn't know that you can actually implement what
> > Andrew wanted with just a couple of simple and straightforward lines with
> > a makefile
> Of course I knew that. Don't be insulting.
You said, and I quote:
"I don't remember. Do you have to actually list the programs in the makefile
that you want to compile? Is a makefile that compiles 50 programs
necessarily larger than one that compiles 5?"
That tells me that you didn't know about the implicit rules in gnu make
that allow avoiding having to call gcc explicitly (hence saving a significant
amount of writing), or you didn't know about gnu make's support for
wildcards. Probably both.
> > I think it's you who didn't understand. What exactly is this 'make'
> > abuse you are talking about?
> If you've never seen abuse of makefiles, then power to you. I think anyone
> who has worked on an ugly system knows what I'm talking about. Otherwise, go
> look up the "buildroot" system for compiling kernels. I mean, hell,
> buildroot was so makefile-abusive that people capable of working on the
> linux kernel said "screw this, let's throw it away and start over."
So some people have abused make to do something it's not designed to do?
Is that supposed to somehow be a negative point about make, or something?
I already forgot the whole point of this "abuse" thing or why you even
brought it up.
> >> The problem is not that you have to tell the compiler what to
> >> compile. The problem is you have to (in C) compile much more than your own
> >> source code in order to compile your program.
> >
> > You have odd problems. I haven't encountered such a problem as far as
> > I remember.
> Well, good for you. The fact that you've not encountered that problem
> doesn't mean that the problem isn't real.
But it could perfectly well mean that it's not as common as you make it
sound (which, honestly, wouldn't actually surprise me).
Some people write bad code. In some such cases other people need to
decipher that bad code. It probably sucks. However, this problem is not
exclusively limited to C and its variants. (And from what I read at
the daily wtf, higher level languages seem to be much more prominently
represented than lower-level languages like C. Not that this means that
in an absolute scale the problems are not more common in C. However,
it does tell that such problems are also quite common even in higher-level
languages. They are in no way safe from idiotic programmers.)
> > If I install a new library from a OpenSuse repository, I still don't have
> > to care where it's installing it. In fact, I don't even *know* where it's
> > installing them, and I don't need to. They will still work.
> Here you're arguing that someone else has already solved the problem for you.
Yeah, isn't it great? The C/C++ library system isn't so bad as you make
it sound, after all. It works like a charm for me.
> > Can this scheme sometimes cause *more* problems than when dealing with
> > C# on Windows using Microsoft's IDE? Probably. It hasn't bothered me too
> > much so far, though.
> Great. Install compilers for three different versions of Linux for three
> different architectures on the same machine. Make sure that you can use all
> three different versions of boost you need on each of those three compilers.
> Let me know how simple your makefiles are.
> (And you're giving *me* shit about not knowing how makefiles work? Really??)
You are still making all this to be some kind of issue about makefiles.
I don't really understand why.
Perhaps next you'll complain how your car broke and it will cost you an
arm and a leg to repair it, and this, too, has something to do with why
makefiles suck.
> >> You don't understand the word "sources" in that sentence? Reading
> >> comprehension, dear.
> >
> > I don't think I have the sources eg. for libc.so installed in this
> > system, hence I don't have to tell the compiler where they might be.
> Um, yes, you do. You have the sources for some of the openssl libraries
> installed, don't you?
Openssl libraries? I have no idea. Why should I even care?
> > I don't get your point.
> Yes you do.
No, I don't. You are writing about library sources now, and I have no
idea what you are talking about.
> >> The fact that you can automate (in some cases) the copying of dependencies
> >> from one place to another does not mean you're not copying dependencies from
> >> one place to another.
> >
> > And I asked why should I care if it happens automatically behind the
> > scenes.
> And I answered this repeatedly, and you picked nits instead about whether
> invoking the C preprocessor is invoking the compiler or not.
Your "answer" seems to be to endlessly repeat the duplication argument.
You are not telling me why I should care if the dependencies are duplicated,
if the duplication happens automatically.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> Warp wrote:
> > Darren New <dne### [at] san rr com> wrote:
> >> Warp wrote:
> >>> How do you resolve this? That's right: You tell the compiler which files
> >>> it needs to compile.
> >
> >> Nope. You tell the compiler which *object* file goes with the appropriate
> >> *source* file.
> >
> > Yeah, huge difference.
> And *this* is exactly why these arguments go on for so long.
> I can't tell whether you're being a truly masterful troll, or whether your
> misplaced egoism has completely blinded you.
> I make a comment. You strawman an argument against it. I point out that
> you're putting words in my mouth. Instead of saying "OK, I was wrong in my
> assertion, I don't see the difference, please explain again why it matters",
> you say "I wasn't wrong, because even tho I was *factually* incorrect, it
> doesn't make any difference, because there couldn't possibly be any
> difference, so I'm really right anyway."
I don't understand what you are talking about.
I said, "you need to tell the compiler which files it should use to
compile the program", and you answer with "no, you tell the compiler
which object file goes with the appropriate source file".
What exactly is the difference here? You are telling the compiler which
source files the program is composed of. What do the object files have
anything to do with this? In fact, you are making it sound *more* complicated
than it needs to be, (Why exactly would I need to specify which object
file goes with what source file? I don't care. Let the compiler figure
those things out. You are in fact making it sound like compiling a C#
program is actually more complicated than compiling a C++ program, if
you need to be explicitly pairing object files with source files.)
Whatever the building process might be, you still need to tell the
compiler in one way or another where your source files are, and that's
the point. If you have two files with the same name, you tell the compiler
which one of them to use. (Your original argument was, after all, what
happens if you have to C files of the same name.) I don't understand what
the "object files" have anything to do with this.
Also, I don't understand what "factually incorrect" thing I have said.
> And you know, for someone who distinguishes "invoking the compiler
> preprocessor" from "invoking the compiler", saying there's no significant
> difference between source code and object code just doesn't ring true.
Somehow it seems that you are talking about something else entirely.
This whole "you tell the compiler which files to compile" argument started
from your example of two C files with the same name. You have now made a
strange jump to some C# object files, and I have no idea why or how it's
related. It seems that you are thinking about something else entirely.
> > Are you saying that it's impossible to have a C# source file with the
> > same name in two different directories and which implement a class with
> > the same name?
> I'm saying that if you do, it doesn't matter, because your compilation isn't
> looking at that source code.
And why not? That's right: Because you only told the compiler to use
*one* of those files, rather than both. It's your decision which one.
You don't seem to get my point here. My point is that your argument about
the two C files with the same name is bogus. In other words, a bad example
and a bad argument.
It's anybody's guess what object files have anything to do with this
whole thing.
> >> Do you really not see the difference between saying "each time I compile
> >> something, I have to pick which source file to compile" and saying "each
> >> time I compile something, I have to pick the right source files that go with
> >> the corresponding libraries of every library I'll eventually link this with"?
> >
> > Not really.
> OK. Then I'm afraid I can't explain it to you.
Well, I just can't see the difference between the two sentences you wrote.
They are saying the same thing.
> > You have to specify which source files the program is
> > composed of.
> It's not my program.
There's a difference between "the" and "my". I wrote "the".
> I've never written a crypto library, nor have I written
> a video codec. But I've compiled the source code for parts of those
> libraries into every C program I've ever written that used them.
So you tell the compiler which source files it should use to compile
the program. So? Isn't that what I'm saying?
> > Your example of the same C file being in two different directories is simply
bogus.
> Why?
Because you tried to use it as some kind of example of why it's "not
possible to figure out dependencies by looking at the source codes only"
and that you need to specify where the compiler has to look for those
sources, and this, apparently, is some kind of "problem" in C.
My answer, which you still don't seem to understand, is that this has
nothing to do with C or any particular language. If you have a file with
the same name in more than one place, you need to tell the compiler which
one it should use. This is obviously true for any language. C isn't somehow
inferior because of this.
Then you start rambling something strange about object files.
> > It has nothing to do with C particularly.
> It is much more common in C than in other languages, I've found. YMMV, but
> that doesn't make me wrong.
You are blaming C for a somewhat common bad practice among C programmers?
If I were to go that path, I would say that C# and ASP are really crappy
languages, judging from what I have seen at thedailwtf. (Of course this
argument would be completely fallacious.)
> >> Indeed, when I use the C# equivalent of stdio (or any other third-party
> >> library), I don't need any source code I didn't write myself, nor do I need
> >> to specify where to find the libraries. I merely say which version of what
> >> implementation I want.
> >
> > And when I write C++, same thing. So what?
> So, when you use boost, you don't need to compile any source code to any
> software you didn't write yourself? Sorry, that's just a lie. I've looked at
> the boost code. It's mostly source code. And you know what? I've worked on
> projects where I've needed two different versions of boost in the same code,
> neither version of which was in the repository. It sucks. It's very
> difficult to get right.
You said, and you quoted it above: "when I use the C# equivalent of stdio",
to which I responded "and when I write C++, same thing". I don't think I
heve the source code for stdio even installed in my linux system.
Also, if talking about template code, in a different subthread I actually
advocated the advantages of having such code in header files, and mentioned
<vector> as an example of this.
I don't understand why you consider it a bad thing that eg. the boost
libraries are mostly in the header files (often because they are fully
templated and cannot be placed in precompiled libraries due to
compiler-technical reasons). So what if I need to "include someone else's
code in my program"? (The biggest issue with that for me would be the
usage license of the library, but that's completely tangential to the
subject.)
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> Warp wrote:
> > Let's take a better example: Every time I want to use std::vector,
> > I have to #include <vector> in the source file where I want to do so.
> > Is there any advantage to this?
> For C++ and templates, yes. Altho (and I know you'll go apeshit over this
> comment) C# manages not to need the source code for generics like that.
It's not so much a question of making it work as much as a question of
optimization.
For example, if you create your own class or struct which has a few
member variables, and then you instantiate a vector of that type, it will
be quite space-optimal: Every element in the vector will only consume as
much memory as the size of the object. There is no ancillary data needed.
Of course the second efficiency advantage is that the compiler will be
able to inline code and to perform type-specific optimizations (for example,
sorting a vector of ints will be very efficient because the compiler will
be able to inline the element comparisons directly into the sorting routine
as a machine code register comparison opcode).
This still doesn't make it technically impossible to compile templates
into precompiled libraries. In fact, the current C++ standard defines such
a possibility (the so-called "export templates"). The only major problem
with export templates is that it's technically extremely difficult and
laborious to implement in compilers, which is why there's only one major
C++ compiler that supports it (and it's because of this that, faced with
the harsh realities of the marketplace, the standardization committee is
going to drop the feature from the next standard).
The problem is that templates need to be instantiated in the context
where they are used. Or in the case of export templates, the context needs
to be "brought" where the export template is being instantiated. This is
an extremely complicated thing to do.
For example, you could have this in one source file:
//--------------------------------------------------------
namespace
{
// 'Point' is a type local to this compilation unit
struct Point { int x, y; }
std::vector<Point> points;
}
//--------------------------------------------------------
And then you could have this in another source file:
//--------------------------------------------------------
namespace
{
// 'Point' is a type local to this compilation unit
struct Point { double x, y; }
std::vector<Point> points;
}
//--------------------------------------------------------
With regular templates this isn't any problem at all, and it's trivial
for compilers to handle. With export templates the problem is enormously
harder. (Basically, the 'vector' template class, if it was an export
template, would be instantiated at the linking stage in its own compilation
unit, with its own context, but it needs to also know the context in which
it was used, as above. The compiler needs to somehow carry all the context
information to the template instantiation process at the linking stage.)
And as far as I understand, the above example is just one of the *minor*
complexities in this whole thing.
On the other hand, it's not technically impossible, and it has been done,
so in principle it would be possible to have precompiled template libraries.
(They would only be slightly less efficient because functions which are not
implemented in the header file would not be inlined. OTOH this isn't different
from regular functions.)
As far as I understand "generics" do not handle things "inline" and
"by value", but instead simply handle references, and basically the only
thing they do is that they allow you to skip doing explicit upcasting.
Generics do not allow things like template metaprogramming, template
specialization, and such. (Well, this at least with Java generics. I have
no idea about C#. Also, at least in Java, you can't handle primitive types
with generics.)
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> Warp wrote:
> > Let's take a better example: Every time I want to use std::vector,
> > I have to #include <vector> in the source file where I want to do so.
> Or, to phrase it differently:
> vector.hpp is a standard file from the standard library. Why the hell are
> you compiling it, over and over, every time you compile your program?
The advantage is that the end result is much more efficient (both
speedwise and memorywise) because it allows the compiler to perform
heavy-duty optimizations on the included code based on the types you are
using as well as many other things. (Of course that's not the *original*
reason to have include files, but it's a nice side-effect of them that
makes them actually quite useful.)
(Curiously, the next C++ standard will include a feature called "extern
template" which allows you to defer the compiling of the templated code
into one single compilation unit. This doesn't have efficiency advantages,
but it can speed up compilation and make object files smaller. It's still
not the same thing as an "export template" though, and shouldn't be confused
with it.)
> Doesn't it strike you as a bit odd that standard libraries that come with
> the compiler still get compiled on your CPU over and over?
Not for templated code, no. As for non-templated code, they usually come
in precompiled dynamically loadable versions (or statically linkable, if
you want).
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> No, I don't. You are writing about library sources now, and I have no
> idea what you are talking about.
So you don't think stdio.h is source file?
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> Warp wrote:
> > No, I don't. You are writing about library sources now, and I have no
> > idea what you are talking about.
> So you don't think stdio.h is source file?
Yes, it's a source file containing declarations.
When you talked about needing "the source for the library", it sounds
like you need the entire library in source code form if you want to use
it in your program.
While header files are source code like anything else from the point of
view of the compiler, it's not usually what is meant by "*the* source code
of the library", which would be *all* the source files needed to create
the precompiled library. When you say "you need *the* source code for
stdio", my answer is "no, I don't". Yes, I need the declarations, but
I don't need the full source code.
I know that you didn't mean the full source code, but you should try
to use common terminology, and "the source code" is not the common term
for "header files".
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> What exactly is the difference here?
I have explained it repeatedly, but it basically breaks down to "I don't
have to compile object code."
> (Why exactly would I need to specify which object
> file goes with what source file? I don't care.
So there's no need to use the right .h files for a given .so file?
> you need to be explicitly pairing object files with source files.)
You need to specifically pair object files you're *linking* against with the
source files you're compiling. But you don't have to find any *source* code
that came with the object code you're linking against.
> Whatever the building process might be, you still need to tell the
> compiler in one way or another where your source files are, and that's
> the point.
Right. And in C, I have to tell the compiler one way or another where *your*
source files are too.
> (Your original argument was, after all, what
> happens if you have to C files of the same name.)
No, that was a trivial oversimplification to try to explain what I meant
when I said the source code isn't sufficient to know what the dependencies
are. Don't apply it to other situations.
> Also, I don't understand what "factually incorrect" thing I have said.
I said "No. The programming language is such that it is impossible to figure
out by looking at the source code what the dependencies are on other source
code."
This is factually true. You argued "If that were true, then it would be
impossible to compile the program."
Then I gave an example of source code from which you could not deduce the
dependencies, and yet which is possible to compile.
Indeed, you're *making reference* to that example right here.
>> And you know, for someone who distinguishes "invoking the compiler
>> preprocessor" from "invoking the compiler", saying there's no significant
>> difference between source code and object code just doesn't ring true.
>
> Somehow it seems that you are talking about something else entirely.
> This whole "you tell the compiler which files to compile" argument started
> from your example of two C files with the same name. You have now made a
> strange jump to some C# object files, and I have no idea why or how it's
> related. It seems that you are thinking about something else entirely.
OK. If you can't read what *i'm* writing about a non-C language without
running it through your C filter and changing the words I'm saying into
something else, then I can't really explain it to you.
If you're going to change where I say "object code" into "source code" and
when I say "library" into "include file" and where I say "link" you say
"compile" and so on, then I'm just not going to be able to explain it to
you. I tried my best, including a couple of detailed and thought-out posts
which you still haven't commented on or said anything to imply you read.
>>> Are you saying that it's impossible to have a C# source file with the
>>> same name in two different directories and which implement a class with
>>> the same name?
>
>> I'm saying that if you do, it doesn't matter, because your compilation isn't
>> looking at that source code.
>
> And why not? That's right: Because you only told the compiler to use
> *one* of those files, rather than both. It's your decision which one.
No. It's because the equivalent code in C# would not look at *EITHER* of
those two source files.
> You don't seem to get my point here. My point is that your argument about
> the two C files with the same name is bogus. In other words, a bad example
> and a bad argument.
It was merely an argument to prove your assertion that having that is
impossible is bogus.
> It's anybody's guess what object files have anything to do with this
> whole thing.
Since it's pretty much the entire point I'm making, I'm not surprised this
is going around and around. You're taking an example I'm using to show one
point and saying "that is nonsense in the context of this other point!"
Well, yes, it's because it's a nonsense example to prove a very simple and
specific point, because you seem to be having trouble following the overall
discussion in a larger way.
>>>> Do you really not see the difference between saying "each time I compile
>>>> something, I have to pick which source file to compile" and saying "each
>>>> time I compile something, I have to pick the right source files that go with
>>>> the corresponding libraries of every library I'll eventually link this with"?
>>> Not really.
>
>> OK. Then I'm afraid I can't explain it to you.
>
> Well, I just can't see the difference between the two sentences you wrote.
> They are saying the same thing.
Here's a simple summary: When I compile code I wrote in C# or Java or etc, I
don't compile code I didn't write.
When I compile code I wrote in C, I almost invariably wind up also compiling
code I didn't write at the same time in the same compilation unit.
>>> You have to specify which source files the program is
>>> composed of.
>
>> It's not my program.
>
> There's a difference between "the" and "my". I wrote "the".
And now you're trolling. You're here *intentionally* ignoring the point I'm
making. You're saying "I don't understand the difference between your source
code and my source code." I say "I don't want to compile *your* source
code." You say "You have to compile *the* source code." Do grow up.
>>> Your example of the same C file being in two different directories is simply
bogus.
>
>> Why?
>
> Because you tried to use it as some kind of example of why it's "not
> possible to figure out dependencies by looking at the source codes only"
Yep! That was the point of the example. Why is it bogus.
> My answer, which you still don't seem to understand, is that this has
> nothing to do with C or any particular language.
Yet, surprisingly, you said "If that were true, then it would be impossible
to compile the program." That's all that example was about: showing you that
your assertion that you can deduce the dependencies solely from the source
code is bogus.
You made a factually incorrect statement. I showed you a trivial example of
how you are factually incorrect. You then denied that you were incorrect
*and* complained that the example was obviously stupid. Now you keep
bringing it up for some reason. Nice moves, Bats!
> If you have a file with
> the same name in more than one place, you need to tell the compiler which
> one it should use. This is obviously true for any language. C isn't somehow
> inferior because of this.
I didn't say it is.
>>> It has nothing to do with C particularly.
>
>> It is much more common in C than in other languages, I've found. YMMV, but
>> that doesn't make me wrong.
>
> You are blaming C for a somewhat common bad practice among C programmers?
Yep! Altho for some reason you seem to think there's some pejorative
"blame" going on here. I also blame any other language with disconnected
and non-modular declarations and defintions. (I don't like FORTRAN block
common statements either, for example, for the same sort of reason, altho
without macros it's somewhat less of a problem in fortran.)
> If I were to go that path, I would say that C# and ASP are really crappy
> languages, judging from what I have seen at thedailwtf. (Of course this
> argument would be completely fallacious.)
Feel free! It would be interesting to hear some of the criticisms of C#
technology.
> You said, and you quoted it above: "when I use the C# equivalent of stdio",
> to which I responded "and when I write C++, same thing". I don't think I
> heve the source code for stdio even installed in my linux system.
So, what happens when you #include <stdio>? Sorry, I thought stdio.h is
source code, yes? I mean, there are precompiled headers, but that's just
running parts of the compiler first and dumping the symbol table, afaik.
Now I'm really curious. What does your stdio.h look like? Cause mine's full
of C source code.
(And yes, I actually trusted you enough that I actually fired up Linux to
check. :-> Plus, there are three stdio.h files under my /usr/include right
now, so the whole idea that you might not know which is the right one isn't
as far-fetched as one might think.)
> So what if I need to "include someone else's code in my program"?
There's a whole slew of problems this enables. No, you might not run into
any of these problems. But let me list again what they might be:
1) There's no way to know which header files go with which object files.
Look at the man page for open() and tell me how you would figure out which
header files you need to include for that to work.
If you compile against object code declarations instead of source code
declarations, you don't have this problem. Instead of saying "I'm using the
version of open() defined in sys/types.h and sys/stat.h and fcntl.h", you
just say "I'm using the version of open() defined in crt.o". Instead of
saying "I'm using the MPEG decoder as specified in RMinit.h, RMerr.h,
RMinp.h, RMthis.h, RMthat.h, RMother.h oh wait I need to put RMthat.h before
RMthis.h, and if I include RMinp.h it includes RMother.h in turn so that
breaks...." I could just say "I'll be linking against RMlib.so, so use that
for declarations when I compile."
2) Header files can contain macros that change how your code behaves. Go
read my post about the awful libraries I used at work, including
#define char }}}}
put in there *explicitly* to fuck up the code of anyone trying to use the
library (in the name of portability, of course). Along with a bunch of crap like
#define IN
#define OUT
etc, to the point where you're reading a declaration and you can't even tell
looking at the arguments what are the types and what are the variable names.
If I'm compiling with declarations from object code, none of this happens,
because I'm only compiling the code I myself wrote.
3) Stuff like #define making it impossible in some cases to track down just
what name goes with what value, as I gave examples of.
Again, if I'm using declarations out of object code, the names vs values
have already been compiled, and they won't change depending on what I put in
my source code.
4) Compilation options for the compilation of a given library is usually not
stored in the object code, and you're recompiling the declarations for each
caller, so a change in calling convention, structure packing, etc between
what the library was compiled with and what the caller was compiled with
will often crash silently or messily, often without any indication of why.
If at compile time I'm supplying the object code instead of the source code,
the compiler can either reject it during compilation, or it can adjust
individual calling sequences to match the library being called.
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> For example, if you create your own class or struct which has a few
> member variables, and then you instantiate a vector of that type, it will
> be quite space-optimal: Every element in the vector will only consume as
> much memory as the size of the object. There is no ancillary data needed.
C# does that. Of course, it's generating bytecodes not machine code.
> Of course the second efficiency advantage is that the compiler will be
> able to inline code and to perform type-specific optimizations (for example,
> sorting a vector of ints will be very efficient because the compiler will
> be able to inline the element comparisons directly into the sorting routine
> as a machine code register comparison opcode).
C# can do this too, but of course that's because it's not completely
compiled until you run the code.
The place C# lacks compared to C++ is that again *because* you're not
recompiling the declaration each time you use it, you have to make
guarantees at the compile time of the generic. So you can't write a generic
that would work on "any object that has a function X taking a single integer
and returns a float". The things you instantiate have to have particular
declarations as required by the generic. This is something I'd take from Go
perhaps - there doesn't seem to be any technical reason the language
couldn't be improved to support this sort of thing. The language already
knows hen you compile the generic if you're making calls you haven't
supported, and it knows when you instantiate the generic what calls are
supported by the class you're instantiating it with, so it would probably
just be an extension of the metadata.
> On the other hand, it's not technically impossible, and it has been done,
I had read that the guys who did it said basically it's impossible to do
right according to the standard, but you can get close. Not being an expert
on the esoteric details of C++ compiler implementation, I might have been
misunderstanding their conclusions. But sure, it can be done, but I'm not
sure what the benefit would be per se? Why does anyone care? Is it just to
hide (in a commercial sense) the source code for the template library?
> As far as I understand "generics" do not handle things "inline" and
> "by value", but instead simply handle references, and basically the only
> thing they do is that they allow you to skip doing explicit upcasting.
That's Java. In C#, they actually changed the object code format (which Java
couldn't afford to do) to support actual generics. So a list of points
doesn't have any pointers in it internally, and your example of
vector<Point> with two definitions of Point works fine too. That's why XNA
(for example) can build a model full of vertexes and not be absolutely
bogged down even on an implementation where the GC is
stop-the-work-mark-and-sweep sucky.
> Generics do not allow things like template metaprogramming, template
> specialization, and such.
Yes, specialization is another thing that (I think) C# lacks that I would
have liked to have on several occasions.
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> I know that you didn't mean the full source code, but you should try
> to use common terminology, and "the source code" is not the common term
> for "header files".
It's not like I didn't say it three dozen different ways over the course of
the conversation, with repeated references to include files.
But now you understand what I'm saying. #include includes source code. No
other compiled language I use needs that feature.
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Darren New <dne### [at] san rr com> wrote:
> Warp wrote:
> > For example, if you create your own class or struct which has a few
> > member variables, and then you instantiate a vector of that type, it will
> > be quite space-optimal: Every element in the vector will only consume as
> > much memory as the size of the object. There is no ancillary data needed.
> C# does that. Of course, it's generating bytecodes not machine code.
Can you compile a C# program into a stand-alone executable that does not
require a JIT compiler environment? (Well, I suppose that if the JIT
compiler is linked into the executable, it could perhaps work.)
But thinking about it, why is the final compilation into machine code
delayed until the program is run? Why cannot it be done at compile time?
> > On the other hand, it's not technically impossible, and it has been done,
> I had read that the guys who did it said basically it's impossible to do
> right according to the standard, but you can get close. Not being an expert
> on the esoteric details of C++ compiler implementation, I might have been
> misunderstanding their conclusions.
AFAIK they added export templates to the standard because they confirmed
that it can be done. They didn't predict, however, how hard it would be,
nor that major compiler writers would just skip doing it because of that.
> But sure, it can be done, but I'm not
> sure what the benefit would be per se? Why does anyone care? Is it just to
> hide (in a commercial sense) the source code for the template library?
Well, if you can avoid having to put tens of thousands of lines of code
in header files (just because the compiler forces you to), making compilation
slower and possibly bloating your program, that's always a plus. Often it's
beneficial when the compiler can inline templates, but there becomes a limit
where it actually becomes a hindrance when you have to put your entire
library in a header file. However, that's not the main problem.
Support for export templates would allow the templated code to have
types, functions and data that are local to the compilation unit (and
possibly shared among all the different template type instantiations)
where the templated code is implemented. This might sound like a small
thing, but it's actually a huge defect in templated code when the compiler
doesn't support export templates.
Just consider this simple example (in a source file):
//------------------------------------------
namespace
{
int counter = 0;
}
export template<typename T>
void foo()
{
++counter;
...
}
//------------------------------------------
What's so special about this? It's special in that all instantiations
of foo() will modify the *same* 'counter' (rather than there having one
'counter' per template type).
The above is simply *not possible* with current C++ compilers (except
Comeau, which is the only one that supports export templates).
(Ok, it's not completely impossible. You could make 'counter' global,
in which case the non-export foo() instantiations could modify it. However,
this obviously reduces modularity significantly, and grants unwanted
access for outside code to the variable.)
Even if you don't really need data that is shared among all the template
instantiations, just the ability to have most of your types, functions and
data local to the compilation unit where the templates using them are,
would increase modularity significantly. It can also reduce executable bloat
(because types and data that are common to all template instantiations do
not need to be duplicated for each one.)
AFAIK people working in the standardization committee are trying to come
up with a different solution to this problem which would be much easier for
compilers to implement.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> Can you compile a C# program into a stand-alone executable that does not
> require a JIT compiler environment? (Well, I suppose that if the JIT
> compiler is linked into the executable, it could perhaps work.)
There's a tool called NGEN that takes the byte code file and inserts
compiled code too. For things you install into the "global assembly
container" (i.e., /lib basically) it runs that tool at install time.
> But thinking about it, why is the final compilation into machine code
> delayed until the program is run? Why cannot it be done at compile time?
I would think it would be difficult to do it before link time, if only
because of the fact that you can inherit from a superclass and then have the
superclass recompiled out from under you. (Which is, in part, why putting
something in the GAC requires that it be cryptographically signed yadda
yadda, so that sort of thing doesn't happen.) Basically, you'd need at
least the entire assembly available. (One assembly is the smallest unit of
compiled code you can distribute. It might be in multiple DLLs, but it
wouldn't make sense to distribute one DLL without the other.)
Also, if you compile the code before you run it and then never throw away
that code, you can't take advantage of precisely which chip it's running on
(like new SSE instructions or something) and you can't do optimizations like
cross-assembly code inlining. There's also odd stuff happening in the
background, whereby new optimizations get pulled down of the internet or
something weird? I don't know, I just turn all that stuff off, but
apparently there's some really deeply funky/screwy stuff going on in that
part of the code generation process.
(As an aside and completely irrelevant to the above points, I found it
really cool the XNA compiler will take per-pixel or per-vertex constant
calculations in shader code and hoist them back to the main CPU. I've never
seen a cross-CPU loop invariant hoist before. :-)
> AFAIK they added export templates to the standard because they confirmed
> that it can be done. They didn't predict, however, how hard it would be,
> nor that major compiler writers would just skip doing it because of that.
As I said, maybe I misunderstood it. The article was by the guys who wrote
the first compiler that supported it. Thinking on it, it's possible what
they were saying is they implemented draft proposals, found where that
broke, and then reported back to the committee, who then fixed those problems.
> Support for export templates would allow the templated code to have
> types, functions and data that are local to the compilation unit (and
> possibly shared among all the different template type instantiations)
> where the templated code is implemented. This might sound like a small
> thing, but it's actually a huge defect in templated code when the compiler
> doesn't support export templates.
Got it. So, making templates more like classes sorta? With "static"
variables and so on?
> (Ok, it's not completely impossible. You could make 'counter' global,
> in which case the non-export foo() instantiations could modify it. However,
> this obviously reduces modularity significantly, and grants unwanted
> access for outside code to the variable.)
Got it. Thanks for the explanation!
> AFAIK people working in the standardization committee are trying to come
> up with a different solution to this problem which would be much easier for
> compilers to implement.
That would be good. Unfortunately, I don't think it's easy to think up a
solution that has as much power as C++ templates (and be as easy) without
having the sources around at compile time.
LISP has macros that are super powerful, but there really isn't a whole lot
of static typing / overloading kind of stuff going on there.
Erlang, again, is dynamically typed. It has compiled macros that are
basically functions which take a AST as input and return another AST as a
result, and that's how you implement macros.
But both of these solutions require running code you just compiled before
you finish compiling, as part of the compilation process. Not something I
really see happening with a language targeting the kinds of projects C tends
to address (in terms of maximum efficiency and portability).
--
Darren New, San Diego CA, USA (PST)
"How did he die?" "He got shot in the hand."
"That was fatal?"
"He was holding a live grenade at the time."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |