6 ms·
> Just the mojo required to print an integer (having to instantiate a generic) was considered complicated That sounds complicated to me, in 2019 with 25 years
by devnulloverflow 7y ago
> Just the mojo required to print an integer (having to instantiate a generic) was considered complicated
That sounds complicated to me, in 2019 with 25 years of C++ experience. (And of course C++ error message sprouting mysterious stdlib templates also seems complicated to me).
- shakna 7y agoIt isn't more complicated than printf, which is also close to being a generic. PutLine("The number is " & num); printf("The number is %zu\n", num);
- dawidw 7y agoprintf is not c++
- ChrisLomont 7y agohttp://www.cplusplus.com/reference/cstdio/printf/ http://www.cplusplus.com/reference/cstdio/printf/
- shakna 7y agoAda is the one that was considered complicated. Making use of PutLine in the way I demonstrated was, at the time, considered complicated and confusing. That it's as easy as printf demonstrates the changes in thinking to today fairly well.
- bdavis__ 7y agopakage int_io is new integer_io (num=>integer); and then int_io.putline(num);
- shakna 7y agowith Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; ... PutLine(num); As far as I can tell, Ada has had Integer_Text_IO that does that all for you, since the early days. [0] (Note that the reference is the first "public" release of Ada outside of the DOD). [0] https://www.adahome.com/LRM/83/RM/rm83html/lrm-14-03.html#14.3.7 https://www.adahome.com/LRM/83/RM/rm83html/lrm-14-03.html#14... (Ada 83 Manual)
- kazinator 7y agoThat's an awful amount of boilerplate for a simple integer hello world. Languages with these modules and import statements should be burned. (Starting with Python.) For pete's sake, couldn't they at least combine this with and use into one keyword so you don't have to repeat yourself? Or can't use be made to forgive a missing with and just get on with the show? Do defense contracts pay by the byte or what?
- 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.
- 7y ago
- fluffything 7y ago> That sounds complicated to me, in 2019 with 25 years of C++ experience. std::cout << X; is not a generic, but on the project I just tested, if I substitute X with a type that does not implement an appropriate operator<<, I get ~1000 suggestions in the overload set, many of which are generic operator<< that are templated on a `typename OStream`. I personally find having to do overload resolution first on a 1000 function overload set containing generic and not generic functions, and then often having to actually instantiate a generic (doing template argument deduction, template instantiation, substitution-failure is not an error so the next overload might be picked, etc. etc. etc.) infinitely more complicated than "just" instantiating a generic.
- zozbot234 7y agoIndeed, type classes as found in languages like Haskell and Rust were first designed as a way to make overloading (aka "ad-hoc polymorphism") work more sensibly, and in a way that plays nice with generics/templates.