Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror

Comment: Re:Modula-3 FTW! (Score 1) 463

by psmears (#48904235) Attached to: Ask Slashdot: Is Pascal Underrated?

For example, you can compare the readability of Arabic numbers vs Roman numerals by asking two people proficient in each to perform the same arithmetic calculations, and you time them.

That would measure how easy it is to perform arithmetic in the two systems... which is not the same as readability. Similarly it's a good idea not to confuse "easy for a computer to read (and execute)" vs "easy for a human to read (and understand)" - both are important in different ways, but they are entirely separate concerns!

Comment: Re:Programs people want to use... (Score 1) 449

by psmears (#48725281) Attached to: How We'll Program 1000 Cores - and Get Linus Ranting, Again

Why haven't you written such a thing before? Because it's too much hassle. Which is the very reason threading is underused.

LOL. Actually there's a better reason such a thread launch facility doesn't commonly get written - which is that, in most circumstances, it really doesn't help performance that much, if at all - and the added complexity makes for a big net minus. There are a number of issues:

Firstly, spawning threads is expensive. Yes, on Linux it's "cheap", but that's "cheap" compared to other implementations - it's still a lot compared to doing a modest amount of work on the local CPU. (Why is it so expensive? Basically because there's a lot of housekeeping to do. In addition to the kernel creating new kernel structures for the new thread of execution (similar to creating a process), the process's thread library must allocate a stack for the new thread (involving modifying the process's page tables), iterate through all loaded shared libraries in order to allocate any thread-local storage they require, and so on, requiring multiple syscalls, a TLB flush, at least one context switch, and so on. To some extent the impact of this overhead can be reduced by maintaining a pool of ready-created threads, but this either takes away control of performance (if done automatically by your language/library) or substantially increases complexity (if you implement it yourself, since you then have to synchronise the threads carefully).

The second problem is that, unless you're very careful, extra threads don't buy you much performance, and can indeed hurt. Take the example you gave - doing some processing on each struct in an array, where each such struct contains an int and a double (16 bytes total, including alignment padding). With 64-byte cache lines (typical on x86), there are 4 such structs per cache line. If you distribute the processing over threads running on different cores, then instead of one core waiting for the cache line to come in to main memory, and then processing the 4 structs very rapidly (since they're now all in cache), you'll have 4 cores each waiting for the data to be available - i.e. up to a 4x slowdown for memory-bound tasks. And that's assuming the structure is only read from; if it's written to as well then the cache line will have to bounce between cores, and the multithreading slowdown will be many times worse. Now, if you ensure that structs in the same cache line get processed by the same core (ideally in sequence, and by the same kernel thread), then you do potentially get a big speedup - provided you don't hit any other gotchas - but the C++ code you're promoting doesn't seem to guarantee this in any way.

Third, and perhaps most importantly, data dependencies matter. In your example you're detaching all the threads; this is not realistic, because that means you cannot ever depend on their operations having finished. In the vast majority of cases you do need to know when an operation has finished: you're generally doing work for a reason - i.e. that you're going to use the result - and you can't begin to use that result until you know it has been produced. That, in of itself, adds complexity: you have to analyse your program's dataflow much more carefully in the presence of threads, because C/C++ will quite happily let you use a variable before another thread has finished assigning to it, without any sort of warning or exception. The analysis can certainly be done, and synchronisation put in place to eliminate the problems - but that is further overhead, both in the program's performance but also in the complexity of the program itself, and hence the time taken to write it (and especially to enhance it later, when the synchronisation model may not be so fresh in one's mind).

Used correctly and in the right circumstances, threads on an N-core system can give a N-times speedup (or greater, due to caching effects). Used badly, at best they'll reduce performance, and usually they'll increase complexity and lead to subtle bugs that are hard to debug.

The new thread features in modern C++ are very cool, but the fact they didn't exist before is not what's been preventing competent programmers from using threads all over the place :)

Comment: Re:Contracts (Score 4, Interesting) 307

by psmears (#48416459) Attached to: UK Hotel Adds Hefty Charge For Bad Reviews Online

Retail or not, contracts are binding.

Contracts tend to be binding even when both parties don't read--most contracts are not read but are binding

Are you sure about that? Note the following (from the American Law Institute):

Where the other party has reason to believe that the party manifesting such assent would not do so if he knew that the writing contained a particular term, the term is not part of the agreement.

i.e. if you put terms into a contract that you know your customers aren't likely to agree to, then they're not binding, even if the contract is signed.

Comment: Re:Not this shit again (Score 1) 834

by psmears (#48360277) Attached to: How To End Online Harassment

None of it, expect of course that the University of Utah confirmed it, and a lot of people there have received this message. Read it for a fine example of crazy reactionary misogyny.

University of Utah confirmed that threat was completely un-credible and there was no credible threat to the students or anyone else. Once again you are so woefully uninformed about the most basic of facts that I wonder if you even so much as googled any of this before posting.

I couldn't find a source to back that up; instead, googling showed that the University of Utah prepared to enhance their security as a direct result of the threat. Or did I miss something? It's admittedly quite hard to search for without the results getting swamped with gamergate coverage of one sort or another...

Comment: Re:You REALLY want to go down that road? (Score 1) 834

by psmears (#48359001) Attached to: How To End Online Harassment

I lost count at 30 people doxxed by those that claim to stand for "feminism" and against gamergate, starting with the black developer who lost his job to racists harassing his boss and going downhill from there to people's bank accounts getting hacked, their utilities turned off, their income held up by fraud, a couple attempts at SWATting, and even syringes, knives, and dead animals in the mail.

I've missed all this... do you have any links?

Comment: Re:Additional... both sides are showing bad behavi (Score 1) 834

by psmears (#48358987) Attached to: How To End Online Harassment

Many of the journalists and supporters of the anti GG side have doxxed people... with their main accounts in the clear. Not sock puppet accounts that could be anyone. But they did it directly.

I haven't seen any of this; do you perhaps have a link?

I don't know why people keep bringing up harassment like this helps the anti GG side because the anti GG side has harassed far more.

Who said "we should bring back bullying" was that GG or anti GG? Anti GG. Every single fucking time.

I did see that one (only once though); at least the idiot in question apologised...

So they have no moral high ground there and I just thought that should be made very fucking clear. To the contrary, it is they that should be apologizing and explaining their own behavior which has been far worse.

People prominent in GG have received death threats, have had people call their work and tell their employers they're pedophiles, have had things mailed to their homes like knives or syringes...

Do you have any links about these?

Comment: Re:Take away for me (Score 4, Insightful) 217

by psmears (#48317627) Attached to: The Effect of Programming Language On Software Quality

the preference of certain personality types for functional, static and strongly typed languages.

Translation: because only very high-skill programmers attempt to use the very unpopular functional languages (like lisp and erlang) the resulting code is, on average, of better quality.

There is another possible interpretation: that programmers who are very concerned about quality - and hence are happy when their language gives them lots of information about potential mistakes - like using languages with features (such as a strong type system) designed to allow detection of certain types of mistake. That is, it's specific features of the languages, rather than the fact that the languages are "unpopular", that draws quality-focussed programmers to them.

Of course, that is just as much conjecture as any other interpretation :-)

SCCS, the source motel! Programs check in and never check out! -- Ken Thompson

Working...