Why [Programming Language X] Is Unambiguously Better than [Programming Language Y]

转载神文一篇如下:

Recently I have seen a lot of people wondering about the difference between [X] and [Y]. After all, they point out, both are [paradigm] languages that target [platform] and encourage the [style] style of programming while leaving you enough flexibility to [write shitty code].

Having written [simple program that’s often asked about in phone screens] in both languages, I think I’m pretty qualified to weigh in. I like to think about it in the following way: imagine [toy problem that you might give to a 5th grader who is just learning to program]. A [Y] implementation of it might look like this:

[really poorly engineered Y code]

Whereas in [X] you could accomplish the same thing with just

[slickly written X code that shows off syntactic sugar]

It’s pretty clear that the second is easier to understand and less error-prone.

Now consider type systems. [Religious assertion about the relative merits and demerits of static and dynamic typing.] Sure, [Y] gives you [the benefit of Y’s type system or lack thereof] but is this worth [the detriment of Y’s type system or lack thereof]? Obviously not!

Additionally, consider build tools. While [Y] uses [tool that I have never bothered to understand], [X] uses the far superior [tool that I marginally understand]. That’s reason enough to switch!

Finally, think about the development process. [X] has the amazing [X-specific IDE that’s still in pre-alpha], and it also integrates well with [text-editor that’s like 50 years old and whose key-bindings are based on Klingon] and [IDE that everyone uses but that everyone hates]. Sure, you can use [Y] with some of these, but it’s a much more laborious and painful process.

In conclusion, while there is room for polyglotism on the [platform] platform, we would all be well served if you [Y] developers would either crawl into a hole somewhere or else switch to [X] and compete with us for the handful of [X] jobs. Wait, never mind, [Y] is awesome!

C++中的局部类与嵌套类

局部类指在函数内部定义的类,自然局部类不能含有static成员,所有函数定义也必须在定义体内完成。基本不会使用。

嵌套类指在类内部定义类,该类名只能在外围类中使用,嵌套类中的函数成员可以在定义体外定义(但是需要使用限定符以使用类名),嵌套类中申明的成员不是外围类对象的成员,反之亦然。

因此分析访问关系时,完全可以当做非嵌套类处理,即嵌套类无法访问外围类的私有成员,也不能对外围类中定义的私有嵌套类创建对象,嵌套类可以访问static private成员,嵌套类中申明的友元也不能访问外围类中的私有成员。

本站总访问量