且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C++ 标准库 - 我应该什么时候使用它,什么时候不应该使用它?

更新时间:2021-07-03 23:27:37

你可能是懒惰或固执.就个人而言,我一直在生产代码中使用它们.

It's possible you're being lazy or stubborn. Personally, I use them all the time in production code.

我这样做并不是为了炫耀,也不是因为我喜欢编写太空时代代码".相反,我这样做是因为我是一个偏执的程序员,而且我知道生产环境是充满敌意的地方,如果有机会的话,它们会破坏代码并使我的程序变成一堆冒烟的无价值字节.

I don't do this to be fancy, and I don't do this because I like writing "space-age code." Rather, I do this because I am a paranoid programmer, and I know that production environments are hostile places that will mutilate code and reduce my programs to smoking piles of worthless bytes, if given a chance.

我这样做是因为我的座右铭是:***的代码,是你永远不会写的代码."学习如何使用 STL &Std Lib 有效,但是一旦你这样做了,你会发现它可以被使用,所以现在的 1000 行代码可能变成了 100 行.这 100 行可能需要与原始 1000 行一样长的时间来编写,但故障点较少.如果你站在别人的肩膀上,代码会更健壮.

I do this because I live by the motto, "The best code, is the code you never write." It takes time to learn how to use the STL & Std Lib effectively, but once you do you'll find that it can be used so that what now is 1000 lines of code becomes perhaps 100. Those 100 might take as long to write as the original 1000, but there are fewer failure points. The code can be more robust, if you stand on the shoulders of others.