现代C ++越来越流行吗? [英] Is modern C++ becoming more prevalent?

查看:55
本文介绍了现代C ++越来越流行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

6到7年前我第一次学习C ++时,我基本上学到的是带类的C". std :: vector 绝对是一个高级主题,如果您真的想要的话,您可以学习一下.当然,没有人告诉我可以利用析构函数来帮助管理内存.今天,在我所看到的所有地方,我都能看到RAII和 SFINAE 以及STL和Boost,以及现代C ++.即使是刚开始使用该语言的人,似乎也几乎从第一天就开始学习这些概念.

When I first learned C++ 6-7 years ago, what I learned was basically "C with Classes". std::vector was definitely an advanced topic, something you could learn about if you really wanted to. And there was certainly no one telling me that destructors could be harnessed to help manage memory. Today, everywhere I look I see RAII and SFINAE and STL and Boost and, well, Modern C++. Even people who are just getting started with the language seem to be taught these concepts almost from day 1.

我的问题是,这仅仅是因为我只看到最佳"问题,即在SO以及倾向于吸引初学者的其他编程网站(gamedev.net)上出现的问题,还是这实际上是整个C ++社区的代表?

My question is, is this simply because I'm only seeing the "best", that is, the questions here on SO, and on other programming sites that tend to attract beginners (gamedev.net), or is this actually representative of the C++ community as a whole?

现代C ++是否真的成为默认值?与其成为专家们写的花哨的东西,不如成为"C ++的方式"?还是我只是无法看到成千上万的人仍在学习带类的C"并编写自己的动态数组,而不是使用 std :: vector ,而是通过手动调用new/delete进行内存管理从他们的顶级代码?

Is modern C++ really becoming the default? Rather than being some fancy thing the experts write about, is it becoming "the way C++ just is"? Or am I just unable to see the thousands of people who still learn "C with classes" and write their own dynamic arrays instead of using std::vector, and do memory management by manually calling new/delete from their top-level code?

就我所想,如果整个C ++社区在短短几年内发展如此之大,这似乎是不可思议的.您的经历和印象如何?

As much as I want to believe it, it seems incredible if the C++ community as a whole has evolved so much in basically a few years. What are your experiences and impressions?

(免责声明:不熟悉C ++的人可能会误以为标题是询问C ++与其他语言相比是否正在流行.这不是我的问题.现代C ++"是C ++中方言或编程风格的通用名称,以本书"现代C ++设计:应用了通用编程和设计模式",而我对此和旧的C ++"完全感兴趣.因此,无需告诉我C ++的时间已经过去了,我们都应该使用Python;))

(disclaimer: Someone not familiar with C++ might misinterpret the title as asking whether C++ is gaining popularity versus other languages. That's not my question. "Modern C++" is a common name for a dialect or programming style within C++, named after the book "Modern C++ Design: Generic Programming and Design Patterns Applied", and I'm solely interested in this versus "old C++". So no need to tell me that C++'s time is past, and we should all use Python ;))

推荐答案

这是我认为事情发展的方式.

Here's how I think things have evolved.

第一代C ++程序员是C程序员,实际上他们将C ++用作带有类的C.另外,STL尚未到位,因此C ++本质上就是这样.

The first generation of C++ programmers were C programmers, who were in fact using C++ as C with classes. Plus, the STL wasn't in place yet, so that's what C++ essentially was.

当STL出现时,这是高级的东西,但是大多数人写书,汇总课程和讲课的人首先学习C,然后学习了额外的C ++东西,因此第二代从此角度学习了.另一个答案指出,如果您习惯于编写常规的for循环,则更改为使用 std :: for_each 不会给您带来多少好处,只是让您感到现代"方式.

When the STL came out, that advanced things, but most of the people writing books, putting together curricula, and teaching classes had learned C first, then that extra C++ stuff, so the second generation learned from that perspective. As another answer noted, if you're comfortable writing regular for loops, changing to use std::for_each doesn't buy you much except the warm fuzzy feeling that you're doing things the "modern" way.

现在,我们已经有使用整个C ++的讲师和书籍作者,并且从这种角度获得了他们的指导,例如Koenig&Co.Moo的Accelerated C ++和Stroustrup的新教科书.因此,我们先学习 char * ,再学习 std :: strings .

Now, we have instructors and book writers who have been using the whole of C++, and getting their instructions from that perspective, such as Koenig & Moo's Accelerated C++ and Stroustrup's new textbook. So we don't learn char* then std::strings.

关于传统"方法的替换需要花费多长时间,这是一个有趣的教训,尤其是当它们具有有效性的记录时.

It's an interesting lesson in how long it takes for "legacy" methods to be replaced, especially when they have a track record of effectiveness.

这篇关于现代C ++越来越流行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆