Slashdot Mirror


User: Wootery

Wootery's activity in the archive.

Stories
0
Comments
1,701
First seen
Last seen
Profile
(view on slashdot.org)

Comments · 1,701

  1. Re:Cutting features and old syntax? on Interviews: Ask Bjarne Stroustrup About Programming and C++ · · Score: 1

    When you have a vector of B*, the compiler must first cast the C* to the B* before inserting it, and it does this by offsetting the pointer.

    But how? The vector is full of pointers. You have no way of knowing whether the pointed-to object is a B instance or a C instance.

  2. Re:Cutting features and old syntax? on Interviews: Ask Bjarne Stroustrup About Programming and C++ · · Score: 1

    class C{ class A parent1; class B parent2; };

    The compiler knows which base class each function belongs to because of static typing, so it knows whether to use parent1.vtable or parent2.vtable. So that's OK.

    I don't see how static typing solves things. If we had a vector of pointers to B objects, and we added a pointer to a C instance (C being a subclass of B), how would the compiler know to offset for the 'parent1' member when it comes to finding the vtable (in the parent2 member) for that instance?

  3. Re:Cutting features and old syntax? on Interviews: Ask Bjarne Stroustrup About Programming and C++ · · Score: 1

    Something I got wrong: looks like the replacement for is_initialized() is to explicitly cast to bool, using static_cast.

  4. Re:Cutting features and old syntax? on Interviews: Ask Bjarne Stroustrup About Programming and C++ · · Score: 1

    ( Just realised the irony in What I don't get is this :P )

  5. Re:Cutting features and old syntax? on Interviews: Ask Bjarne Stroustrup About Programming and C++ · · Score: 1

    What I don't get is this: suppose Dog inherits from Eater and Walker. If I have a vector of pointers to Eater objects, and I add a pointer to a Dog instance to that vector, and I call eat(dogFood) via that pointer, how can the vtable handle both the Eater and Walker member-functions? Surely they each have an idea of which member-function pointer belongs in which index of the vtable. If we have two vtables, surely we mess up the offsets for one of them. Or do we just bounce all the calls for Eater through a trampoline to handle the offsets?

    Looking at Boost.Optional...

    Boost.Optional's is_initialized() is now deprecated, presumably you're meant to just implicitly cast to bool now.

    Apparently there are some pretty major compiler-compatibility issues with Boost.Optional, including the latest Visual Studio compiler, and GCC 4.5 (but not newer GCCs, happily).

    Some StackOverflow discussion and toy examples.

  6. Re:Cutting features and old syntax? on Interviews: Ask Bjarne Stroustrup About Programming and C++ · · Score: 1

    The idiomatic C technique is to have one function pointer per virtual function in the class as a member.

    Is that how GObject works?

    I admit I never really 'got' vtables. How they handle multiple inheritance still doesn't make sense in my head.

    You get the condition that all code you look at can assume the class is in a vaild state. It makes code much simpler to read and write.

    I'm a fan of that. I'm not a huge fan of being forced to use exceptions, though. The fact that the LLVM coding standards forbid them on performance grounds has to count for something.

    Even without that in C, you have to remember to call that macro to initialise things every time. Each time is an opportunity to forget and there's another bug.

    Indeed, unless you macro-horror your way out of the chance to forget.

    If you want to not use exceptions, you can add a validity flag to the struct which you have to test and/or add a .init() method which runs any code that might fail on construction. It's more verbose and possibly slower than using C++ properly.

    Vaguely related: the rather neat Boost.Optional library. There's no way to make it 'safe' and implicitly check against use of uninitialised objects, annoyingly (though you can query it manually), but the machinery seems to be there.

  7. Re:Cutting features and old syntax? on Interviews: Ask Bjarne Stroustrup About Programming and C++ · · Score: 1

    he clearly doesn't understand C++ and has some very odd ideas about it

    Maybe, yes. (I'm quite pro-C++ myself, at least compared to C; I clearly think nothing like Torvalds.)

    I don't see how having constructors instead of manually calling macros and virtual functions built into the language (much better dcache performance than the C version) would do anything but be an improvement.

    How would the cache performance be different? Also, there are things not to like about C++ constructors, error-handling being one of them.

    Agree that any sane developer wanting to write a new C++ compiler (backend) or static-analysis tool would almost certainly be unwise to do anything but use an existing frontend (Clang, EDG... g++ maybe, I guess).

  8. Re:Cutting features and old syntax? on Interviews: Ask Bjarne Stroustrup About Programming and C++ · · Score: 2

    What is the compile-time-friendly subset?

    constexpr. The subset was grown considerably in C++14.

    Its primary remaining use is conditional compilation. That hardly counts as a language.

    Well, no, it does count as its own language, because... it is. If you grant that the preprocessor is, at least. It's clearly separated from the C++ 'core' language, and it's something non-trivial that a C++ programmer needs to know about. Much like the preprocessor.

    There are plenty of neat tricks to be had with the template system that aren't really just conditional compilation. Type traits, static-asserts, Boost.Function and Boost.Bind spring to mind.

  9. Re:Cutting features and old syntax? on Interviews: Ask Bjarne Stroustrup About Programming and C++ · · Score: 1

    What about Clojure?

    Also, I'm not sure it's true that there are no good reasons to start a new project in C. If Linus started the kernel today, I'm sure he'd still go with C. I'm sure there are plenty of embedded programmers who think the same way. C compilers are almost guaranteed to exist for whatever your target platform may be, and there's no shortage of C programmers.

    C is much simpler than C++, and that will always be an advantage to C. Static-analysis, or writing your own compiler, are much simpler with C than C++. (OpenCL uses C rather than C++, for example.)

  10. Re:Cutting features and old syntax? on Interviews: Ask Bjarne Stroustrup About Programming and C++ · · Score: 2

    Reminds me of of a blog-post I stumbled across a while ago: Heat Death Of Programming Languages

    Other than a select few (C and Scheme spring to mind), programming languages get more and more bloated and incoherent over time. We certainly see this in C++, which is probably the 'best' example of the ugliness that arises through backward-compatibility. There are 4 different languages in C++ now: C++ proper, the preprocessor, the template system, and the compile-time-friendly subset.

    I suspect the D language may be growing too big for its own good. They're much less concerned with backward-compatibility, which I suspect helps with the ugliness problem, but doesn't help with, say, high-barrier-of-entry-to-reimplement, or high barrier until you're able to read real-world D code.

  11. Re:Japan is still pretty backwards in some ways on Telegram Not Dead STOP Alive, Evolving In Japan STOP · · Score: 1

    You might want to double-check the attribution of the quote in your sig. Or is it intended to be ironic?

  12. Re:So, such rules are bad for keeping people worki on California May Waive Environmental Rules For Tesla · · Score: 2

    Oh, of course. The great Illuminati/Inventor conspiracy.

  13. Re:FÜÇK ÿèàh on Gmail Now Rejects Emails With Misleading Combinations of Unicode Characters · · Score: 1

    Could've sworn Slashdot had zero support for unicode characters.

    (I appear to be unable to paste in a 'Trademark' symbol. What is this magic, AC?!)

  14. Re:False. on About Half of Kids' Learning Ability Is In Their DNA · · Score: 1

    I see now that I wasn't clear: I was actually thinking not of racism in the researchers, but 'societal racism' in that, for instance, your ethnicity might affect your odds of going a sub-average school. (I strongly suspect there is such a correlation in, say, the USA.)

    Showing that people of a particular ethnicity do poorly in a certain test might not reflect anything genetic, unless you control for the fact that society isn't 'colourblind'.

    strangers with equivalent academic abilities shared genetic similarities

    But maybe imbalances in society mean that your ethnicity affects your odds of getting a high-quality education.

    As an extreme example: if the top 20 universities operated a whites only policy, we'd expect to see that genes associated with being white are also associated with superior academic similarities.

  15. Re:False. on About Half of Kids' Learning Ability Is In Their DNA · · Score: 1

    I missed this gem:

    You may think you’re better at reading than you are at math (or vice versa), but new research suggests you’re probably equally good (or bad) at both. The reason: The genes that determine a person’s ability to tackle one subject influence their aptitude at the other, accounting for about half of a person’s overall ability.

    ...

    The brilliant mathematician — that’s all they do for decades, they just think math and work on math. It’s not like it comes to them with a flash of inspiration. It’s really a long, long process of thinking about these things.

    Right, obviously. So why are they assuming that I have similar ability in math as in reading?

  16. Re:False. on About Half of Kids' Learning Ability Is In Their DNA · · Score: 2

    Thank you. Just what I was thinking.

    A complementary analysis of unrelated kids corroborated this conclusion — strangers with equivalent academic abilities shared genetic similarities.

    This could be of real interest, but racism might skew things.

  17. Re:Gaming? on AMD Prepares To Ship Gaming SSDs · · Score: 1

    AMD treating its customers like idiots? Say it ain't so!

  18. Re:As a European... on Wikipedia Reports 50 Links From Google 'Forgotten', Issues Transparency Report · · Score: 1

    .....doesn't necessarily belong in that article.....

    As AmiMoJo points out, a better example is that of someone falsely accused of rape.

    "not wanting it to be reported" should not be a matter for the law.

    And I wasn't saying it should be. I was pointing out a problem with Opportunist's suggestion. If you reject the intent of the law, you aren't on the same as Opportunist.

    The US still has much to learn from Europe, but we absolutely got freedom of the press right.

    I'm inclined to agree (Brit here, for what that's worth), but again, I was commenting on the 'one strike' idea.

  19. Re:As a European... on Wikipedia Reports 50 Links From Google 'Forgotten', Issues Transparency Report · · Score: 2

    So how about a compromise: You have the right to be forgotten. Once

    Well, no, because it's obviously a broken idea. There are legitimate uses for the 'right to be forgotten' principle, right? As you said, you agree with the intent of the law. What is it which guarantees that no individual will ever have a need to be 'forgotten' twice?

    Example off the top of my head: a victim of two unrelated rapes, who doesn't want a Wikipedia article about them.

    (This is to say nothing of the unenforceable/Streisand/free-speech concerns.)

  20. Re:Naming Conventions on AMD Launches New Higher-End Kaveri APUs A10-7800 and A6-7400K · · Score: 1

    s/Vison/Vision/

  21. Re:Naming Conventions on AMD Launches New Higher-End Kaveri APUs A10-7800 and A6-7400K · · Score: 1

    AMD have the most awful marketing I can think of. Here is archive.org's backup of an old (now deleted) Wikipedia article which nicely summarised the 'AMD Vison' lies.

    They were telling people that low-end machines would be fine for playing DVDs, but wouldn't cope with ripping CDs.

    I really want to like you, AMD...

  22. Re: name and location tweeted... on Man Booted From Southwest Flight and Threatened With Arrest After Critical Tweet · · Score: 1

    Except there are good arguments to suggest the TSA does a pretty poor job of catching weapons, and in truth, you are safe thanks to the fact that very few people out there are set on killing you on a plane.

  23. Re:Not sure how well this will stop cheating on Nuclear Missile Command Drops Grades From Tests To Discourage Cheating · · Score: 1

    Agreed. Intranet, internet. Fourty, fourteen. Absorb, adsorb. And my personal favourite: can, can't. Using the appropriate American pronunciation, the two are almost indistinguishable.

  24. Re: Really? on "ExamSoft" Bar Exam Software Fails Law Grads · · Score: 1

    Interesting points; thank you.

    As I understand it, in China, the lawmakers are generally not lawyers, and they have more ex-engineer politicians. I have no idea if their laws are more comprehensible, though.

  25. Re:RACIST! on Jesse Jackson: Tech Diversity Is Next Civil Rights Step · · Score: 1

    That's not something anyone in the technology sector can effect, though...