« first day (91 days earlier)      last day (4843 days later) » 

12:03 AM
@MooJuice it doesn't answer the question and it's not a good example of doing what it tries to show
 
Okay, fair play. I wanted to show how he might write something to sort it himself.
 
you're sorting the set, he asked how to change the listview's sorting
maybe that's the wrong way to go about it, but that's not what he asked and if you think that, you need to strongly back it up (instead of not even mentioning it)
 
@FredNurk the listview is correctly sorted, as pointed by one commenter. If it isn't what OP expects, then he should explain the sorting criteria in order to get a better answer, IMO.
 
@jweyrich: it's incorrectly sorted according to the question, which wants the same order as std::set uses (which is std::less)
it's hard to ignore "is there any way to write a sort function for listview or should i insert them manually at locations in listview?"
neither current answer even mentions that, much less address it
as I said, if you think he's going the wrong way about it, then back that up – but beware you have no idea (yet) of the context of what he's doing – the guy leaving a comment started that process
 
@FredNurk I really doubt the default std::set sorting is what OP should be using, but I agree that @MooJuice's answer is vague and doesn't mention the reasoning for changing the set ordering instead of the listview.
 
12:10 AM
in particular, see the comment ending with "My main point is that the ordering you are seeing from the list view is the ordering that a human would expect to see in their dictionary. The ordering of set is some sort of computer ordering that would seem alien to a human. **Since I've no idea what your are doing, or what your target audience is, I don't know what you should do.**"
@MooJuice: and FWIW, I wasn't the downvoter, because I don't downvote :)
 
@FredNurk, it's cool. I don't mind it. If I can help someone by an answer, great. If I can learn from my OWN answer and why it is incorrect/vague, I can only learn MYSELF which is of far more use to me.
I'm not one of these programmers who refuses to learn or believe I am always right
2
How else can I mature as an engineer?
 
@MooJuice I am.
 
@FredNurk, good. Then when, one day, you say to me in a comment "Shit, you're right". I can go to bed knowing I've changed the world :P
 
I always think myself as not being sufficiently humble. While I have some strong opinions, I'm very flexible regarding to good counter-arguments. And I tend to assume people are "better than me" to avoid any kind of frustration.
 
be kind in interpretation of and ascribing motivation to others, admit what you don't know, but still hold your convictions – or else you might as well have none
 
12:22 AM
@MooJuice Don't know about the downvote, but I added comment to original question.
 
@AlfPSteinbach, it's a good point.
 
never forget context, especially when unstated – something I knew was right in 1991 may be wrong in 2011
 
I am humbled by most of the C++ gurus on SO.
My first realisation on arrival here was that I knew nothing :)
 
12:34 AM
whats c++ for? i.e platform?
 
@FredNurk A great thing about SO is that it knocks down wrong convictions people have. Even if they try to stand, they are likely to be proven wrong. It doesn't happen very frequently to me, but has already happened, and won't be the first nor the last time.
@XcodeDev it's for world domination.
 
haha but seriously....
im not sure whether to learn c or html/php or c++ next?
 
@XcodeDev it's a hard question. I think it would be a good one to post at Programmers, if people didn't ask that already.
 
ok and what ide do you use for developing c++? Microsoft VB?
 
@XcodeDev you mean Microsoft VS? I personally develop for Unix-based systems solely. I use mostly vim, and eclipse+cdt.
 
12:44 AM
ok thanks. I thought you used Visual Basic for C++
 
@XcodeDev Visual Basic is a completely different language. Nothing related to C++, not even the default "IDE". You might want to take a look at VisualStudio (VS).
 
ah ok thanks
 
@XcodeDev you're welcome.
 
personally I am a obj-c coder so I was thinking about testing out "c"
 
@XcodeDev be aware that C isn't C++, even if they share a common base.
 
12:50 AM
I know but c is the foundation of obj-c so it would initially improve my knowledge of apple computing!!
*apple computer development
 
@XcodeDev if you already know ObjC, I'd rather invest time to get better at it instead of learning C. Don't feel discouraged though, it's just my opinion.
 
@XcodeDev learn Python
 
Ah, of course, also learn C#, Java, JavaScript, and... people can throw many languages at you. Your long-term goal is what should dictate what you must learn.
 
@XcodeDev: ignore all that; learn Python
 
@FredOverflow provide him some strong arguments so he can see any benefit maybe?
 
1:02 AM
if he already knew a language or actually had long-term goals, then I could
as things stand, he has to take someone's word for it and just accept the chance of working slightly less efficiently (since learning any mainstream language is hardly a horrible choice); IMNSHO, taking my word is better than most :)
 
@FredNurk you're making assumptions out of thin air. Even if you're correct, you shouldn't say "learn it, just learn it" without providing a good reason for that.
 
sure you should, that's how most education happens
e.g. public/mainstream school systems in most countries
 
@FredNurk while you're a child, of course.
 
someone who mixes up VB and C++ as above is a child in the realm of programming
it won't take him long to learn Python and be productive (at least for his own needs) in it, and it'll give him perspective on where to go next
 
As I understand it @XcodeDev knows a bit of JavaScript, a bit of PHP, and a bit of "Cocoa" (is that some Apple thing where C is mixed with something-something?) Is that right?
 
1:06 AM
I don't know much cocoa, apart from the foundations. I have been learning objective-c for nearly a year and a half.
 
@AlfPSteinbach: I only see that he knows people use those names
 
@FredNurk Treat people the way you would like to be treated. If you want people to respect you, respect them equally. Even when (and if) they're wrong.
 
I did not disrespect him
 
@FredNurk no? Oh, pardon me. I though saying he was a child that knew nothing about programming would fit that criteria.
 
@FredNurk I am relatively offended by that comment.
 
1:09 AM
@jweyrich: you introduced child as a placeholder for "beginner that doesn't know what or how to learn more"
I continued to use the euphemism
@XcodeDev which one?
 
@FredNurk that was probably not clear. I meant child literally, as you mentioned how you see education.
 
@jweyrich It was clear...
 
Well, I guess we can focus on constructive comments.
 
@jweyrich: then you misunderstood, because I was including education up to and including university level: it all is full of "learn this, you can find out why yourself (usually later), but we won't strive to make that clear beforehand"
 
@FredNurk turns out it was a sequence of misunderstandings then. Better :)
 
1:13 AM
that is, you misunderstood unless you don't believe calling such 20-somethings children isn't perjorative
 
@XcodeDev: depends on how much Objective-C experience you have, but if you can make things from scratch, then it's not unrealistic to have a go at learning C++. Only, you need to keep in mind that nobody ever learns the complete language. :-)
 
@FredNurk IMO grown ups are capable of critical thinking, differently from children. Thus my understanding. You can't enforce "learn it this way" to a grown up.
 
@jweyrich: it is a learned skill, but don't confuse correlation with causation
 
coffee consumption -> car accidents
 
@jweyrich: you might want to check how many programming books have an "rationale" introduction explaining why they chose a particular method (none I have read do)
@jweyrich: you, as a learner, can of course drop the book and read something else (barring outside restrictions), just as he could stop learning Python at any step of the way
to be clear, I'm strongly disagreeing with your stance on "learn it this way"
 
1:23 AM
Remember:
22 mins ago, by Fred Nurk
@XcodeDev: ignore all that; learn Python
 
I stand by that
 
I'll restrict my words to what I've already said. Let's move on.
 
for anyone asking what to learn I see Python as much more valuable than C#, Java, and JavaScript (which you mentioned), plus any other mainstream language
 
@FredNurk that's quite argumentative so I won't go into details. Note I'm myself a Python programmer. That's why I mentioned it would be a good question for Programmers.
 
Except for the Python 2.x versus 3.x thing. I don't think NumPy (for example, hope I got the name right) is still available for 3.x. So it's like choosing between two very similar languages.
 
1:30 AM
@jweyrich it's intended to avoid the debate he won't (yet) understand, decide the issue and get some action – i.e. learning – going
@AlfPSteinbach you can't avoid that with any language; cf. c++03 and 0x
 
NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
 
@FredNurk I understand that. I just said you should provide some reasons for him to learn it.
 
> There will be a minor outage in the next hour as we upgrade our database server.
 
@FredNurk The problem is that many of the nicest libraries are not available for 3.x, and also that most tutorials & explanations on the web are for 2.x, while 3.x is the future. Is that right?
 
@jweyrich as I said, because my experience indicates it would be beneficial
 
1:32 AM
This debate reminded me of xkcd.com/386.
 
@AlfPSteinbach much is made about incompatibilities – much more than they warrant
@AlfPSteinbach: from an internal API view, which a library such as numpy is concerned with, the differences are huge; much, much, much less so for someone learning the language – the biggest difference they need to know is "use print(), it's a function rather than a statement"
@jweyrich in fact, I gave the reasons before you told me I shouldn't omit them
mere seconds, perhaps (since I can't turn on timestamps), but that's the order it shows here
 
swoooosh! and a Korean good morning to you.
 
@JamesMcNellis time backup our data! Or too late? Let's hope not.
Geez @tina, you got the 666th star!
 
look to the right, starred messages
Yes, anyone can star a message that they find interesting or funny or just like
yes
i'm already everywhere
 
1:49 AM
You two, get a room!
 
sbi
2:22 AM
@jweyrich The Number Of The...ern, Tina. :)
 
2:41 AM
Nice! New flagging choices.
@sbi lol. Took me time to get it. Had too much pizza to think sanely.
 
 
8 hours later…
10:33 AM
0
Q: Prefer algorithms to hand-written loops?

FredOverflowWhich of the following to you find more readable? The hand-written loop: for (std::vector<Foo>::const_iterator it = vec.begin(); it != vec.end(); ++it) { bar.process(*it); } Or the algorithm invocation: #include <algorithm> #include <functional> std::for_each(vec.begin(...

 
answered
 
@DeadMG thanks
 
no prob
 
Too bad I have to use VS2008 (for my job) which does not have lambdas :(
 
btw, are there any reliable, up to date benchmarks for the overhead introduced by lambdas/bind over manual closures?
 
10:45 AM
there isn't any
and there never was
the compiler produces a closure automatically which, in worst case, is the same as the closure you wrote manually
in the best case, the compiler has many optimizations available
for example, if you refer to a lot of stack variables, the compiler can pass a stack pointer rather than a manual reference to every variable
and, for example, the lambda doesn't need a run-time member function selection
whereas when using the bind system, you have to de-reference that member function pointer
 
By the way, I am really looking forward to the new for loop:
for (auto& x : vec)
{
    bar.process(x);
}
 
@DeadMG I’m not sure. Over manual closures – OK. But over hand-written loops? The compiler has to copy local variables … introduce extra indirection (pointer overhead)
@FredOverflow BOOST_FOREACH!
 
what local variables?
 
Hey guys
 
if you refer to them, then it doesn't do any copying
 
10:48 AM
@KonradRudolph I once tried to figure out how BOOST_FOREACH worked and got a massive headache.
 
and the body of std::for_each is just as far away in memory as the body of a normal for loop
 
@DeadMG right, copying was the wrong word. But there is an extra indirection through the reference or a pointer
 
not after inlining
 
and what happens for lambdas that are returned from a function (can C++ do that?)
@DeadMG right, that seems reasonable
 
either the references are busted, as normal
or you copied the values and they're fine
 
10:49 AM
@FredOverflow what? headache? it works exactly like your loop above
 
@FredOverflow, I read an article on how it works and it bust my head aswell.
 
(forget that comment, misunderstood)
 
lambda bodies, especially in the case of simple algorithms like for_each, are practically the poster child for easy, effective inlining
 
It's really quite clever.
 
@FredOverflow I know but I don’t like it, that only confuses more
(see? ;-))
 
 
1 hour later…
12:06 PM
I looove these log messages:
> changeset:8008 comments out the failing tests. We need to re-enable them when we fix this.
“so the test is broken? let’s disable it until we have time to fix the problem”
Somehow I don’t think this is how testing should work
 
lol
 
12:25 PM
@KonradRudolph "Don't mind the crash. We simply turn off assertions in the release we ship" I thought it was a joke...
2
 
Wasn’t there a recent DailyWTF about this?
 
Dunno. Above was, 2005? Not sure, it was a GIS system for military training
They were using C++ as a "scripting language" on top of the GIS engine. It was a mess.
 
@AlfPSteinbach That is scary. Did they use such a system to aim their rockets, too? ;-)
Fire and forget gets a whole new meaning now
 
No, it was training for what do you call them, those who direct planes?
Sorry, I'm Norwegian: not 100% English here.
 
pilots?
 
12:33 PM
no, those who direct the pilots
 
flight controllers?
 
ok – doesn’t make it less scary though
 
i thought it was plenty scary
 
C++ as a scripting language?
lolwot?
 
12:52 PM
A doubt: In C++, we can assign a value while declaring itself ( i.e., int i=10; ) and can serve this as an example of RAII. In 'C' we can do the same and but why we say that the advantage of 'C++' is RAII ?
 
because in C, no class can have destructors
an int does not serve an example of RAII
only classes with destructors implement RAII
 
@DeadMG: So, only user defined types serve as an example of RAII
 
yes
as no primitive type has a non-trivial destructor
 
Can't we say a "C Struct" as an user defined data type ?
 
does it have a destructor?
 
12:58 PM
No
 
then no
 
If a user defined type has a destructor, then only it can serve as an example of RAII (period)
 
yes
RAII is about destruction, nothing else
I guess, more accurately
 
So, compiler is going to deallocate the resources of a "C Struct". Right ?
 
only user defined types with a non-trivial destructor exhibit RAII
only if it's stack allocated
 
1:01 PM
Ok
What do you mean by non-trivial destructor ?
 
a destructor implemented to actually do something
 
So, compiler generated destructor is trivial.
 
not necessarily
 
Aren't the compiler generated constructor/destructor empty?
 
only if the class has no members or bases that themselves don't have destructors
the compiler must destruct all the data members of your class
if you only have members and bases that don't need destructing, like primitive types
then the compiler destructor will be empty
but if you have a type that has a custom destructor, the compiler must call it
same for constructors
the definition of the compiler-generated copy constructor, for example, is the copy constructor of all members and bases of the class
and default constructor and assignment operators
this is why they are preferable- because the compiler maintains the list itself
and if you change like a variable name or add new variables, you don't have to update them
 
1:09 PM
So, if all the resources are managed by compiler, compiler generated destructor is going to destruct them. If a class manages resources, ( i.e., if it has pointer ) it is the responsibility of the programmer to deallocate it int the destructor.
 
uhm
nearly
the compiler doesn't manage all resources
only guarantees to destruct all members of the class
equally importantly
managing resources is not the same as owning a pointer
it normally is, but not always
 
If you copy a pointer but not the value pointed by the pointer
can serve as an example
of "it normally is, but not always" of your statement
rightn?
right?
And pointer is a member of a class
 
well
more than that
you can have resources that aren't pointers but references or opaque types
or even represented by just constructor and destructor
 
Thank you very much and BTW, can we bookmark this chat history? Or the only way is to search the chat history
 
1:35 PM
no idea
never tried
 
@Mahesh On the right hand side, go on the text “room▼”, select “create new bookmark” and follow the instructions
 
2:21 PM
quick question
are there any UI elements that can't be implemented as containing buttons?
considering that I'm looking to implement a relatively simple UI framework
 
2:44 PM
What about a list box?
Or do you mean can any UI element contain a button?
 
3:20 PM
@Mahesh If you're using C, sure. If you're using C++, then you can't define a "C Struct".
 
If you had to buy exactly one book an algorithms, which one would it be?
 
Would I really have to?
Can't I have a bike instead?
 
"The Super Sexy Book of Algorithms, by DeadMG, £10000"
2
 
@AlfPSteinbach meta-pilots!
 
Air Traffic Controllers
 
3:33 PM
man
I hate UI code :(
3
 
sitting in the Air Traffic Control tower
 
oh, wait
not every button has text
that's kinda silly of me
 
@DeadMG What language does this book represent the algorithms in? DeadMG++?
 
lol
that's the silliest name every
ever
maybe it does
if I told you that it did, you wouldn't know the difference, since you've never seen or read DeadMG++
 
@DeadMG good point
 
3:39 PM
The DeadMGLib
 
by the way
 
or DML if you're stupid
 
is it bad practice to define all my class members inline because I'm just lazy and don't want to have to redeclare all the return types and stuff?
 
lol
I used to prefer that. For whatever reason I've been semi-convinced by the argument NOT to do that. And I can't even remember what the argument is.
(I can really)
 
well the thing is that since I'm frequently altering my design as I increment on the previous version
it was getting a tad ridiculous to keep going back
 
3:40 PM
think that's the price you pay for not maintaining your interfaces!
 
lol
 
you should be punished by having to change return types in both places
then perhaps you won't change your interfaces quite as much.
 
you mean, not designing them beforehand? :P
 
go go express programming
bah
 
3:41 PM
haha
GO GO GADGET BREAKFAST
 
in DeadMG++ the compiler infers the return type for you in all reasonable situations
see, I think it was a bad idea to have a separate class to abstract over the operating system and abstract over the rendering system
now I want to implement classes, but it's going to be annoying because the primary application class already took all the input callbacks
I mean
UI controls
 
If you're not sharing your code with anyone else, just do what you want. If you are sharing, it tends to be a lot easier to read the class declaration without a lot of inline code. It can also make compilation faster if the function definitions are not in the header file.
 
would it really? MSVC does cross-file inlining anyway
 
@DeadMG On the one hand, defining complex member functions in class definitions increases compile times and potentially causes code bloat. On the other hand, templates must be defined inline, and if you strive for maximum genericity, you will end up with templates, anyway.
 
you know what's really annoying?
I get a separate notification again every time you edit
so I read it, start to think about what I'm gonna say, and then it pings me again
 
3:50 PM
@DeadMG So make a suggestion to the SO creators.
 
@FredOverflow You can define a template member function in the header file after the class declaration. It doesn't have to be inline, just defined before the first use.
 
nah
it was my opinion that their editing and such restrictions are completely insane, but they disagreed
 
@Alex You mean member function template and class definition, right? Anyway, the member function template definition still has to be inside (or included from) the header file, you cannot put it in a separate translation unit.
 
@DeadMG That's why I said it can make it faster. It depends.
@FredOverflow Right
 
Did I already mention that I hate C++'s compilation model (header files instead of true modules?)
 
3:53 PM
why yes
I also hate it
 
(I need to vent regularly.)
2
> a *= a *= pi >> area;
OMG my eyes hurt!
 
lol
is jurt a technical term?
and you're not the only one :P
plus
m
yeah
he wrote (a * pi) ^2, too
not a * a * pi
plus UB for double modification between sequence points
 
@DeadMG I'm pretty sure Matt has never heard of UB.
 
There may well be that possibility
 
Does your language have UB?
 
3:59 PM
yeah
fact is, you just lose more power than I'm willing to give up in order to scrap UB
 
If we get ever bored with C++, we need a new language where 99% of the stuff is UB, and well-defined behavior is the special case.
 
rofl
 

« first day (91 days earlier)      last day (4843 days later) »