OSDev and C++0x
Re: OSDev and C++0x
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!
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!
- Combuster
- 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
Eheheh, temptingJamesM wrote:We should get some Haskell-fanboy in here to preach about the benefits of wide-ranging type inference. Combuster - care to weigh in?
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...
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.
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: OSDev and C++0x
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.
Re: OSDev and C++0x
Hi ,
goto is not completely bad . If you disagree , you disagree with Donald E Knuth as well . Please take a look at this paper : http://portal.acm.org/citation.cfm?id=1241535 .
-- Thomas
goto is not completely bad . If you disagree , you disagree with Donald E Knuth as well . Please take a look at this paper : http://portal.acm.org/citation.cfm?id=1241535 .
-- Thomas
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: OSDev and C++0x
Wha? Concepts have solved those!Combuster wrote:hard to debug error messages
Re: OSDev and C++0x
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.Thomas wrote:Hi ,
goto is not completely bad . If you disagree , you disagree with Donald E Knuth as well . Please take a look at this paper : http://portal.acm.org/citation.cfm?id=1241535 .
-- Thomas
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: OSDev and C++0x
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:JamesM wrote: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.Thomas wrote:Hi ,
goto is not completely bad . If you disagree , you disagree with Donald E Knuth as well . Please take a look at this paper : http://portal.acm.org/citation.cfm?id=1241535 .
-- Thomas
- 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 ]
[ Project UDI ]
Re: OSDev and C++0x
Isolate the loops in a function and use return instead of goto.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)
Every good solution is obvious once you've found it.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: OSDev and C++0x
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 ]
[ Project UDI ]
Re: OSDev and C++0x
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...
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...
Every good solution is obvious once you've found it.
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: OSDev and C++0x
An addendum: I was just reading up on C++0x and discovered Concepts have been cut. AwwOwen wrote:Wha? Concepts have solved those!Combuster wrote:hard to debug error messages
Re: OSDev and C++0x
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.
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.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: OSDev and C++0x
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 ]
[ Project UDI ]
Re: OSDev and C++0x
One thing I think is just frigging stupid:
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.
Code: Select all
nullptr