Slashdot Mirror


User: bunratty

bunratty's activity in the archive.

Stories
0
Comments
3,482
First seen
Last seen
Profile
(view on slashdot.org)

Comments · 3,482

  1. Re:Are templates always necessary? on C++ Templates: The Complete Guide · · Score: 1
    Sorry, I forgot one bytecode for the first test, which uses instanceof:
    12 aload_1
    13 instanceof #10 <Class java.lang.Number>
    Of course x has to be pushed onto the stack before we can test if it's a Number.

    The response to my challenge brilliantly demonstrated my point about reflection. It's way trickier than it looks! DON'T USE REFLECTION IF AT ALL POSSIBLE!!!

  2. Re:Are templates always necessary? on C++ Templates: The Complete Guide · · Score: 1
    Thank God no idiot modded you up. You couldn't be more wrong. Try running this code:
    public class TryIt {
    public static void main(String[] args) {
    Object x = new Integer(3);
    System.out.println(x instanceof Number);
    System.out.println(x.getClass() == Number.class);
    }
    }

    Here's the output of running the code:
    true
    false

    Here's the bytecode for the first test:
    13 instanceof #10 <Class java.lang.Number>

    Here's the bytecode for the second test:
    22 aload_1
    23 invokevirtual #12 <Method java.lang.Class getClass()>
    26 getstatic #13 <Field java.lang.Class class$java$lang$Number>
    29 ifnonnull 44
    32 ldc #14 <String "java.lang.Number">
    34 invokestatic #15 <Method java.lang.Class class$(java.lang.String)>
    37 dup
    38 putstatic #13 <Field java.lang.Class class$java$lang$Number>
    41 goto 47
    44 getstatic #13 <Field java.lang.Class class$java$lang$Number>
    47 if_acmpne 54
    50 iconst_1
    51 goto 55
    54 iconst_0

    Now go compile and run that code yourself and use javap -c and look at the bytecode. Then read what I originally wrote again and come back with a more sensible response!

  3. Re:Are templates always necessary? on C++ Templates: The Complete Guide · · Score: 1
    And instanceof is also more powerful than ".getClass().getName().toLowerCase()". It can report whether the class is a subclass of the type you are expecting, not just the exact class. The cast will work in the subclass case, and this is exactly what instanceof tests. The corresponding reflection test would be even more complicated than the code shown.

    Anyway, if you want the exact class test, it's better to write "if(x.getClass()==Integer.class)" and compare Class objects instead of dealing with Strings. Either this code or the instanceof code will be more robust and faster than the original code.

    Exception handling is not the way to go to handle casting issues, unless it truly is an exceptional or unexpected condition that the cast will fail.

  4. Re: Put templated code in the .h file on C++ Templates: The Complete Guide · · Score: 1
    I notice you've put templated code in a .cpp file instead of putting it in the .h file. I always had to put all templated code in the .h file so the compiler can make the proper code generation. It looks like you'll need the compiler to do the code generation because the linker barfs when you ask it to do it.

    It's a real shame if this book doesn't explain implementation details like this!

  5. Re:Bloat on C++ Templates: The Complete Guide · · Score: 1
    They seemed to me a recipe for bloat/cache thrashing/ugliness.
    You have an excellent point. There's a subset of C++ called Embedded C++ that removes templates, multiple inheritance, new-style casts, exceptions, and some other features. Those are features that tend to make C++ programs bigger and slower than C programs. By limiting the features used by a program and its libraries, and Embedded C++ compiler is able to make leaner, faster code. This can be a huge benefit in embedded systems, hence the name.
  6. Re:Are templates always necessary? on C++ Templates: The Complete Guide · · Score: 3, Informative
    The nice thing about Java to counter, though, is reflection. You can always check the class type and methods before casting.
    It's almost always better to avoid reflection than to use it. In this case, an instanceof test will be easier and faster. Example: Quick, write this code using reflection instead of instanceof:
    if (x instanceof Number) {
    Number n = (Number) x;
    // ...
    }
    Now time how much slower it is...
  7. Re:Are templates always necessary? on C++ Templates: The Complete Guide · · Score: 3, Informative

    GJ is the old implementation of Java Generics. It has since evolved into JSR-014. Sun has a prototype implementation of a compiler that supports generics, and there's even an entire forum for discussing Java generics.

  8. Re:Deterrent on Texas Rep Wants To Jail File Traders · · Score: 1

    Ever hear of the punishment fitting the crime? Certainly we can deter crime by giving everyone who breaks any laws outrageous sentences. But the overall effect of sending millions of people who violate minor laws to prison for years is to erode the fabric of society.

  9. ST: TNG on Texas Rep Wants To Jail File Traders · · Score: 1

    Why don't we just secretly pick one area of each city to thoroughly police each day, and execute everyone who commits any crimes in that area? That'll really make people think twice before littering and speeding, won't it? Certainly this would lead to the perfect Utopia! Sheesh!

  10. Re:And they still doen't support IE's DHTML model on Mozilla.org Launches Mozilla 1.3 · · Score: 3, Interesting

    Where did you get the 95% figure? It's hard for me to find any sites that don't work in Mozilla, and I go to plenty of sites that use JavaScript and DHTML. When I do find a site that doesn't work in Mozilla, it's nearly always very poorly designed and it's just an accident that it happens to work in any browser.

  11. Re:and still no fix for horrible DNS caching bug on Mozilla.org Launches Mozilla 1.3 · · Score: 1

    You mean bug 151929? Developers are not "refusing to address" the issue. They have marked that they want help in addressing it, in fact.

  12. Re:about:config? on Mozilla.org Launches Mozilla 1.3 · · Score: 1

    Yes. Actually, the new feature is that you can now edit your settings in the about:config window!

  13. Re:find NEXT as you type on Mozilla.org Launches Mozilla 1.3 · · Score: 2, Informative

    F3 or Ctrl-G

  14. Re:Bad import feature! Bad! on Mozilla.org Launches Mozilla 1.3 · · Score: 4, Informative

    It's bug 176715 and should be fixed by Mozilla 1.4: http://bugzilla.mozilla.org/show_bug.cgi?id=176715

  15. Re:Begging you not to Beg the Question on Sun Rethinking Linux Strategy Over SCO Lawsuit · · Score: 1

    No, that's not what "begging the question" means, either. Begging the question is assuming true what you are attempting to prove.

  16. Re:It doesn't beg the questions on Sun Rethinking Linux Strategy Over SCO Lawsuit · · Score: 1
    Your example is a presupposition, which is a question or statement that assumes a previously unstated fact to be true.

    This is completely different from begging the question, which means that in trying to prove something, you assume it's already true.

    Both of these are completely different from what the summary author meant, which is "leads to the question."

  17. Re:And they shouldn't make money why? on Antibiotic Resistant Staph Antibiotic Discovered · · Score: 5, Insightful

    You obviously have no idea how much money it takes to conduct studies that prove the drug safe and effective. This needs to be done before the FDA and other drug agencies approve the drug for use. It can take millions of dollars to conduct just one study, and usually multiple studies are needed to test the safety in kidney patients, the elderly, and the young. If drug companies couldn't make billions of dollars a year for about a decade from "blockbuster" drugs like this, there wouldn't be any drug companies at all, and thus no new drugs.

  18. Re:PHP scripting/coding/whatever on Do Scripters Suffer Discrimination? · · Score: 0
    Just tell him that both PHP and Java are both interpreted languages...
    There's no such thing as an "interpreted language". Any language can be compiled or interpreted. Java is first compiled into bytecode, and modern JVMs compile the bytecode into machine code.

    A more useful distinction to make is between scripting languages, which usually have an eval feature to evaluate an expression, and programming languages, which usually do not have eval.

  19. Re:Older Hat on Automatic Wireless Network Organisation · · Score: 1

    Seems like you're way behind the curve. Six years ago the company I worked for teamed up with a company that had been doing this for years. That company was acquired by Nokia in 1999.

  20. Re:Why isn't there SFTP support from the browser? on FTP: Better Than HTTP, Or Obsolete? · · Score: 1

    It's bug 85464 in Bugzilla. Here's a link to it: http://bugzilla.mozilla.org/show_bug.cgi?id=85464

  21. Usability Experts on Why Users Hate IT Products and Developers · · Score: 2, Insightful

    It's incidents like this that make me think it really is time to listen to the usability experts. Sure, the extremists we hear about seem to have some crazy ideas, but there must be some out there that have a clue about how we can make interfaces more usable, right?

  22. Re:Opera 7.0 on Opera 7.0 Security Holes ... Fixed · · Score: 1

    Opera always develops its software for Windows first, then ports it to other platforms. That's why Opera 7 is available only on Windows right now.

  23. Re: Evolution of Java on Guido van Rossum on Programming at Python Speed · · Score: 2, Informative

    Funny, I thought the Java Community Process and the Bug Parade were step 2! As a result of feedback, Java has added nested classes, strictfp, generics, enums, foreach, reference objects, tons of library classes, as well as fixed thousands of bugs.

  24. Re:Unices? on Large File Problems in Modern Unices · · Score: 1
    Oh, that brings up a pet peeve of mine -- when people call a matrix a "matricee"! When I hear someone say that word, I roll my eyes and think "this guy has no idea what he's talking about!"

    Getting back on topic, maybe the plural for Unix should be Unixen, like the plural for Vax is Vaxen?

  25. Re:Why large files on Large File Problems in Modern Unices · · Score: 2, Interesting

    Over Christmas and New Years, I helped my wife run a simulation of 1000 different patients for an acedemic pharmacokinetics paper. The run took ten days and had an input file of about 1.5 GB. If her computer was faster, or she had access to more computers, she would have wanted to simulate more patients and would easily have needed support for files larger than 4 GB. As CPUs get faster and hard disks get larger, there will be much more demand for these large files as well as more than 4 GB per process.