ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Herb Sutter's brief look at C++11

<< < (4/5) > >>

Eóin:
Yep, most of it it header only, so all gets compiled in. The other stuff is built as static and dynamic libraries. If you link against the static ones then there are no extra DLLs that need to be shipped with EXE. Build boost takes a lot of time and needs a lot of hard disk space. v 1./47 uses 10GBs for me, 3.5 GBs when NTFS compression is turned on. That's for 8 versions; debug/release * static/dynamic * x86/x64.

The EXE size will grow though, generic coding generates loads of code, the idea being that the compiler optimizes each version it generates for the specific types that are used by your program.

phitsc:
I will use auto like crazy. I will actually use it wherever possible. I think using auto will actually raise productivity. Lambdas will come in handy as well. They will finally allow us to get rid of the boilerplate functor code which is currently necessary to make effective use of some standard algorithms. Both of these are also a clear testimony that C++ is adopting important aspects of yet another programming paradigm (which I think is a good thing), namely functional programming. Even with auto, C++ is still a strongly typed programming language. auto does also not replace typedef, as the type of a lambda expression for example is only known to the compiler (if you want to assign the lambda expression to a variable).

f0dder:
Sounds like a great way to make code disposable, because coming back at a snippet months later it wont be real clear what the hell it does if it isn't commented thoroughly. ...And then you're just changing what you have to type (not eliminating it).-Stoic Joker (November 01, 2011, 11:22 AM)
--- End quote ---
If misused, yes - but if used correctly, it's going to make code a lot easier to read, because it reduces irrelevant line noise.

Iterating a collection is one example, already shown - it's pretty atrocious in old-style C++, and franky... You don't need all the information present in such a block, it's noise. What you're interested in 99% of the time is not how you iterate, it's what you're doing in each iteration. Simplifying the 99% is, by itself, a pretty good idea... and it makes the 1% where you have funky iterator needs stand out. That's good as well.

And for declaring variables - you already have the full variable type on the right-hand side of the assignment expression, duplicating it to the right is a waste of time, and nothing but line noise (unless you need to construct some concrete subtype, and assign it to a generic interface type... but that's another case of the specific and special use case that with C++11 doesn't drown in the 99%).

C++11 is meh. I mean, lambda functions, wtf are they good for? Especially combined with "auto".-Tuxman (November 01, 2011, 04:31 PM)
--- End quote ---
It's good for writing expressive, elegant and succinct code... focusing on what's going to happen, instead of the (often irrelevant) minutiae of implementation details. It also lets you rethink API design - turning things inside-out can be quite beneficial.

You might see lambdas as just syntactic sugar for function objects, but they're the glue that makes functional-style programming feasible in C++... The STL algorithms used to be a real pain to use, it's much more interesting now we have lambdas.

And you get all this goodness while still having a strong statically typed typesystem, compiler-checked, and with pretty much the best damn performance of all of the higher-level languages.

So C++15 or something will maybe allow us to drop the type completely, let's call it "C++ PHP Edition". Oh wait, PHP introduced types...-Tuxman (November 01, 2011, 04:31 PM)
--- End quote ---
Please educate yourself :)
 
I will use auto like crazy. I will actually use it wherever possible.-phitsc (November 03, 2011, 12:02 PM)
--- End quote ---
I think you can go a bit overboard, really. I wouldn't personally use it for primitive types - and I'm wary of using it for variables assigned to the result of a function call. Yes, an IDE will show you the type on mouse-hovering, but you don't always have an IDE... and even when you have, it takes precious milliseconds to deduce the type of a variable that way.

It depends on the code, though. If the variable type seems entirely irrelevant, and all operations are clearly understandable by looking just at the code using the variable, I might still use auto for function-return-assigned variables.

auto does also not replace typedef, as the type of a lambda expression for example is only known to the compiler (if you want to assign the lambda expression to a variable).-phitsc (November 03, 2011, 12:02 PM)
--- End quote ---
Variables with "unspeakable (type) names" - I love that expression :D

Tuxman:
Please educate yourself :)
-f0dder (November 18, 2011, 03:52 PM)
--- End quote ---
How?

f0dder:
Please educate yourself :)
-f0dder (November 18, 2011, 03:52 PM)
--- End quote ---
How?-Tuxman (November 18, 2011, 04:49 PM)
--- End quote ---
Try actually using some of the new features. Think about how they can change the way you code, for the better. Read blogs - I'd suggest checking out C# and Scala stuff, those have had lambdas and type inference longer than C++ (thus more information available, more experiences on "oops" and "aha!" moments) - and while having some FP traits, they're both a lot closer to C++ than the "real" functional languages.

Multi-paradigm ftw.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version