C++ standard library - when should I use it and when shouldn't I?

前端 未结 8 596
离开以前
离开以前 2020-12-29 19:23

I was wondering how often people actually use much of the standard c++ library, particularly the stuff in the and

8条回答
  •  星月不相逢
    2020-12-29 19:54

    You should use standard libraries in all languages, not only C++. That's pretty much a basic rule in programming these days.

    Your impression is wrong; any good project will benefit from building upon known, tested, libraries. The amount of time and man-hours there's behind these libraries is just something that an individual can't achieve alone.

    Lots of people have suffered, sweated, sweared and fought over the years in order to get those libraries properly running. The combined effort of writing, debugging and arguing over each particular implementation detail can probably be measured in decades. On top of that, uncountable machine cycles have been spent running test after test just to make sure that everything worked according to the specs.

    Yet pretty much every programmer has now and then that thought. You know the one.

    "I can do better in one evening".

    I know. I understand. I have been there.

    Go ahead. It's a good experience.

    A long, sinuous path will extend before you. On the initial part of your journey, you will find little implementation pebbles here and there. Some of them will slip into your shoes, most won't.

    Later on the path will stop being so straight; it'll start branching out. Soon you will find yourself trying lots of different paths and backtracking frequently. And occasionally you will encounter a profound chasms of algorithmic uncertainty or a tiresome refactoring mountain.

    All that while you watch your peers speeding on the clean, straight, maintained Standard Libraries Highway.

    Gradually you will realize that refusing to use standard libraries and isn't just lazy or stubborn, but foolish. And terribly inefficient!

    In conclusion - if you want to reach somewhere, no matter how fast you can run, driving a car will get you there faster and more safely (unless you are going to the store downstairs for some milk)

提交回复
热议问题