Tuesday, July 30, 2013

he C++ Memory Model and Modern Hardware by Twisted Oak Studios

 


Comment on atomic Weapons: The C++ Memory Model and Modern Hardware by Twisted Oak Studios | Unity3D Consulting | Technical Magic

[…] months ago, I watched a talk by Herb Stutter called Atomic Weapons: The C++ Memory Model and Modern Hardware (Part 1, Part 2). One of the lessons from the talk is: if you want sequential consistency, then […]

Read More »


 

Sunday, July 28, 2013

Welcome to the Jungle by seo workshop

 


Comment on Welcome to the Jungle by seo workshop

It should be noted that while Google has targeted many article distribution sites, you will
not be penalized for having your content on these
sites- the more likely possibility will be these back links will have less power and thus be less effective- so there is no need to remove any of your content from these sites.
To increase your number of links just write and submit more articles to article directories.
SEO Tampa is a way to get your site seen, more traffic
equals more sales right.

Read More »

Comment on Complex initialization for a const variable by online form generator

Now, there are hundreds of programs available ranging from free to
hundreds of dollars, including everything from a bare bones setup to an
all inclusive image editing suit. Rather, they’re designed to help spark possibilities in your own mind. Therefore it’s better to always do the intelligent point
and take these tips.

Read More »

Comment on GotW #1 Solution: Variable Initialization – or Is It? by Anubhav

In 1 (a), is it totally correct to say ‘Note that w is not initialized…’ for the case of a trivial class? $8.5/6 third bullet does not apply to this case (the first bullet applies) and hence I think that initialization is performed.

Read More »

Comment on GotW #1 Solution: Variable Initialization – or Is It? by Herb Sutter

@Anubhav: Yes, the first bullet does apply, but the invoked constructor may be trivial. References to N3690 (current draft): 8.5/12: “If no initializer is specified for an object, the object is default-initialized…”. Which takes us to: 8.5/7: “if T is a (possibly cv-qualified) class type… the default constructor (12.1) for T is called…”. If widget is a class type, which can still be trivial or int-like, this takes us to: 12.1/4 which says that “… the default constructor is trivial” if the list I mentioned in 1(a) is satisfied. So yes, a constructor is called, but it may be trivial and have no effect. When construction is trivial, the language also allows you to access members before the constructor runs, goto past a local variable’s initialization, and such.

Read More »
  

Saturday, July 27, 2013

FeedaMail: Comments for Sutter’s Mill

feedamail.com Comments for Sutter's Mill

Comment on Recommended reading: Why mobile web apps are slow (Drew Crawford) by opciones binarias

Hey there! I realize this is kind of off-topic however I had to ask.
Does operating a well-established blog such as yours require a large amount of work?
I am completely new to running a blog but I do write in my diary daily.

I’d like to start a blog so I will be able to share my personal experience and feelings online. Please let me know if you have any ideas or tips for new aspiring blog owners. Thankyou!

Read More »
 
Delievered to you by Feedamail.
Unsubscribe

Thursday, July 25, 2013

FeedaMail: Comments for Sutter’s Mill

feedamail.com Comments for Sutter's Mill

Comment on Reader Q&A: When will better JITs save managed code? by HTML5SALON沙龙

[…] 下面这段话出自于Herb Sutter,现代C++中最著名的人物之一: […]

Read More »

Comment on Recommended reading: Why mobile web apps are slow (Drew Crawford) by HTML5SALON沙龙

[…] Sutter在自己的博客中推荐了一篇文章《Why mobile web apps are […]

Read More »

Comment on Lost two comments by The Krever Kreymborg Kriangsak Chomanan Krieg Kriege Krieger Kriemhild Kries Krigia Krigsman Krilov Krinthos Krio Kriophoros Krips Kris Krischer Krisha Krishna Krishna Menon Krishnah Krishnaism Krishnaist Krishnaite Krishnaitic Krispin Kriss Kriss Kringle

Excellent enthusiastic analytical attention for the purpose of fine
detail and may anticipate problems before they will take place.

Read More »

Comment on GotW #2 Solution: Temporary Objects by The Bogus SE/SE Rule | Bulldozer00's Blog

[…] Single Entry / Single Exit (SE/SE) “rule” of programming. I wish I had this eloquent Herb Sutter treatise on hand when it […]

Read More »
 
Delievered to you by Feedamail.
Unsubscribe

Wednesday, July 24, 2013

FeedaMail: Comments for Sutter’s Mill

feedamail.com Comments for Sutter's Mill

Comment on Recommended reading: Why mobile web apps are slow (Drew Crawford) by 为什么移动Web应用程序很慢(译) – tangzhnju | 查问题

[…] Sutter在自己的博客中推荐了一篇文章《Why mobile web apps are […]

Read More »
 
Delievered to you by Feedamail.
Unsubscribe

Tuesday, July 23, 2013

FeedaMail: Comments for Sutter’s Mill

feedamail.com Comments for Sutter's Mill

Comment on My //build/ talk on Friday @ noon PDT (webcast) by Tom

=D This talk was some of the best news I’ve heard in 2013! Not sure why so many comments are thinly-veiled insults. Herb, you and the ISO C++ team and the VC++ team are doing a ton of very meticulous work and I just wanted to let you know it’s greatly appreciated!

Read More »

Comment on Reader Q&A: auto and expression templates by Radics Péter

I think it would be better to have something like ‘using auto = my_preferred_auto_type;’ instead of ‘my_preferred_auto_type operator auto();’ to avoid code duplication and to keep all the conversion operators look the same (as in, no return type specified). Although my first idea was also operator auto when I first encountered this problem, so from the discoverability point of view it is probably better :)

Read More »
 
Delievered to you by Feedamail.
Unsubscribe

Monday, July 22, 2013

FeedaMail: Comments for Sutter’s Mill

feedamail.com Comments for Sutter's Mill

Comment on My //build/ talk on Friday @ noon PDT (webcast) by lotto

Such agreements can be downloaded from your lottery provider’s website and in many cases can be picked up from your lotto retailer. Decide on a large online game which provides out numerous scaled-down prizes. Your odds of successful maximize with the lower ball video games.

Read More »

Comment on GotW #6a Solution: Const-Correctness, Part 1 by C++ Const-correctness with volatile and external datat acess | BlogoSfera

[…] method const for the reason stated in the question. This is especially true after stumbling upon this GotW article, which states that the meaning of const is changing to mean “able to read […]

Read More »
 
Delievered to you by Feedamail.
Unsubscribe

Sunday, July 21, 2013

FeedaMail: Comments for Sutter’s Mill

feedamail.com Comments for Sutter's Mill

Comment on Recommended reading: Why mobile web apps are slow (Drew Crawford) by Fredrik

Yet I’ve NEVER experienced anything even remotely close to a GC slowdown on my Windows Phone. Or when trying out older WP7 phones or low memory WP8s.

Read More »
 
Delievered to you by Feedamail.
Unsubscribe

Saturday, July 20, 2013

FeedaMail: Comments for Sutter’s Mill

feedamail.com Comments for Sutter's Mill

Comment on Lost two comments by slimmer you garcinia cambogia

Thanks for sharing your thoughts on Slimmer You Garcinia Cambogia.
Regards

Read More »

Comment on My //build/ talk on Friday @ noon PDT (webcast) by Rajiv

Hi Herb: A bit off topic but given this is on the future of C++ I thought I’d ask. What do you think of some of the newer native languages like Rust? Rust though very immature at this point, seems like it is doing a lot of things right, with it’s focus on compile time correctness and pretty syntax. How do you see C++ compete with these newer languages?

Read More »
 
Delievered to you by Feedamail.
Unsubscribe

Thursday, July 18, 2013

A good book to learn C++

 


Comment on Reader Q&A: A good book to learn C++11? by incinerador de grasa

I drop a comment each time I especially enjoy
a article on a site or I have something to contribute to
the discussion. It is a result of the passion communicated
in the article I looked at. And after this post Reader Q&A: A good book to learn C++11?
| Sutter's Mill. I was actually excited enough to write a thought :
-P I actually do have a couple of questions for you if
it’s allright. Could it be only me or do some of the responses appear like they are written by brain dead individuals? :-P And, if you are posting at other online social sites, I’d like
to keep up with you. Would you make a list all of your shared pages like your linkedin profile,
Facebook page or twitter feed?

Read More »
  

Wednesday, July 17, 2013

Why mobile web apps are slow

 


Comment on Recommended reading: Why mobile web apps are slow (Drew Crawford) by Herb Sutter

@Zeckul: “The equivalent of an array of MyClass in C# would be an array of MyClass* or MyClass& in C++; the equivalent of an array of MyClass in C++ would be an array of MyStruct in C#. Let's not compare apple to oranges.”
“Array of MyClass” is exactly an apples-to-apples comparison that shows how the barrel of apples is much smaller on the managed side. In C++ you only need to resort to an array of * or & only when you want polymorphism, for fundamental reasons that would apply to any language. In C# you have to resort to its equivalent for nearly all types.
You simply cannot do a true (contiguous) array of any old type in C# or Java. You can in C++. Yes, you can do it for all value types (which can be user-defined types at least in C#) but that’s a small and restricted subset of types that are not useful for all kinds of types — objects must be bitcopyable, you cannot even inherit, etc. They are first-class in a sense, but they are absolutely not general-purpose. When you want an array of arbitrary Objects (cap intentional), including boxed values types, you can’t get it contiguously.
To get contiguity, you have to drop down to value types, which is very restrictive and which I correctly said is actively working against an environment and language built around an Object base class of nearly all types — including even boxed value types which can’t be held contiguously.

Read More »

Comment on Recommended reading: Why mobile web apps are slow (Drew Crawford) by Zeckul

@HerbSutter: I think that even in an application containing lots of performance-sensitive code, only a small fraction of types need being placed contiguously in arrays for fast access in tight loops. Moreoever these types are typically raw-data-like, i.e. numerical or geometric data for instance. In addition, implementation inheritance would typically not be used for such types anyway because it becomes difficult to understand their memory layout which is kind of the whole point. Note that value types can implement interfaces (and these methods can be called without boxing with proper use of generics).
With that said, while you are right to say that value types are limited compared to reference types in .NET, these restrictions are not an issue in the concrete cases where value types are indeed required. I would be curious to see an example to the contrary.

Read More »

Comment on Recommended reading: Why mobile web apps are slow (Drew Crawford) by The Curse of Reading and Forgetting : The New Yorker | Glasses

[…] Read more… […]

Read More »
  



Tuesday, July 16, 2013

FeedaMail: Comments for Sutter’s Mill

feedamail.com Comments for Sutter's Mill

Comment on Recommended reading: Why mobile web apps are slow (Drew Crawford) by Zeckul

@HerbSutter: "GC'd object graphs are antithetical to performance" -> I don't see what "GC'd" has to do with the performance of object graphs vs arrays. Object graphs have poor data locality whether they're GCed or not.

"you can still get arrays but you're fighting against the system" -> How are you fighting the system? Arrays and value types are first-class in .NET and popular .NET languages. The syntax, semantics and performance characteristics are the same. If using first-class citizens of the runtime and language is fighting the system then worse should be said about automatic pointers, memory pools and such techniques in C++.

"control over hold/cold data separation and cache line layouts both of which are hard in managed environments that often don't give you the control you need to specify things like alignment directly" -> .NET offers the same control over data layout as C++. Alignement is certainly a valid example where things are easier in C++ but it's not exactly rocket science to do it in managed code either.

The article applied to Javascript and I find that generalizing to all GC'd/managed environments is unfair. .NET and C# were clearly designed with performance and low-level control in mind unlike Javascript, and save from writing intrinsics or inline assembly there are precious few cases where dropping down to native code is necessary. It's entirely possible to avoid GC by managing object pools and arrays exactly like it's done in C++, and it's not "fighting the system" any more than trying to do the same in C++.

Read More »

Comment on Recommended reading: Why mobile web apps are slow (Drew Crawford) by Herb Sutter

@Zeckul: Quick reply — yes, the emphasis is on “graphs” which popular GC-based languages are built around and encourage. Having said that, GC’d object graphs add an additional layer of performance overhead because they need to be traversed by the system, which adds extra memory operations and in some cases contention with program threads/cores.

You can get array allocation, but have to fight the system’s natural way of working and don’t get full support — for example, common limitations/gotchas of arrays in managed languages include that you can only use them with true contiguity with a subset of types (typically fundamental/value types and arrays of big-Oh Objects aren’t contiguous but are really arrays of references), you can’t make use of contiguity unless you pin (that’s a major performance penalty), you can only make arrays up to a 32-bit index size, multidimensional arrays are not contiguous, typically there’s no alignment control, and/or other limitations. BTW, I said “GC-based languages” in the previous paragraph because the language design itself often assumes a GC, making node-based allocation and GC semantics inherent in the language in places — you’re fighting those assumptions and that normal common-path way of working when you opt for arrays, that’s all.

Arrays just aren’t used as much in managed code, whereas they’re the recommended default container ([] and std::vector) in C and C++ code. I haven’t done this experiment, but try counting the mentions of techniques that use arrays in books/articles about managed code vs. books/articles about native code. Note: If you want to try this experiment, be careful when you count, because types called “*Array*” in C# and Java are not always actually arrays in the contiguous sense we mean! — which is symptomatic of what I’m talking about.

Read More »

Comment on Recommended reading: Why mobile web apps are slow (Drew Crawford) by pjmlp

C# and Java are not the only languages with GC, there are quite a few that offer the same memory control that C and C++ do, besides GC.

As mentioned, so far they failed to make a dent into then mainstream due to lack of corporation support, but that doesn’t mean we should now take C# and Java as examples of the only way to implement GC in system languages and its performance.

Read More »

Comment on Recommended reading: Why mobile web apps are slow (Drew Crawford) by Zeckul

@HerbSutter: thanks for clarifying your point. The equivalent of an array of MyClass in C# would be an array of MyClass* or MyClass& in C++; the equivalent of an array of MyClass in C++ would be an array of MyStruct in C#. Let’s not compare apple to oranges. .NET arrays and Lists are contiguous blobs of memory exactly like native arrays and std::vectors. It’s up to the programmer, in both cases, to make use of that contiguity for data locality as need be.

I understand your point on different emphasis, but even then I find it unfair since, as I said, value types are first class citizens of .NET; they’re fully supported and easy to write and use. It’s not like value types were an esoteric feature (as could be said of many C++ features ;) ). For example, all geometric and math primitives in the XNA Framework are value types. If someone cares about performance and avoiding GC overhead it’s entirely feasible to rely heavily on value types and contiguous arrays in managed code, and it’s not particularly difficult or obscure code to write either. At any rate it’s certainly less obscure than most C++ code out there.

“you can't make use of contiguity unless you pin (that's a major performance penalty)” -> You get the data locality performance benefits whether you pin or not, but granted, you can only use pointer arithmetic if you pin. That said, pinning only hurts performance if the array is small (LOH is never moved in memory) and if GC happens to run while it’s pinned; if you only pin for brief amounts of time as is idiomatic with the fixed statement, and do some manual memory management (object pools, value types etc) to avoid putting too much pressure on the GC, the impact can be kept minimal.

“you can only make arrays up to a 32-bit index size” -> Not likely to be an issue even for most performance-sensitive programs. One can always allocate unmanaged memory if need be, exactly as they would in native code.

“multidimensional arrays are not contiguous” -> What is called a “multidimensional array” in .NET *is* contiguous in memory ( http://stackoverflow.com/a/597790/154766 ), although array access are unfortunately not inlined by the CLR. Jagged arrays require an indirection per dimension, but so they do in C++ as well, i.e. an unsigned char** is two layers of indirection exactly like a C# byte[][].

“typically there's no alignment control” -> There’s no built-in wrapper for alignment control but nothing stops someone from allocating a chunk of unmanaged memory (using aligned malloc if need be) and using pointers in C#. While this is not particularly easy, I don’t find C++ to make things so much easier in that regard either.

“True (fully contiguous) arrays just aren't used as much in managed code, whereas they're the recommended default container ([] and std::vector) in C and C++ code.” -> Strange, I thought [] and List were the recommended default containers in C# as well. If you browse MSDN samples for C# those are by far the most commonly used collections. But if managed code litterature makes heavier use of fancy data structures in .NET, perhaps it is simply because they’re more abundant and easier to use.

Similar to how C++ lets you opt-in to use certain “heavyweight” features (virtual methods, exceptions), C# lets you opt-out of GC and type checking (value types, unsafe code). Certainly the defaults and emphasis are different, but let’s not underestimate the possibilities of managed code.

Read More »
 
Delievered to you by Feedamail.
Unsubscribe