Re: The Expressive C++17 Coding Challenge in D

2018-02-15 Thread aberba via Digitalmars-d-announce

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Very well written. Nice read. I recommend you write more these 
days.


Re: The Expressive C++17 Coding Challenge in D

2018-02-15 Thread Steven Schveighoffer via Digitalmars-d-announce

On 2/15/18 2:11 PM, Seb wrote:


I reworded the entire paragraph and it now shows the AST:

https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d/#4-whats-up-with-this-enforce 


eh...

"string which is an alias for an array of const(char) elements"

It's not actually, it's an array of immutable(char) elements.

But I think the reason we see const(char)[] delegate and not 
immutable(char)[] delegate, is that enforce's actual signature is:


T enforce(E : Throwable = Exception, T)(T value, lazy const(char)[] msg 
= null, string file = __FILE__, size_t line = __LINE__)


Not lazy string as you originally said.

https://dlang.org/phobos/std_exception.html#.enforce

In fact, you can see "string" output by the AST generator in other 
places (e.g. void main(string[] args) ), so even that whole explanation 
that it has "resolved" string already is misleading ;)


BTW, I have to click on the AST button on run.dlang.io (at least on my 
browser) to see the generated AST, it's not done automatically.


My idea was that we have this subtextual message: "look, D isn't 
complicated and we can always look behind the scenes".


I like the message, a lot! I think it's a very nice way to show some 
well-written D code while explaining each part so they make sense to 
outsiders.


-Steve


Re: The Expressive C++17 Coding Challenge in D

2018-02-15 Thread Seb via Digitalmars-d-announce
On Thursday, 15 February 2018 at 16:22:17 UTC, Steven 
Schveighoffer wrote:

On 2/13/18 6:35 PM, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Nice article!


Thanks!


Typos and Grammar:


Thanks a lot!
Yeah I shouldn't have published it directly after writing it...


This part is slightly incorrect:


Good point! Thanks.
I reworded the entire paragraph and it now shows the AST:

https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d/#4-whats-up-with-this-enforce

My idea was that we have this subtextual message: "look, D isn't 
complicated and we can always look behind the scenes".


Re: The Expressive C++17 Coding Challenge in D

2018-02-15 Thread Steven Schveighoffer via Digitalmars-d-announce

On 2/13/18 6:35 PM, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread today and I 
thought this is an excellent opportunity to revive my blog and finally 
write an article showing why I like D so much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D features, 
but maybe it's helpful for beginners looking into D.


Nice article!

Typos and Grammar:

" How often how you encountered code like a + b"

How often have

---

"Yes, the D compiler does all the hard work for."

for you

---

"In short: the compiler does a few smart lowering for you"

lowerings

---

"Yes D is statically typed, but the compiler is pretty smart, so we can 
let him do all the hard for for us."


hard work

"auto is a filler word for the compiler that means “whatever the type of 
the assignment, use this as type of this variable”."


the type

---

"Okay to recap, we have taken the input of a file by line, splitted 
every line by commas"


splitting

---

This part is slightly incorrect:

" Isn’t this done before the enforce is called?

No, lazy is lazy and the string concatenation doesn’t happen at the 
caller site, but can be requested explicitly by the callee."


Technically, the concatenation is done at compile-time, which can be 
seen via AST: https://run.dlang.io/is/OVKxee


But normally, if the concatenation involved runtime strings, it would be 
done lazily.


-Steve


Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Walter Bright via Digitalmars-d-announce

On 2/13/2018 3:35 PM, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread today and I thought 
this is an excellent opportunity to revive my blog and finally write an article 
showing why I like D so much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D features, but maybe 
it's helpful for beginners looking into D.


Very nice article, you write well!




Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Ola Fosheim Grøstad via Digitalmars-d-announce

On Wednesday, 14 February 2018 at 20:37:24 UTC, bachmeier wrote:

There's (almost) no such thing as bad publicity...


Programming languages and operating systems have a long history 
of hot advocacy...  not sure how it relates to adoption, but it 
affects perception.


E.g. vocal mac users gave the mac a certain (not so great) 
reputation in tech circles. I don't think that perception changed 
till iOs and mac mini.




Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread bachmeier via Digitalmars-d-announce
On Wednesday, 14 February 2018 at 20:14:41 UTC, Ola Fosheim 
Grøstad wrote:

On Wednesday, 14 February 2018 at 19:40:12 UTC, Seb wrote:

https://www.reddit.com/r/programming/comments/7xih66/the_expressive_c17_coding_challenge_in_d


It is getting shot down…


That's implied when someone says it's posted on Reddit.

There's (almost) no such thing as bad publicity...


Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Ola Fosheim Grøstad via Digitalmars-d-announce

On Wednesday, 14 February 2018 at 19:40:12 UTC, Seb wrote:

https://www.reddit.com/r/programming/comments/7xih66/the_expressive_c17_coding_challenge_in_d


It is getting shot down…



Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Seb via Digitalmars-d-announce

On Wednesday, 14 February 2018 at 18:55:23 UTC, bachmeier wrote:

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Someone posted a comment in our subreddit that you may want to 
check:

https://www.reddit.com/r/d_language/comments/7xi9n3/the_expressive_c17_coding_challenge_in_d/


Thanks a lot for the ping!
Someone posted it also to /r/programming - it's on the second 
place as of now:


https://www.reddit.com/r/programming/comments/7xih66/the_expressive_c17_coding_challenge_in_d


Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Ola Fosheim Grøstad via Digitalmars-d-announce
On Wednesday, 14 February 2018 at 18:33:33 UTC, Jacob Carlborg 
wrote:

On 2018-02-14 19:00, Ola Fosheim Grøstad wrote:
For a fair comparison Swift should only use libraries that are 
available both on macOS and Linux.


Are any projects using Swift outside of the Mac eco system?
Would it be more fair if Swift was Mac only? (re Visual Basic)

Would you include React when evaluating Javascript and Angular4 
when evaluating TypeScript? Why should a standard library be 
evaluated differently from any other library?


That's more the issue.

If the standard library for one language ensure better interop 
between third party libraries, then it becomes significant, but 
if it is an independent feature then I see no difference between 
standard library and third party library.




Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread bachmeier via Digitalmars-d-announce

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Someone posted a comment in our subreddit that you may want to 
check:

https://www.reddit.com/r/d_language/comments/7xi9n3/the_expressive_c17_coding_challenge_in_d/


Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Jacob Carlborg via Digitalmars-d-announce

On 2018-02-14 19:00, Ola Fosheim Grøstad wrote:

For instance, Swift drags in all of Os-X on the default platform, so 
writing an audio/video loader would be relatively short in comparison to 
other languages. Would that be fair or instructive? Of course not. The 
Os-X libraries are quite massive.


For a fair comparison Swift should only use libraries that are available 
both on macOS and Linux.


--
/Jacob Carlborg


Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Ola Fosheim Grøstad via Digitalmars-d-announce
On Wednesday, 14 February 2018 at 17:13:28 UTC, John Gabriele 
wrote:
But even then, I don't think you should discount or put off 
using std.csv as "cheating".


Yes and no.  The problem with all these exercises is that they 
say nothing about the language and a lot about some default 
library, which isn't particularly revealing.


For instance, Swift drags in all of Os-X on the default platform, 
so writing an audio/video loader would be relatively short in 
comparison to other languages. Would that be fair or instructive? 
Of course not. The Os-X libraries are quite massive.


Anyway, these kinds of exercises are only impressive for people 
looking for an alternative to scripting...


For general system programming you need to show off the language 
and not the esoteric features of the standard library. Basically 
show off how it can deal with a task it has not been designed 
for. Which is the typical use scenario.




Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Seb via Digitalmars-d-announce
On Wednesday, 14 February 2018 at 17:13:28 UTC, John Gabriele 
wrote:

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Great article! Thank you!


Thanks for the typos. Fixed them.

But even then, I don't think you should discount or put off 
using std.csv as "cheating". I'm guessing std.csv handles 
things like quoted elements containing commas.


Yes.

I realize that maybe you're being pedagogic and wanting to show 
off D's File byLine and splitter,


Yes.

but I think the first thing a reader will think when they see 
you rolling your own csv reader by hand is that something must 
be wrong with D or it's ecosystem if you're resorting to this, 
and they'll run for the hills (especially in an intro article, 
*and* one in which you point out that the goal is *expressive* 
code).


Understood. Fair point.
I changed the motivation of why std.csv isn't used and added a 
warning that one shouldn't roll one's own CSV parser.


I immediately assume it's either old/incorrect, the language is 
very low-level only, or else maybe the language's std lib must 
be impoverished.


Haha. This could be Rust's or C++'s new slogan ;-)


Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread John Gabriele via Digitalmars-d-announce

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Great article! Thank you!

Typo: "and finally format bundles" --> "and finally std.format 
bundles".


Another typo: "In the latter article I will also present a 
solution which only uses 12 lines, but it uses the built-in 
std.csv module and I think D doesn’t even need to cheat." should 
probably instead start "Later in this article I'll also 
present..." or "Further down I'll also present".


But even then, I don't think you should discount or put off using 
std.csv as "cheating". I'm guessing std.csv handles things like 
quoted elements containing commas. I realize that maybe you're 
being pedagogic and wanting to show off D's File byLine and 
splitter, but I think the first thing a reader will think when 
they see you rolling your own csv reader by hand is that 
something must be wrong with D or it's ecosystem if you're 
resorting to this, and they'll run for the hills (especially in 
an intro article, *and* one in which you point out that the goal 
is *expressive* code).


In fact, I'd go so far as to say that, when searching online for 
how to read in a csv file for a given language (see many examples 
at ), if the 
example involves splitting on commas, I immediately assume it's 
either old/incorrect, the language is very low-level only, or 
else maybe the language's std lib must be impoverished.




Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Dukc via Digitalmars-d-announce

On Wednesday, 14 February 2018 at 14:17:31 UTC, Seb wrote:

changed the text to:

...and D even supports native interoperability with C and most 
of C++.


Great!


Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Ola Fosheim Grøstad via Digitalmars-d-announce
On Wednesday, 14 February 2018 at 10:17:21 UTC, psychoticRabbit 
wrote:
I believe the programming langauges of the future, and the ones 
people should invest their time learning, are those that can be 
best understood in the least amount of time.


Yes, I would say so, unless they bring something new to the table 
like formal verification (proven correctness) or some kind of 
expert system geared towards a set of common domains (e.g. data 
flow).


This is because programs are getting larger and more complex, 
and to understand them at all, they have to be simple to 
understand.


Right, so which is an argument in favour of agent based systems. 
Kind of the direction that has happened on the server side with 
micro services.


C++ is not simple. It never has been. The so called 
'modernisation' of it is not helping me to change my mind about 
it ;-)


Right, because, even though C was simple, it isn't simple to 
debug, so C++ has all that + a wide variety of overlapping 
features. So C++ cannot become simple.


It's time to stop 'improving' C++ and redesign it from scratch 
- or move to D.


Well, yes, but then D needs to make a case for itself and do a 
reset so that the disadvantages in switching is offset by the 
advantages. Either that or some other language will squeeze in, 
which is ok too. I don't care who does it, could even be Rust if 
they add some features, but it should happen. Right.




Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Russel Winder via Digitalmars-d-announce
On Wed, 2018-02-14 at 13:21 +, Seb via Digitalmars-d-announce
wrote:
> On Wednesday, 14 February 2018 at 09:42:47 UTC, Russel Winder 
> wrote:
> > Seb,
> > 
> > I believe this blog post would make a great article for 
> > Overload or CVu.
> 
> Cool idea, but I'm not so familiar with these. What can/should I 
> do to make this happen?
> We can also talk in private (seb [at] wilzba [dot] ch).

For the email list record, CVu and Overload are the ACCU journals.
Historically Overload has been a C++ language, tools, and techniques
vehicle put is now adding detailed technical articles on other
languages. CVu has anything else, including some technical stuff.

https://accu.org/index.php/journal

Seb and I have started a personal email exchange and I am getting the
editors of said journals involved.
 
-- 
Russel.
===
Dr Russel Winder  t: +44 20 7585 2200
41 Buckmaster Roadm: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk


signature.asc
Description: This is a digitally signed message part


Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Seb via Digitalmars-d-announce
On Wednesday, 14 February 2018 at 08:06:13 UTC, Mike Franklin 
wrote:

Aren’t you concered that Rust is faster in this benchmark?


Not at all. The challenge was to write expressive code and if 
performance really matters I can always opt to optimize the 
hot path of the program and don’t need to pay a > 4x code 
duplication cost upfront.


You've gotta address this, IMO.  What's the 
performance/expressiveness tradeoff like in D?


Mike


Good point. I tried to address this and changed the text to:


Not at all. The challenge was to write expressive code. When 
performance really matters D provides the same tools as C or 
C++ and D even supports native interoperability with C and most 
of C++.


In this example, however, I/O is the bottleneck and D provides 
a few convenience features like using locked file handles, s.t. 
accessing files is thread-safe by default, or supporting 
unicode input. However, it’s easy to opt out of such 
productivity features and for the interested readers I have 
attached a slightly optimized version at the end.


Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Seb via Digitalmars-d-announce
On Wednesday, 14 February 2018 at 09:42:47 UTC, Russel Winder 
wrote:

Seb,

I believe this blog post would make a great article for 
Overload or CVu.


Cool idea, but I'm not so familiar with these. What can/should I 
do to make this happen?

We can also talk in private (seb [at] wilzba [dot] ch).


Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Dukc via Digitalmars-d-announce

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much


I first looked into C++ and Rust examples, just quickly without 
thinking them deeply. I thought that wow, the problem is probably 
more complicated than it looks. Seems to need many functions to 
solve eleganty.


Then when I saw your example I, of course, concluded that the 
problem is as simple as it seems. I would really have excepted 
C++ or at least Rust to come close to D, perhaps even achieve the 
same LoC count with a bit of luck.


Excellent article all-in-all, because it shown so many D features 
in a compact AND realistic way. I think a good D programmer might 
well write programs in that style for everyday use, not just for 
show. If someone asks "what would then be an unrealistic program 
then" it would be one that excessively uses introspection.


One improvement proposal: in the "Other features" part, you 
mention full compatibility with c. I think you should add "and 
with most of c++" because it might be a killer feature for some 
potential users.


Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread psychoticRabbit via Digitalmars-d-announce
On Wednesday, 14 February 2018 at 09:50:31 UTC, Ola Fosheim 
Grøstad wrote:


If C++ isn't viewed as a competitor, why bother with repetitive 
complaining about C++?


Because it doesn't get enough criticism ;-)

I believe the programming langauges of the future, and the ones 
people should invest their time learning, are those that can be 
best understood in the least amount of time.


This is because programs are getting larger and more complex, and 
to understand them at all, they have to be simple to understand.


C++ is not simple. It never has been. The so called 
'modernisation' of it is not helping me to change my mind about 
it ;-)


And chances are, when you go to work in some C++ environment, 
you'll have to deal with lots of legacy style code - which you 
will be expected to understand as well.


It's time to stop 'improving' C++ and redesign it from scratch - 
or move to D.




Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Ola Fosheim Grøstad via Digitalmars-d-announce
On Wednesday, 14 February 2018 at 09:28:48 UTC, psychoticRabbit 
wrote:
yeah.. even the more modern C++ code still makes me want to 
stay clear of it...(perhaps even more so).


I just never get the same feeling when I look at D programs.


I get the same feeling from both languages, to be honest.  
Average library code for both languages are harder to read than I 
think should be the norm (granted Python libs can also be 
somewhat hard to read, but still much easier on average).  Both 
languages are easier to read when you spend time with them 
yourself, obviously.  Both languages are easier to read when the 
programmer has been conservative in his/her use of features.


This situation is what happens when you add features at a high 
rate in the early years and don't want to clean up because of 
backwards compatibility. C++ has been at it for longer and are 
adding more features at a higher rate than D... so C++ becomes 
harder and harder to master if you read other people's arbitrary 
code. That doesn't mean D shouldn't clean up... I'd say it is 
necessary to get ahead.


For both languages you can always stick to your own idioms and 
write cleaner code than you see on github, and blog posts tend to 
be feature-show-offs (surprisingly often written by people who 
don't write a lot of code in the language they are posting about) 
so I don't think blogs are the right measure. Look at large code 
bases that are in widespread use to get an idea of what happens 
over time in terms of maintainability.


Anyway, C++ at this point has slightly better lambdas than D and 
D will notice the competition if C++ ends up adding stackless 
coroutines (e.g. Python like generators). Not a big discrepancy 
in features at this point, but C++ is moving at a higher rate... 
and that should be a concern if C++ is viewed as a competitor.


If C++ isn't viewed as a competitor, why bother with repetitive 
complaining about C++?




Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Martin Tschierschke via Digitalmars-d-announce

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Very nice read!!! Thank you!


One "typo?" Chapter 8)

same format function that would normally be called at 
compile-time

 s/compile/run/

It would be good to say a little more about the '!' ct-parameter

At fist when reading D code coming from ruby (after, 
php,...C++,C, Pascal...),
I thought, that the ! is like in Ruby just an way to distinguish 
between a function modifying the contend or not (compare gsub to 
gsub!) it took sometime before this important bit came clear to 
me.
So just something, like functions in D may have two parameter 
brackets:

One for compile-time and one for run-time parameters:
fun!(ctParam)(rtParam) ... short fun!(cParam)() ... fun!ctparam

Other point:

Showing some more alternative D solutions for the same problem, 
might be a little contest in this thread, just post your shorter 
and better solutions :-)




Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Russel Winder via Digitalmars-d-announce
Seb,

I believe this blog post would make a great article for Overload or
CVu.

On Tue, 2018-02-13 at 23:35 +, Seb via Digitalmars-d-announce
wrote:
> Someone revived the Expressive C++17 Coding Challenge thread 
> today and I thought this is an excellent opportunity to revive my 
> blog and finally write an article showing why I like D so much:
> 
> https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-i
> n-d
> 
> It's mostly targeted at beginners as I explain many basic D 
> features, but maybe it's helpful for beginners looking into D.
-- 
Russel.
===
Dr Russel Winder  t: +44 20 7585 2200
41 Buckmaster Roadm: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk


signature.asc
Description: This is a digitally signed message part


Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread psychoticRabbit via Digitalmars-d-announce

On Wednesday, 14 February 2018 at 08:53:31 UTC, drug wrote:

14.02.2018 11:45, Ola Fosheim Grøstad пишет:

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to 
revive my blog and finally write an article showing why I 
like D so much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Sadly, he just picked the solution that used most C++17 
features and not one that was clean and compact... :-/


I guess the point was to create a C++17 tutorial, and not a 
coding contest as such.


It's sadly that using most C++17 features fails to provide 
clean and compact solution...


yeah.. even the more modern C++ code still makes me want to stay 
clear of it...(perhaps even more so).


I just never get the same feeling when I look at D programs.



Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Arredondo via Digitalmars-d-announce

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Down in the 'Other cool D features' you have:


* Inline documentation
* Contracts
...
* Built-in documentation
* Contracts and invariants


Nice read!


Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Ola Fosheim Grøstad via Digitalmars-d-announce

On Wednesday, 14 February 2018 at 08:53:31 UTC, drug wrote:
It's sadly that using most C++17 features fails to provide 
clean and compact solution...


I don't usually use iostream, but this "challenge" was a 
reasonable fit for it. If you look over the 4 submissions then 
the iostream one provides the best encapsulation of the problem:


http://coliru.stacked-crooked.com/a/4675a74c8124750f

C++ blogposts tend to choke on features... usually not good 
examples of maintainable code.




Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread drug via Digitalmars-d-announce

14.02.2018 11:45, Ola Fosheim Grøstad пишет:

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread today and 
I thought this is an excellent opportunity to revive my blog and 
finally write an article showing why I like D so much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D features, 
but maybe it's helpful for beginners looking into D.


Sadly, he just picked the solution that used most C++17 features and not 
one that was clean and compact... :-/


I guess the point was to create a C++17 tutorial, and not a coding 
contest as such.


It's sadly that using most C++17 features fails to provide clean and 
compact solution...




Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Ola Fosheim Grøstad via Digitalmars-d-announce

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Sadly, he just picked the solution that used most C++17 features 
and not one that was clean and compact... :-/


I guess the point was to create a C++17 tutorial, and not a 
coding contest as such.









Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Simen Kjærås via Digitalmars-d-announce

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Nice! Good overview of many of the good things in D.

Nitpicks:

I used the following rdmd script to generate a simple CSV file 
with 10 fields and 10m lines:


rdmd --eval='10.iota.map!(a=> "field".text(a)).join(",")
.repeat(10_00_000).joiner("\n").writeln' > input_big.csv


10_00_000 should probably be 10_000_000.


They are only view on the actual memory and you don’t copy the 
array, but just the view on (in D it’s called a slice).


Missing some words here: "only *a* view". "but just the view on" 
seems to be missing the second half of the sentence.



There's also a few typos: 'vauge' should be 'vague', 'it 
providers' should be 'it provides', 'shot yourself in the feet' 
should probably be 'shoot yourself in the foot'


Thanks for writing all this - it's a great intro to the language.

--
  Sien


Re: The Expressive C++17 Coding Challenge in D

2018-02-14 Thread Mike Franklin via Digitalmars-d-announce

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Nice work!  I was recently asked by my employer "why D?".  I 
think I need to show them this.



Aren’t you concered that Rust is faster in this benchmark?


Not at all. The challenge was to write expressive code and if 
performance really matters I can always opt to optimize the hot 
path of the program and don’t need to pay a > 4x code 
duplication cost upfront.


You've gotta address this, IMO.  What's the 
performance/expressiveness tradeoff like in D?


Mike


Re: The Expressive C++17 Coding Challenge in D

2018-02-13 Thread Seb via Digitalmars-d-announce
On Wednesday, 14 February 2018 at 06:42:23 UTC, Arun 
Chandrasekaran wrote:
It takes a lot of time and effort to write such quality 
content. Thanks for detailed explanations.


Thanks :)
Now if we had a magic automaton that makes more of these ...

// import std.algorithm, std.exception, std.format, std.range, 
std.stdio;
Do you think it is worth mentioning about 
std.experimental.scripting in section 2?


Well, it hasn't been released yet, but maybe I get around writing 
another article ;-)
Also looking at the C++ "competitor", I think we aren't too bad 
off with a few modules for now:


---
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;
namespace fs = std::experimental::filesystem;
---


Syntax highlighting is missing in some snippets.


Thanks for the pointer. Fixed!


Re: The Expressive C++17 Coding Challenge in D

2018-02-13 Thread Seb via Digitalmars-d-announce
On Wednesday, 14 February 2018 at 07:11:08 UTC, Nicholas Wilson 
wrote:

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Cool! The contrast of the code is very low (very on light 
brown?),


Thanks for the feedback. Fixed!


Re: The Expressive C++17 Coding Challenge in D

2018-02-13 Thread Nicholas Wilson via Digitalmars-d-announce

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Cool! The contrast of the code is very low (very on light brown?),


Re: The Expressive C++17 Coding Challenge in D

2018-02-13 Thread Arun Chandrasekaran via Digitalmars-d-announce

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


It takes a lot of time and effort to write such quality content. 
Thanks for detailed explanations.


// import std.algorithm, std.exception, std.format, std.range, 
std.stdio;
Do you think it is worth mentioning about 
std.experimental.scripting in section 2?


Syntax highlighting is missing in some snippets.


Re: The Expressive C++17 Coding Challenge in D

2018-02-13 Thread Seb via Digitalmars-d-announce

On Wednesday, 14 February 2018 at 02:57:28 UTC, ketmar wrote:

Seb wrote:

Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


a typo:

writefln!"%d"(foo");

it should be `"foo"`, i guess. ;-)


Fixed. Thanks!

great article. now i want to learn D again, it looks so 
beautiful and powerful! ;-)


Thanks!
Well, you could upstream your fork and go back to "pure" D again 
;-)


Re: The Expressive C++17 Coding Challenge in D

2018-02-13 Thread Seb via Digitalmars-d-announce

On Wednesday, 14 February 2018 at 03:40:41 UTC, jmh530 wrote:

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Typo with "(~200 LoC)" and "> 300 LoCs"?


Fixed. Thanks!


Re: The Expressive C++17 Coding Challenge in D

2018-02-13 Thread jmh530 via Digitalmars-d-announce

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


Typo with "(~200 LoC)" and "> 300 LoCs"?


Re: The Expressive C++17 Coding Challenge in D

2018-02-13 Thread ketmar via Digitalmars-d-announce

Seb wrote:

Someone revived the Expressive C++17 Coding Challenge thread today and I 
thought this is an excellent opportunity to revive my blog and finally 
write an article showing why I like D so much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D features, but 
maybe it's helpful for beginners looking into D.


a typo:

writefln!"%d"(foo");

it should be `"foo"`, i guess. ;-)

great article. now i want to learn D again, it looks so beautiful and 
powerful! ;-)


Re: The Expressive C++17 Coding Challenge in D

2018-02-13 Thread psychoticRabbit via Digitalmars-d-announce

On Tuesday, 13 February 2018 at 23:35:36 UTC, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread 
today and I thought this is an excellent opportunity to revive 
my blog and finally write an article showing why I like D so 
much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D 
features, but maybe it's helpful for beginners looking into D.


What a great article!

I love the depth of explanation too, that really makes it 
worthwhile reading.





Re: The Expressive C++17 Coding Challenge in D

2018-02-13 Thread Ali Çehreli via Digitalmars-d-announce

On 02/13/2018 03:35 PM, Seb wrote:
Someone revived the Expressive C++17 Coding Challenge thread today and I 
thought this is an excellent opportunity to revive my blog and finally 
write an article showing why I like D so much:


https://seb.wilzba.ch/b/2018/02/the-expressive-c17-coding-challenge-in-d

It's mostly targeted at beginners as I explain many basic D features, 
but maybe it's helpful for beginners looking into D.


This topic appeared on Learn a few months ago:

  https://forum.dlang.org/post/or0o85$tvc$1...@digitalmars.com

Ali