3 ms·
'use' allows you to integrate namespaces, that's all. You can have multiples of those within the same file. Not all 'with' statements will only expose a single
by shakna 7y ago
'use' allows you to integrate namespaces, that's all. You can have multiples of those within the same file. Not all 'with' statements will only expose a single namespace.
Nothing different than std in C++.
- kazinator 7y agoC++ is awful also; it is not a good choice of benchmark for brevity. Though a single use declaration will get you the identifier in C++, the right header file has to be #included. At least it's possible for a single include to bring in lots of material: #include <biglib> // just one of these use bigfoo::bar; // one per identifier use bigwidget::zark; But C++ has lots of irritating repetition like: class foo { foo(); ~foo(); }; foo::foo() { } foo::~foo() { } Seven repetitions of foo just to set up an empty class skeleton with non-inlined constructor and destructor. (The C++ people are self-conscious about verbosity, and trying to fix the problem; unfortunately, in wrongheaded ways that are making the language worse.)
- shakna 7y agoI'm not sure brevity is a benchmark for a good language either. So far as I can tell, you dislike how verbose the Ada "hello world" is, because it supports namespaces, and uses them. That wouldn't be something I'd agree with, especially not when dealing with any program of significant size.
- Supermancho 7y ago> I'm not sure brevity is a benchmark for a good language either. It's the only benchmark that we have any kind of analysis for (https://www.researchgate.net/publication/3188171_The_Confounding_Effect_of_Class_Size_on_the_Validity_of_Object-Oriented_Metrics https://www.researchgate.net/publication/3188171_The_Confoun...), which correlates to less defects and less time per feature. Less code is better. Until I see evidence to the contrary, I think it's a valid criticism. YMMV
- shakna 7y agoI agree with less code, but the tokens themselves needing to be shorter, not so much - so long as they remain easily readable.
- kazinator 7y ago> When we controlled for class size all of the effects disappeared, providing compelling evidence for a confounding effect of class size Holy crap; are they really saying that all the various correlations seen between numerous software metrics and fault proneness are actually the effect of nothing but raw size? That's so intuitive. Because in our daily experience, almost all reasonable approaches to to various aspects of program organization actually work fine in programs of a size that one programmer can comfortably fully understand and maintain. Even for any technique reviled as "bad" and discouraged in coding standards, there are counterexamples of it working fine. Those counterexamples are in the context of small programs, so we are told, "just wait, that approach will burn you in a big program". But it looks like what will burn you is just the size of that big program, no matter what techniques you wield, whether blessed or not. That little paper you pointed to there (thank you) looks pretty darn important.
- NikkiA 7y agoclass foo { foo() = default; ~foo() = default; }; Is actually the idiomatic version of that C++ class, far less repetitive.
- kazinator 7y agoThe class I wrote has a non-default constructor and destructor. The idiomatic way to write your class is just: class foo { }; allowing the compiler to supply the default constructor and destructor. The purpose of the C++11 default mechanism is to request a default implementation of a special function in situations when it would be suppressed. For instance class foo { public: foo(int x); // this will suppress the default constructor foo() = default; // this requests it back };