does using external libraries in C++ make sense? -
a colleague of mine stated that
c++ based off of templates completely. dlls c-leftover. 95% of classes templates, why dlls not make sense , not work c++.
i kind of understand argument, @ least large parts of standard library using templates. on other hand, argument not apply shared objects plain, statically linked archives, stating kind of external library "c-leftover", not seem true me.
personally though, of classes not templated , have never had problems building static or shared libraries, while had templates.
so, concluding, colleague bring argument, or rather invalid? furthermore, how libraries boost manage handle templates?
i "i don't agree that." if car industry, equally "now have plastic , carbon fibre, don't need metal build cars. sure, it's possible build cars [aside engine , wheelbearings, etc] in plastic , carbon fibre. @ same time, it's not practical, , it's not "best choice" (unless running formula 1 team, or working @ ferrari, porsche, etc), expect ford, audi, chevrolet, fiat , skoda continue using lot of steel in cars - use more plastic did 5 years ago, , whole lot more 50 years - because it's right thing modern machinery , techniques - doesn't mean metal "useless , no longer needed".
just many things in life, usage of shared libraries (dlls windows term, same concept exists ".so" , ".dynlib" in other oses) or not not straightforward "yes or no" question, sliding scale of "here it's useful" "here's making life difficult , not useful".
templates great solving kinds of problems, large projects, if use templates, whole project not (can not practically) recompiled 1 unit. @ projects such llvm + clang, build compiler in c++. yes, uses templates appropriate, uses classes without templates other things. not mean don't need split project (or introduce code other projects) , using shared libraries not bad idea.
it depends on problem trying solve, , how go solving problem. not is/should solved templates in c++. sure, templates great types of solutions. templates make 0 sense other problems.
i have pascal compiler have written, , if search template
, this:
$ grep template *.cpp *.h expr.cpp:template<> stack.h:template <typename t> stack.h:template <typename t> stack.h:template<typename t>
you can see code doesn't use many templates. mean colleague couldn't write compiler using templates? not. me, templates aren't natural solution of problems in compiler. c++ more template language, has classes , functions without templates too. having said that, should @ using bit more template code... think there places refined...
also, if have project build several executable files share code large extent (for example 1 or more of gui components, database interface, math logic perform calculations, (complex) file-format, or such), using shared library excellent way produce small executable files, rather duplicating [most of] code every application.
Comments
Post a Comment