guys, I reached the 30 posts limit in that C++ death thread.
So you can go to http://www.csdn.net/expert/topic/796/796188.xml?temp=.8755152
so we can continue.
He he. it's reasonable to compare C# with Java. Actually this kind of debate never cease ever since the day c# is born. I've written some comparision too.
Forgive me using those jargons. Not showing off anything. Just want to show that C++ is not something that "you can do everything in it freely". Of course, for many of them, Java does not support either.
Restate my two points:
1. C++ is not something perfect. some of its features are bad. Don't make it like the tiger's butt. :)
2. Java IS cross-platform, while c++ IS NOT. you've got to know something before you comment on it.
我没有说那些特征是不重要的,所以“I needn't tell you why those features not in C++ are not important because I also think they are important”。我只是说那些特征可以通过库,通过利用现有的手段来实现。而且我也举例说明了这么做的原因:如果把特征加入语言,那么那些用不到这些特征的程序员就非得为此付出额外的代价,这种代价有时是不可接受的。
不过你最后一段话说到点子上了:“in C++, you have to be experienced and very careful to program cross-platform”。确实,只有相当有经验而且受过良好训练的程序员才能用好 C++ (不仅仅是在可移植性方面),因为 C++ 里的陷阱太多了。这是 C++ 最大的缺点,我同意。
在我看来,C++ 给程序员自由,不强迫程序员以某种特定的风格编程,不把负担强加给不需要那些特征的程序员,这造就了 C++ 的灵活与强大;但同时这么做不是没有代价的,代价就是只有那些受过良好训练、富于经验的程序员才能用好 C++ ,才能避开 C++ 中到处都是的陷阱,才能用 C++ 写出可移植的程序来。
Elminster:
when we criticize that C++ has some problematic features that should be banned, you said: C++ gives you freedom.
While when we say C++ does not have these features, you said: adding those cost much.
your reasoning still sounds to me like "C++ is good because c++ is good".
if we say "feature A is good because C++ has it. C++ gives you freedom"; "feature B is not in C++ because C++ has its own rules, and you may use lib to implement it"
That sound you just define C++ as good.
Whatever C++ support, good. Whatever it does not support, does not matter.
:)
随着标准 C++ 的进一步推广和更多跨平台库的出现
if your software just call class libs, then it's fine. As I said earlier, 1+2 is always cross-platform. i++ is always cross-platform.
But, software is complex. a software that only calls different libs is ideal, but not so common.
By the way, the long list cannot be implemented by a lib (that's why I did not list concurrency control in it).
they are just language features.
请不要把我的观点推向极端,我说“C++ 相信程序员,给予程序员自由,没有强迫”,是指较之其他大多数语言,C++ 的“自由”与“严格”平衡点更多的靠近“自由”这一端,而不是说 C++ 中没有严格的规则 ——— 无论无何,语法规则你总得遵守。
可移植性的问题,你说“migration of software written in C++ is always a big project”,其实不然,我眼前就有一个例子:一个数据的采集、处理、服务软件,因为广泛采用了标准 C++ 和一些跨平台的库,从 WIN NT 平台移植到 SUN UNIX 平台下,所要做的事情只是重新编译而已 ——— 当然了,我得承认有少量代码是有两份实现的 ——— 不能说是 a piece of cake 吧,至少离 a big project 实在远的很。而且我相信,随着标准 C++ 的进一步推广和更多跨平台库的出现,这样的情况会越来越多。
SnowFalcon(恶魔吹着笛子来) :
covariance is not fully support. It only supports covariant return value, not parameters, not template.
people call the friend operator== a double dispatch. But that's only a joke.
continuation? could you give more details rather than just give me some fancy names? don't just read a few lines of ad and recite it as you do for the covariance stuff. :)
Elminster();
did not want to go extreme. But you did not tell me why those features not in C++ are not important, while those in are indespensible.
for 工作在内存紧张的平台上的程序员, I would suggest them using C instead of C++. many c++ fancy features requires overhead at runtime.
interface keyword matters only at compile time. But it does encourage the seperation of interface and class. it enforces you don't have implementation in interface. it tells you explicitly what is the difference of interface and class. they are quite different things, why mess them up together?
C++ is now having gc libs.
just want to emphasize:
in C++, you have to be experienced and very careful to program cross-platform.
But in Java or any other interpreted language, an idiot can write a cross-platform one.