I really can't see what C++ has given to Java that it didn't get more directly from C, Smalltalk, and a few other experimental languages.
You mean apart from almost the entire OO framework, more recently also the generic programming concepts, and most important of all the familiarity with using these things in a language with C-style syntax?
You're right. A lot of our work would suit a functional programming language very well, say, and probably would be significantly more concise and readable when written in one. Unfortunately, as things stand today, the performance overheads those languages incur and the need to be portable to such a wide range of platforms are prohibitive: you're almost forced to work with a filtered list in the example I gave, for example, and even though that list-handling might be quite heavily optimised in a typical functional language and/or lazily evaluated, it'll still be slower than tight C++ code written for that exact filter.
Well, you argument was you were programming maths, which is why you shouldn't use counter, and make the code look more like maths.
Erm, yes. And as I pointed out in my previous post, it is quite idiomatic in maths to use i as a suffix. I have a degree in the subject, and I now use it professionally every day, and I promise you I see far, far more suffix i's than imaginary ones.
Yes, even it the worst possible case 'static code generated to be read by a machine and not by humans' the compiler still doesn't need to return all over the place to be efficient.
It's not about efficiency, it's about readability and maintainability. The structure of assembly code output after various phases of compilation and optimisation has precious little to do with the structure of the original code.
In that case I would recommend finding something better suited to your need than c(even if it's just a pre-processor), more a mathematical less functional language, as you said 'the only alternative in a typical structured programming language'
Or we could just use the technique we do, which has no problems in this area other than conflicting with your personal preferences about coding style.:-)
(FWIW, the sort of alternatives you propose aren't even close to fast or portable enough for our application. We write mathematical libraries that are shipped on dozens of platforms, and you can never have code with execution too fast or memory requirements too low in that context.)
yes, i = srqt(-1) are you using imaginary numbers for your matrix elements.
That's hardly a compelling argument, given that i is used idiomatically both by many programmers to represent a loop counter and by many mathematicians to represent a suffix.
I spend some of my time picking though compiler generated assembler that does all kinds of things, and you rarely see an early return.
Did it occur to you that the assembly code generated by a compiler doesn't have to be particularly maintainable or human-readable?
Anyhow, I expect you are writing something like (obviously with a few more levels)
dosomething(a,b,c,d){ if d = 0 return NAN; e = b * c / d; if e - d = 0 return NAN return a / (e - d); }
Well, to some extent, yes, but those "few more levels" make rather a difference to the scalability of your appproach. It's more like this:
do_something(graph_node *n) { for (/* each neighbour node to 1st node */) { if (/* 1st test on 2nd node */) continue; if (/* 2nd test on 2nd node */) continue; // Several more similar tests
for (/* each neighbour node to 2nd node */) { if (/* 1st test on 3rd node */) continue; if (/* 2nd test on 3rd node */) continue; // Several more similar tests
// Several more nested loops later...
for (/* each neighbour node to 6th node */) { if (/* complex test on all nodes collected succeeds */) { return/* something indicating which nodes were identified */; } } } } return/* something indicating that the required subgraph wasn't found */; }
The nested loops here are basically unavoidable; the only alternative in a typical structured programming language is to hide them inside functions, which is a bad idea for the reasons I described previously.
The tests could be separated into a pre-loop that filtered the relevant list of neighbour nodes at each stage prior to looping over it, but that wouldn't really gain anything in terms of clarity. More seriously, it probably involves either constructing a new list, possibly with thousands of elements, inside deeply nested loops, or introducing flagging overhead on each node. The performance and memory usage implications aren't pretty.
Alternatively, we could continue to write our code in the style above, where anyone coming to the code for the first time can immediately see the structure of the algorithm, wrapped up in a single meaningful function. Unlike the "absolutely no early returns" approach, this style scales to a large number of conditions and/or nested loops if necessary, without compromising the readability or maintainability of the algorithm.
Mid function returns are evil, causing duplicated or worse, skipped, cleanup code.
If that's a problem for you, either your programming language or your knowledge of it is insufficient. Learn to use destructors/finally blocks/macros (real ones)/whatever the resource management idiom is in your programming language of choice.
Many modern systems need this sort of architecture whether you allow explicit early returns or not, because of the potential effects of exceptions, parallel processing, etc.
Don't the x and y's belong to something, like screenx, imagex etc.. can't you use counter instead of i?
You are unwise to generalise so readily. Suppose I'm writing a simple function to multiply two matrices. Do really think it's going to make clearer code if I called the matrices matrixA and matrixB and index them with variables like counter? What's wrong with the programmer-idiomatic and mathematically familiar notation, such as the following?
M[i][j] += A[i][k] * B[k][j];
Would you rather I wrote this statement as shown below?
mid function returns are good, its what stops your code from looking like spaghetti to avoid them
bollox, write good code, refactor, maybe two functions is a thousand need mid function returns, an I can cope with my checker giving me a few false positives, no Turing AI just a human to flag the functions once.
Again, you are unwise to generalise too readily. I work with mathematical algorithms every day that use literally dozens of tests within an otherwise quite simple function. If we followed your standards -- no early returns (or exceptions or breaking out of loops, presumably?) and refactor inner logic out into separate functions -- we would lose all the clarity we currently have (you can see the whole algorithm in one function of a reasonable length) and replace it with lots of small functions containing logic that makes no sense out of context anyway.
Having done that, we would have gained no meaningful abstraction and no increase in reuse. However, we would have lost a lot of readability, and in scattering the algorithm over a wide area we would have crippled maintainability.
Is this really an advantage? I think not. No-one who's worked with complex decision-making code of this complexity has ever questioned the approach, and pretty much all the code of this nature that I've seen is written the same way. Often I find the kind of people who think quicksort is a complicated algorithm don't really understand this, and sadly, this includes people who profess to be experts in software development, programming language design, etc. etc. Fortunately for those of us who write this stuff for a living, we aren't constrained by the coding standards of the ill-informed.
As an off-topic aside, he won't be "Sir William", but rather "William Gates KBE". In today's enlightened global family, you're only allowed to be "Sir" if you're from a Commonwealth nation. Go figure.
[C++] has not really revolutionised even C programmers, let alone the world of programming generally, has it?
Given that it's likely most of the software that most of the people reading your comment use today is written in C++, I can only assume that you're trolling?
It's not any more? Damn! I just spent all day recoding the highly readable 50 lines of C++ I wrote yesterday as a single line Perl before checking it in.
C++ failed in part because of the unfounded belief that its supporters had in its abilities
I must have missed the memo that C++ had "failed". I'd call being one of the most popular languages around, still a major part of the software industry some two decades after its introduction, one of the bigger success stories in software development history.
As for belief in its abilities: the problem C++ has is more PR than anything else. A lot of people learned it ten years ago, or were taught by or learned from books written by someone who did, and as a result there is a wider difference between "expert practice" and "common practice" than in just about any other programming language in at least moderately common use today. C++ was designed as a tool for serious programmers -- those who are going to understand and follow best practices, and who are going to take steps to avoid shooting themselves in the foot. For these people, it is an exceptionally good practical tool.
The fact that it has also been adopted by mainstream application developers -- a market it never sought, nor was designed to cater to -- isn't really C++'s problem. Sooner or later (but, sadly, probably later) a much better general application development language will come along and most people will migrate, leaving C++ to the systems programming, high performance maths, etc. that it's best at, in the hands of programmers who will make good use of it.
If the manager is managing technology, he should understand it.
If, however, the manager is managing technologists, he has more need of understanding the people than the technology.
I couldn't agree more.
In even a moderately large organisation, the guy at the very top usually isn't going to be charge of details. The most important requirements are that he knows how to find good people who will be, he understands what the organisation's strategic objectives are, and he can co-ordinate his team to ensure each member has the resources they need to work towards those objectives effectively.
Amusing that you chose this reply to reply to instead of answering any of the other ones indicating such tidbits you ignored the first time through as: This guy has been in court for years suing for the right to see the rule.
This is a very frustrating thread. About a dozen people have now replied, half of them as ACs, arguing a point I never challenged and indeed have agreed with explicitly throughout this thread. This is known as "attacking a straw man". The usual bits about "I assume you didn't read the article" don't exactly put them in a good light, when they clearly haven't even read the post to which they're replying properly.
Right now, I'm replying to a few random respondents, but since about 80% of the replies to my posts here should be hit with (-1, Redundant), I can't be bothered to repeat myself when they didn't read either my original post or the follow-up explanation I gave to another respondent already.
If you read the article, or the other posts, you would see that the problem here is that the goverment (eventually) admitted that yes, there was a written security regulation on ID requirements, but then refused to show that regulation even in court.
I did read them, and I've now agreed several times in this thread that secret laws are wrong. That was never my point. My point was that the manner in which the protest was made was unhelpful.
This is most definitely NOT about some smart-ass insisting that the security guard be able to cite chapter and verse of the law.
That might not be the point, but tell that the gate agent who faced Gilmore's Spanish Inquisition when she couldn't cite the law.
The sad thing here is that Gilmore does have a valid point, but his childish behaviour at the airport has detracted from it terribly.
Using the same logic, you would get the following:
Yes, you would (and for most people, most of them are true, too). Of course, anyone who isn't convinced by one of those claims is welcome to go and consult some appropriate authority on the subject to get a more informed opinion, but would you really expect a salesman to explain to you exactly how to configure Linux, the guy in the book shop to tell you which math books describe contour integration, or the guy flipping burgers to tell you the nutritional content of the salad? If not, why do you expect the security guard to know the exact details of the law he's paid to enforce?
I'm not trying to be obtuse; I just feel like you're backed into a corner and won't just admit that common sense is not the basis for law.
No it's not, and I've never said it should be anywhere in this thread.
My point here is not that it's right for the law to be secret. I've never said that either.
My point is that going into an airport, and causing trouble because someone whose job is to enforce the law couldn't quote the actual wording to you like a lawyer, and not accepting "it's what the law says" as a reasonable explanation when common sense tells you the law could well say that, is an unhelpful approach.
The number of people who have replied to my original post and missed the point, the number of other posts elsewhere in this discussion that missed the point about the "hidden law", and the number of negative mods my original post got all support my case that Gilmore's actions here have done nothing to highlight what he should have been highlighting, and everything to make him look like a fool who wastes security officers' time.
Do you not understand that requiring ID does not increase security? That all the 9-11 hijackers had legitimate ID's?
Do you not understand that many, many criminals have been caught after trying to travel on bad ID, that 9/11 is not the only terrorist incident in the history of the world, and that just because in that case the hijackers do seem to have had valid ID it doesn't mean every other criminal does so?
You are about the millionth person to reply with that argument, which I have already addressed in another post. Please read other replies and follow-ups before posting redundantly. Thanks.
So how would you define common sense in this case:
How about this: if I ask a large sample of randomly selected people whether they would expect to be required to produce identification before boarding a plane, and the vast majority of them say yes, then common sense says you will be.
He's not arguing that he should be able to fly without ID. He's arguing that he should be able to read the law that says that he has to show ID to fly.
But he did it the wrong way. The guys at the airport aren't there to tell him the law, they are there to stop him breaking it. Of course it's wrong that he can't read the law in some appropriate source, but walking into the airport and deliberately causing trouble was about as immature a way of complaining about that as you could get. As I said, that sort of childish behaviour does nothing to advance the cause of civil liberties, and diminishes efforts to complain about real violations (like the fact that he can't read the law in some appropriate place in this case).
So it doesn't bother you that you are subject to laws that you don't even have the right to *look at*?
As I said in another reply in this thread, that in itself is clearly wrong.
However, that is different to expecting any random individual required to enforce an area of law (e.g., the guys checking ID at the airport) to quote me chapter and verse on demand. That is not their job. In this case, common sense says that a law requiring ID would not be unreasonable and probably exists, the other guys are just doing their job, and walking in with an attitude to create a scene was the wrong answer.
The correct answer was to find a lawyer and/or get proper legal information (note that this is the point where the real problem here becomes apparent and he can legitimately complain) and then if the law really doesn't require ID, he can attempt to fly and when refused access seek compensation for his loss as provided for in law (which is probably none for other reasons anyway, but at least he'd be arguing from a valid position).
Really, just strolling into the airport and creating an unnecessary problem doesn't help anyone. Try going into the US as a foreigner, joking that you really are there to assassinate the president, and seeing how the officials react then. They have better things to do than deal with people knowingly wasting their time, and frankly if I were flying, I would rather the security guys spent their time dealing with real security too.
As I write this, I notice that my grandparent post is both (+1, Insightful) and (-1, Overrated). My usual reaction to that combination (which I get quite a lot) is "oh well, the truth hurts".
This sort of thing always annoys me. I'm basically a liberal in my views, but that doesn't mean I'm an idiot. I advocate defending civil rights and liberties, and I'm pretty unconvinced by much of the recent erosion that's been done in the name of the "war on terror", but not to the extent that I put not offending someone's sensibilities ahead of an obvious-to-five-year-olds security risk.
Complaining about people trying to confirm basic identity details in a context where there is a well-known, genuine and, sadly, sometimes fulfilled threat is just the worst kind of anal retention. It does nothing to improve respect for civil rights; on the contrary, it diminishes the impact of any protest against genuinely over-the-line behaviour "for security purposes". This idiot should be grounded -- I don't care who he is -- and it would be better for all concerned if the media didn't give him any more attention either. People like him given civil rights organisations a bad name.
You mean apart from almost the entire OO framework, more recently also the generic programming concepts, and most important of all the familiarity with using these things in a language with C-style syntax?
You're right. A lot of our work would suit a functional programming language very well, say, and probably would be significantly more concise and readable when written in one. Unfortunately, as things stand today, the performance overheads those languages incur and the need to be portable to such a wide range of platforms are prohibitive: you're almost forced to work with a filtered list in the example I gave, for example, and even though that list-handling might be quite heavily optimised in a typical functional language and/or lazily evaluated, it'll still be slower than tight C++ code written for that exact filter.
Erm, yes. And as I pointed out in my previous post, it is quite idiomatic in maths to use i as a suffix. I have a degree in the subject, and I now use it professionally every day, and I promise you I see far, far more suffix i's than imaginary ones.
It's not about efficiency, it's about readability and maintainability. The structure of assembly code output after various phases of compilation and optimisation has precious little to do with the structure of the original code.
Or we could just use the technique we do, which has no problems in this area other than conflicting with your personal preferences about coding style. :-)
(FWIW, the sort of alternatives you propose aren't even close to fast or portable enough for our application. We write mathematical libraries that are shipped on dozens of platforms, and you can never have code with execution too fast or memory requirements too low in that context.)
That's hardly a compelling argument, given that i is used idiomatically both by many programmers to represent a loop counter and by many mathematicians to represent a suffix.
Did it occur to you that the assembly code generated by a compiler doesn't have to be particularly maintainable or human-readable?
Well, to some extent, yes, but those "few more levels" make rather a difference to the scalability of your appproach. It's more like this:
The nested loops here are basically unavoidable; the only alternative in a typical structured programming language is to hide them inside functions, which is a bad idea for the reasons I described previously.
The tests could be separated into a pre-loop that filtered the relevant list of neighbour nodes at each stage prior to looping over it, but that wouldn't really gain anything in terms of clarity. More seriously, it probably involves either constructing a new list, possibly with thousands of elements, inside deeply nested loops, or introducing flagging overhead on each node. The performance and memory usage implications aren't pretty.
Alternatively, we could continue to write our code in the style above, where anyone coming to the code for the first time can immediately see the structure of the algorithm, wrapped up in a single meaningful function. Unlike the "absolutely no early returns" approach, this style scales to a large number of conditions and/or nested loops if necessary, without compromising the readability or maintainability of the algorithm.
Blockquoth the AC:
If that's a problem for you, either your programming language or your knowledge of it is insufficient. Learn to use destructors/finally blocks/macros (real ones)/whatever the resource management idiom is in your programming language of choice.
Many modern systems need this sort of architecture whether you allow explicit early returns or not, because of the potential effects of exceptions, parallel processing, etc.
You are unwise to generalise so readily. Suppose I'm writing a simple function to multiply two matrices. Do really think it's going to make clearer code if I called the matrices matrixA and matrixB and index them with variables like counter? What's wrong with the programmer-idiomatic and mathematically familiar notation, such as the following?
Would you rather I wrote this statement as shown below?
Is that really an improvement?
Again, you are unwise to generalise too readily. I work with mathematical algorithms every day that use literally dozens of tests within an otherwise quite simple function. If we followed your standards -- no early returns (or exceptions or breaking out of loops, presumably?) and refactor inner logic out into separate functions -- we would lose all the clarity we currently have (you can see the whole algorithm in one function of a reasonable length) and replace it with lots of small functions containing logic that makes no sense out of context anyway.
Having done that, we would have gained no meaningful abstraction and no increase in reuse. However, we would have lost a lot of readability, and in scattering the algorithm over a wide area we would have crippled maintainability.
Is this really an advantage? I think not. No-one who's worked with complex decision-making code of this complexity has ever questioned the approach, and pretty much all the code of this nature that I've seen is written the same way. Often I find the kind of people who think quicksort is a complicated algorithm don't really understand this, and sadly, this includes people who profess to be experts in software development, programming language design, etc. etc. Fortunately for those of us who write this stuff for a living, we aren't constrained by the coding standards of the ill-informed.
As an off-topic aside, he won't be "Sir William", but rather "William Gates KBE". In today's enlightened global family, you're only allowed to be "Sir" if you're from a Commonwealth nation. Go figure.
[Double-clicks PowerPoint logo]
[Clicks File]
[Clicks Open...]
[Double-clicks my_project.exe]
This application has attempted an illegal operation and will be shut down.
Nope, the code doesn't work too well as the design, either.
Given that it's likely most of the software that most of the people reading your comment use today is written in C++, I can only assume that you're trolling?
It's not any more? Damn! I just spent all day recoding the highly readable 50 lines of C++ I wrote yesterday as a single line Perl before checking it in.
Nor, I imagine, would Java programmers, C# programmers, ...
I must have missed the memo that C++ had "failed". I'd call being one of the most popular languages around, still a major part of the software industry some two decades after its introduction, one of the bigger success stories in software development history.
As for belief in its abilities: the problem C++ has is more PR than anything else. A lot of people learned it ten years ago, or were taught by or learned from books written by someone who did, and as a result there is a wider difference between "expert practice" and "common practice" than in just about any other programming language in at least moderately common use today. C++ was designed as a tool for serious programmers -- those who are going to understand and follow best practices, and who are going to take steps to avoid shooting themselves in the foot. For these people, it is an exceptionally good practical tool.
The fact that it has also been adopted by mainstream application developers -- a market it never sought, nor was designed to cater to -- isn't really C++'s problem. Sooner or later (but, sadly, probably later) a much better general application development language will come along and most people will migrate, leaving C++ to the systems programming, high performance maths, etc. that it's best at, in the hands of programmers who will make good use of it.
I couldn't agree more.
In even a moderately large organisation, the guy at the very top usually isn't going to be charge of details. The most important requirements are that he knows how to find good people who will be, he understands what the organisation's strategic objectives are, and he can co-ordinate his team to ensure each member has the resources they need to work towards those objectives effectively.
This is a very frustrating thread. About a dozen people have now replied, half of them as ACs, arguing a point I never challenged and indeed have agreed with explicitly throughout this thread. This is known as "attacking a straw man". The usual bits about "I assume you didn't read the article" don't exactly put them in a good light, when they clearly haven't even read the post to which they're replying properly.
Right now, I'm replying to a few random respondents, but since about 80% of the replies to my posts here should be hit with (-1, Redundant), I can't be bothered to repeat myself when they didn't read either my original post or the follow-up explanation I gave to another respondent already.
I did read them, and I've now agreed several times in this thread that secret laws are wrong. That was never my point. My point was that the manner in which the protest was made was unhelpful.
That might not be the point, but tell that the gate agent who faced Gilmore's Spanish Inquisition when she couldn't cite the law.
The sad thing here is that Gilmore does have a valid point, but his childish behaviour at the airport has detracted from it terribly.
Yes, you would (and for most people, most of them are true, too). Of course, anyone who isn't convinced by one of those claims is welcome to go and consult some appropriate authority on the subject to get a more informed opinion, but would you really expect a salesman to explain to you exactly how to configure Linux, the guy in the book shop to tell you which math books describe contour integration, or the guy flipping burgers to tell you the nutritional content of the salad? If not, why do you expect the security guard to know the exact details of the law he's paid to enforce?
Absolutely. Do you really expect every official responsible for basic security checks to be a fully qualified lawyer?
No it's not, and I've never said it should be anywhere in this thread.
My point here is not that it's right for the law to be secret. I've never said that either.
My point is that going into an airport, and causing trouble because someone whose job is to enforce the law couldn't quote the actual wording to you like a lawyer, and not accepting "it's what the law says" as a reasonable explanation when common sense tells you the law could well say that, is an unhelpful approach.
The number of people who have replied to my original post and missed the point, the number of other posts elsewhere in this discussion that missed the point about the "hidden law", and the number of negative mods my original post got all support my case that Gilmore's actions here have done nothing to highlight what he should have been highlighting, and everything to make him look like a fool who wastes security officers' time.
Do you not understand that many, many criminals have been caught after trying to travel on bad ID, that 9/11 is not the only terrorist incident in the history of the world, and that just because in that case the hijackers do seem to have had valid ID it doesn't mean every other criminal does so?
You are about the millionth person to reply with that argument, which I have already addressed in another post. Please read other replies and follow-ups before posting redundantly. Thanks.
How about this: if I ask a large sample of randomly selected people whether they would expect to be required to produce identification before boarding a plane, and the vast majority of them say yes, then common sense says you will be.
But he did it the wrong way. The guys at the airport aren't there to tell him the law, they are there to stop him breaking it. Of course it's wrong that he can't read the law in some appropriate source, but walking into the airport and deliberately causing trouble was about as immature a way of complaining about that as you could get. As I said, that sort of childish behaviour does nothing to advance the cause of civil liberties, and diminishes efforts to complain about real violations (like the fact that he can't read the law in some appropriate place in this case).
As I said in another reply in this thread, that in itself is clearly wrong.
However, that is different to expecting any random individual required to enforce an area of law (e.g., the guys checking ID at the airport) to quote me chapter and verse on demand. That is not their job. In this case, common sense says that a law requiring ID would not be unreasonable and probably exists, the other guys are just doing their job, and walking in with an attitude to create a scene was the wrong answer.
The correct answer was to find a lawyer and/or get proper legal information (note that this is the point where the real problem here becomes apparent and he can legitimately complain) and then if the law really doesn't require ID, he can attempt to fly and when refused access seek compensation for his loss as provided for in law (which is probably none for other reasons anyway, but at least he'd be arguing from a valid position).
Really, just strolling into the airport and creating an unnecessary problem doesn't help anyone. Try going into the US as a foreigner, joking that you really are there to assassinate the president, and seeing how the officials react then. They have better things to do than deal with people knowingly wasting their time, and frankly if I were flying, I would rather the security guys spent their time dealing with real security too.
As I write this, I notice that my grandparent post is both (+1, Insightful) and (-1, Overrated). My usual reaction to that combination (which I get quite a lot) is "oh well, the truth hurts".
Yes, and that is wrong in itself, but you shouldn't need a law to tell you to use your common sense regardless of any other legal issues.
This sort of thing always annoys me. I'm basically a liberal in my views, but that doesn't mean I'm an idiot. I advocate defending civil rights and liberties, and I'm pretty unconvinced by much of the recent erosion that's been done in the name of the "war on terror", but not to the extent that I put not offending someone's sensibilities ahead of an obvious-to-five-year-olds security risk.
Complaining about people trying to confirm basic identity details in a context where there is a well-known, genuine and, sadly, sometimes fulfilled threat is just the worst kind of anal retention. It does nothing to improve respect for civil rights; on the contrary, it diminishes the impact of any protest against genuinely over-the-line behaviour "for security purposes". This idiot should be grounded -- I don't care who he is -- and it would be better for all concerned if the media didn't give him any more attention either. People like him given civil rights organisations a bad name.