Slashdot Mirror


User: david_thornley

david_thornley's activity in the archive.

Stories
0
Comments
26,427
First seen
Last seen
Profile
(view on slashdot.org)

Comments · 26,427

  1. Re:Recursion is dead! on Developer Argues For 'Forgotten Code Constructs' Like GOTO and Eval (techbeacon.com) · · Score: 1

    In C and C++, "break" usually replaces "goto" for leaving loops, but when you need to break out of multiple loops there's really nothing better than a goto with a nice descriptive target label.

  2. Re:Recursion is dead! on Developer Argues For 'Forgotten Code Constructs' Like GOTO and Eval (techbeacon.com) · · Score: 1

    You might want to free your memory and close your open file on success also. Now, if you were using C++ and unique_ptr, everything would automatically be freed and you wouldn't have a memory leak if you add an allocation and don't put the free() in at the end.

  3. Re:Recursion is dead! on Developer Argues For 'Forgotten Code Constructs' Like GOTO and Eval (techbeacon.com) · · Score: 1

    Memory cleanup is a nonissue in many languages. A lot use GC to dispose of memory, and C++ uses destructors. Putting cleanup code at the end of a function is somewhat fragile, particularly in a language with exceptions.

  4. Re:Doing it wrong? on Developer Argues For 'Forgotten Code Constructs' Like GOTO and Eval (techbeacon.com) · · Score: 1

    The number one reason not to use recursion is because it is very easy to exhaust the stack in system with more limited memory like embedded systems.

    If the algorithm is recursive, it probably requires you to maintain a stack if you don't use recursion. If the algorithm gets into unlimited recursion, it will blow either way. If you're working in tight embedded systems, you probably can't afford to make a stack without hard limits on it anyway, and again it doesn't matter (except that you can probably make the special-purpose stack take less memory than recursion).

    The next most important reason to not use recursion is because it is slower....Recursion uses more memory.

    Computers tend to be bigger and more powerful than we actually need, and sacrificing raw efficiency for things like readability, maintainability, etc., is completely standard in most cases. Modern software tends to be sufficiently complex that it would never get written without compromises like that.

    Recursion is a maintenance nightmare.

    Let's assume we have a binary tree with nodes like struct node { datapackage stuff; struct node * left, right; }

    where "datapackage" is a struct or class type. Now, for in-order traversal:
    void traverse (struct node * n) {
    if (left) traverse(left);
    process(stuff);
    if (right) traverse (right);
    }

    Now tell me how difficult this is to maintain. Now, write code to do the in-order traversal without using recursion and tell me how easy that is to comprehend at a glance.

  5. Re:Doing it wrong? on Developer Argues For 'Forgotten Code Constructs' Like GOTO and Eval (techbeacon.com) · · Score: 1

    If we're talking about an inherent recursive algorithm (tree traversal is an obvious example), we have to maintain a manual stack. Go through your earlier questions and ask them about the manual stack.

    As far as adding a 2MB array, I have a suggestion: test your code before you check it in.

    Also, problems you don't know a solution to may in fact have solutions, although you may not realize this due to Dunning-Kruger.

  6. Re: Doing it wrong? on Developer Argues For 'Forgotten Code Constructs' Like GOTO and Eval (techbeacon.com) · · Score: 1

    This is why recursion should be forbidden: People don't even think about it or don't have a clue.

    Eliminate every programming construct that careless people can misuse, and you've got nothing left.

  7. Re:Doing it wrong? on Developer Argues For 'Forgotten Code Constructs' Like GOTO and Eval (techbeacon.com) · · Score: 1

    There are ways to avoid trees decaying into linked lists. As long as you have to treat it as a tree, though, you need to keep a stack, and a manually controlled stack can blow stack space itself.

  8. Re:Doing it wrong? on Developer Argues For 'Forgotten Code Constructs' Like GOTO and Eval (techbeacon.com) · · Score: 1

    Overall, it's generally impossible to say that, of two reasonable approaches to programming, one is always better. (It is possible to do this with unreasonable approaches to programming, such as generating random programs until one passes the acceptance test.)

    Abstractions can leak when they're used in unusual ways. As Joel Spolsky put it, TCP is an abstraction that makes it possible to maintain a continuous lossless two-way connection - until you find that the reason it isn't working is that your pet snake chewed through the Ethernet cable. At that point, you have to disregard abstraction of the hardware layer. Even in a world with snakes, though, it's almost always better to use TCP facilities when appropriate than to go to the bare metal.

  9. Re:Doing it wrong? on Developer Argues For 'Forgotten Code Constructs' Like GOTO and Eval (techbeacon.com) · · Score: 1

    If you're working with cache constraints, recursion might be better than iteration. In different circumstances, different techniques can be better.

  10. Re: Doing it wrong? on Developer Argues For 'Forgotten Code Constructs' Like GOTO and Eval (techbeacon.com) · · Score: 1

    Exactly. Recursion is heavy on stack use, and you cannot be sure that your target system has enough stack space available.

    If your solution involves a stack, it doesn't matter within a constant factor whether you use recursion or keep a stack manually. If it's recursing endlessly, it's going to blow either way.

  11. Re: Doing it wrong? on Developer Argues For 'Forgotten Code Constructs' Like GOTO and Eval (techbeacon.com) · · Score: 1

    Yup. Programming with limited resources can result in hard-to-understand programs that would be easier to understand if the right abstractions were available, typically on a larger machine. PNGs at 11.

  12. Re: Doing it wrong? on Developer Argues For 'Forgotten Code Constructs' Like GOTO and Eval (techbeacon.com) · · Score: 4, Insightful

    Some algorithms are naturally recursive. For example, in-order traversal of a binary tree is easiest described as: deal with the left child, deal with this node, deal with the right child. Tower of Hanoi is easily solvable with: Move all disks above the one you want to move to the other peg, move the disk you want to move to the peg you want to move to, move the disks you moved earlier to on top of the disk you wanted to move.

    In these cases, if you use loops, you're going to be making up all the stuff recursion is good for, and you're going to be maintaining your own stacks. There's no advantage to doing this rather than using recursion. If you were going to get into a loop and recurse indefinitely, if you translate it into loops you're going to get into a loop and push indefinitely.

  13. Re:Warrant issued upon probable cause on Police Use Pacemaker Data To Charge Homeowner With Arson, Insurance Fraud (networkworld.com) · · Score: 1

    That's irrelevant, and was brought up in the post I was replying to. The question is not whether it was possible, but whether it was possible without leaving evidence in the pacemaker logs.

  14. Re:Let's hope it's true! on Scientists Marvel At 'Increasingly Non-Natural' Arctic Warmth (msn.com) · · Score: 1

    It was decades ago that a Republican Senator (Dirksen?) said "A billion here, a billion there, pretty soon you're talking about real money." Half a billion out of the Federal budget is pretty close to trivial. BTW, who said the transfer was illegal?

  15. Re:They don't get it. on Microsoft Seeks Trump Order Exemption for Workers With Visas (bloomberg.com) · · Score: 1

    That would appear to mean that Trump wanted to change vetting and that Obama actually put together the list rather than signed the major appropriations bill it was a rider of.

  16. Re: Indeed! on False News, Absurd Reality Present Challenges For Satirists (apnews.com) · · Score: 1

    Okay. Put the idiot propaganda down and back away slowly. Mussolini was a socialist before he became a fascist, true, but that's about where your truth ends.

    Socialism is anti-corporation. Fascism was pro-corporation. Socialism is anti-nationalist. Fascism is nationalist.

  17. Re:History lesson on False News, Absurd Reality Present Challenges For Satirists (apnews.com) · · Score: 1

    I think you'll find that's not what the courts say about emoluments. The primary meaning I found was pay for service.

  18. Re:Is it too soon? on False News, Absurd Reality Present Challenges For Satirists (apnews.com) · · Score: 1

    Way too soon to talk about it. We need to wait until it happens.

  19. Re:FUD people. on False News, Absurd Reality Present Challenges For Satirists (apnews.com) · · Score: 1

    hacking of electronic voting machines. When that was proved ridiculous

    It was never proved ridiculous. Some of those voting machines are very hackable, and some people found some statistical evidence that they had been hacked. We know Russia favored Trump and is quite willing to hack into US stuff (I assume we return the favor), so we have motive, method, and opportunity. What we don't have is anything like solid proof that it happened.

  20. Re:History lesson on False News, Absurd Reality Present Challenges For Satirists (apnews.com) · · Score: 1

    Who are you arguing with? The comment was about Mussolini. If Trump gets the degree of control Mussolini did, or screws the US up like Mussolini screwed up Italy, then I'll approve of assassinating him (although I'd rather he was deposed and tried).

    Other than that, I agree with you.

  21. Re:History lesson on False News, Absurd Reality Present Challenges For Satirists (apnews.com) · · Score: 1

    What I don't know is who rioted. I've become increasingly suspicious of possible agents provocateur over time. Who benefited form rioting? Clearly Trump supporters, who could blame leftists for violence.

  22. Re:History lesson on False News, Absurd Reality Present Challenges For Satirists (apnews.com) · · Score: 2

    Now that's just sad. Comparing Trump to Hitler? Seriously?

    Yup, seriously. His base is composed largely of disaffected white people who blame their problems on minorities. He stirs race and national and religious hatred. He has no regard for the truth. He shows strong authoritarian and us-vs.-them tendencies. He's strongly nationalist at the same time he makes the state of the US sound as bad as he can. The feel of Trump and his campaign is much like the feel of Hitler and his campaign. Read some history.

    Fortunately, Trump is a lot less competent than Hitler, and has much worse impulse control. As you note, it's harder to become a tyrant in the US than in Weimar Germany, although legal barriers are only as strong as their enforcement. You do realize that some border agents defied the court ruling about the entry ban, don't you?

    Trump nominates an "originalist" to the Supreme court, a guy who says that he must interpret the laws as they where INTENDED by the original authors and decide the issues based on that, not his personal feelings.

    And, of course, nobody connected to Trump has ever lied, right? Hint: Everybody nominated to the Supreme Court interprets the laws as they were intended. Just ask them.

    Name ONE of Trump's orders that has attempted to expand the power of the presidency or make a new law? (Hint: there isn't one as of this writing)

    The travel ban might be illegal; we'll have to let the courts decide that. If so, it's either an attempt to expand the power of the Presidency or make a new law. And "as of this writing" is two weeks after Trump became President. Give him time.

    In the meantime, I'd bet that he's violated the Constitution, in that I think it very likely that a government has had dealings with part of the Trump empire. Trump is going to make it as hard as possible to find out for sure, of course.

  23. Re:Please put down your KoolAid and re-enter reali on False News, Absurd Reality Present Challenges For Satirists (apnews.com) · · Score: 1

    So Trump upholds the constitution,

    Sweeping assertion with no support whatsoever. If any part of his business empire does business with foreign or domestic governments, he's violating the Constitution. (This doesn't apply to foreign private citizens or corporations, although a state-owned corporation probably counts as government). He's awfully secretive about his finances for a guy who didn't put his assets in a blind trust.

    appoints a constructionist supreme court judge who will protect the constitution and bill of rights as written

    Hint: The Supreme Court nominee $YOU agree with is going to protect and enforce the Constitution and Bill of Rights. The one #YOU disagree with will trample on it. A casual statement like yours strongly suggests that you're being highly partisan.

    Take a look at the list of actions he has taken thus far and tell me which ones have hurt you

    I'm a white cis straight upper-middle-class male of northwest European descent and Protestant heritage. Aside from screwing things up in general, Trump's not going to hurt me any time soon. However, I'm of the "First they came for the Muslims, and I said 'Not this time, motherfucker!'" persuasion.

    Which of these actions send brown shirts to your house in the middle of the night?

    Um, you do realize that Hitler took some time to consolidate power, don't you? Trump's been in office two weeks, and the situations are somewhat different.

    Which executive actions authorize incarceration of innocent people?

    So you're telling me that legitimate visa holders from all countries were allowed to leave the airport and go about their business? A person from the Middle East with a US visa has been vetted up the wazoo already.

    120 day travel ban (not permaban) on visitors from terrorist hotbeds (Obama banned travelers/refugees from the same countries for 6 months after they found to terrorists had made it through the vetting process)

    Odd that no citizen of any of the listed countries has killed anyone in a terrorist act in the US, then, while citizens of similar countries not on the list have. Also, Obama delayed the granting of visas. He didn't suddenly arbitrarily and possibly illegally block normal entry into the US of people who had visas.

    If popular support for unpermitted immigration

    Which has nothing to do with Trump's actions, since every person he barred entry has been checked thoroughly and found not to be a significant threat - otherwise, they wouldn't have visas.

    Hardcore Islam is at war with America

    That's cute. This is a great country, regardless of what Trump says. We'll deal with hardcore Islamists pretty much as we like until one of them manages to kill almost as many people as die in accidents in about a month, and then they'll find out that the US isn't weak at all. Osama bin Laden got our attention, and we invaded his refuge country and eventually hunted him down and killed him. Al-Qaida was mostly ineffective until we invaded Iraq and revitalized them. This is what a great terrorist success looks like: you get your organization trashed, and you hide for as many years as you can while the US hunts you down like a dog. Lucky guys.

    We are America and we have our own culture and when you come to America, we expect you to become an American, not some hyphenated class who enjoys the economic benefits and peace while still wishing you were in your homeland.

    Have you ever looked at any history of immigration? This is how it's always worked. There's a lot of nationalities that have been assimilated, but that's because they've been here for generations. We'll assimilate the Arabs just like we assimila

  24. Re:Indeed! on False News, Absurd Reality Present Challenges For Satirists (apnews.com) · · Score: 1

    Hitler was not a socialist. The Nazis got along swimmingly with German industrialists, and allowed them to retain ownership and control of their enterprises and profit from them. The German labor union was mostly powerless and existed primarily for cosmetic effect. Hitler never did take the "socialist" and "worker" out of the name of the National Socialist German Workers' Party, and Mein Kampf discusses why you keep the propaganda consistent when you change the political realities. There was a socialist wing in the NSDAP, and that was eliminated with extreme prejudice in the 1930s.

    Which bio were you referring to? When I was digging into this, Kershaw's was generally considered the best.

  25. Re:Indeed! on False News, Absurd Reality Present Challenges For Satirists (apnews.com) · · Score: 1

    Hitler did not have a well-defined ideology. National Socialism was not particularly coherent. You can pick out a lot of individual things they strongly believed, but you can do that with Trump.

    My best conclusions are that the Nazis didn't believe in rationality and thought, but rather in emotions and an evil form of mysticism. Try picking something coherent out of it besides things like "Jews are evil", "We need to make Germany great again", "we must obey the Leader", and stuff like that.