« first day (312 days earlier)      last day (4629 days later) » 

12:35 AM
Request for comments:
I'm writing a parser for Python / JavaScript / PHP.
(Well, not a single parser for all 3 of those - a separate one for each of them.)
Anyone see any obvious flaws with the approach?
 
room topic changed to Lounge<C++>: It's been 0.5 seconds since we changed the room description. [c++] [c++11]
 
12:50 AM
:P
Any comments on my approach?
 
I can't see any obvious problems with it. But I'm not at full speed right now :)
 
1:02 AM
@George: dunno, is the problem that a token can extend over two or more lines?
just represent linebreak as a single character, like, uh, \n?
might also help to do tokenization (conceptually) before higher level parsing
 
@AlfPSteinbach Oh sorry...
...this is the tokenization step.
I guess I kind of mixed things up a bit.
 
well, no problem then :-)
 
Great.
Thanks for looking over it.
 
0
Q: Please remove the C++11 tag synonym

Martinho FernandesSometime ago there was a bit of a mess around the tag synonyms of c++11 and c++0x. At the time there was some reluctance to accept the c++11 tag as the master tag, so everything remained as it was. But now that the FDIS was unanimously approved, I hope that any doubts about the "11" are now gone....

 
 
2 hours later…
3:32 AM
Hello C++ people, I feel somewhat silly asking especially since I have an open question asking the same thing... but can someone please explain to me why I should use private as an access modifier rather than public when it comes to class members functions / variables?
It just seems like a lot of code to make functionality even harder...
 
Well, I wrote an answer to that question. Is there something unclear about it?
 
Well, specifically, like... when I'm reading any book about coding they seem to convey the idea that it is literally "unsafe" to use public variables / functions in some cases. Also, is there a proper way to do a get from a C++ standpoint, as most of my knowledge seems to be more c-style than C++ style.
 
@HunderingThooves You should in general not provide getters and setters. They're Evil(TM). At least for beginners. Once you get out of that habit, it's much easier to understand private and public. Of course there are exceptions to that rule, but in general.
3
 
Access qualification is usually emphasized in more object-oriented design approaches.
So if you're reading a book about OO, it likely encourages you to write an interface first, and to include access qualification in that interface.
 
Also, let me emphasize: getSin is a command to dance, play cards, drink alcohol, have sex, and generally have a good time. sin is a function to compute a sine value.
3
 
3:41 AM
Hahahaha
 
But C++ does a lot more than OO, and I haven't found that approach to be the best.
 
What approach do you find to be best?
 
The first thing I write is whatever I'm most certain about :D
 
As I've approached it from a more 'problem solving' standpoint, and I've seen decent results with that, but when it comes to object handling I feel like I'm lacking.
Furthermore, I feel like I'm WAY behind the curve around here because I don't know the first thing about boost.
 
Don't look for solutions in search of problems…
 
3:44 AM
Well, I never plan to, but it seems like an endless feedback loop, the more I learn, the more it seems I need to learn.
 
Dunno. At least you're learning :)
 
Fair enough.
Can you give me your opinion then. Under what circumstances should I use private as an access modifier until I know more about how to use it, or not at all.?
 
As much as possible.
The shorter you can make your public interface the better.
3
 
Well, private implies it's only going to be used internally by the class. And having an accessor implies that there might be side effects to the variable.
So, a private accessor should only be used when you have an internal variable with side effects. For example, player::set_name could graphically update the name in the corner of the screen.
 
I think simple explanation is to imagine that you're talking to Someone Else who's going to be using your class. And you are planning on maybe modifying the class later, so you want to not be locked in by what the Someone Else's code uses of your class. And then you saying "private", that means "None of yer f***king business! Don't even look at it!". :-)
 
3:49 AM
Sorry, I got terminology mixed up a bit there…
 
uh, was that too strong?
but anyway, like that
 
Hrm, it seems like the general idea is that it should be private if it's not going to be used by other classes, or if it's something that I generally want to be "unseen"
 
Right.
 
Rockin, thanks for taking the time to clarify that for me. Do either of you gentlemen know of a good site to start reading more about boost? I read the new user guide on boost.org, but it didn't really seem to satiate my questions about using it effectively, nor did the documentation strike me as being very 'readable'
 
3:55 AM
The general idea is pretty simple: you define what something does as public -- and anything/everything related to how it does that is private. In reality, it's rarely that simple (the line between "what" and "how" isn't always clean), but it's the general idea of what you're trying to accomplish in any case.
3
 
@JerryCoffin: Very well put.
 
@Potatoswatter Thank you.
 
@HunderingThooves Boost is a random collection of informal proposals for the Standard Library. Since C++11 just doubled the size of that Library, it might be a good idea to see what's in there first… unfortunately I took the approach of "just learn Standardese" so I can't point at a good, accessible overview.
 
Is C++ 11 officially a standard now?
Or well "0x" ?
 
It's been approved, it's a matter of finishing up the bureaucracy and publishing it.
 
4:02 AM
Ahhhh, so, more waiting. Hasn't it been in the waiting phase for quite some time?
 
"Publishing" in this context meaning dead trees. The final text was put online and then later pulled.
So if you happen to have a copy of working draft N3290, there is no wait.
 
You can always build the document from source.
 
@RMartinhoFernandes That's public, and wasn't pulled?
There was a whole slew of documents that were put behind the firewall all at once.
 
@Potatoswatter Keep in mind that being in Boost doesn't necessarily mean something is proposed (even informally) for the standard either. A lot of additions to the standard come from Boost, but there's quite a bit in Boost that I'm pretty sure nobody really thinks belongs in the standard, at least without substantial modification. Some of it explores what can be done with the current language, to help clarify where/if the language needs additions to better support library writers.
 
4:13 AM
@JerryCoffin Yeah. It's evolved into a sort of halo for the standard. There are some crufty old libraries too, though.
 
And some new wacky ones.
@DeadMG: Have you seen this old "metacode" proposal open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1471.pdf? I think it might be interesting to you.
 
@Potatoswatter Well, I was thinking of things like its compatibility library (by definition not standard material) or Boost Wave (really just an implementation of part of what's already specified in the standard, but not as part of the library).
 
4:30 AM
could anyone find google's sexagecimal notation proposal? i think it was funny. :-)
 
hey quick regex question if you don't mind. I have a bunch of text in a file that starts with [0] or [1] or any number less than 32. I want to match all the lines that DON'T start with the zero [0]
^[[^0]]
 
Ami
4:51 AM
I just answered the day's most popular question...the accepted answer has 113 upvotes and I'm pretty sure that answer is completely wrong (sub-optimal)
87
Q: Find an integer not among four billion given ones

SecureFishIt is an interview question: Given an input file with four billion integers, provide an algorithm to generate an integer which is not contained in the file. Assume you have 1GB memory. Follow up with what you would do if you have only 10MB of memory. My analysis: The size of the file is 4×...

 
@Xaade My best guess is that he is talking about single dispatch.
 
Ami
My answer:
http://stackoverflow.com/questions/7153659/find-an-integer-not-among-four-billion-given-ones/7170524#7170524
any thoughts?
 
@Ami The answer is exactly two words: Bloom filter.
 
Ami
@Potatoswatter, never heard of it...reading about them now
I don't think that's more efficient than the method I outlined in my answer
Just realized why my answer was wrong
and deleted it
 
It only works if the cardinality of the set of numbers equals their length.
 
Ami
5:04 AM
correct
I didn't think of that
actually...I think I can salvage my answer
 
Hmm… if you try to work around it by extending the numbers or the "accumulator register", then you end up increasing the space complexity and developing a sort algo.
 
Ami
if the amount of bits in the output digit is greater than the amount of bits in any number under inspection, that number can be skipped without any loss of generality
but if we assume a fixed number of bits to an int...
it fails again
goodnight
 
gnight, don't let the algorithms bite
 
5:41 AM
hm, that was an interesting question, because it has a conflict between theory and practice. in theory the answer single pass updating bitmap, is good. but in practice, on a windows machine you can expect a lot of swapping when you're using a large fraction of available address space, so that this method may be rather sub-optimal. not sure what would be best then. as the old saying goes, measure, measure, measure.
 
Bloom filters are like magic. This problem can easily be solved in 10 MB.
 
what's a bloom filter?
 
Wikipedia has a very good explanation. It's just a bitmap of hash values.
The trick is that you insert several hash values for each set element inserted.
 
hm, i don' understand how that buys anything
i think with 10 MB you can just check buckets
 
So, say the element 15 is represented by setting 2, 8, and 25.
A bloom filter is essentially like very smart buckets.
12
A: Given a 1TB data set on disk with around 1KB per data record, how can I find duplicates using 512MB RAM and infinite disk space?

PotatoswatterUse a Bloom filter: a table of simultaneous hashes. According to Wikipedia, the optimal number of hashes is ln(2) * 2^32 / 2^30 ≈ 2.77 ≈ 3. (Hmm, plugging in 4 gives fewer false positives but 3 is still better for this application.) This means that you have a table of 512 megabytes, or 4 gigabits...

 
5:47 AM
but, we're talking 4 billion numbers, that's 32 bit, which is 16+16 bits. so a first pass can check all 65.526 most significant part buckets. then second pass can check all values in some bucket that has a unused number. how can bloom be faster than that, i.e., avoid a second pass?
 
You're basically reinventing the bloom filter, though. You've got essentially two hash functions and two hash tables. It's simply more efficient to unify those into one bigger table.
 
hm, will read up on it, later.
thanks for mentioning it :-)
 
6:11 AM
Hmm, now I'm starting to doubt whether that really is the solution…
 
6:35 AM
Ah, easy. 4 billion numbers out of 4.3 billion means 6.8% of the numbers are correct guesses. If you fill up 10 MB with 2.5 M sorted random guesses, then go through the file and eliminate matches, then the probability of failing to find one is (4/4.3)^2.5M = too small for my calculators to handle.
If there were only 1500 numbers missing instead of 300M, then things would start to change…
 
6:57 AM
@AlfPSteinbach with a bloom filter you just compute several hashes, and if they all match, you assume you've found the correct item, without doing an actual equality check on the item itself
so you have a (small) risk of getting false positives, but you avoid having to actually compare objects for equality
afaik
 
@jalf: if you're looking at that question, upvote this answer -
4
A: Find an integer not among four billion given ones

leftaroundaboutEDIT Ok, this wasn't quite thought through as it assumes the integers in the file follow some static distribution. Apparently they don't need to, but even then one should try this: There are ≈4.3 billion 32-bit integers. We don't know how they are distributed in the file, but the worst case is...

 
@Potatoswatter I wasn't, actually. Just commenting on what you guys were saying here :)
 
Well, I still wouldn't stop you from upvoting it in ignorance ;v)
 
 
1 hour later…
sbi
8:17 AM
9 hours ago, by DeadMG
fine by me because I'm the Lord his God and he would never dare to be angry at me
@DeadMG For a god, your memory is pretty lousy.
@RMartinhoFernandes Actually, that was a joke (I thought that was obvious?), although it seemed well-received. And it only annoys me when every message is starred (or every other, or whatever), rather than witty ones.
Haha!
Regular expression to search for Gadaffi http://t.co/RnA97jW
That's a good one!
 
8:39 AM
Should we add to the room info?
 
sbi
@RMartinhoFernandes Just go ahead and do it.
 
I have put a C++ prj to compile. Its compiling for more than 30 mins and linking for 10 mins.. uff!!
 
Oh, and btw, I suggested the correct synonym between and . We don't need a schism on this thing, and obviously is the winner. Please vote.
 
sbi
@VenkateshKumar Then it's either a big project, or a badly decoupled one (or both).
 
Its both. :-)
 
8:43 AM
room topic changed to Lounge<C++>: It's been 0.5 seconds since we changed the room description. [c++] [c++11] [c++-faq]
 
@RMartinhoFernandes great, I can't. Not enough rep in c++11 :)
 
sbi
@RMartinhoFernandes The problem is that you are the only one having the required rep in the tag to vote for this.
 
What?
I retagged a bunch of questions. I thought those would be enough :(
And from looking at the tag top users page, seems like there are 11 users that can vote.
(But yeah, none of you is there.)
 
sbi
@RMartinhoFernandes Oh, I didn't look closely enough. You only need 2.5k rep for suggesting a synonym. Well, I also re-tagged a few of mine, so I think I'll be able to vote tomorrow. :)
 
Is the new std actually published then?
 
8:48 AM
My old C++ prj compiles to a 14 MB DLL Goodness me!!!
 
Good grief! Thank god we're all running on several gigas of RAM and bordering on teras of hard disk.
 
Eeeeek! Interview tomorrow, how to prepare best?
 
@TonyTheTiger get a good night's sleep
2
 
@jalf hahah yes, that too :)
 
Try not to get anxious. I don't know what works for you, but do whatever helps you best against anxiety.
 
8:51 AM
hmmm, good tip, yes.
 
Read the company's website, make sure you have a reasonable idea about what they do. Refresh some of the things you might want to tell them about (for example, browse over your old projects so they're fresh in your mind if they ask you to talk about them)
other than that, just try to stay calm, I guess ;)
 
ah yes, I will do that
 
@KillianDS Not yet. The "publishing" step is what is left. It's been unanimously approved.
 
oh, and spend 5 minutes making up an answer to the inevitable "so where do you see yourself in 5 years" question ;)
 
@Tony: For technical questions: show your reasoning (often way more important than the actual answer) and if you really get stuck, don't be afraid to ask questions.
@jalf: hehe, I was actually surprised that I wasn't asked that question for my current job :)
 
9:02 AM
"Where do you see yourself in 5 years?" "I'll be 5 years from now. I still haven't made up my mind about the other three dimensions."
 
sbi
9:13 AM
@TonyTheTiger Remember: You are interviewing them as much as they are interviewing you. You go there to see whether they like you and you like them. If you don't like them, you don't want to work there. If they don't like you, you don't want to work there either. So just go there and figure this out. No need for desperation.
 
> We were hiring and it was our lucky day: a female candidate had applied for the job! As a team of three male programmers who would likely get alarming results on the autism test, we knew that she would be a very welcome addition to our team.
Why does this sound wrong to me?
 
@sbi and as a corrolary to that: try to prepare a few questions for them as well. As @sbi said, there are definitely things you'll want to know about them, plus it makes you seem more interested and engaged, and keeps the interview from being purely a one-sided interrogation. ;)
 
sbi
@RMartinhoFernandes Yeah, why?
 
can ask about anything, really, their work environment, policies towards this and that, or whether they use some form of continuous integration or write unit tests
 
Ask if they have programmisses.
And programmesses too.
@sbi I don't like the sexist undertones, and the implication of something about autist people.
And the rest of the article doesn't help much.
 
9:24 AM
Hah! The "male services" one is funny. :)
 
sbi
@RMartinhoFernandes I really can't follow you there. As a fact, an unusual number of programmers I have met in this industry seem to have a slight Asperger syndrome. If we're honest, it's common among us. (In fact, it might include me.)
And, as a team of one sex only, where's the harm in enjoying the thought of getting a new team member of the opposite sex? If it was the other way around, would you consider it sexist? If not, it probably isn't, at least not according to my definition.
 
@sbi And why would she be a welcome addition to the team because they had mild autistic symptoms?
 
@RMartinhoFernandes yeah, sounds pretty bad to me too. It's not just you :)
 
sbi
@RMartinhoFernandes Because someone with a reasonable set of social skills would help a team to get along?
 
@sbi yeah, but it doesn't say anything about her social skills, just that she's female
 
9:30 AM
Eh… it makes sense to have someone who can facilitate communication, if that tends to be a problem. Apple had a mostly-female staff of inter-project coordinators when I was tehre.
 
iow, her gender by itself is the reason she's a "very welcome addition to the team", is the impression the article gives
 
But that story is basically all about prejudice, and unapologetically.
 
@sbi She's a programmer (at least they think so), so she probably scores "alarmingly" on an autism test as well, no?
 
sbi
@jalf Well, on average women do have higher social skills than men, and I found this to be true in this industry.
@RMartinhoFernandes Not necessarily. She might do so among kindergarten teachers, but not among programmers.
 
@sbi yes, but the way the article is written, it's pretty clear that it's just a matter of "hey, a woman? DO WANT"
 
sbi
9:32 AM
@jalf Again, would you consider it sexist if a team of women would show the same attitude towards a potential male candidate for their team?
 
@sbi yep. Pretty much by definition. Isn't that what sexism means? Giving people different treatment based on their gender, rather than their actual skills/qualifications/abilities (for example, their social skills)
 
Of course it's sexist. It doesn't have to feel negative to be sexist. Many women engineers often get a kick out of the attention. The problem is when it's tiresome or alienating. But that's not all the time.
 
@Potatoswatter I doubt "many" get a kick out of it. Most just put up with it, I'd imagine
 
Help! I need to talk about programming with someone.
 
sbi
@Ancide If you want to talk about programming, this room is not for you. :)
 
9:35 AM
We're talking about sex.
 
@Ancide Programming or sex.
 
sbi
Sexism, also known as gender discrimination or sex discrimination, is the application of the belief or attitude that there are characteristics implicit to one's gender that indirectly affect one's abilities in unrelated areas. It is a form of discrimination or devaluation based on a person's sex, with such attitudes being based on beliefs in traditional stereotypes of gender roles. The term sexism is most often used in relation with discrimination against women, within the context of patriarchy. Sexism involves hatred of, or prejudice towards a gender as a whole or the blind application...
 
Damn
I just feel so alone
 
sbi
I can see no discrimination in looking forward to a potential candidate joining the team.
 
Being the only programmer at the office
I want to talk about algorithms and analysis. But no one understands me :/
 
9:37 AM
Did you try wearing a hardhat and tight-fitting jeans?
 
@sbi perhaps you should read the article then. Their excitement isn't about a potential candidate joining the team, but about a woman joining their team, and their (prejudiced?) notions of what her gender would imply
I think your own wiki quote says it pretty well: "It is a form of discrimination or devaluation based on a person's sex, with such attitudes being based on beliefs in traditional stereotypes of gender roles"
 
sbi
@jalf I have already read it.
@jalf And what's devaluating in expecting skills in others which you miss?
 
Skills like being hot?
> We still don't have a hot programiss on the team... which is probably for the better.
 
sbi
@RMartinhoFernandes That's not what you quoted (although I do remember that the article mentioned their expecteation, and I do agree that that's pretty low, and could probably be called sexist).
 
@sbi it is pretty devaluating for a programmer to be considered a good candidate solely because of her looks or gender
 
sbi
9:43 AM
@jalf Again, the looks is not what Martinho quoted and to which I asked what's wrong with it.
 
@sbi Ok, I can understand that then. I should probably have quoted the second paragraph instead.
 
I honestly don't know where you see the whole "she might have great social skills which we lack, so she would really improve our team" angle. It's not there in the article. It just goes on about her being female and being hot
 
sbi
@RMartinhoFernandes Yes, probably. I asked first, and went and read the article later.
 
so, in other news, hitting 'rebuild' when you intended to click 'build' can be fairly annoying
 
sbi
30 mins ago, by R. Martinho Fernandes
> We were hiring and it was our lucky day: a female candidate had applied for the job! As a team of three male programmers who would likely get alarming results on the autism test, we knew that she would be a very welcome addition to our team.
 
9:44 AM
@jalf The story said she would lighten the mood and put smileys in comments
 
sbi
I was asking what's wrong with the attitude quoted in this message.
 
@Potatoswatter yep, which I'd consider sexist rather than "great social skills"
 
sbi
@jalf I can see where you're coming from, but I still maintain that this interpretation (of what @Potatoswatter quoted, just to be sure) is overly PC.
 
If their main problem is doom and gloom, then that would be a needed social skill.
I'm not saying it's a good way of thinking, but there are at least two perspectives anyway.
 
@sbi I'd say the "it was our lucky day: a female candidate had applied for the job" part is pretty hard to interpret as not-sexist. The autism part doesn't bother me though, if that's what everyone else is focusing on
 
9:53 AM
Why is it sexist?
Men are excited about women.
Sexist, IMHO, would be if they said "it was our lucky day: a female candidate had applied for the job, we can pay her only 80% of the men's sallary"
 
Ah, we have hiked and trekked and made it to the slippery slope!
 
We have female programmer in team
 
@wilx but once men let it affect their work practices, it becomes sexist
and they do when they consider it an advantage in itself that someone is female
 
@wilx How heteronormative. (It's also wrong on other levels.)
 

« first day (312 days earlier)      last day (4629 days later) »