« first day (547 days earlier)      last day (4392 days later) » 

10:00 PM
@Viper Not really, sorry.
 
c:3305267 each .c(pp) file is internally expanded to contain all included file before compiling
 
If you are using gcc then you can use the -E option to only output preprocessed code. It's quite enlightening to see what actually get fed to the compiler.
 
hell, you can edit your messages, nice! :)
 
But is all source code made to one long file which is compiled?
 
each .c(pp) file is separate compilation unit
 
10:03 PM
Yes. And macros are also expaned.
 
then it's up to linker to link output of those units togather
 
@Viper Indeed. And each .cpp file combined with it's header includes becomes an object file (file.o or file.obj). After all files have been compiled (i.e. converted into object files) then the linker will bundle them into an executable.
@Viper Can you predict what will happen if you put a function with implementation in a header file (as opposed to only its declaration), and have that header file included by multiple .cpp files?
 
and that's why c++ compilation takes time (in addition to complex syntax)
@StackedCrooked he probably can't :)
 
I think it's good to think about it.
@MladenJanković :)
 
You are redefining the function each time....but to be honest I dont think I underatand
 
10:08 PM
yes you are correct
compiler will accept it
 
@MladenJanković: I believe the major reason C++ compilation takes time becomes of the presence of templates and over use of meta-programming in stl.
 
but linker will go nuts
 
@Viper Indeed! And the linker then needs to collect the functions into one executable but it will encounter a function that has more than one implementation.
 
What does the linker do and what is object code then?
 
10:09 PM
@Abhijit yes, but even if you don't use templates, c++ will take more time to compile then c# for instance
object code is product of compiler
 
@MladenJanković: You mean, a simple C++ program without STL will have more compile time than C#?
 
@Abhijit not simple, you can still have complex C++ code, just without templates :)
object code contains compiled code (actual instruction) and some additional headers which allows linker to find functions and global variables from different compilation units (.cpp files) and to bind them togather
 
If the content of a header file is simply copy/pasted then the c(pp) file will have only the function declaration at the top when it is compiled right? Does something happen with this in the linker or what?
 
@MladenJanković: A big reason why C++ compilation takes quite a bit of time is because compilers will apply rather aggressive optimizations before producing the binary
 
How do I pad text with cout statements?
 
10:14 PM
linker doesn't know about header files (theoretically)
 
A C# compiler doesn't have to perform such optizations because of the JIT compiler
 
@Viper A C++ Header file should have a preprocessor directive to prevent multiple inclusion in a translation unit. To a linker, this will be considered as a declaration, but as long as there is one unique definition that it needs to map, its usually not a problem.
 
It's a matter of moving the optimization procedure from runtime to compile time
 
What happens in this bind together thing you talked about?
 
So that, for example, A "time object" with hours, minutes, and seconds all show in hh:mm:ss format?
 
10:15 PM
@Insilico i meant 'one of the reasons it takes time' ....
 
@Insilico danke
 
We are getting close to the part i don't understand....the reason why you have/ need function declarations at the top and how these are prossesed?
 
@Moshe: Also use en.cppreference.com/w/cpp/io/manip/setfill to set the fill from " " to "0", if necessary
 
@Viper Few Reasons would be
 
10:17 PM
@Viper: You don't necessarily need them at the top. They just need to be declared before you use them
 
1. To share across multiple translation Unit
 
compiler needs to know how it should make a call to the function
that's why you need declaration before you make a call
 
2. To make it publicly available. So not to expose the implementation details incase someone wan;t to link a library statically or dynamically
 
how many parameters, which types are they, what is calling convention
 
Yes, but is the function declarartion a reference....how is it resolved??
 
10:19 PM
@Viper: I don't understand your question
 
and it's name, so it can find the address of the function, or pass that job to linker if definition is not in the same c(pp) file
 
When a compiler sees void Foo(int x) it now knows there's a function called Foo that takes an int and returns nothing
The definition of Foo might be somewhere else
 
@Viper: Function declaration are required during compilation. You do not need a definition to compile a function which references the function. During linking time all references are mapped and resolved with an implementation which may be present in another translation unit or a seperate .lib file
@Viper: Why we need a header file, a good example is the standard library functions. The implementations are present in a dll or so but when compiling your program you only need to include any of the standard header files which do not have the implementations of the standard library functions.
 
The whole declaration model is stupid and outdated.
Like anything regarding C++ compilation model.
 
10:27 PM
I am probably stupid but I don't understand
 
Also, new people who don't link to silly questions and run away! Hi.
 
@CatPlusPlus yes it is, but i'm not sure how it could be impoved
 
@MladenJanković I've seen a few links from that site and they were all totally moronic.
 
@MladenJanković Multipass compiler for one. Modules for two.
There's a proposal for that, so maybe.
There's shred of hope things will start to actually improve.
 
@DeadMG well to be honest, the guy who wrote it, was/is working on digitalmars compiler
 
10:29 PM
Declarations will probably stay, though.
 
i guess he knows a few things
 
@MladenJanković Funny, cause I thought D's design was lacking.
 
DigitalMars has C++ compiler, too.
 
true
 
Nobody uses it, but still.
 
10:30 PM
also true
 
but that doesn't necessarily mean that it's of quality
 
Eh, it's C++ compiler.
 
also true
 
I think Walter Bright "invented" RVO.
 
could be true :)
@CatPlusPlus are you referring to N2073? wow it's from 2006, little chance we're going to see it as a part of standard c++
 
10:35 PM
According to Wikipedia he invented NRVO in 1991.
That's 21 years ago :D
Dammit, C++ is old!
 
@MladenJanković There are several revisions. N3347 is the latest one.
So, no, it's not dead yet.
 
@StackedCrooked thanks for ruining my night :)
 
@MladenJanković My pleasure :)
 
Why would this compile and this not?
        //void print(){cout << setw(2) << setfill('0') << month << "/" << setw(2) <<  dom << "/" << setw{4} <<  year; }

        void print(){cout << setfill('0') << setw(2) << month << "/" << setw(2) <<  dom << "/" << setw(4) << year;}
 
The first is commented out.
 
10:38 PM
Well, no, I commented it out.
 
lol
 
Aside from that.
 
We don't know. What's the error?
 
@CatPlusPlus so well have to wait another 5-7 years to see
 
setw{4}?
 
10:38 PM
Also gawd, formatting and namespaces.
 
@StackedCrooked Oh.
That.
@CatPlusPlus That's an inline function in a class, don't ask.
 
Also, an example of why streams suck for formatting.
 
I believe that we, the members of the Lounge<c++>, have already established the fallacy of academic programming.
Now, moving right along...
 
I still don't really get streams.
 
@StackedCrooked Thanks.
 
10:39 PM
One does not simply get streams.
 
streams: they suck
 
Streams does not simply suck. ? (Although my grammar does there.)
 
Grammar fail.
 
Lol.
 
streams suck pretty hard
 
10:40 PM
Streams don't suck simply, they suck complicatedly.
 
@StackedCrooked Ah, so what you're saying is that:
 
please don't spam in here
 
One does complicatedly walk into the C++ room.
@DeadMG OK, whoops.
 
@Moshe That's one way to approach it, yes.
 
Eh, it's not spam.
 
10:42 PM
Not trying to make trouble. This HW has me in a troll-like mood. Which is unlike me.
 
tasty
 
@StackedCrooked i dont even need to click
 
Fail.
 
10:43 PM
There, we um, go.
Complicatedly. Yea, that's it.
 
so little productive time, so much stuff to work on
 
It's failnight in Failville.
 
lol
 
Mwahaha cough 'scuse me.
 
I have a project to do in Java.
 
10:44 PM
temporal coherence: must exploit it
EXPLOIT IT LIKE A BITCH
 
@CatPlusPlus sorry about that
:)
 
I have a Japanese test tomorrow. Took a day off :D
 
why do c++ programmers hate java?
 
because in C++, you can do what you want
 
I don't hate Java.
 
10:45 PM
in Java, every time you want to do something even remotely interesting, or useful, the language says "AMAGAD CAN'T DO THAT"
 
I merely despise it.
 
i don't hate it, i just find it disgusting :)
 
except reflection, which is both interesting and useful and awesome
 
@DeadMG yes but that has its costs
 
@bughi Costs which are my choice to pay.
 
10:45 PM
I know enough languages to know a primitive language that only hinders productivity.
 
if I want to pay them, I do; if not, then I just don't use that feature.
in Java you don't get a choice
 
Java reflection is offset into negative infinity by checked exceptions.
 
the job of the language is to shut up and do as I say, not hinder me
 
I've toyed a little with reflection. It's nice, but it doesn't really compensate all the suckage.
 
oh, I admit that the suckage outweighs reflection by miiiles
but reflection is still cool in as of itself
 
10:47 PM
and truth to be told, RAII model of managing resurces is much better then crap called GC
 
If you dive into reflection then you lose all type-safety for one.
 
truth is i don't really appreciate the limitations, but i just love eclipse
 
GC is not bad.
 
makes everything really easy
 
GC is not bad- if paired with RAII
that's my opinion
GC alone is awful
 
10:48 PM
that's my point
 
GC is like functional programming
it has a time, and it has a place, and it's great at that
 
Awesome.
 
but it fails pretty hard as soon as you overstep the boundaries
that's just my opinion, anyway
 
@DeadMG How does one pair GC with RAII?
 
10:48 PM
std::unique_ptr.
std::shared_ptr.
 
is it possible to have RAII in java?
 
Assuming RAII == Scope bound resource management?
 
RAII does not have to be about memory
consider something like std::unique_ptr<FileStream, CloseFile> kind of thing
 
there's using scope in c#, but i'm not sure about java...
 
unique_ptr doesn't have to know or care where the memory came from, or who's gonna clean it up- it can still close the file for you
@MladenJanković using is broken for 999999 reasons
 
10:49 PM
try (Resource r = new Resource()) { /* closed automatically */ } catch (...) {}
That's Java 7.
 
GC is non-deterministic. You don't now when it will trigger. So you can't build on it as a foundation like C++' scoping rules.
 
You introduce scopes for resources, instead of objects.
 
non-deterministic GC is fine and dandy; if you don't need particularly deterministic performance
 
That's like reimplementing C++..
 
Not really.
Reimplementing C++ would be reimplementing C++.
 
10:52 PM
cool, but it still doesn't make me love java :)
 
Resource scopes go back to Lisp.
 
Non-deterministic GCC seems useful to me when you need to cleanup many objects without incurring an immediate cost on scope-exit.
 
(with-resource closure)
 
Ok, but that's not GC.
 
quotation with-destructors in Factor.
 
10:52 PM
GC is mostly useful because it just takes care of it for you and you don't have to deal with it
 
GC deals with memory.
 
GC also closes files.
 
apart from that, it can have some algorithmic upsides
but that's pretty much it
 
Finalizers in GC are last-resort cleanup.
 
it's not very flexible at all
@StackedCrooked You can't reasonably close files with a GC.
 
10:53 PM
It's not a behaviour you want to rely on.
 
I could never clean up GPU buffers with a finalizer or anything like that
 
That's why you need resource scopes.
 
they have to be done deterministically
 
@DeadMG No, which is why I prefer RAII here.
 
yes
 
10:54 PM
Or, resource scopes. That's fine by me as well. But that's not GC.
 
Python has with blocks and context managers with __enter__ and __exit__.
 
RAII or death! :)
 
RAII > resource scopes like using
 
Resource scopes are used precisely because GC is used.
 
even a well-implemented using, which C#'s is definitely not
 
10:55 PM
Objective-C has the NSAutoreleasePool which is also a sort of scoped resource.
 
Third category is C, which doesn't have anything useful for this.
 
C just doesn't have anything useful, full stop, realistically
building a complex program in C is like trying to create a microchip with your fists
 
you guys really hate c, eh? :)
 
I once tried to create a program in C and gave up after a few minutes.
It's unbearable.
 
C, Java and PHP.
 
10:56 PM
C, Java, PHP are the most popular
because they're the worst
 
@StackedCrooked i guess it's about way of thinking :)
 
although C#
is a bit of a design-by-moron
 
If you want C, you can use Go now.
At least eliminates stupid compilation model and most of the boilerplate.
 
How bout C++.
 
C++ has a lot of potential
but the weight of C compatibility is definitely holding it on the ground
 
10:58 PM
@CatPlusPlus unless you want to do some interesting stuff in kernel, or go embedded :)
 
if you could do C++ right, you'd end up with a massive pile of awesome
 
@MladenJanković I'm probably the only one here who does any real code in C. I'm surprised I haven't been lynched yet. :P
 
I wouldn't want C for a kernel.
 
@DeadMG C++ seems more like it's streched already beyond it's capabilities. Sort of..
 
a pity that most of the C++ successor pretenders can't learn the most basic lessons from it
 
10:58 PM
Ok, constructor question.
If I have a custom class which contains other custom classes, how do I use a member initialization list?
As in:
 
C++ after C pruning would be really nice.
 
C++ is like a 75 year old diva who just got a make-over.
 
@StackedCrooked I meant as more of a general principle. Things like no universal base, value types which are first-class citizens, proper deterministic destruction support
it's hard to find a "C++ successor" which doesn't have even worse failings of it's own
 

« first day (547 days earlier)      last day (4392 days later) »