« first day (119 days earlier)      last day (4812 days later) » 

8:02 AM
indigestion?
Sorry, I had to say it. Nothing really useful to add there.
 
8:32 AM
hi, anybody in here?
 
nom nom nomouseactivate
2
 
sbi
9:23 AM
@geekGod <standard_joke> Nope. </standard_joke>
 
 
3 hours later…
12:25 PM
hi
 
I have a quick question
for a .net developer are there any libraries that are similar to .nets standard libraries?
for C++ I mean
 
12:44 PM
What's the difference between a C array & pointer?
 
@Raynos: Get a good C reference like K&R, it explains both concepts very well.
 
Yeah I realized it a was a really stupid comment. There different but are they conceptually the same? The syntax is a bit different for the two.
 
No! They're conceptually completely different. My apologies if I sound irritated. It comes up so often and it's fundamental.
 
@CharlesBailey it's ok I realised that it was a stupid comment.
 
Indeed, and both have different purposes.
 
12:49 PM
Oh. i see, pointers need to be malloced and unassigned where as arrays can be treated as local variables
That's a pretty big difference.
 
@Raynos That's not really it. Pointers can hold a value that is a null value or they can point to another object. That object doesn't have to be dynamically allocated, it can be a static or local object but pointers don't 'contain' the object; they just point to it.
 
How is an array different? I always thought of it as a pointer to array[0] and you increment the pointer i times to get array[i]
 
Arrays are aggregate objects that are a contiguous sequence of a fixed number of objects. The array consists of all of those objects; there's no external object being pointed to.
@Raynos You have to understand the concepts before you understand what operations operators perform when acting on objects of different types.
 
My lectures lied to us for simplicity when they said arrays and pointers were the same. They keep doing that I guess the advanced C module will begin with "Remember everything we taught you last time? It's all lies"
 
@Raynos I don't get it. Arrays and pointers are so fundamentally different that pretending that they are the same or similar is completely misleading. If this is a common teaching method then it's no wonder this confusion comes up so often on SO.
 
12:58 PM
An array is a contiguous block of memory and every index points to an object in that memory in the expected order. I can understand that pointers aren't arrays but arrays virtually seem like pointers to me
 
@Raynos So what do you undestand by pointer, then?
 
A reference to a block of memory the same size as the type of the pointer
And an array could be treated as a reference to a block of memory the size of the type of the array * the size of the array.
 
A pointer is an object in its own right and it can hold a value that points at another object. E.g. int *a; a can point at an object of type int or it could be null to indicate that it isn't pointing at anything.
You can't do that with an array. An array just holds other values. An array is much more like a value than a pointer. In the degenerate case, int a[1]; is much more like int a; in storage behaviour than it is like int *a;.
 
A pointer holds a value which indicates what block of memory its pointing to. It's either pointing to an int or to null. By reference I meant it holds an integer(?) which represents a location in memory
 
@Raynos I'd substitute "address" for "integer(?)".
 
1:06 PM
That makes more sense
 
Whereas an array doesn't hold addresses or point elsewhere it just is a block of objects.
 
Yeah I see what you mean now.
@CharlesBailey thanks for being patient. I can understand these things being frustrating
 
@Raynos That's OK. C has a lot of features that make it confusing if you don't understand the core concepts first.
For example, in most expression contexts, the name of an array 'decays' to a pointer to its first element. So often myarray behaves like &myarray[0].
 
That's what I was thinking. Wrote a bit of code on codepad and the first thing it says was "Segmentation fault" I think I will do some C when I need to.
 
Similarly, you can't pass arrays by value in C. Functions which are declared as though they take arrays actually take pointers. E.g. int f(int a[]); actually means int f(int *a); .
 
1:16 PM
That's quite confusing.
 
@Raynos It certainly is if you're not absolutely comfortable with the difference between arrays and pointers in the first place.
Once you are... it's a feature.
 
that's why we use C++ and std::array<type, size>
none of this pointer shenanigans
 
@DeadMG but C++ is even more evil then C
 
bwahahahaha
you have actually used C++, right?
 
nope. just a bit of C. But I know C++ is evil!
Besides I like writing good code. I'd take me months to get comfortable with C++. I have yet to spend the time doing that
 
1:22 PM
there is that
but on the other hand, once you know C++, then you'll realize how incredibly abominable C is in comparison
 
@DeadMG I would think oh man! If only I could write in C. It would be so much nicer.
Besides can't we all just give up and do D ?
 
I'm not really convinced of the benefits of D over C++
it seems like I could just get them moving to C#
nah, you would think, "Man, my old C code was so incredibly unsafe and it took me so long to accomplish basic tasks, I'm amazed I ever wrote any programs in it that actually worked that I completed in a reasonable timeframe."
 
@DeadMG but they were more pure!
 
pure is a useless idea
3
 
Besides I do my code in dynamic interpreted language. None of this type safety!
 
1:28 PM
I'm enjoying this, go on. :D
 
@DeadMG I do code because it's fun. If I need to make money from it then yes whatever gives the greatest gain
It's more satisfying to write pure C code. Besides C++ looks a bit ugly. I do get absolutely nothing done in a reasonable timeframe
 
this just amazes me
don't you care about the quality of your code?
 
@DeadMG yes. I can write higher quality C then C++ (Fractionally. It's pretty obvouis I can do neither)
 
that's an oxymoron
code written in C is of a fundamentally lower quality than code written in C++
 
@DeadMG are you degrading to my level?
 
1:33 PM
no, it's a fact
C code has numerous holes that simply don't exist in C++ code
 
That's why we need competant C coder's
C++ has many holes C doesnt have though
 
no, it's why you need to upgrade to C++
C's holes don't disappear just because you're competent
 
Are you being serious or just playing devils advocate.
 
of course I'm serious
 
I'll get round to learning C++ one day.
 
1:37 PM
if you don't know C++, how can you suggest that it has many holes C doesn't?
 
@Rayno Start with Effective C++, by Scott Meyers.
 
you would have to actually know a language to debate it's merits
5
 
@DeadMG Can't I just make wild assumptions and rely on hearsay?
 
no
 
Spoilsport.
I agree though, In most cases you want to use C++ instead of C.
 
1:38 PM
@Raynos You could. Politicians do it all the time. But it won't work on us.
 
no
in all cases
if C++ is available, there is no code that will be better in C
 
Faster, maybe :)
 
@DeadMG C is good for embedded devices.
There are places where C++ is too much overhead and you want to use a mixture of C and hand-written assembly.
 
C++ does not invoke any overhead
that's a complete myth
C++ compiles to native code just like C does, and the same code compiled as C++ will not be any slower than the same code compiled as C
2
and then there are many operations which are known to be substantially faster in C++ than C, such as sorting
because C++ provides a much more advanced compilation environment
 
Are you sure that C++ doesn't use more resources then C ?
 
1:42 PM
of course I am
C++ was explicitly designed that way
it was explicitly designed so that if you don't use exceptions, then you won't pay any cost for them, and the same goes for every other C++ feature
 
Ok fair enough, that's a myth then.
Still I think it's easier to write bad C++ then bad C.
 
I completely disagree
"good" C++ is provided by the C++ Standard library in many cases
if you use std::vector to manage your heap memory, you will never leak, or double free, or anything like that
if you use malloc, then there's no guarantees and your program could have a dozen subtle bugs and you wouldn't even know it
 
I just having a feeling there are so many more ways to shoot myself in the foot with C++
 
you don't even know the language.
how could you possibly even think that there are more ways?
 
Because I've touched a bit of C++ and like playing devil's advocate.
 
1:50 PM
it's easy to write secure reliable code in C++
miles easier than it is in C
 
I guess so.
If you don't have experience in either C++ is safer.
 
no, no
see, that's the big difference
experience in C will not protect you from anything
it will just make it less likely
experience in C++, on the other hand, will completely protect you
 
Are you saying a C++ programmer can write C as good as he can write C++ ?
 
no
what I'm saying is that if you're a C++ programmer, and you know the language well, then you can use the language to enforce certain rules about your program
such as, cleaning up of heap memory
 
That makes sense.
 
1:53 PM
if you're a C programmer, and you know the language well, then that won't stop you from having a bad day and forgetting to free() at the right time
in C++, having the compiler guarantee destruction protects you from huge quantities of human error
 
That's pretty useful actaully.
 
it's extremely useful
 
So there's absolutely no reason to use C? (Apart from legacy maintenance)
 
well
there are some parts of C99 that are not in C++03
like variable length stack arrays and variable macros
but those are pretty niche, and variadic macros are in C++0x
and there are common extensions for dynamic stack allocation, like _alloca()
 
Which version of the spec should I learn when I start?
 
1:56 PM
depends on what you're starting from
if you're a student or hobbyist, then I'd grab the latest compiler for your favourite platform and learn that
I'm a student and I have MSVC10, so I work to a C++0x draft Standard
and you can get the GCC 4.6 beta which has a lot of C++0x support in it
 
VC ?
 
Visual C++
it's the primary Windows compiler
but if you need code that's very portable beween compilers, or your workplace will dictate a compiler, then you'll need to look at C++03
I mean, if you're getting started, then the difference between 0x and 03 isn't that big a deal
 
Ah MSVC10 is a compiler.
 
yes
Microsoft Visual C++ 10
 
Is it also an ide or just bundled into the microsfot ide.
 
1:59 PM
it's part of Visual Studio, which also has IDEs for C# and a few other languages
well, strictly speaking, it's the same IDE with a few different modes
 
I always though visual C++ was an ide rather then a compiler
Why did they use the word visual :\
 
it's both
well
an IDE always has to include a compiler, else how can it be integrated?
 
Dont quite see why there's a visual C++ and not a visual C# just seems like a weird thing microsoft did
 
I've no idea why they call it Visual, probably because most of the other compilers at the time when it was first started were text-based
there is a visual C#
and a visual basic, too
but mostly, those names are reserved for the specific compiler, and Visual Studio is the overall package
 
Ah I see. It's microsoft ways of saying we're going to take the specification and modify it :)
 
2:03 PM
Visual C++ is not notably less conformant than GCC
 
I'd hope not.
 
I mean
it does have a bit of a reputation for nonconformance
and that was entirely deserved, about eight years ago
since then they've done a lot of conformance work
 
That's good.
 
well
as a student who mostly depends on Windows-specific features like DirectX anyway, it doesn't affect me in the slightest
 
@CharlesBailey I take back the comment that I wasn't taught C properly at university. I didn't learn C properly at university. My lecturer was incredibly competant and wouldn't have taught me something wrong.
@DeadMG C++ doesn't have garbage collection right? I mean it's at least completely optional?
 
2:16 PM
doesn't have any
or rather, you can get GC extensions for C++, but it's not Standard
 
2:34 PM
anybody heard of 'transitive causality'?
some processors did have this, esp the first round of P4 SMP's, however I'm not sure what it actually is and Google is not much help
 
Hi there
can i ask a doubt about sockets?
 
if it relates to C++ yes
 
Ok,but my doubt is in java,i think both are almost same in this case
My confusion is about Sockets and ServerSockets
think of the google talk or yahoo messenger,what will be the Hostname and port number used in client side and server side?
I mainly want to know about host name used
 
What I love about it in here
is the sheer quantity of utter bollocks I see spouted
 
2:50 PM
@ChrisBecke and you are referring too?
 
Well, most recently, claims that programming in C++ somehow magically results in "better" code than C
 
@Jinjavajin normally the port on the server is an assigned number and the client will use any port above 1024 as below are ports assigned for specific services
the host name is the the name give to the machine
@ChrisBecke I think that some it is based on personal opinion rather than fact
and opinion can differ from person to person
so I think, unless proven by research, you'll have to view some statements as opinion
 
3:03 PM
@Tony and tho hostname will be something other than google.com?
 
yes, cause google.com is a domain name
the domain name is translated to an IP address via a protocol called DNS
 
@Raynos You cannot learn C++ in a couple of months, it takes several years to master.
 
the hostname and IP address are mapped using the netbios naming service on a LAN, but on a WAN I don't think that hostnames are of any significance, as machine are identified by IP address
 
@Raynos C is the opposite of a "pure" language. It's completely non-orthogonal and full of special rules.
 
SMB is the newer version of netbios
 
3:07 PM
@ChrisBecke While it certainly doesn't do so magically, if you learn C++ from something like Accelerated C++, in a typical case your code will run at least as fast as, and often faster than, any reasonable equivalent in C. Not that I think I'm telling you anything you didn't already know...
 
@karlphillip "Effective C++" presupposes that the reader already knows C++, I wouldn't recommend it as a first C++ book at all. Maybe second or third.
@ChrisBecke Well, can you show me the C equivalent of pushing an unknown number of elements into a std::vector? Pointers and realloc all over the place, right?Reinventing the wheel for the n-th time, right? What you actually want to do is buried by low-level details that have absolutely nothing to do with the problem at hand.
That's why C++ is superior to C. You get high-level abstraction for absolutely no performance penalty at all. If there was a way to "fake" a C++ feature in C and get away with better performance, I'm sure every compiler writer would kiss your feet if you told them how to pull it off, because then they would simply rewrite their compiler to take advantage of that trick.
 
@Tony then,what will be the hostname used if i connect to you?
 
my routers IP address
that is the host identifier
well, technically an IP address is a network identifier and host identifier, depending on the subnet mask used
 
then what hostname i have to use?
how can i find it while writing the program
 
3:23 PM
you have to to enter it when the program is running, I don't see any other way. Besides maybe (if you're within the same LAN) doing a broadcast looking for IP address or hostname X.
 
@FredOverflow I have to disagree with "absolutely no performance penalty at all". It's true that a penalty is pretty rare -- and even more rarely significant. Nonetheless, some minuscule penalty is still possible.
 
@user492182 Hi. How are you today?
 
3:47 PM
@FredOverflow there are deficiencies in C++03 which C doesn't have, such as move semantics
in C, because it's completely manual, you have complete control and can do what you need to
in C++ (03), your compiler may or may not elide copies, and often will copy where you'd want to move
IO formatting is a very common example: stringstream::str sucks
that and identical situations in other libraries are why implementations went to COW strings (which are supposed to be disallowed in 0x)
@FredOverflow in C you'd write your own vector_realloc function, and it wouldn't be that long or hard for the exact example you give, but I agree with you in spirit
 
Ell
4:18 PM
hi guys:)
 
4:31 PM
hi
 
4:57 PM
@FredOverflow theres a diferencce between learn and master. Your always learning. I can learn enough about C++ to use it every day in a couple of months but itll indeed take years to master
 
nobody ever masters any language
 
5:17 PM
has anybody seen this: microsoft.com/downloads/en/…
it looks interesting
 
is it possible to react to application closing in debug mode (VS "stop debugging" command) to perform some cleanup? my application has no visible window which would get the appropriate quit, destroy etc. messages.
native win32
 
5:36 PM
Apparently there is no way and it's the same if you kill a process using the task manager.
 
6:23 PM
@72con Both of these methods are hard aborts that are designed to kill misbehaving processes so that shouldn't be too much of a surprise.
 
No, I'm not that surprised.
 
@Tony powerpoint presentation about C++ UB, from Microsoft. well. one thing is for sure, and that is that most Microsoft programmers don't even understand the concept.
 
@AlfPSteinbach for sure, however WHO is giving the presentation?
 
consider, re level of competence at MS, with C++0x Visual C++ will have to state whether it's a hosted or freestanding implementation, so it will either fail to be standard-conforming with respect to main, or with respect to that requirement, or will be forced to say that it's a free-standing implementation. he he. :-)
 
just trying to say that just because it's MS, that it will always be bad, is a bit of a generalization.
 
6:32 PM
As someone moving from C to C++, what should I know about differences in memory management?
 
@IDWMaster use smart pointers
and RAII
 
@Tony possibly. but i can't think of any counter-example. all things that apparently are good and from MS, are things they have got from elsewhere and dumbed down. it started with DOS (got from elsewhere). then e.g. Stacker disk compression. so on and so forth, everything I know of.
 
How do smart pointers work, and when are objects associated with smart pointers freed?
 
@AlfPSteinbach that may be so, then it just means that they aren't very inventive and cannot make up their own good product, doesn't mean that the product itself is bad, even if it was taken from elsewere
 
@Tony argh, you will get me ranting in no time. :-)
 
6:34 PM
@IDWMaster I think you should read up on that
@AlfPSteinbach ok, I don't want to have an argument with you, I'm not a huge fan of MS either, just saying that sometimes the criticism they get is a tad unfair. They have been trying... somewhat
 
@Tony think of me using Windows XP, where I have a volume control with global bass and treble. that functionality was removed in Vista. dumbed down, bass and treble to "advanced" for ordinary users. but even in XP they didn't manage to make volume control work properly. takes looooooong time to appear, when should have been instant
 
And now they disabled C++/CLI integration in VS 2010 (just read up on that). It was a bug in their product which was 'by design'.
 
@AlfPSteinbach yea the volume control is a bit of a painful thing
and the 'by design' story isn't any better in most cases
but also they have quite a wide user base and not all users are as advanced as us, so they have to cater for them too
I can only think of most of my family :p
 
or think of clipboard viewer. it worked splendidly up till windows 2000, when some idiot manager introduced shared clipboard (security hole and inefficiency with extra process). then in XP it still says "clipbook" viewer, and menu choices just grayed out where they removed that shit, but background process still there. then in Vista removed whole thing, I think
 
I also work on a lot of C# programs, and noticed some odd memory leaks in the managed GDI+ library. I reported it, and it was closed as 'by design' once again. Are all of their bugs 'by design'. Did they make Internet Explorer non-standards compliant 'by-design'?
 
6:38 PM
or think of the analog clock. first the removed the single-instance functionality. then they removed clock completely. in vista a clock is back, as desktop widget, but that's not where you want that clock. it's idiotic.
 
@AlfPSteinbach I don't particularly miss clipboard tbh
 
I never even knew that 'clipboard viewer' even existed.
 
in Win7 the clock is just where it used to be, bottom right startbar
 
or think of the "shutdown" choice in Start menu. they used like 4 man years to design that menu choice for Windows XP.
@Tony no, i'm talking about the analog clock display, it's a desktop widget in Vista
 
@AlfPSteinbach now in win7 you have to click on the digital one and you get to see the analog one
unless you have the widget off course, but I don't like them
 
6:41 PM
void SetRenderFunction(void (&newRenderFunction(void))); can any one see a reference to void their? or any other reason why this is invalid?
 
And now I have to wait 6 months before MS can re-verify me with GeoTrust for their Windows Phone development kit (and WP7 doesn't even support C or C++! What's with that?). They certainly don't like to make their developers happy.
 
other then the obvious use of void that is :P
 
or for c++ programming consider configuration of projects, at different levels, in visual studio
their documentation is wrong
the relevant menu choices hidden by default
the whole thing tucked away in hidden XML file
 
@AlfPSteinbach Not wrong, just obsoleted (the choices in their documentation don't exist in the 2010 version anymore).
 
a gazillion + 1 choices that don't do anything, a big whole bewildering of dialogs that don't do anything
 
6:44 PM
Could someone please explain why strcpy is obsolete?
 
just to make it completely laughable, they still use the icon bitmaps from Developer Studio (Visual C++ 6.0)
 
Is it still safe to use it?
 
16 color icons with dithering
and it's the same detail-level dialogs as from DevStudio, so they just cobbled together Very Old Code, haphazardly
 
@IDWMaster purley a guess this, but I would assume that it is still techically ok to use, but their is probably a better function to use
 
it's like a schizoprenic designed it
 
6:45 PM
strcpy_s is supposedly 'better', but doesn't seem to work in my edge-case.
 
it probably does something like make more copies of the data then is really needed
 
Why can't MS just FIX their old functions?
 
@IDWMaster strcpy has not changed. messages that it has been deprecated are incorrect, Microsoft dis-information. they probably believe it themselves.
 
what edge case breaks strcpy_s?
 
If the source const char* comes from an std::string, it doesn't work
 
6:47 PM
@IDWMaster It works.
 
Says that it's not null-terminated
 
forgotten my const rules, const char* is a pointer to a char that is constant right?
 
@IDWMaster To get a null-terminated string from std::string, use the c_str metod
 
7:08 PM
That's what I used
Just got back from a meeting
Is it really worth it to change all of my strcpy's to strcpy_s's?
I have about 12,000 strcpy's in my code.
@AlfPSteinbach That is what I have been trying, and it still doesn't seem to work. I'm compiling for x64 platform.
 
7:38 PM
@IDWMaster can you show the relevant code?
 
strcpy is very deprecated if you believe in safe code
std::string ftw
 
@DeadMG The term "deprecated" is defined by ISO with specific meaning. strcpy has not been deprecated. There are not degrees of deprecation, just as there are not degrees of being pregnant: either you are pregnant, or you're not.
@DeadMG :-) it's the only one we have, so we have to luv it. Dear std::string, you were born with Down's syndrome, but you're our only child. We luv you.
 
7:58 PM
@Fred - you have to be kidding. o performance penalty at all?
Look. I love a lot of what can be done with c++
but I can't pretend that, just using templated code doesn't impose some kind of overhead.
simply, a C solution, vs a c++ solution using generic code
will compile to something far, far larger.
well
using the latest VS and GCC compilers.
and bigger executables mean less stuff fits in the cpu cache
then theres all the implicit shit invoked whenever you invoke a copy constructor or something. which makes the instruction pointer bounce all around.
anytime you do anything trivial with a vector, or any stl object at all
well, just fire up the debugger
and see the amound of crap you have to trace through.
crap that does not magically get optimized out in release builds.
I use those c++ abstractions myself
because theyre fucking useful
but in not naive enough to thing for a second that the code Ive produced is as fast as the equivalent ideomatic C implementation.
 
8:40 PM
wow, Chris, you really are ignorant
 
8:51 PM
@DeadMG i think he's on to something. but it's well known, and even has a name: abstraction cost. whether to take on that cost (to gain other benefits) is an engineering decision, a decision to be made for each particular case at hand, with no general guideline or rule possible.
@DeadMG E.g., Blaze docs, "The guiding implementation principle was to reduce the abstraction cost per output byte."
 
9:03 PM
in theory, using templates should not induce any overhead to the run time code. templates only induce compile time overhead, which is ok by my book, it saves me having the write the same function over and over just because I want to use a different type.
virtual though, that does induce overhead at run time
Like chris and alf said, (I think :P ) these abstractions make it an easier language to use, but have their cost some where
 
9:17 PM
@thecoshman isn't the code compiled from templates less optimized than that from other solutions? most C++ compilers aren't that smart
 
if you have a template function that say, added together to values. say add(<type>a , <type> b); it /should/ be as writting a specific function for adding floats
 
@thecoshman I doubt that scales up to more complex cases
 
if you called the template add function, with your own class, then assuming your class has an overloaded add operator, it should still work.
 
@thecoshman are c++ compilers really smart enough to do that?
 
and add function is a kind of lame example... think more or a 'node' class
 
9:25 PM
i mean some can't even implement the language spec right
 
in a linked list, you want nodes. what ever data your node holds, you still want it to work the same, weather its ints, chars or your own complex class.
You could have a node that has a void* to the data. But this means a node can point to another node that contains a different type of data
it also means your node and its data are not in the same space in memory
but by templating, you can make a new instance of your node that is of type int, char or my class
Also, whilst compilers do differ, it is partly from them trying to optimise code, something that spec doesn't actually cover (as far as I know) and partly from parts of the spec that do not define how certain things should be done, thus leaving it up to compilers.
 
9:51 PM
0
Q: reference to void... it calims

thecoshmanI have a sneaky feeling this may be an issue due to compilers. void SetRenderFunction(void (&newRenderFunction(void))); This is causing GCC to proclaim that I "cannot declare reference to ‘void’" Now, I have used the same function prototype (more or less) under visual studio on windows. On...

any one know function pointers?
 
10:30 PM
@DeadMG sure you can. as long as the language never changes
 
11:14 PM
Ah, finally, full functionality.
"You have earned the highest level of privilege in our community -- short of being elected a community moderator. You can ...

* cast delete and undelete votes on questions
* view deleted posts
* see spam and offensive flags on posts
* have access to moderator tools

... and assist our elected community moderators, as you have time, in maintaining our community."
But I don't understand the utility of being presented with lots of spam?
 
sbi
@AlfPSteinbach Cong-rats to you for breaking the 10k barrier!
@AlfPSteinbach Spam? What Spam??
 
@sbi "You can ... see spam "
 
sbi
@AlfPSteinbach Ah. Are you being deliberately obtuse or do you really misunderstand that?
 
@sbi yes
 
sbi
@AlfPSteinbach I thought so.
 
11:20 PM
"roll over, take it from behind" ... flaggers! :-)
 
sbi
Anyway, to throw in my POV re the debate on whether C++ is inherently safer than C:
The way C++ is taught too often ("C with Classes"), it might indeed be less safe than C, as it combines C's inferiority in resource management with C++ magical calling copy constructors, throwing exceptions, and whatnot. However, if you teach C++ right (Accelerated C++), then it is vastly superior to and much safer than C.
2
 
11:34 PM
@sbi I fully agree with you here. So many of my friends on my course think of C++ as just an extension of C rather then a separate language. C will be better then C++ if you write your C++ code as if it where just C with some extra stuff. To fully reap the benefits of C++ you need to be thinking of it as if their was no such thing as C
 
When referring to individual lines of source code, do I say in the n-th line or on the n-th line?
 
sbi
To throw in another useless suggestion: at?
 
@FredOverflow I would say "on line n".
 
@ChrisBecke Abstractions can also make code faster in many cases :-) For example, std::string::length() is O(1) whereas strlen(const char*) is O(n), and std::sort beats the crap out of qsort any day because the C++ compiler can inline the comparison functor.
@thecoshman C doesn't have virtual. It is meaningless to say that a virtual C++ function is slower than a classic C function, because they have different semantics.
If you emulate "virtualness" in C, you won't get any faster than the "real virtual deal" in C++.
 
@FredOverflow That would be an ecumenical matter
@FredOverflow I know that C doesn't have virtual. My point was that people seem to look at C++ as some sort of wrapper for C, and this extra functionality must make it more complex then C code.
 
11:50 PM
@thecoshman It didn't sound like that from your post. The fact is that virtual does not induce any unnecessary overhead that could be reduced by going plain C and emulate virtual.
 
Well then, this appears we have come a non-debate
 
@FredOverflow There are tests of that can be done, and it's generally not true -- for better or worse, C++ took a route that saved memory at the expense of a little speed. Most people who simulate virtual functions in C put pointers to functions directly in their struct instead of a pointer to a vtable that holds the pointers to the functions. Although the difference is small, it does (generally) favor C.
At the same time, I should add that the extra level of indirection doesn't necessarily cause a slow-down. In particular, since you're reusing the same pointers to functions, you typically get better cache usage and better branch prediction. Especially if you have lots of instances of a few types of objects, the vtable route can improve performance.
 

« first day (119 days earlier)      last day (4812 days later) »