« first day (442 days earlier)      last day (4489 days later) » 

sbi
2:06 PM
Quiet here today. Is everybody still drunk?
 
Or contemplating the loneliness in their lives?
 
sbi
@StackedCrooked Uh. Are you depressed?
 
Nope. Just my favorite form of sarcasm/cynism.
I think I learned from a teacher.
I do feel depressed that I have to go to work tomorrow. I had just gotten used to the holidays.
 
sbi
@StackedCrooked Debbie??! Looks apprehensively.
 
Hehe. Actually it was a lecturer.
 
sbi
2:10 PM
@StackedCrooked Lemme rub this in: I have two more days off. :)
 
If he didn't have enough time to go deeper on a certain topic during class (usually because it was out of the scope of the class), then he'd say that we should look into it ourselves on a lonely Saturday evening.
@sbi I wish.
 
sbi
@StackedCrooked LOL!
 
@sbi Yeah, it was his standard joke :)
I think I was one of the few who thought it was funny.
 
sbi
I just read that the Berlin firefighters (who also operate the ambulances here) had to run 1583 missions between 7pm and 6am last night. They had ~1500 humans (plus an unnamed number of police and hospital personal) wasting their New Year's Eve by trying to save people many of which we'd be better off with them being removed from the gene pool. I'm glad I'm a programmer.
 
@sbi Who knows it might be a satisfying experience for some people.
I actually started programming after the party, around 4am.
 
2:27 PM
lol
I'm playing Terraria and killed myself with my own traps :(
 
// erasing a non-existing element from a set is silently ignored.
std::set<int> s;
s.erase(1);
^ I think I finally understand why.
The alternative would be to throw.
However, erase is a method that is likely to be called from within a destructor. (Unregistration and similar mechanics usually take place during destruction.)
Does that make sense?
 
well, I would say that more logically, the semantics of erase is that the argument is guaranteed to not be in the set when it returns
 
@DeadMG yeah, I'd go with that too
why throw an exception, if the end result is exactly what the caller requested anyway?
 
as long as after erase returns, the element is not in the set, then erase has completed successfully
 
@DeadMG I'd agree, but it does seem like a definition that was formulated afterwards in order to make it match with the actual behavior.
@jalf I find it a little sloppy. Just a subjective thing probably.
 
2:39 PM
The way I see it, error handling is a bitch. So the fewer cases we have to consider as errors, the better
 
Also, inspecting the return value reveals how many elements were there.
 
well, I'd say that if you need to know whether or not an item was actually deleted, you're doing it wrong
 
if I try to remove an element from a set it's not actually in, then we could consider that an error, and then I'd have to do error handling. Or we could say ok, it is no longer in the set, and then I can continue doing something interesting
 
sbi
@StackedCrooked Pretty much like my oldest boy then. When I tell him to please take the trash out, and he finds that someone else has already done so, he just silently returns to whatever he had done before, implicitly taking credit for a task he hasn't done. His older sister still has to learn that trick.
@LucDanton Yeah, I think this is the real reason: You can check it if you want, but don't have to catch anything in case you don't need to know. (Well, and also that throwing takes performance.)
 
@jalf When I write a container I usually throw when non-existing element is tried to be deleted. Because it is an early indicator that something is wrong. And it's always better to discover errors early.
 
2:44 PM
depends on the container, and the typical use cases, I suppose
but I can imagine a handful of cases where I'd just want to say "remove this element form the set, if it exists"
 
sbi
@StackedCrooked I would only hardwire this behavior for a very specialized container that has exactly this requirement. Otherwise I'd make this a policy. Well, actually I might make it a policy in any case.
 
@sbi I see an analogy with the std containers. Really.
@sbi You often use policy-based designs?
 
sbi
@StackedCrooked Um, weren't we talking about the std containers??
 
And since the Standard Library can't second-guess the typical use, it picks the 'easiest' API. Translating an erase with exceptions to non-exceptional is more painful than the other way around IMO.
 
@sbi If the containers that your oldest son is (not) emptying are std containers. :D
 
sbi
2:46 PM
@StackedCrooked When I used to do C++ for a living, I did. It might be some kind of sloppy thinking, too, though, if you overdo it. (Like "I have don't know whether this might have other requirements, too, and I'm too lazy to think about it, so I'll just make this a policy and stop worrying...")
@LucDanton Exactly my point, only you say it so much more eloquently. :)
 
You don't do C++ for a living anymore?
 
he does C#
 
What!?
 
sbi
@StackedCrooked Look at my questions: stackoverflow.com/users/140719/sbi
 
@sbi I've read a few times that some people find the switch from C++ to C# very liberating. Because it has all the IDE conveniences. Is that your experience as well?
 
sbi
2:49 PM
@StackedCrooked Sadly, yes. :( Really, haven't you looked at twitter.com/#!/tweetsbi? I got hired for being a good C++ programmer, being asked whether I feel like I could pick up similar languages, like Java or C#, easily. Then they forced me to write C#, and having to feed a herd of kids, I had to submit.
@StackedCrooked VS support for C# is fantastic when you come from C++. Also, C#' lambdas were love at first sight. And I learned to love LINQ a lot.
 
The last few months I've been coding mostly in Java. Our app is a C++ server with Java desktop client. I don't mind so much as long as I can work in my own code.
 
Yeah, C# isn't all bad
it's mainly the boring Java-esque core language and class library that bugs me
 
agreed
 
@sbi I don't really see the need for LINQ in most of my work. If I understand well it's a SQL-like syntax for extracting data from a container. I don't think I ever needed that.
 
Oh, and generics. I don't think I can ever forgive them for being so tantalizingly similar to templates, and yet so, so limited
 
sbi
2:52 PM
But, really, while C# is a neat little toy language, it feels like wielding a cute little girl where C++ feels like a fully-armed battle-hardened elite soldier. I miss the raw powers of C++ templates so badly.
@jalf Ha!
 
@StackedCrooked Any time you iterate over a container, you use something like that
LINQ is C#'s attempt at map/fold and all that FP trickery
more or less :)
 
I like LINQ, in general
 
sbi
@StackedCrooked I dunno about DB access using LINQ, as I tend to shy away from anything with a "DB" label on it. But it's very expressing to use with enumerations.
 
or std::transform and all the others. That'd be done with LINQ too in C#
 
2:53 PM
I don't like it's interface-based implementation, I'd rather a template one
but ultimately, LINQ is nothing more than <algorithm> with a much cleaner syntax
which is obviously a good thing, but it's not anything fundamentally new
 
@DeadMG although with the one core limitation that it only works with what's basically forward iterators
or it might even be closer to input iterators
 
I sometimes do need to order a container on more than one property. For example sorting a list of chat users by name, but grouped by their online status (Online, Away, Offline). I'd do this with std::sort and std::partition. Is this an example where LINQ rules?
 
well, it wouldn't be hard to write a direct equivalent in C++
I've done it
 
@sbi wielding a cute little girl?
 
sbi
@jalf Ah, finally someone noticed. I thought you had me all on your ignore lists.
 
2:56 PM
just because of the (iterator, iterator) representation of ranges in the C++ libraries, it's not terrifically compatible
 
@StackedCrooked Yeah, for example. Or just applying a function to every element in a sequence. Or selecting all elements from a list which satisfy some predicate
or chaining several such operations, of course
 
it's the composability of LINQ which is so much better than <algorithm>
 
room topic changed to Lounge<C++>: C++: not like wielding a cute little girl [c++] [c++11] [c++-faq]
@DeadMG yeah, I like iterators and <algorithm>, but composability is really where it falls down
 
sbi
@jalf ROTFL!
@StackedCrooked This is the second example of LINQ usage I found in a real source file I was working last thing at work last week: var missingPaths = from entry in Entries where !entry.Value.Exists select entry.Value.FullPath. I find this hard to beat in expressiveness.
 
I prefer to use the explicit lambda notation
 
2:59 PM
@DeadMG Methods do seem superior to functions when it comes to composing queries. elements.sort().group_by(...) vs group_by(sort(elements), ...).
 
For some reason I usually prefer the plain function syntax: Entries.Where(e => !e.Value.Exists).Select(e => e.Value.FullPath)
 
Entries.Where(entry => !entry.Value.Exists).Select(entry => entry.Value.FullPath);
 
sbi
Yeah, I know that, but it's far less expressive than the almost English-like LINQ syntax.
 
what makes you say that?
 
@sbi Yeah, in C++ I'd take more work and more thought.
 
3:01 PM
I find the other syntax less expressive
the function syntax lets you re-use intermediate variable names, for one
 
sbi
@DeadMG Why? from x in Xs where cond select x.y is almost plain English.
 
it's not close enough to English to actually be more expressive than code, though
anything that doesn't have a direct translation into lambda syntax isn't going to compile
 
oh yeah. I worked with C# for years, and the one thing I've still not understood is that weird variable scoping thing where sometimes you can't declare a variable because the name clashes with something used further up, but which is no longer visible
 
because otherwise would be natural language processing
and the other thing is variables
if I say
 
Happy make_shared<Year>() everyone!
 
3:03 PM
@sbi Natural language is hard.
Well, non-natural languages aren't necessarily easy of course.
 
if I recall correctly, if (...) { int x; } int x; error?
 
sbi
@jalf I find that annoying, too. It's like the language attempts to hold my hand all the time, thereby severely limiting my freedom to roam.
 
from x in Xs where ... then you need to know all the ... to know what happens to x
but if you do Xs.Where(x => ....), then you know all future uses of x are independent and you can forget about it
 
but it also kept bugging me when doing linq queries with the "plain english" syntax
 
it's more tightly scoped
 
3:04 PM
@FredOverflow Don't you mean make_shared(new Year())?
 
@LucDanton Indeed. I sometimes wish I could use programming syntax when explaining a complex procedure to another person.
 
@sbi I don't think writing C# for a living is a reason to be ashamed. In fact, I would love to broaden my horizon that way.
 
make_unique(new Year());
 
well, I don't program C# professionally, but I think that I have a basic enough grasp to know it's upsides and downsides
 
@jalf No, you don't need new with make_shared, that's the cool thing about it. Only one memory allocation for both the object and the counter.
 
3:06 PM
yeah, then you'd have a shared_ptr<Year*>
 
@FredOverflow yes, but you usually say happy new year
 
I would like to use Lisp full-time for a while and see how that goes. But not gonna happen.
 
so it doesn't make sense if you omit the new :)
 
sbi
@FredOverflow I'm not ashamed to do C#. I'm annoyed.
 
That's what they all say.
Joking :)
Btw, @jalf do you have any updates of your lib?
 
3:12 PM
@StackedCrooked hmm, nothing very significant. Haven't had that much free time, and mainly been working on getting it to work on osx
 
@jalf I'm using it on osx.
 
@jalf Well duh, new is exactly what I wanted to avoid :)
 
@StackedCrooked Ah cool. The library code just seemed to work too, but my benchmarks needed a bit of work
 
> Assembly Chat: A chat for those who wish to discuss code optimization and assembly. This may include other lower level languages such as C or C++ as well.
C++ is a low level language?
 
also performance seems to be much worse on osx for some reason. I'm suspecting some quirk of their TLS implementation
 
3:15 PM
@jalf Which compiler are you using for C++11 support on Mac?
 
g++ 4.5 and up
Clang shouldn't be a problem, but then I'd have to remove my lambdas :(
and dunno, looking at it now, it doesn't look thread safe. I remember going over that code fairly carefully though, and if there was a problem, I'd have expected my tests to pick it up. I'll have a look at it though. :)
 
I've installed GCC 4.6.2 via MacPorts. But for some reason I doesn't work well with gdb.
 
Why were you digging into that code? Having problems with it?
 
sbi
@FredOverflow C++ is a low-level language, too.
 
Valgrind DRD was reporting some race conditions. Mainly on line 29 (static tls_data data;).
 
3:19 PM
ah
 
However, these errors no longer occur after upgrading to Valgrind 3.7.
 
@sbi Aha, so C++ is a multi-paradigm, multi-level language? :)
 
However, today I'm very sleep deprived so my conclusions are very unreliable.
 
hmm, putting it on my todo list to have a look at it. I think you might be right, something's not right in that code
 
@StackedCrooked Should have gone to sleep at noon.
 
sbi
3:20 PM
@FredOverflow Yeah, of course. It scales well from low-level embedded stuff to high-level enterprise apps.
 
So C++ is both low-level and high-level. Does it also have a bonus-level? :)
2
 
oh doooh
no, of course it's thread safe
 
@jalf Seems like you had to jump through some hoops avoid GCC complain that thread-local statics can't be initialized dynamically.
 
It's a thread-local variable. Other threads won't see it, by definition ;)
 
sbi
@FredOverflow Yeah, there's a Turing-complete meta language hidden, coined TMP. It takes long to unlock this achievement, though.
 
3:23 PM
@jalf I suspect that my older version of Valgrind didn't recognize thread-local variables.
 
also, tbh my TLS code is horrible. I used to use Boost's, but ran into some performance issues with it. And no compilers have implemented C++11 TLS yet, so I had to whip up my own as a stopgap measure
 
@jalf You might want to peek at Poco's implementation. The Poco authors seem pretty confident about their threading API.
Not sure if this is helpful at all. Just a suggestion :)
 
I'll take a look. The problem is I really need top-notch performance, since I have to do these TLS lookups for every transaction, and I want transactions to have low enough overhead that you don't need to worry about using them
 
Ok, might not be tuned for that.
 
oh, of course another factor is that I want to minimize dependencies. Should be easy to use the library, and having to set up boost or poco is kind of a lot of work just for that ;)
but still, worth checking out
 
3:31 PM
I didn't mean to add Poco as dependency to your project. Just see if you can borrow some of their ideas into your own code.
 
ah yeah, could do that
I assume they handle non-POD types correctly too? Neiher POSIX nor Win32 threads can handle calling destructors. POSIX has an optional callback you can register to emulate it, but with Win32 you're just screwed
Boost does some really impressive, but evil, CRT hackery to get around that
thought about copying that, but in the end I decided that was too scary, and I'd rather just postpone that and hope for compilers to implement C++11 TLS ;)
 
3:47 PM
why not just have something like std::vector<void*, std::function<void(void*)>> on the thread's stack
 
Today I discovered that the GCC option -fno-inline is very helpful to get nice stack traces during debugging. It also slows down my code with a factor of 10 - 100.
 
@DeadMG because I don't control the thread's stack. I don't want to add a requirement that all threads using my library must place some magic variable on their stack, and guarantee its lifetime
That's why I'm forced to use TLS in the first place. Otherwise I'd just put everything on the stack like a sane person ;)
 
ah, lols
 
how do I find size of object containing non-pod?
 
sizeof?
 
3:55 PM
@jalf not working
 
yes it is
what were you expecting it to do?
 
struct foobar{std::string TT; foobar(): TT(std::string(50,'a')){}}; , how to find size of foobar object I mean?
sizeof always says 4 bytes
 
sizeof(foobar)
 
that's because the foobar object is 4 bytes in size
if you want to include the memory dynamically allocated by std::string, you will have to manually ask it what the size is
 
@DeadMG aah , thats what I was asking, Thanks
 
3:58 PM
@jalf Ok, having looked at Poco's thread-local implementation I guess its performance is horrible relative to your goals. It doesn't make use of native features at all. Getting a thread-local requires a lookup in a std::map.
 
yeah, I just looked at it too
ah well
 
@DeadMG 4 bytes due to string object in it, right , without any padding etc?
 
the hell should I know? Ask your compiler's documentation
 
@DeadMG WT... you were the one who was answering me :/
 
the fact that the sizeof() does not include the dynamically allocated memory is Standard-defined
padding and alignment is most definitely not Standard-defined
well, maybe in C++11, but I don't know much about that
so without knowing your implementation, I'd have absolutely no way to know the answer
and even if I did know your implementation, I'd have nothing to say but "look at the documentation" anyway
after all, you can affect alignment with pragmas and such
 
4:05 PM
Ok, I'll now start the OS X Lion installer. In case I never see you guys again, it was nice knowing you.
 
@StackedCrooked fun fun
 
I feel left out. I never get to write any for loops with multiple increment variables :(
 
4:32 PM
lol
terrible
 
user406009
4:44 PM
So if I understand correctly, Return Value Optimization does not work on function arguments?
 
I'm back. It went better than expected.
@EthanSteinberg Nope.
@EthanSteinberg RVO is easy to understand if you think in terms of stack-addresses.
 
user406009
Oh well.
 
hmm, could you explain it then? I've always been a bit unsure of when exactly (N)RVO would work
 
I did some tests a few months ago and it turns out that GCC always performs RVO even if optimizations are not enabled (-O0). Even if I put a unconditional throw in the copy constructor it is still optimized away (changing the behavior).
@jalf Since you know a lot more than me I now fear that the only reason I find it easy to understand must be due to utter ignorance.
 
5:00 PM
@StackedCrooked yeah, it does. As I recall, MSVC also does RVO when optimizations are enabled, but GCC even does NRVO
@StackedCrooked no, it's just that I've never really looked into it. :)
 
I thought that MSVC had NRVO
in fact, I thought they practically invented it in VS2005
 
I just have the mental model of the stack as a linear contiguous chunk of memory. Each variable increments the stack pointer. If you enter a function and declare a variable there then it will be "physically" (in my mental model) right next to the position of the stack pointer before entering the function. The only distance is due to stack frame.
 
that is pretty much how it is
 
Without RVO the return value would need to be copied just a little to the left.
Or even nothing if you omit frame pointers.
So it's an optimization that comes naturally.
I'm not sure if I'm making sense now.
But in my mind, it does..
 
but you're assuming a specific fixed calling convention.That's what usually trips me up, that all this about where the return value should be stored, and where parameters are going to be located, is implementation-defined and varies with calling convention. And yet we have this broad general-purpose promise that sometimes this copy can be omitted
 
5:07 PM
the optimization is calling-convention independent
you start with std::string func(); int main() { auto x = func(); }
 
how so? How would it work in a calling convention where the return value isn't simply stored in "the next address on the stack"?
 
@jalf I understand it through a simplified analogy. I know nothing of the nitty gritty details going on under the hood. (I wish I did though.)
 
and you go to void func(void* ptr) { new (ptr) std::string(); } int main() { char buffer[sizeof(std::string)]; func(buffer); }
 
@jalf And isn't the point of a higher-level language to hide all this from you?
 
@DeadMG yeah, can pass in a hidden additional parameter, of course. Do implementations actually do this?
 
5:10 PM
Hi.
 
anything else is just an optimization of that situation and has nothing to do with RVO in particular
 
@DeadMG yeah, but I'm curious about the specifics ;)
 
and is exactly the same as you'd expect to see if you simply set the buffer to all zeros or all ones or something like that
void func(char* ptr) { memset(ptr, ptr + 5, 5); } int main() { char buffer[5]; func(buffer); }
 
what if you call a function defined in a separate dll, for example? You can't pass secret parameters to that, because that'd alter its signature. Does that mean RVO just doesn't work in those cases?
 
I'd expect so, yes
however, since in reality, DLLs that don't use C interfaces are realistically bound to a single compiler
you might argue that in fact, you can perform RVO anyway
 
5:12 PM
yeah, me too. But it's something I've never bothered to dig into, but I'm curious about it :)
 
because there are lots of other reasons that nobody else is going to call into your C++ interface
a problem I've almost entirely fixed in WideC, of course /shamelessplug
 
SO is broken?
@DeadMG One thing that seems to be missing on your blog is a brief description of what WideC is.
Am I right in remembering that it was going to compile to C++?
 
I propose "Something even better than sliced bread".
 
Sliced bread is hard to beat.
 
I switched to using LLVM, in theory
haven't gotten that far yet
 
5:23 PM
I think compiling to C++ would be appealing to many of us.
OMG, OS X Lion reversed the direction of the scroll wheel.
 
See, they love to improve usability.
2
 
Took me a while to figure out why everything behaved strangely.
 
@StackedCrooked yes. Trying to be more tablet-like, I guess. I kinda like it, after getting used to it, but it can be disabled somewhere
 
maybe if you wanted it to take six decades to compile
 
@jalf I'm glad it can be disabled. However, I don't like it because I work on various systems and I like them to behave similarly.
 
5:27 PM
and there are some features where they may not have an equivalent form in C++
 
@DeadMG I think you're right that technically LLVM is the better choice. I was thinking from the perspective of the user. According to Scott Meyers the spread of C++ is for a great deal thanks to CFront, a compiler that compiled C++ to C.
 
user406009
I would much rather have a language that actually had a portable api than compiling to C++.
 
user406009
C++ abi sucks.
 
What would a C++ abi achieve exactly? Does it mean that I should be able to compile a static library on Windows and be able to use it on Linux?
 
the difference is that C++ tools and compilers suck
and C's don't
 
5:39 PM
No a standard ABI means that libraries and object files compiled with different compilers might work together.
 
also C++ and C are closer in many ways than WideC and C+
 
@DeadMG But compiling to LLVM bytecode is not much different than compiling to C++. It's mostly a matter of familiarity I guess.
 
it's very different
no shitty grammar, for one?
no #includes, for two?
and secondly
with LLVM I can create, JIT, and execute functions at compile-time
I can't do that by compiling to C++
I'd have to ditch my biggest feature
the fact is that WideC source code is not directly reducible to C++ source code
and any tool capable of performing the conversion would have to be able to convert WideC source code to native code anyway
 
@DeadMG Ok. It would be nice though if one could rewrite a small portion of a larger C++ codebase in WideC. That's pretty much the background of my reasoning.
 
you can
I considered this long ago
 
5:44 PM
@DeadMG If you can leverage LLVM's functionality to do this for you then that's a huge gain.
 
oh yes
 
@DeadMG Using COM?
 
no
how would COM possibly accomplish this?
by using Clang to lex, parse, and analyse the C++ code
then add a simple extension, like, __widec("file"); as a declaration, with the semantic effect of introducing the WideC types and functions defined in that file to the C++ file it originated from
allowing, for example, to instantiate C++ templates with WideC types, to instantiate WideC metafunctions with roughly equivalent C++ types, to cross-inherit, to use WideC code to reflect on C++ code, and such things
 
You could reverse compile the LLVM bytecode to C++ and include that in your original codebase. Or is that too crazy?
 
wut?
 
5:48 PM
I should sleep soon before I start to hallucinate.
 
that might help
 
Ell
what is c++ anyway?
loljk
:D
 
I'm still waiting for new Xcode to download. I want to check out its C++11 support.
 
Ell
I <3 c++11
 
@Ell IMO a language is defined by its syntax.
 
Ell
5:53 PM
but what about the standard library? surely that plays a major part?
 
Yes it does.
I once read that there is a project that provides an alternative syntax for C++ so that it has a EBNF form. I think this doesn't make sense. If you change the syntax then you change the language.
You can't treat syntax as an implementation detail.
 
that's not true at all
languages are defined by their semantics
syntaxes are trivial
C++ with prettier syntax still can't take a std::map as a template parameter
it won't fix the old exception specifications, or prevent array decay, or fix #include
 
Ell
@deamg thats what I'm thinking
 
those things which actually matter won't be fixed at all by changing the syntax
 
Dammit, now I need to Google for the difference between syntax and semantics before I can continue this discussion.
 
Ell
5:59 PM
buffalo buffalo buffalo buffalo buffalo
 
semantics -> what happens, e.g., cannot assign std::string to int, syntax -> how you communicate what you want, e.g. int x;
 

« first day (442 days earlier)      last day (4489 days later) »