« first day (450 days earlier)      last day (4498 days later) » 

8:00 PM
@JamesMcNellis Your cat's been on your keyboard again.
 
sbi
@sehe If you think this is funny, have you seen the one this one's a reply to?
 
@sbi Of course, otherwise, it wouldn't have been funny
 
Ugh, there's a four star variable in there.
 
sbi
@RMartinhoFernandes Well, a cat does have four legs, right?
Oct 8 '11 at 0:25, by sbi
> If I were king I’d just start beheading people for writing factories that make factories. It’d collectively save us billions of dollars. And every time you make a singleton, God kills a start-up, two if you think you’ve made it thread-safe. – Landon Dyer
 
I don't see anything wrong with factories, and singletons too.
 
8:09 PM
then learn to code
 
sbi
We should set up a bot that posts as a comment to all questions in the tag the sentence "And every time you make a singleton, God kills a start-up, two if you think you’ve made it thread-safe." And when the bot is through, it just starts all over, replacing the old comments with a new copy, so everyone in that tag is so annoyed, they stop using singletons just because they can't endure the comments anymore.
 
it's like goto %) everyone heard somewhere that it's an evil
 
no, I heard it from myself
I know exactly why goto is bad, why factories are a pile of donkey shite, and why Singletons should be annihilated on sight
I didn't hear it from somewhere
 
ok.
 
well, technically, factories aren't so bad
 
sbi
8:10 PM
@Abyx While I wouldn't share @Dead's wording, I do share his sentiments.
 
they have a place
 
everything have a place.
 
Except singletons.
 
it's just about ten times smaller than the Java crowd would have you believe
and no, Singletons don't have a place
anywhere
ever
 
you can replace singleton with global variable %)
 
8:12 PM
@Abyx And how does that make a singleton have a place?
 
so, global variables are evil too?
 
uh
yes, global variables are really, really bad
 
Arrghh, so you don't even know what a singleton is, huh?
 
sbi
Damn, my google fu is failing me. There was this great article, where someone showed how to make a simple fnargle algorithm in Java, and then kept adding to and complicating the thing, until it almost collapsed under its own weight. And only then he said "this is all bullshit". What was it? Where was this?
 
Singletons are even worse, though
 
8:13 PM
singletons are better than global variables
 
ahahahahahaha
 
Gosh what?
@Abyx Name one advantage.
 
they have all of the global-access massive problems, and then the even worse fact of the single instance
 
sbi
202
Q: What is so bad about Singletons?

Ewan MakepeaceThe Singleton pattern is a fully paid up member of the GoF Patterns Book but lately seems rather orphaned by the developer world. I still use quite a lot of singletons, especially for Factory classes, and while you have to be a bit careful about multithreading issues (like any class actually), I ...

 
@RMartinhoFernandes singleton can guarantee that it's always constructed when accessed
 
8:14 PM
@Abyx You don't need the "single instance" crap for that.
 
Ell
one thing I dont understand is
 
also, in C++, singletons can be header-only
 
Ell
why use singletons over global variables?
when singletons are actually applicable - aren't global variables?
 
Why use global variables?
 
Ell
access to a shared resource?
 
8:16 PM
Here's a challenge: name an advantage of a singleton over "static variable in a function".
 
@sbi "All samples of radioactive material are completely harmless"
 
Ell
im just thinking, theres no need for getInstance when you can just use a global variable?
 
@RMartinhoFernandes static variable in a function is not thread-safe in C++03
 
@Abyx A singleton is not magically thread safe either.
You have to make it thread safe yourself anyway.
So, they're on the same ground on that.
Next.
 
sbi
8:17 PM
@Abyx Just as a singleton isn't. But you can make it thread-safe (just as a singleton).
> And every time you make a singleton, God kills a start-up, two if you think you’ve made it thread-safe.
 
Ell
i dont understand thread safety :s
 
Don't worry, no one does.
 
Ell
iv never done multithreaded stuff so i dont really see what the big deal about it is
why is it bad if two things call a method at the same time?
or whatever the problem is
 
@Ell The problem is manipulating shared state at the same time.
It's bad because you can't maintain the invariants (unless you make it thread-safe of course :).
 
 
8:20 PM
The fact that it's not necessary for anything.
 
Ell
@RMartinhoFernandes what are invariants? o.O
 
@RMartinhoFernandes what's "it" ?
 
@Abyx The singleton template.
That's just a singleton template. The real singletons are elsewhere.
 
sbi
@Ell An invariant is, for example, that list.size() will always (invariantly) return the number of nodes in the list. While you're in insert(), this is hard to make sure. That's no problem in single-threaded code, but might become in MT code.
 
who said that singletons are necessary for anything?
 
8:22 PM
@Abyx So, singletons are not necessary?
I agree with that.
 
Ell
but then again nor is anything
we will all die eventually so why bother :L
 
well, I misread it :( (as "everything")
 
But if you want, the singleton template in Boost.Serialization is used, for example in void_cast.hpp.
 
Ell
@sbi apologies, I'm still struggling with the definition :s
 
anyway, in lot of cases, program will have global state, and I think that singleton is right way to deal with it
 
8:25 PM
@Ell Invariants are properties you can always say about the state of an object.
@Abyx But a singleton is not "global state".
 
@Abyx Programs with global state should be refactored to avoid global state wherever possible.
 
A singleton is a class with a single instance that is accessible everywhere.
 
and secondly, there's absolutely no need to go from "I need global state" to "I need a Singleton"
 
It's global state but worse.
 
Ell
"the only time I would use a singleton is to provide access to a shared resource" says me
 
8:26 PM
@Ell I would never use a Singleton.
 
@Ell That needs an object. It doesn't need a class that can't be instantiated.
 
Ell
@RMartinhoFernandes but i thought singletons could be instantised :O
you just do Singleton.getInstance().blah()
 
@Ell Taking away the ability to instantiate it is the whole point of a singleton!
@Ell That's taking an existing instance.
You can't do Singleton x;
 
Ell
Oh fair enough
hmmm
 
@RMartinhoFernandes class Foo {}; class FooSingleton : Foo { static FooSingleton& instance(); }; - Foo can have multiple instances, FooSingleton is singleton.
 
8:28 PM
@Abyx That's pointless, then. Just make it a static in a free function.
Why do you want a class that can't be instantiated and provides nothing but a static function?
 
@RMartinhoFernandes why free function?
 
This is C++, you don't need to stick everything in a class.
 
Ell
well at least put it in a namespace
i put everything in a namespace
it just seems neat and the right thing to do
 
and stick everything in a free functions too.
 
Then you're not arguing in favour of singletons.
 
8:30 PM
@Ell It is.
 
FooSingleton is namespace for instance
 
Ell
yaay I am right for once!
 
How is everything in one namespace better than nothing?
 
The point is, you changed what the GoF said a singleton was to make it not evil.
 
because it doesn't conflict with the next library that puts everything in one, different, namespace?
 
8:31 PM
Because the GoF singleton exists because a class is soooo dangerous that it can't be instantiated.
 
GoF book was written in '95, now it's 2011, things changed
 
Ell
argghhh somebody stop me listening to this pacman song! ARGHHH
 
now singleton != GoF singleton
 
I just spent an hour debugging my "find" function. Turns out it was fine. bool iterator::operator!=(const iterator& rhs) const {return data==rhs.data;}
 
@Abyx No one writes singletons like you mentioned.
Go look around.
 
8:33 PM
guys can you give me your oppinion on this stackoverflow.com/questions/8794305/…
 
They're all GoF singletons.
 
@MooingDuck GG :D
 
races again =\
 
Ell
would anyone here call the c++ library "rich"?
 
Because it has loads of gold.
 
8:35 PM
@RMartinhoFernandes well, my singletons are unusual singletons, and they aren't evil
 
you can't just re-define it
it's not a singleton; don't call it a singleton
 
Ell
i mean like - why doesnt the c++ string class have things like "reverse!" and "upper!" etc.
like the ruby one
 
uh
std::string reverse(other.rbegin(), other.rend());
?
 
@Ell The C++ string class is well-known for having too many functions already :)
 
@Ell because we have std::transform
 
8:36 PM
@DeadMG asdasd! would be in-place mutating operation, IIRC
 
Not as many as the Ruby string class, but well...
 
@DeadMG looks like a crap, comparing to other.reverse();
 
Ell
i just love ruby tbh :L
 
@Abyx Waaah waaah
what the fuck does it matter what it looks like?
what matters is that it reverses a string
 
Ell
yeah but its much less obvious
well
 
8:37 PM
In-place toupper can be done with std::transform.
 
@Abyx use #include <boost/range/algorithm.hpp> and happily write boost::sort(str); boost::reverse(vector1, vector2); the rest of your life
 
Ell
not obvious - its more verbose
 
damn had to edit that post too many times before it made sense. Hope not too many noticed :)
 
Ell
I have trouble differenciating from a duck-typed language with a dynamic language
 
sbi
@DeadMG Syntax matters.
Still, wouldn't std::reverse(str.begin(), str.end()) work?
 
Ell
8:39 PM
can you have a static typed dynamic language?
 
that's because virtually the only place you can find static duck typing is C++'s templates
 
Ell
meh i'l google it
 
@Ell Those are opposites.
But you can have languages with both static and dynamic typing (look at C#).
 
sbi
Actually, I can't remember whether I have, in the last twenty years as a programmer, ever needed to reverse a string. Probably not. When would you need to do this?
 
Xeo
@sbi In an interview and a puzzle / quiz.
 
8:40 PM
@sbi To test for palindromness!
 
@sbi never. to_lower is a better example of his thought process though
 
Xeo
That's about it though. Same for the palindrom tests
 
Ell
@RMartinhoFernandes I thought "dynamic/static typing" differed from "dynamic languages"?
 
I still like std::equal for palindrome
 
sbi
@RMartinhoFernandes Yeah. I think I have never written a palindrome-testing algorithm. Did I miss out on something important?
 
Xeo
8:41 PM
I mean, most of the time you don't even need a reversed string but a reversed view of a string. That is, string.rbegin() and string.rend().
 
@sbi No, it's really useless.
 
sbi
@Xeo Yeah, it's a good example for an algorithm to implement for students. It's practically almost useless, though.
 
Xeo
I recently really came to like this view thingy
 
@sbi bubble_sort
 
you know
 
sbi
8:42 PM
@MooingDuck Actually, to_lower() and to_upper() are even worse. Except for English, in which languages does this really work? Certainly not in German.
 
I will never be satisfied with this damn parser
 
@Ell Oh, I misread what you said. I don't think you can have a "statically typed dynamic language". You can't do a lot of the dynamic language magic with static types.
 
sbi
2 hours ago, by jalf
@DeadMG because some of us prefer questions to be answered in our lifetime ;)
 
lol
 
@sbi <cough>You could of course use it as an optimization before calling std::reverse on a very large container - avoid the case where the output would be identical</cough>
 
sbi
8:43 PM
@sehe Haha! I don't think I ever, in twenty years as a programmer, wanted to reverse a very large container.
 
@sehe that can be slower on average if you aren't careful.
 
@sbi What if you want to test a container for palindromness?
 
@sbi Every monday, when collect the garbage, I reverse a large standard container in top-down, last-in first-out fashion. Classic procedure, you know.
 
I could write my own LR parser generator
I mean, how hard can it be? :P
 
@MooingDuck <cough>fuck, he noticed</cough>
 
8:45 PM
You're sick?
You should take care of that cough.
 
sbi
4 mins ago, by sbi
@RMartinhoFernandes Yeah. I think I have never written a palindrome-testing algorithm. Did I miss out on something important?
 
Very much so. And my <funny>tags</funny> aren't coming through clearly today
 
Come down with a case of xml fever?
 
4 mins ago, by R. Martinho Fernandes
@sbi No, it's really useless.
 
sbi
@sehe Actually, they are.
@RMartinhoFernandes I feel like we're going in circles.
 
Xeo
8:46 PM
@sehe cont.rbegin() and cont.rend(). Really, I see no need whatsoever for reverse().
 
ok, slightly more seriously
how hard can it be to write an LR parser generator?
 
Btw, is WideC heteroiconic?
 
wtf is that?
 
@DeadMG We are still awaiting the verdict. Some of the contestants in our lab project are not quite Dead-enough-MGs yet and so we can't call the winner yet
 
Ell
it has different icons
for parser and lexer
sorry im just trolling
 
8:48 PM
@Ell Dammit. You troll, you don't apologize, takes all the fun out of it. Tits or bust
2
 
lol
@DeadMG The opposite of homoiconic.
 
well
 
Ell
@sehe but I feel bad afterwards :O
 
Languages like Lisp are homoiconic: the representation of data and code is the same.
 
@RMartinhoFernandes Languages like C++ are homoiconic - oriented: their source code and machine code representations both consist of nothing but 0's and 1s
 
8:49 PM
Machine code is homoiconic too.
 
why in the name of myself would I ever want to enforce programmer data to be represented in any specific structure?
 
@sehe lol
lol @ "in the name of myself".
 
Ell
@sehe doesnt all data consist of nothing but 0's and 1's?
 
No.
Not all data is digital.
 
well, I was going to write "in the name of the Lord Jesus", except I don't believe in Jesus and frequently invoke his name in rather offensive ways
 
Ell
well yeah i know I mean all digital data
 
@RMartinhoFernandes You know, Larry Wall? "God". Guido van Rossum? "God". Bertrand Meyer? "God". So, it makes sense for the Chief Architect of the world next dominant programming language to start invoking his own name for authority
 
Ell
and since when do we have analog computers & compilers?
oh wow yeah ternary o.O
 
@Ell trolling like a pro. phew, you still have it in you
 
Ell
how about quantum computers?
 
8:52 PM
@sehe Larry Wall doesn't think of himself as God.
 
well
 
@Ell We have analog communication channels. You know, channels that transmit data.
 
@RMartinhoFernandes I didn't say he does...
 
I don't know about the others.
 
I figure that my own name carries more than enough authority, why would I want to invoke the name of God?
 
8:53 PM
But Larry sees himself more like a prophet.
 
Muhahahahaha!med
 
@DeadMG The same reason you would want to reverse a string. "Dog".reverse()
 
Ell
i dont see how ternary logic works (I can understand data storage)
like what does
0 && 2 mean?
0 and 2
 
@Ell It's easy: you have true, false, and file not found.
4
And then just work up from there.
 
8:54 PM
@Ell forget it. It is antiquated in 5 months
 
Ell
@RMartinhoFernandes so is true & file not found = file not found?
does file not found just always give file not found in every expression?
 
sbi
@RMartinhoFernandes The classic tribool, eh? There's no upward from there, it's only downward from thereon.
 
Ell
lololol
 
@Ell I believe there is more than one way to do it (Tim Toady). You can have file not found as the absorbing element or as the neutral element.
 
sbi
8:56 PM
@Ell You are trying to apply boolean (aka binary) operations to ternary logic. It means the same as "5 && 42": nothing.
 
lol
 
A tri-state with five possible values, but only two are supported. Can you come up with a design that is more braindead than this?
 
Ell
a tri state with 0 possible values :L
it just doesn't exist .O
o.O
 
@sbi No, there are interesting properties of the expression 5 && 42. Mainly, that it has the same Half-life and criticall mass as "Hello" ~= "World" in WideC
 
there was a version of Lua which had bool values that could be both true and false
 

« first day (450 days earlier)      last day (4498 days later) »