找回密码
 FreeOZ用户注册
查看: 3600|回复: 7
打印 上一主题 下一主题

[新技术交流] C++之父Bjarne Stroustrup谈C++0x标准

[复制链接]
跳转到指定楼层
1#
发表于 23-8-2008 21:13:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?FreeOZ用户注册

x
FROM:http://developers.solidot.org/developers/08/08/23/0417239.shtml

C++0x是计划中C++语言的新标准,将取代现有的1998年发布、2003年更新过的C++标准ISO/IEC 14882,预计将于2009年推出。C++之父Bjarne Stroustrup在接受DevX 的采访时,将C++0x中新增的特性归于3大类别:并发性(Concurrency)、库和语言。其中在并发性中引入了ABI线程(Threading ABI),原子类型(Atomictypes),Mutex和Lock类,线程本地存储(Thread LocalStorage),异步信息交换等,这些都使得C++语言在多核处理器上更容易使用。
回复  

使用道具 举报

2#
 楼主| 发表于 23-8-2008 21:23:54 | 只看该作者
FROM: http://www.devx.com/SpecialReports/Article/38813/0/page/1

Bjarne Stroustrup, inventor of the C++ programming language, is acomputer scientist and the College of Engineering Chair Professor ofComputer Science at Texas A&M University. He has always been highlyinvolved in the standardization of C++. Since 2004, Bjarne and thestandards committee have been busy hammering out the details of a newstandard, temporarily titled C++0x. Bjarne was gracious enough to taketime out of his busy schedule to speak with DevX C++ Pro, Danny Kalev,about new C++0x features and the state of the C++ language.

                               
登录/注册后可看大图
The C++0xstandard will be finalized during 2009. Can you outline its majorfeatures and its overall importance to the C++ community?

                               
登录/注册后可看大图
We hope to voteout a draft standard for public review in October 2008 so that we'll beable to hand in a final draft for international vote in 2009. Becauseof this heavy ISO process, it's touch and go whether C++0x will beC++09, but there is still hope and the major features are now known(barring disasters). We can classify the extensions like this
Concurrency: //这次C++还真是下了血本来支持并发了

  • memory model supporting modern machine architectures
  • Threading ABI
  • atomic types
  • mutexes and locks
  • thread local storage
  • asynchronous message exchange
Libraries:
  • regex: regular expressions 正则表达式
  • unordered_map,  etc. (hash tables) hash表
  • smart pointers 智能指针
  • array: fixed-sized array
  • improvements to containers based on new C++0x features
  • tuples 元组
  • date and time (maybe)
  • various library components to held library builders
Language:
  • rvalue references (move semantics)  大名鼎鼎的右值引用问题
  • static_assert: static assertions
  • variadic templates
  • strongly typed enumerations with scoped enumerators
  • constexpr: generalized constant expressions
  • control of alignment
  • delegating and inheriting constructors
  • auto: deducing a type from an initializer
  • decltype: a way of using the type of an expression in a declaration
  • control of defaults
  • nullptr: a name for the null pointer
  • a range-based for loop
  • lambda functions
  • raw string literals
  • UTF8 literals
  • concepts (a type system for template arguments)  concepts是对模板的革命性支持
  • initializer lists and uniform initializations syntax and semantics
  • in-class member initializers
Lists are, by themselves, not very interesting, but you can readup on a description of my general philosophy for language evolution andsome of the individual decisions in my HOPL-iii paper "Evolving a language in and for the real world: C++ 1991-2006." You can also find more information than you could possibly want on the committee's web site.Basically, the "concurrency" features will standardize the basic layersneeded to do systems programming in a multi-core world. Obviously,facilities for doing that already exist in C++ implementations, butthey are not standardized. I'd have liked to see library support forsome high-level concurrency models, but the committee didn't have thetime or consensus for that.
"I'd have liked to see library support for somehigh-levelconcurrency models, but the committee didn't have the timeor consensusfor that."
The library facilities provide a set of new library components and someimprovements to the existing ones. I would have liked to see many more,but the committee is a volunteer effort and we just didn't have theresources for a massive extension of what was offered. Fortunately,there are many libraries available "out there," possibly already onyour machine. For example, many of the C++0x libraries (e.g., regex and unordered_map) are now shipped by major vendors and boost.orgoffers many components (for instance, file system and networking) thatwe'll probably soon see in the standard. There is also much talk of atechnical report on the libraries we most wanted but had to postpone.
The language extensions are a varied lot. Fortunately most aresmall and fit together with each other and with existing facilities tomake a better integrated language. Consider a few examples:
  1. // using C++0x features:
  2. vector<string> v = {"Gorm", "Harald", "Sven",  "Harald", "Knud" };
  3. for (auto p = v.begin(); p!=v.end(); ++p) cout << *p <<'\n';
  4. for (auto x : v) cout << x <<'\n';
复制代码
I suspect most is pretty obvious. You can provide an initializer list directly for a vector,you can deduce the type of an iterator from its initializer, anditerate through a sequence without explicitly mentioning the iterator.More examples:
  1. enum class Season { winter, spring, summer, fall };
  2. int summer;                        // doesn’t clash with Season::summer
  3. Season s = Season::spring;        // note qualification
  4. summer = s;                        // error: no Season to int conversion
  5. Season += Season::fall;        // error: can’t add Seasons

  6. for_each(v.begin(), v.end(), [](const string& s) { cout << s <<'\n'; });
复制代码
You can have enumeration types (class enums) that behaves more like types than glorified integers and the “lambda” notation ([],etc.) is a simplified notation for defining a function object. Each ofthese simple examples can without heroic effort be written today.However, in C++98 that code would be twice the size and in every caseopen opportunities for making errors and/or for introducing overhead.Note that all "primitive" features are meant to be used incombination and in combination with existing features to solveproblems. For example, there is no "magic" for initializing vectors inparticular or even any new "magic" for constructors. Instead, theinitialization of vector was achieved simply by a rule that state thatan initializer_list<T> can be initialized by a list of any numbers of Ts {t1, t2, t3} for any type T. Given that rule, we simply give vector<T> a constructor that accepts an initializer_list<T>. Incidentally, this mechanism can also be used to eliminate about 80 percent of the uses of the type-unsafe stdargs macros.
回复  

使用道具 举报

3#
发表于 23-8-2008 21:29:31 | 只看该作者
完蛋,越搞越复杂了,像多线程,并发性这些不是应该留给OS来完成吗?
回复  

使用道具 举报

4#
 楼主| 发表于 23-8-2008 21:42:22 | 只看该作者

回复 #3 ubuntuhk 的帖子

有一篇文章分析为什么并发必须在语言级别上才能被真正地、彻底地、优雅地解决:


对C++ 0x新特性的讨论介绍有一个精彩的《C++0x漫谈》文章值得一看
系列文章见:
http://blog.csdn.net/pongba 刘未鹏的CSDN博客,国内写C++ blog我最喜欢的一个。
回复  

使用道具 举报

5#
发表于 25-8-2008 13:14:16 | 只看该作者
C++——我心中永远的痛。
回复  

使用道具 举报

6#
 楼主| 发表于 25-8-2008 19:27:08 | 只看该作者

回复 #5 beysup 的帖子

痛啥,说来听听
回复  

使用道具 举报

7#
发表于 26-8-2008 12:30:32 | 只看该作者

回复 #6 coredump 的帖子

一言难尽啊,读大学的时候就自学C++,Linux。工作后用了4年多VC,感觉C++博大精深,业界都这么说,C语言有高手,但是没有绝对的C++高手。用C++做程序最深刻的感受就是要时刻考虑很多系统级的东西,比如内存分配,进程调度,空间/时间复杂度,算法,二进制,必要时还要掌握硬件方面的知识。本人对系统爱好甚于应用,对开发商业软件不是很感兴趣。理想与现实之间就是有差距。
回复  

使用道具 举报

8#
发表于 27-8-2008 13:39:40 | 只看该作者
惭愧,我从来没有集中精力关注过任何一门编程语言。硬件发展作为编程语言C++也随之发展,好事情。感谢coredump所作的介绍。呵呵,楼上的兄弟应该不是理想问题而是金钱问题。
回复  

使用道具 举报

您需要登录后才可以回帖 登录 | FreeOZ用户注册

本版积分规则

小黑屋|手机版|Archiver|FreeOZ论坛

GMT+10, 11-5-2024 18:09 , Processed in 0.050512 second(s), 24 queries , Gzip On, Redis On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表