Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Comments

top

Interviews: Ask Bjarne Stroustrup About Programming and C++

Wootery Re:Cutting features and old syntax? (425 comments)

That makes sense. So we essentially have several different 'this' addresses depending on how we're treating our instance. Crazy.

Does that mean a pointer equality comparison might behave unexpectedly, if the two pointers are of different types but refer to the same object?

5 hours ago
top

Interviews: Bjarne Stroustrup Answers Your Questions

Wootery Re:Ah yes, for that we have D (89 comments)

Laziness.

Me qualifying my comment with a nod to that I'm about to discuss a non-C++ language doesn't, in itself, make me an irrational zealot.

I even pointed out that C++ beats D if you're after a "zero-cost abstractions only" language. I had hoped that would be enough to prevent your sort of waste-of-space comment.

I do all my real programming work in C++, by the way. That's mostly because C++ is a more mainstream language than D, but the superior integration with C code is also nice, as is the far superior tooling.

6 hours ago
top

Interviews: Bjarne Stroustrup Answers Your Questions

Wootery Ah yes, for that we have D (89 comments)

Not to be a fanboy, but: a lot of this stuff makes me think "Ah yes, that's why we have D".

We dream of cleaning up the mess

Yep. D is pleasantly free of the mess.

a direct mapping to hardware plus zero-overhead abstraction

Here, D and C++ differ somewhat. D isn't totally unusable without its trusty garbage-collector, but it's not something that's often done.

Being a fan of range/container algorithms

Andrei Alexandrescu agrees. See also these.

Ranges are a standard thing in D.

I think we should think more about isolating unsafe code in a program than to eliminate it. Putting the necessary unsafe code into a different language limits our control of it, limits what can be communicated to it, and typically imposes overheads.

Precisely why D has a safe subset and the @safe and @trusted attributes.

Of course, D doesn't have compatibility with old C++ code, or even with old D code (that's why there's the ancient-but-stable D 1.0 language).

11 hours ago
top

Nuclear Regulator Hacked 3 Times In 3 Years

Wootery Re:Good Job NRC (66 comments)

unless the hackers were dumb enough to believe that the NRC would store sensitive information on a public-facing server?

To be fair, very few organisations take security seriously, even when it's their entire job.

It's not dumb of a hacker to make the assumption that their target is incompetent. Cynical, maybe, but not unfounded.

2 days ago
top

Ask Slashdot: Would You Pay For Websites Without Trolls?

Wootery Re:Very subjective (380 comments)

What on Earth are you talking about?

By that preposterous understanding of 'basic freedom', a technical committee which requires members to submit their real names must also be an infringement on your freedom.

I'm talking about an idea for a forum (and perhaps playing a little devil's advocate), not overturning the First Amendment.

2 days ago
top

Ask Slashdot: Would You Pay For Websites Without Trolls?

Wootery Re:Very subjective (380 comments)

What if we trade-off not monetary price, but anonymity?

Typical trolls neither pay to post, nor have to reveal who they are. If there were a real-names policy (an actual, checked, real-names policy, not bullshit like what Google tried to pull), one would surely see less trolling.

2 days ago
top

Interviews: Ask Bjarne Stroustrup About Programming and C++

Wootery Re:Cutting features and old syntax? (425 comments)

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.

3 days ago
top

Interviews: Ask Bjarne Stroustrup About Programming and C++

Wootery Re:Cutting features and old syntax? (425 comments)

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?

4 days ago
top

Interviews: Ask Bjarne Stroustrup About Programming and C++

Wootery Re:Cutting features and old syntax? (425 comments)

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.

5 days ago
top

Interviews: Ask Bjarne Stroustrup About Programming and C++

Wootery Re:Cutting features and old syntax? (425 comments)

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.

5 days ago
top

Interviews: Ask Bjarne Stroustrup About Programming and C++

Wootery Re:Cutting features and old syntax? (425 comments)

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).

5 days ago
top

Interviews: Ask Bjarne Stroustrup About Programming and C++

Wootery Re:Cutting features and old syntax? (425 comments)

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.

5 days ago
top

Interviews: Ask Bjarne Stroustrup About Programming and C++

Wootery Re:Cutting features and old syntax? (425 comments)

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.)

5 days ago
top

Interviews: Ask Bjarne Stroustrup About Programming and C++

Wootery Re:Cutting features and old syntax? (425 comments)

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.

about a week ago
top

Gmail Now Rejects Emails With Misleading Combinations of Unicode Characters

Wootery Re:FÜÇK ÿèàh (79 comments)

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?!)

about a week ago

Submissions

Wootery hasn't submitted any stories.

Journals

Wootery has no journal entries.

Slashdot Login

Need an Account?

Forgot your password?

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>