« first day (287 days earlier)      last day (4653 days later) » 

1:11 AM
howdy gents
 
 
1 hour later…
2:20 AM
Do you guys have a favorite design pattern?
 
4:11 AM
howdy gentiles
101
Q: Why is subtracting these two times (in 1927) giving a strange result?

FreewindIf I run the following program, which parses two date strings referencing times one second apart and compares them: public static void main(String[] args) throws ParseException { SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String str3 = "1927-12-31 23:54:07"; ...

 
man, tough getting rep on questions when it is late in the US :)
oh well, guess time for bed then
 
4:51 AM
mugiwaraaaaa
 
5:19 AM
@roymustang86 present!
@roymustang86 did you say that in Moria's voice?
 
5:43 AM
@StackedCrooked that's a really lazy implementation, just putting a lock around the get function. The performance of the entire app suffers for that first out of 1 million gets where the lock actually does something.
I'd be wary of any lib that has code like that
 
5:58 AM
@Kometes Ah
Btw, if you really need so much performance that you can't even afford a mutex lock, then you're probably better off writing your own custom specialized code.
@Kometes By the way, the Poco C++ libraries are highly esteemed for their code quality and frequently recommended by Bjarne Stroustrup.
 
@StackedCrooked I'm a fan of Strategy and Template Method. Usually together.
 
@MartinhoFernandes interesting..
 
Those are some of the few that to me don't look much like they're addressing the language's shortcomings.
 
@MartinhoFernandes are you still or just awake?
 
Just awake.
 
6:05 AM
Ah
Good for you :)
 
I guess you are still :)
 
My favorite design pattern is the decorator. Unfortunately, this is one of the patterns that is more of a workaround for lacking language features. However, I just can't help loving it.
And, yes, I haven't slept yet.
I watched two episodes of "Steins Gate" and did some programming. I also drank 3 liters of beer.
 
I like Visitor too, but it regularly annoys me. I want pattern matching or multiple dispatching! Or both.
 
The visitor pattern is cool as well, but it is also one of the patterns that compensates for a missing language feature. (JavaScript wouldn't need visitors..)
 
Yeah, it has multimethods.
There was a proposal for addition of that to C++.
rummages through old bookmarks
 
6:11 AM
Btw, according to Steve Yegge the two most commonly mentioned design patterns by job candidates are the singleton pattern and the vistor pattern. (Steve says that they refer to it as the "visitator" pattern, which is his trigger to shout "NEXT" (as in: they didn't get the job)).
 
@StackedCrooked Yeah, I read that too :)
 
:D
I stick with the decorator.
The one pattern to rule them all.
@MartinhoFernandes btw, have you read Steve's most recent blog post? It's quite cool.
 
the code should look like if (s == nullptr) { ScopedLock; if (s == nullptr) { s = new } } return s;
Every get after the first would be reduced to an atomic pointer read instead of a full lock.
 
The one about jobs at Google?
 
@MartinhoFernandes yep
 
6:14 AM
@Kometes Does that guarantee that s gets visible in other threads?
 
Btw, what are multimethods exactly? (I used to think that it is the same as overloading, but I'm probably very wrong on this.)
 
It's like overloading at runtime.
 
if its not visible it will be after it acquires the lock, that's why the second check is there
 
@Kometes You can file a bug report at poco-develop.lists.sourceforge.net.
 
You could have the same thing as the visitor pattern without the part where you pick which visit method to call.
@Kometes Under which memory model?
Double checked locking doesn't work under some memory models.
 
6:17 AM
@MartinhoFernandes what are you talking about? (it's not you, it's me)
 
There is a deluge of low quality c/c++ posts right now... ugh
 
@StackedCrooked ideone.com/S0Sw1
This would print 1 with multimethods.
 
@Josh easy rep :)
 
The overloads get picked based on the runtime type, not the compile-time type.
 
if it doesn't work for some memory model then just add barriers, but that code would work on x86
 
6:20 AM
@Kometes Would it?
 
@MartinhoFernandes I see.
 
@StackedCrooked yeah, if they were valid questions. Most if not all of them didn't even make sense.
 
Is it that bad? Let me check...
 
On a different, possibly related note, I'm about to pop my 1k cherry
 
Double-checked locking is broken on some common memory models that run on x86.
 
6:22 AM
@Josh are you saying that you're gonna lose your virginity right now? (I didn't want to hear that :$)
 
I'm hanging on 999 right now, I'm thinking about just editing some post from someone who doesn't have a good grasp on english, get my 2 points and call it a night.
 
@Josh Oh, you mean 1K rep. Heh...
 
@StackedCrooked Haha - no, I meant it as a metaphor
 
Well, you've been a member for 3 and a half months. That's quite good.
 
whoa
 
6:23 AM
I +1'd one of your answers for mentioning blowfish.
 
something magic just happend?!
Thanks :)
I love anything that comes out of Bruce Schneier
yay :)
 
Congratulations on 4 digits.
 
It's still 3 digits atm.
 
Chat caches that.
 
Thanks. I told my wife a couple hours ago I was at 999, and she asked me if anyone was paying me for this. I sent her to the RSA motivation video :) (I assume you guys have seen it - if not youtube.com/watch?v=u6XAPnuFjJc )
OoOo I can see up and down votes now :)
 
6:26 AM
I told my imaginary girlfriend I had 5k rep. And she ridiculed me for being a nerd.
I hate her.
 
@StackedCrooked The bitch!
 
number of digits is not that important, unfortunately. I met a 100k suggesting using unsigned for the radius of a circle in C++
 
Your imagination is broken.
 
@Josh yeah, I punched her in the face after she said that!
 
@6502 I see nothing inherently wrong with that.
@StackedCrooked You beat your girlfriend?
 
6:27 AM
@6502 Maybe he is from Alabama USA. I heard they passed a law making Pi a rational number. He just took it a step further and made it countable too :)
 
@MartinhoFernandes you bet, and I kicked her shins too.
 
@martinho: then you also don't understand what unsigned is in C++...
 
I do.
Please explain what you find wrong.
 
She pretended it didn't hurt, but I saw the tear in her eyes.
Ha.
 
I should expand on that - I was implying something floating point would be appropriate, because it would be easier to to make it part of operations with non-whole numbers
 
6:30 AM
after that my mom got scared and said "You're moving with your auntie and your uncle in Bel-Air."
 
@StackedCrooked Great show.
 
@Josh So, you're assuming you will be doing that.
 
Unsigned basically means bitmask in C++, as the only properties are related to two's complement. It has nothing to do with non-negative numbers. The difference of two unsigned quantities is unsigned in C++, clearly a nonsense if you want to see that as "non-negative".
 
Yeah, I assumed.
 
@6502 No, it doesn't.
 
6:31 AM
@MartinhoFernandes the mutex would be using an atomic exchange which is a locked instruction. Loads/stores are not reordered across locked instructions on x86, they have a total order.
 
Also the implicit conversion direction is from signed to unsigned... another nonsense if you want to see that as "non-negstive"
 
(Message deleted, because stuff like this get's me flagged.)
 
hehehe... yeah "every number is implicitly a non-negative number" :-)
 
unsigned means: unsigned integer.
 
no
 
6:32 AM
Quote.
 
I like the "unsigned" keyword, because it's so easy to type.
 
or, to say it better, not for C++
 
unfortunately it means that in english, and many programmers are fooled by that
 
Typing "size_t" is really hard compared to "unsigned"
 
6:33 AM
@6502 You lost me here. Can you elaborate? I think @MartinhoFernandes knows how signed numbers work (as do I). Are you saying that it was foolish to express a radius as unsigned because that is a weak way to declare it as > 0 ?
 
sizet_t being unsigned is an historical accident dating back to the 16 bit era, it has nothing to do with the concept of non-negative
 
I WANT A QUOTE FROM THE STANDARD!
Using unsigned can bite you in some situations.
 
google for size_t being unsigned and Stroustrup opinion on that, i remember finding a page where it was admitteted it was an error
 
But it is just an unsigned integer.
@6502 QUOTE.
 
@6502 I wonder how a "size type" could ever be negative? Do you have any sources to support your claim?
 
6:35 AM
Or link.
 
@6502 Yeah, give us nice LINK Mr nice person! ( I don't like being flagged).
 
In Wikipedia speak: [citation needed]
 
I'm thinking maybe we are missing something. I'm not sure what you are claiming.
 
of course the size of an object cannot be negative
this doesn't make it a two's complement bitmask however
 
@StackedCrooked Kind of slap happy right now, eh??
 
6:37 AM
consider for example this typical bug...
 
@6502 There's no mention of two's complement in the standard.
There's no mention of two's complement in the standard.
 
"slap happy"? I'm not familiar with that expression.
 
@StackedCrooked Like giddy, silly, usually as a result of sleepiness or drunkeness
It's american slang I guess, sorry
 
@Josh Probably the latter.
 
> term used to describe one's mood when sleep deprived or tired. Signs of being 'slap happy' include inane rambling, strange remarks, odd random behavior (such as giving oneself a wedgie), uncontrollable laughter at one's own jokes.
^ Urban dictionary.
 
6:38 AM
30 mins ago, by StackedCrooked
I watched two episodes of "Steins Gate" and did some programming. I also drank 3 liters of beer.
 
for (int i=0; i < v.size()-1; i++) draw_line(p[i], p[i+1]);
 
@Josh Thanks, I learned a new saying!
 
@6502 How does that change the standard text?
 
@MartinhoFernandes Wow, 3 liters of beer? I'll bet!
 
do you see the bug?
 
6:39 AM
It's a bug.
Because you used unsigned integers.
Subtraction is not a total operation on unsigned integers.
 
@StackedCrooked Np. I'll always hit you up with the most wicked lingo. You'll say I'm all that and a bag of chips, but really, I'm just down to get up.
 
@6502 And what's the bug, mind you?
 
:P
I did just mix like 3 decades there, so that's pretty contrived.
 
If you do a - b + c where a, b and c are unsigned integers and b is bigger than a but smaller than c. Does it still yield the correct result?
 
It's not a bug because you used "bitmasks"
 
6:41 AM
the bug is that the difference of two "non-negative numbers" can clearly be negative, but unsigned means someting different
 
Subtraction does not make sense with bitmasks!
 
@MartinhoFernandes This is true.
 
@6502 [citation needed]
 
exactly. but the size of a container (or the radius of a circle) is hardly described as a bitmask
 
@6502 unsigned is not the same as non-negative? Can you elaborate on that? (I'm such a noob.)
 
6:42 AM
@6502 Unsigned is not a bitmask.
> §3.9.1/4 Unsigned integers, declared unsigned, shall obey the laws of arithmetic modulo 2^n where n is the number of bits in the value representation of that particular size of integer.
 
@6502 what are you suggesting he use instead? I use unsigned integers all the time for integers where I don't need a sign...?
 
I hate that size() unsigned crap, I use this function as a workaround to return an int
 
unsigned for c++ means bitmask (because of all the arithmetic rules of the language), in english it means "non negative" for most programmers
 
@6502 QUOTE.
See my quote above?
What does it say?
Does it say bitmask?
Or does it say "unsigned integers" with arithmetic?
There is no arithmetic on bitmasks.
 
i used the term bitmask because it's easier to understand. the real technical term is "member of Z_{2^n}" if you studied that ring
 
6:44 AM
I recently learned that difference_type is equal to (size_type - 1), and that therefore size_type is guaranteed to be long enough to contain difference_type. So it's always safe to alias (typedef) difference_type to size_type.
 
@6502 I don't see any mention of rings in the standard.
 
no... indeed the definition in the standard stands formally correct, it's a LOGICAL historical error of C++
 
@6502 That's a pretty bold claim.
 
@6502 QUOTE.
 
@6502 are you one of those people they call "trolls"?
 
6:46 AM
let me search that again...
 
Extraordinary claims require extraordinary evidence.
 
@MartinhoFernandes well said.
 
@MartinhoFernandes have you ever read any of Jeff Dunteman's assembler books? I think I first read about 2's complement from there in the 2nd edition (all 16 bit asm, of course, the bad old days! )
 
No. I never read that.
I rarely read technical books.
 
IIRC one of the chapters was called "They're diggin' it out in chunks!" with reference to memory segments
 
6:48 AM
@Josh have you read "Het koekoeksnest"? It's one of the great Dutch classics.
 
@MartinhoFernandes Ah. That surprises me. You seem to be pretty technical.
@StackedCrooked No, but I heard about it less than a minute ago.
 
Well, usually I'm very sloppy with technicality.
 
:1131878 Sure that was beer?
 
@Josh what beer?
 
@StackedCrooked Ah. Are there any green fairies around, by chance?
 
6:51 AM
still searching that page... anyway see this nice answer that for reasons i don't understand has been deleted stackoverflow.com/questions/1114017/…
 
@StackedCrooked Snap.
 
@6502 That doesn't say this is a mistake in C++.
It talks about not making mistakes yourself.
 
Lol. I would have thought before tonight I would never see the intersection of "drunk" and "C++ chat"
 
In Java long is 64-bit. However, unsigned long doesn't exist in Java, therefore one is required to use either long (losing one bit) or BigInteger. Which one would you prefer?
 
6:53 AM
@StackedCrooked Huh, C#'s ulong :P
 
Now, more seriously, it depends.
 
@Marinho java :)
 
It may be essential to have that extra bit.
 
@MartinhoFernandes you might enjoy that link I just posted to. Don't recognize the language (it might be Dutch, actually, a Dutch speaker sent it to me)
 
6:55 AM
In that case BigInteger seems more appropriate.
 
@Josh WOW! Nice movie!
 
If that bit is not essential, go long.
Lemme see that video.
 
time to go to work... later guys
 
@StackedCrooked Yeah, everyone at work got a pretty good laugh today about it
 
@Josh: Oh, I've seen that before.
 
6:56 AM
@MartinhoFernandes Ah ok.
 
It's amusing, but it's a very biased portrayal.
 
@MartinhoFernandes Well, it's just meant to be goofy.
 
Yeah, I know.
Also, I think I found a new entry for my plonk file.
 
What is a plonk file?
 
Plonk is a Usenet jargon term for adding a particular poster to one's kill file such that the poster's future postings are completely ignored. It was first used in 1989, and by 1994 was a commonly used term on Usenet regarding kill file additions. The word is an example of onomatopoeia, intended to humorously represent the supposed sound of the user hitting the bottom of the kill file (imagining perhaps the kill file as a bucket). It is also sometimes given as an acronym standing for Please Log Off, Net Kook, though this is likely a backronym. Other used expressions are "put lamer on kill...
 
6:58 AM
@StackedCrooked If you did, your child would be a prick, right?
 
@StackedCrooked You should try that as a pick-up line.
 
@MartinhoFernandes Ah, yes. Makes sense.
 
@MartinhoFernandes it might just work.
 

« first day (287 days earlier)      last day (4653 days later) »