6 ms·
It 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);
by shakna 7y ago
It 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