11:01 AM
Then what's the point of a sorting algorithm that doesn't work well with unsorted data?

It performs really well with data sets with patterns.
And when you generate data, you often end up with patterns.
Here you go. You can see that `pdqsort` tends to beat them all above 10~15 elements.

@IsmaelMiguel The answer is easy though, a shame answering off-topic questions is a bad habit.
@Phrancis Today was my last day as well :)

@Morwenn Try to get your hands on their sourcecode and try to optimize on pdqsort. If possible
@Mast I don't know the answer. Except a big "NO!"

@IsmaelMiguel I don't think it'll be doable in any easy way. But I can simply make my algorithm fall back to `pdqsort` for values of `N` greater than 10.

That's almost like cheating
But not a bad idea

11:08 AM
That's actually how lots of stuff works in practice

Now, you need to test pdqsort and std::sort with 100 elements.

Sorting algorithms are always "cheating": most of them use two or three different sorting algorithms depending on the size of the input.

The one that beast the other, wins

Anyone with a comment hammer around?

`pdqsort` already has its own benchmarks I can rely on.

11:09 AM
@Morwenn I think I can make a sorting algorithm for lists of size n <= 1
2

@skiwi `cppsort::sort` already has one :D

@Morwenn Saves on your work then
@Morwenn pdqsort seems the best choice

No lurkers around when you need them...
Ah well, can we mass flag the following comment please?
The code would be funnier if the question is are you gay, or something. — Edwin 4 hours ago

@IsmaelMiguel `timsort` beats it for patterns but is not as good for shuffled input. On average, `pdqsort` indeed seems to be the best truly general purpose one.

@Mast Why?
@Morwenn It barfs a bit on patterned data, but does quite well on random crap

11:14 AM
It barfs less than the standard library sort :p

True, true on that
I should make my own sorting as well
I will call it iSort, and sell it for 300x it's value

@IsmaelMiguel Offensive, not constructive, too chatty, pick one you like.

@Mast Too chatty it is. I don't see offensiveness. I've had a comment somewhat like that before. I laughed my a\$\$ off and edited the code to match the comment. easy +10

Let's put it this way: the comment is not doing anything remotely useful/helpful/funny over there.

That's true.
I'm just saying it isn't offensive in my opinion
Other than that, burminate it

11:22 AM
oh, that's very enjoyable....

On what took me 11 questions and 119 answers on Stack Overflow to get 1773 reputation, took me 19 questions and 23 answers to get 1647 reputation here

restricting a subselect over the same table with the primary key.. possibly or not?

Possible
I do it a lot
If that is what I think

column reference pk is ambiguous...

Change the names of the tables
Example:

11:24 AM
@Vogel612 I wouldn't see a reason why it wouldn't be possible.

`select * from my_table as table1 where (select 1 from my_table as table2 where table2.pk > table1.pk)`
That's pseudocode

hmm... yes that seems simple enough.
thanks

You're welcome
Hope it works

hmm... doesn't like it..

Can you show a tiny bit of SQL?

11:27 AM
okay I didn't know that you could `UPDATE table AS ..`
now it works

You can
You can even do a join in the update
To update 2 tables at the same time

TIL

Look at this query:
`UPDATE site a INNER JOIN lang b ON b.id = a.lang SET a.name=?,a.title=?,a.seo_key=?,a.seo_desc=?,a.maintenance=?`
And it works
Is it ugly? A lot!

```UPDATE table1 as outr SET country_fid =
(SELECT contact.country_fid FROM table1 as person
JOIN table2 as contact ON person.table2_fid = contact.pid
WHERE person.pid = outr.pid)
WHERE country_fid IS NULL;```

Does that work?

11:35 AM
yep

That's quite a craft you have there

that's only a runonce update... I've been working on normalizing out countries for like... 5 hours now..
all in at it's not that bad
~700 records uncrecoverably NULL in table1 and ~560 in table2

Well, it doesn't look bad

the pre-normalization from the times where that was a free-text field is hella ugly though.

I have almost 198000 regists to convert from JSON to a database
And I have no idea how to do it

11:39 AM
2

I've been working on a VBA macro that parses HTML into a an Excel sheet. The code is functional, but extremely slow (it takes roughly 20 seconds to fill 270 lines from columns B to M). Due to the code being functional, I suspect it would be best submitted to Code Review. But. The code I have is ...

Because I don't know how to organize it

@IsmaelMiguel sounds like a job for batch parsing

@Vogel612 You mean, regex and headaches?
I have it split on 2 files, each with over 30MB

@IsmaelMiguel not necessarily
you could try to parse the JSON with a parsing lib
regex would be an option though...

@GrimaWormtongue Who the heck is Grima? Did I miss something?

11:41 AM
assuming you have always the same data you can generate insert statements rather simply
@Mast Grima posts MSO questions tagged

Duga for MSO?

The data is out of order

Cpt. O for MSO

Ah, feed.

11:43 AM
Any particular reason that feed got a fancy name while the MSE one doesn't?

none. MSE wants a cool name, too?

I don't know, perhaps it should.
So you can identify where it was posted by the username instead of looking for a tiny little icon in the top right of the post.
But perhaps MSE should be the only one without name.

in Java<> on Stack Overflow Chat, 2 hours ago, by Vogel612
Ahh it's so nice to "generate" SQL from available data with simple regex match-replaec

@Vogel612 I have an array with data like this: `{"id":"3750-011","location_name":"Alcafaz - AGADÃO","postal_designation":"AGADÃO","district_name":"Aveiro","county_name":"Ág‌​ueda"}`
I need to write data into 2 or 3 tables
And each don't have a well-defined structure yet
I have to write the name of the city on one table, with a language identifier
Then I have to write the `"id"` into another table
And then I have to insert more data into another table with the translations and a bunch of stuff
All those depend on the primary key of the city created
It's really complicated

write yourself a small script...

11:52 AM
But I don't know (yet) how to organize this data and make decent relationships

imgcur is blocked, damn

this is nothing to do by hand. retrieve foreign stuff by label (case insensitively) and create new stuff on demand

I can't do manually but can't write any script until I know how to organize this stuff
And I predict a 100MB SQL file to run on over 150 websites
Fun AF

@EthanBierlein Yes.
@Mat'sMug Can I write apps for Windows in Objective-C on my Mac?

12:03 PM
@nhgrif I know you pingged Mat, but I think you can't. You will need to have a compiler capable of compiling to windows. As far as I know, compilers compile to the operating system they are in.
I may be wrong, I may be right. I don't know

I didn't ask if I could compile.
I asked if I could write.

Probably

And I guess with writing comes testing.

Does it have Windows-specific stuff?

I don't know.
But what's the big deal about writing a Windows app in Objective-C if you have to be on a Windows machine to do it?
There are ZERO developers who write Objective-C who sit around and see "Gee, Objective-C is great! If only I could use this on a Windows machine to write Windows app."
No.
People write Objective-C because before Swift, that was the best way to write native OS X and iOS apps.

12:07 PM
Calm down

Is there anyone who writes VB.NET and sees "Gee, VB.NET is great! If only I could use this on a Mac to write Mac apps."?
Nope.

@nhgrif that's only because VB.NET is a pile of crap..

VB.Net is a multi-plataform framework
(It wasn't a while ago)
Same goes with Java

I didn't mention Java.

But if you want to test a Windows program, you need Windows (or similar, like Wine)

12:09 PM
Although, if I want to write a great native app, I'm not picking Java.

No one sane will

Not that Java doesn't have it's uses...
If I still need Windows to at least give a really cursory alpha test to a Windows application, then nothing great has been accomplish by creating Objective-C.NET
Nothing that Microsoft couldn't have done 30 years ago when Objective-C was a new language.
They've waited till after Swift as all the people who know Objective-C are converting over to Swift.

If it is .Net, it's different
As long as you don't use Windows-only features, I think you are ok.

@Vogel612 I'd argue that Objective-C is too compared to C# or Swift.

But, I haven't updated myself on .Net

12:12 PM
Also, I know that Microsoft has at least limited confidence in this Objective-C project.

these people got too much time on their hands...

Time to go to lunch

I'm working on a pretty big Objective-C iOS application for a client. Microsoft is also paying for us to build a Windows/Windows Phone application for the client.
And when I say paying for... I don't mean they're paying for us to convert the Objective-C project.

Why?
> You think all the iOS developers will now buy a PC to port their apps to the windows world? NOT
NOT
If you want to attract people from the iOS/Apple world, think about OS X Dev tools.
Pretty much that.
This is great news for an extraordinarily small segment of the developer world.
1. Very small companies that couldn't support a full Windows team but want to put out a Windows port of their Objective-C iOS app.
2. Successful indie devs that want to increase their profits by what they see as a zero-cost way to release to Windows.
This may also be relevant to this conversation:
Symbolic: iOS unit sales are now matching Windows PCs. http://t.co/4qsNg3ntYW

12:25 PM
@IsmaelMiguel That's usually how it works, but cross compilers compile for different architectures or OSs

This is obviously a bad question:
0

I am implementing a Stack using an array. I have written the below code and it works fine #include<stdio.h> #include<stdlib.h> int isFull(int top, const int unsigned size) { if(top==size-1) return 1; else return 0; } int isEmpty(int top) { ...

I'm still undecided on whether or not it should be closed...

but he's just asking for a comparison of his code versus code on a linked website.
And the fact that the two answers do no more than that is evidence of this question's problem.

I VTC'd, based on: "Does the method to implement a Stack as given in the above link is more efficient than my code and What is the better way to implement Stack my method or the one given on that website ?"
That screams for an explanation (understanding) of their code.

That's not what that close reason is for really, not quite.
but... don't retract your close vote if you think it should be closed.

12:36 PM
That's exactly what it's for. "Questions seeking an explanation of someone else's code." This question completely satisfies that VTC reason.

No.
That's not what it's for.

Then please, elaborate about how that VTC is not for what it says it is for.

That close reason is for when the code in the question is hypothetical, pseudocode, stub code, or code that the author didn't write.
It doesn't say it's for questions seeking an explanation of code.
The part about explaining code is to help partially explain why we're closing code that falls under one of the above reasons.
12

Inspired by this question: Custom Close Reason Post-Mortem. Can we alter Questions must involve real code that you own or maintain. Questions seeking an explanation of someone else's code are off-topic. Pseudocode, hypothetical code, or stub code should be replaced by a concrete example. T...

Greetings, Programs.

"Questions must involve real code that you own or maintain. Pseudocode, hypothetical code, or stub code should be replaced by a concrete example. Questions seeking an explanation of someone else's code are also off-topic." That question asks, "Does the method to implement a Stack as given in the above link is more efficient than my code and What is the better way to implement Stack my method or the one given on that website ?"

12:43 PM
0

I had to write a generic wrapper that enables me to pass variable number of arguments for execution of some methods and repeat it up to a few times when it fails because of network connection problems. What I came up is this class and a helper method. Well I can't say it's perfect - it is suffi...

Unless we are only qualifying the last sentence of that close reason if the question only involves code that the author owns, than that close reason is completely valid here.

1. You can't just change the emphasis to your own personal liking.
2. Did you read the meta?
I'm done debating it here. If you disagree, go post an answer to the established meta question.
This is not a new issue.
Keep in mind these things...

1. Yes.
2. Yes.

@nhgrif I still don't agree it's declined.
Understanding != Review

@Mast The request for rewording is declined.
@Mast Also, please don't get confused. I'm not arguing that question is on-topic. I'm arguing that @EBrown has used the wrong close reason.
I voted to close the question as off-topic, if you'll notice.

12:46 PM
@EBrown If the question can be made on-topic by removing a single line of text, then it wasn't off-topic in the first place

@nhgrif This was not the wrong close reason.

I used a custom close reason.

Don't hold on to the rules literally and allow for an interpretation in the spirit of the rule

@EBrown Stop, let me catch up @Mast... and then I'll continue to explain to you how wrong you are.

@nhgrif You can explain to yourself, I don't have time to sit here and argue with you.

12:47 PM
@JeroenVannevel For the sake of this question, the answers are evidence that it's a really bad question. The asker doesn't want a review. And the answers he's getting aren't reviews.
@EBrown You're in disagreement with the community at large. Not just me.
In fact, myself (and other long standing community members) once thought like you did about this close reason, but there are things you need to understand.

@nhgrif That's unfortunate.

Not wanting a review on it's own makes it off-topic.

@Mast please catch up. No one is disagreeing that about whether or not it's on-topic.

You can VTC or not (for whatever reason you like), I'm using mine. And I'm not going to sit here and waste time I can be doing something else for voting to close the question for the fact that, as far as the text stands, it is off-topic by at least one sentence in that VTC. If that sentence in that VTC is not intended to apply literally, then it should be reworded to be more explicit.

For Christ's sake... I told you, if you think it should be reworded, then go to the meta and offer a suggestion....

12:49 PM
The question specifically asks for, "is that method more efficient", and "which code is better".

You're making yourself a regular in the community

"Is that method more efficient" can satisfy the VTC I used, as well as several others I'm sure.

So it's important that you catch up with the rest the community up to date
At the end of the day, the point is to not confuse the person whose question got closed
And the experience we've had with that close reason is that when people get their question closed with it, they come back and say "But that's not hypothetical code, and I did write it myself!"

"Which code is better" can satisfy "not requesting a review" (as I'm sure that's a valid custom reason).

It happens every time.
And that's why you used the wrong reason.
If we close it with that reason, now we have to explain to the asker the problem with their question
"Which code is better" has a tag.

12:52 PM
I'm not saying that it's an invalid idea, but that posting that specific example with a comparison of "my code" (from the author's perspective) and "someone else's code" would still warrant a VTC, for the reason I did.

@nhgrif I did. I agree with your close reason and added a vote to it.

And I would still use the same VTC I did.

@nhgrif Which should burn IMHO.

And it'd be the wrong reason every time.
And you'll be the only person using it every time (because you're right, you can vote however you want).

I'm not going to sit here and argue with you.

12:53 PM
You are sitting here arguing with me

The fact is, unless that VTC is reworded to make more explicit justification, it's valid for this question.

@EBrown Don't take it personal, we all want the same thing: Improving this place.

If you don't like it, vote a different way.

If you have a problem with the wording, take it to the meta.

(Which you did)

12:54 PM
@EBrown Your grossly failing to see the problem with your behavior.

I don't have a problem with the wording, I have a problem with everyone's interpretation of the wording.

Voting to close for the wrong reason is HUGELY problematic.

It's not the wrong reason.

Here's the thing.

I have failed to see any evidence that it's the wrong reason.

12:54 PM
You don't understand how these close reasons are supposed to work, clearly

@nhgrif This would be an edge case on that in my opinion.

Read the VTC reason, and read the question.
Technically, the question requests an explanation of which code is better, which requires an explanation of the linked (non-author) code.

Just stop, for a second. Act like I've been a major part of the meta and this community for almost 2 years, and you're relatively new. Give me that credit, and let me explain this to you

Which satisfies that VTC.

@Donald.McLean that's absolutely amazing.

12:55 PM
Just stop give me 2 seconds to explain it instead of digging your damned heels in.
Just listen to one explanation

@RubberDuck Are you next? ^^

These close reasons are supposed to be pretty specific and used for one specific common problem (per close reason). We're limited to three. But they're not supposed to be a catch-all for as many reasons as we can fit in the character limit. If a close reason appears to apply to multiple problems, then there is a problem with the wording. The close reason we're talking about is for when the asker has posted code that is hypothetical code, pseudo code, stub code, or code for which he is...
...not the owner or maintainer. And that is it. The extra sentences (talking about explaining) are there to help clarify why it's a problem and provide extra links to the meta discussions about that specific problem.
The code in the question isn't hypothetical code, isn't pseudo code, isn't stub code, and to the best of our knowledge, the asker is the owner/maintainer of it. Thereby, this close reason does not apply.
And if it were closed for this reason and the asker asked on the meta why it was closed, our only explanation would be that the wrong close reason was used, and then we'd explain the actual problem with the question.

Then perhaps there should be a couple qualifiers linking the two ideas together. Because as I see it, one reason can (and should) apply to several problems. This is obviously an edge case, because there is equal justification each way.

Instead of doing that and waiting for it to get to the meta, you should use a custom close reason so the user more quickly gets a clearer explanation of their problem.
I have multiple times in the past asked that we should have a custom close reason purely for people seeking an explanation of code.
We only have 3 close reasons though. And the three we're using happen more frequently than people outright asking for explanations (and none of the others apply)
If we got a 4th close reason, asking for explanation might be that 4th reason

related discussion on meta about close-reason usage:
17

Note: For chat-like discussions of this subject, let's use this Discuss Close Reasons chat room Code Review currently has three standard off-topic reasons: Questions containing broken code or asking for advice about code not yet written are off-topic, as the code is not ready for review. A...

1:02 PM
I'm not saying a custom reason would not be more appropriate/more qualified, what I am saying, is that my using of that VTC is not "wrong." It may not be the "most qualified", but the VTC can still be interpreted (pretty plainly/easily) to apply to this question.

If it can be interpreted to apply to this question, then by your estimation, it needs to be reworded.
Because none of these reasons apply:
4 mins ago, by nhgrif
The code in the question isn't hypothetical code, isn't pseudo code, isn't stub code, and to the best of our knowledge, the asker is the owner/maintainer of it. Thereby, this close reason does not apply.

There may be code in the question that is not the askers, but for a full understanding of the question, one must also read and understand the linked-code, which is not the askers.

Sure

Just because the question has code that is the askers, doesn't mean that VTC doesn't apply (as it is worded now, at least).
The question (essentially) has two code snippets: the one included, and the one linked.

Yes, it does. And if the wording makes you think it does apply, then the wording needs improvement.
We don't review linked code (Even if the asker wrote it himself).
It's there for context only.
Context can't make your question off-topic.

1:05 PM
The one included is completely on-topic, and based on that alone does not make it a bad question; the one linked is where things start to get hinky.

The problem has nothing to do with the linked code though.
The problem is that the asker isn't seeking a review.
He's not interesting in hearing how the code in the question can be improved.

@EBrown drop away the link and have the code included in the question, the problem of the question remains the same

@Vogel612 I'm not sure what you mean by that. It would still be someone else's code that he wants a comparison with.

aside from the fact that he only wants a comparison with respect to one implementation detail
comparison != review
restriction to one implementation detail != any or all aspects are up for critique

I've said it before and I'll say it again: should be out-of-scope.

1:09 PM
Even if it were his own code he wanted comparison with, I leave my close vote exactly as is because that is the overriding problem: he doesn't want a review

@Mast take it to meta

@Mast I'm agreeing more and more
basically there's a list of priorities
and the first thing each question has to bring is: "I want X reviewed"

so it works? If you after feedback you'd be better off putting this on codereview.stackexchange.comLiam 37 secs ago

@nhgrif I would then not submit my VTC for the reason I did.

we have no dedicated reason for that because it happens so seldom....
but if that's out, you can `throw new OffTopicException(Reason.custom("not seeking a review"));`
no need to go down further in the close-reason hierarchy

1:12 PM
On a totally more friendly note, has anyone noticed yet it's Friday?
3

preparing for NOOOOOOOOOO!

-2

if (word1Length !== word2Length) { return false; } for (var i = 0; i < word1Length; i++) { } Affordable Dental Implants in Parramatta

@Quill don't edit spam
ever

Oh hey, Parramatta is in Australia

irrelevant, 'tis spam
NUKE IT!!

1:15 PM
hey hey, just tryin ta chill da m00d out a tad

it's kinda hard to chill when you're poisoning the bayesian spam filter...

@Quill Rolled back because we shouldn't edit spam, in the process editing it again. Perhaps this wasn't a good idea.

-7 ... 10 minutes...
this gotta get better..

@Mast -_-

spam should die with -6 without mod intervention, people ~motivated

1:19 PM
@Vogel612 it'll hit tavern on the meta and get killed anyway

-8 and counting...
@Quill don't rely on it

4

Going through a book, I encountered the following assignment: Write an application that asks for the userâ€™s first, middle, and last names and replies with the userâ€™s initials. Are there any flaws you notice immediately? Is there any way this code can be improved? I'm not really interested...

That can get reopened, I think. The OP fixed the code.

I think that a comparative review should be 2 questions, and then the user can take the answers from both and do the comparing on their own. then they can decide what is going to work best for their situation.
7

@Malachi I'd steal that for a meta question.
Unless you prefer writing one yourself of-course.

where is the meta?

1:22 PM
here: meta.codereview.stackexchange.com

gotta love magic links

sorry I would love to write it, but I am dealing with some work issues at the moment...I will write one when I get the chance

@Malachi Only if you prefer to do it, otherwise I'll write one.

The insurance company is currently inspecting my car to determine how much damage was caused when I got rear-ended on Wednesday.

are you guys telling me to open a new question or answer one of the 2 already there?

1:24 PM
@EBrown You should always start with the biggest problem a question has. And this is especially true for questions that already have answers. When we start with smaller problems, the asker tends to have trouble seeing the forest through the trees.

@Malachi open a new one, if it's not a dup

okay, I was going to say that my answer would not fit well....lol

@nhgrif If that's the case, then the close dialogue should specify that. I pick the first reason I find that is well-satisfied by the question. If there is not one, I add a custom reason.

Experience specifies that. I'm giving you a shortcut.

@jacwah I didn't though about that... It really makes sense. But won't it require some slow compatibility layers?

1:37 PM
@IsmaelMiguel Why? It just generates machine code, it doesn't run it. en.wikipedia.org/wiki/Cross_compiler

@jacwah Sorry, I ate some words. Yeah, I meant to run and debug it. For that, you will need a Windows machine?

1

I think that a comparative review should be 2 questions, and then the user can take the answers from both and do the comparing on their own. then they can decide what is going to work best for their situation. This came from chat. There is a lot of discussion in Chat about comparative-revie...

@Malachi Double-paste

@Malachi You pasted it twice. :P

oops
I haven't had any coffee yet

1:39 PM
I had my first coffee in 2 weeks

I had to work on a big issue here at work so I haven't moved from my desk yet

@IsmaelMiguel Yes if you don't use Wine or another compatibility layer as you already said (or run it in a VM)

I also posted an answer. I don't post on meta very often, I do try to keep track of stuff on meta though, hopefully @Jamal will edit my Q&A a little bit and make it pretty

@jacwah God bless scripting languages for this.

1

I think that a comparative review should be 2 questions, and then the user can take the answers from both and do the comparing on their own. then they can decide what is going to work best for their situation. This came from chat. There is a lot of discussion in Chat about comparative-revie...

1:42 PM
@IsmaelMiguel But their interpreters still need to be compiled... Using them is like using a cross platform compatibility library

@jacwah @IsmaelMiguel Not only that, but you must have an interpreter that works on every environment you plan to run on. I.e., if there is no interpreter for Windows, then you're SoL.

@jacwah True, but then the programmer doesn't have to move the script to other machine. (Except operating-system-specific scripting languages)

@IsmaelMiguel Same if you don't use any OS specific libraries in your native code

@EBrown SoL? (To me, SoL is "sol" with capitals amngled, which means sun)
@jacwah You made a really good point. This is no argument, but you won.

@IsmaelMiguel "Sh-- out of Luck", or "So out of Luck."

1:45 PM
@EBrown Thank you. I would never guess due to the double-o there (`"out of"`).

@Malachi I only just noticed your question, after I posted mine.
Should I remove mine or turn it into an answer on your question?

@IsmaelMiguel In my experience it's usually spoken as the abbreviation, as it's a commonly accepted acronym in English. ("Man, my car is S-O-L after that accident Wednesday.")

Or merge them, or whatever.
@IsmaelMiguel I thought it was the reverse of Line of Sight.

@EBrown I'm really awful to remember abbreviations/acronyms. That's why I've made Memer.
@Mast The SoL? Or the "sol"?

@Malachi Nvm, I hope I succeeded in turning my question into an answer on your question.

1:52 PM
If "better solutions" demoralize you, don't ever go to Boost's website. Anyway. I notice that you tagged this c++11, which sets you well ahead of most beginners already. If you want some competent advice on a working piece of your code, you can post a question on Code Review. StackOverflow here is for code that doesn't work, so people can help you spot the problem. Beware to make it a good question though, have a look around to know what to do and not to do. Welcome to the Stack ! — Quentin 23 secs ago

@Mast May I speak with you in private? Just want to ask something quick.

@IsmaelMiguel There is no such thing as private on SE.
Feel free to create a room or pick an existing one and ping me though.

You know what I meant
That's what I meant

I'll respond to it, but I'm on my way out currently. So it may take an hour or so.

I've made the room. It won't take 5 minutes