OSDev and C++0x

Programming, for all ages and all languages.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: OSDev and C++0x

Post by Solar »

Exactly...
Every good solution is obvious once you've found it.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: OSDev and C++0x

Post by JamesM »

We should get some Haskell-fanboy in here to preach about the benefits of wide-ranging type inference. Combuster - care to weigh in?

Type inference is a beautiful beast, allowing strongly and statically typed programs while removing a lot of the verbosity. It is especially nice for implementing polymorphic types...

... oh look, that's what we're implementing in our current project! How coincidental! ;)
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: OSDev and C++0x

Post by Combuster »

JamesM wrote:We should get some Haskell-fanboy in here to preach about the benefits of wide-ranging type inference. Combuster - care to weigh in?
Eheheh, tempting

No, Haskell folks who don't define types for their functions are IMO just as bad for maintainability as the ones who think they can get away with goto... :wink:

Now when I'm posting anyway, C++0x doesn't solve the current problems with c++, very annoying for beginners, hard to debug error messages, no context-free grammar, and no widely available compiler that is fully compliant.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: OSDev and C++0x

Post by Owen »

Goto is still the best way to handle errors when RAII isn't available, though. Sure, there are other methods; but they're clunky, and involve bludgeoning control structures to do things they're not supposed to.
User avatar
Thomas
Member
Member
Posts: 281
Joined: Thu Jun 04, 2009 11:12 pm

Re: OSDev and C++0x

Post by Thomas »

Hi ,
goto is not completely bad . If you disagree , you disagree with Donald E Knuth as well :D . Please take a look at this paper : http://portal.acm.org/citation.cfm?id=1241535 .
-- Thomas
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: OSDev and C++0x

Post by Owen »

Combuster wrote:hard to debug error messages
Wha? Concepts have solved those!
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: OSDev and C++0x

Post by JamesM »

Thomas wrote:Hi ,
goto is not completely bad . If you disagree , you disagree with Donald E Knuth as well :D . Please take a look at this paper : http://portal.acm.org/citation.cfm?id=1241535 .
-- Thomas
Donald Knuth, while a legend, has never been a paragon of good software engineering practice. By the same token, if you hold your opinion, you also disagree with Edsger Dijkstra.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: OSDev and C++0x

Post by Love4Boobies »

JamesM wrote:
Thomas wrote:Hi ,
goto is not completely bad . If you disagree , you disagree with Donald E Knuth as well :D . Please take a look at this paper : http://portal.acm.org/citation.cfm?id=1241535 .
-- Thomas
Donald Knuth, while a legend, has never been a paragon of good software engineering practice. By the same token, if you hold your opinion, you also disagree with Edsger Dijkstra.
Literate programming is considered a good practice. Anyway, I don't really care much about either what Knuth or Dijkstra think but I see goto of being useful in any of the two following situations:
  • Jumping out of a nested loop (since break only takes you out of the current one)
  • When produced by parser generators or other types of compilers
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: OSDev and C++0x

Post by Solar »

Love4Boobies wrote:...I see goto of being useful in any of the two following situations:
  • Jumping out of a nested loop (since break only takes you out of the current one)
Isolate the loops in a function and use return instead of goto.
Every good solution is obvious once you've found it.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: OSDev and C++0x

Post by Love4Boobies »

Why? Just to avoid writing "goto"? I think that practice is much worse and decreases readability (not to mention performance).
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: OSDev and C++0x

Post by Solar »

I think it very much improves readability because it gets rid of the goto. A return, even a break, is very well-defined in where it returns / breaks to. A goto doesn't carry that kind of information, you have to search for the target label.

As for performance, a) inline functions aren't that hard to do and b) I'd worry about the nested loop's contents more than about the one additional function call.

Oh, and c) I worked years in an environment where code containing "goto" statements would get rejected by the pre-commit hooks of the version control system, so... 8)
Every good solution is obvious once you've found it.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: OSDev and C++0x

Post by Owen »

Owen wrote:
Combuster wrote:hard to debug error messages
Wha? Concepts have solved those!
An addendum: I was just reading up on C++0x and discovered Concepts have been cut. Aww :(
thre3dee
Member
Member
Posts: 34
Joined: Mon Nov 03, 2008 7:42 pm

Re: OSDev and C++0x

Post by thre3dee »

The thing with auto in C++0x's case is that the type is still uniquely defined by the r-value. Whatever expression is returning an r-value, the type must always be a certain type since the r-value itself can never be a "dynamic" type because of C++'s inherent statically typed nature which is why I'm very much looking forward to it.

The other thing is that IDEs will easily know what type the variable is given that they will know what the r-value's type is so as long as you are using a capable IDE, you won't need to go back to the variable definition to see what type is being assigned.

I don't really care for GC and managed-ness in C++0x as I would rather it retain the speediness of native unmanaged code. The other thing is that C++ is ubiquitous with being manually memory managed and I'm sure most of us still like the fact that we have control over this.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: OSDev and C++0x

Post by Love4Boobies »

I most certainly do. If C++ had managed code and GC and I needed those features I wouldn't use C++ anyway, I'd use C# instead which is better for this type of high-level programming for many reasons.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
-m32
Member
Member
Posts: 120
Joined: Thu Feb 21, 2008 5:59 am
Location: Ottawa, Canada

Re: OSDev and C++0x

Post by -m32 »

One thing I think is just frigging stupid:

Code: Select all

nullptr
WTF? Every other language uses NULL or null. Are they just trying to defy convention? No sh|t null is used in the context of pointers. :roll:
Post Reply