0

Are there any and if yes, which ones?

Shinnok
  • 6,279
  • 6
  • 31
  • 44
  • 1
    Can you clarify what you mean by "paradigm shifts"? That typically means a drastic change in basic assumptions. Is that what you're talking about? – Cody Gray - on strike Jan 28 '11 at 12:03
  • @Cody Gray Kind of, yeah, what exactly will c++0x change in the way we currently do/assume and work with oop in c++? – Shinnok Jan 28 '11 at 12:06

3 Answers3

4

What do you mean by "paradigm shift"?

C++0x introduces many new features that will of course change the way you write programs.

There are little things that will probably have a big impact on the syntax used, but which won't change the semantics that much. Examples are lambda functions and range-based for-loop: they'll provide a better syntax for what we all are already doing.

Then there are big things that will change the way things work. In particular:

  • Rvalue reference could make you think in a different way about how objects work and how to use them: it'll probably be easier to pass (and return) objects by value.

  • Explicit conversion operators will let us define conversion operators, while doing this in C++03 was risky.

peoro
  • 25,562
  • 20
  • 98
  • 150
1

C++0x does not introduce any new paradigms and doesn't change any paradigms.

Edit: The implementation of those paradigms, however, is subject to some pretty big change with variadic templates and rvalue references, just to begin with.

Puppy
  • 144,682
  • 38
  • 256
  • 465
  • 3
    I dunno, even if you're technically right (which I'm unsure of), that makes it sounds like *no* coding practices will change, which is definitely false. I think the terms may be too vague, though. – GManNickG Jan 28 '11 at 11:53
  • 2
    The OP specifically asks about paradigms, not coding practices, and the two are distinctly different. – Puppy Jan 28 '11 at 12:07
  • See the question comments for an explanation. – Shinnok Jan 28 '11 at 12:17
  • That's where my confusion lies. I think "paradigms" is a vague enough word where it could mean "code practice". Though a reminder that I was only unsure what your implications were, not assertive. :) – GManNickG Jan 28 '11 at 12:19
1

As a matter of fact, I think that yes, there is a paradigm shift. Caveat: I have never written object-oriented code in C++.

The change that may allow a paradigm shift is the standardization of the smart-pointer std::shared_ptr. Now finally does the standard library contain a well implemented, efficient and probably bug-free shared pointer.

C++ experts know how hard it is to get them right, and that most library implementations of reference-counting pointers probably contain subtle bugs. It’s therefore important to finally have a reliable implementation even if (for some brain-dead reason) the company forbids the use of Boost.

This might have drastic consequences on the number of memory leaks: If object oriented C++ applications stopped leaking memory, that would be a paradigm shift.

On the other hand, companies that use their own smart pointers in OOP code will probably not switch to C++0x in the next ten years anyway.

(Just to emphasize this once more, since it’s been repeatedly misunderstood: I am not referring to the technology of smart pointers as a paradigm shift. I am referring to the complete disappearance of memory leaks in object-oriented architectures.)

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
  • 3
    that's not a paradigm shift. The underlying principle is RAII and that is around for decades. They just acknowledge that this specific pointer is of general use and thus added to the standard library. – Tobias Langner Jan 28 '11 at 12:16
  • @Tobias: the abolishment of memory leaks is not a paradigm shift? Well, I do think it is (or rather, would be. I’m not optimistic.) NB: it’s not the *technique* that I’m calling a paradigm shift, it’s the *consequence* on software. – Konrad Rudolph Jan 28 '11 at 12:18
  • 1
    This is a big deal, but it's not a *paradigm*. It's not a fundamentally new idea. It's just a better implementation. – Puppy Jan 28 '11 at 12:21
  • @DeadMG: as I said, I wasn’t referring to the technology (which is a better implementation), I was referring to the potential *consequences*. Your complaint doesn’t apply to them, surely? – Konrad Rudolph Jan 28 '11 at 13:34
  • @Konrad: The consequences of `shared_ptr` do not constitute a paradigm shift. `shared_ptr` does not suddenly mean that SRP is void, or that encapsulation is unnecessary, or we don't need inheritance any more. People will not mass develop new languages based around `shared_ptr` and completely re-evaluate their ideas of what constitutes good code. Those would be *paradigm* shifts with regards to OOP. – Puppy Jan 28 '11 at 13:44
  • @DeadMG: Again, to re-iterate my point: why wouldn’t the *complete disappearance of memory leaks* in software constitute a paradigm shift? I remember it being called a paradigm shift when Microsoft eliminated a whole class of errors from their kernel code by checking *all* numerical operations for overflow. – Konrad Rudolph Jan 28 '11 at 13:53
  • @Konrad: Are people going to go out and mass-design new languages purely around `shared_ptr` like they did for OOP? Does `shared_ptr` mean that you can just throw away the book on memory management and get a new one? Does the difference between `shared_ptr` or not make or break languages? No. None of that is going to happen. We already have languages without memory leaks, and none of them produced a paradigm shift- *especially* since with the advent of concurrency, you need to consider ownership anyway. – Puppy Jan 28 '11 at 14:05
  • @DeadMG: We clearly have different definitions of paradigm shift. **Of course** languages without pointers have led to paradigm shifts. I find that evident. Programming in languages without explicit memory management is fundamentally from programming C++ and I would say that yes, introducing this into C++ would clearly be a paradigm shift. Your questions are completely irrelevant in this context; none of this (except perhaps throwing the book away, to which I would say: yes!) pertains to the definition of a paradigm shift, – Konrad Rudolph Jan 28 '11 at 14:19
  • 1
    @Konrad: The paradigm is RAII. This paradigm was known before. The shift is, that a single additional raii container is now available in the STL. There was an raii container for allocated memory called auto_ptr available before. Now there are 2 named shared_ptr and unique_ptr. Not a big deal, especially since you still need to program your own for other resources and since there were tons of them available in every major library before. In short, no shift, just an acknowledgment of the need. – Tobias Langner Feb 04 '11 at 14:03