www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Advent of D

reply Jordi =?UTF-8?B?R3V0acOpcnJleg==?= Hermoso <jordigh octave.org> writes:
I wrote a blog post about working on Advent of Code in D. You can 
read it here:

http://jordi.inversethought.com/blog/advent-of-d/
Mar 06 2018
next sibling parent David Gileadi <gileadisNOSPM gmail.com> writes:
On 3/6/18 11:09 AM, Jordi Gutiérrez Hermoso wrote:
 I wrote a blog post about working on Advent of Code in D. You can read 
 it here:
 
 http://jordi.inversethought.com/blog/advent-of-d/
I really enjoyed this. Thank you!
Mar 06 2018
prev sibling next sibling parent reply Joakim <dlang joakim.fea.st> writes:
On Tuesday, 6 March 2018 at 18:09:21 UTC, Jordi Gutiérrez Hermoso 
wrote:
 I wrote a blog post about working on Advent of Code in D. You 
 can read it here:

 http://jordi.inversethought.com/blog/advent-of-d/
What's with the mammoth D blog posts lately? Nice write-up, worth sharing on reddit/HN.
Mar 06 2018
parent reply Jordi =?UTF-8?B?R3V0acOpcnJleg==?= Hermoso <jordigh octave.org> writes:
On Tuesday, 6 March 2018 at 20:09:58 UTC, Joakim wrote:
 Nice write-up, worth sharing on reddit/HN.
Thanks. I tried posting it to HN, but it didn't pick up. If several of you try posting it too, it might pick up. Posting to Reddit is easier, but I don't have a recognisable account on Reddit to post it from. I did post it to Lobsters, though: https://lobste.rs/s/b4qki7/advent_d
Mar 06 2018
next sibling parent Adam D. Ruppe <destructionator gmail.com> writes:
On Tuesday, 6 March 2018 at 21:09:06 UTC, Jordi Gutiérrez Hermoso 
wrote:
 I did post it to Lobsters, though:
This is random but I have been thinking about asking for a lobsters invite... can you hook me up?
Mar 06 2018
prev sibling parent reply Mike Parker <aldacron gmail.com> writes:
On Tuesday, 6 March 2018 at 21:09:06 UTC, Jordi Gutiérrez Hermoso 
wrote:

 Posting to Reddit is easier, but I don't have a recognisable 
 account on Reddit to post it from.
I'll post it. There are good times and bad times to post on /r/programming in terms of getting attention. A good time would be in about ~12 hours or so.
Mar 06 2018
parent reply Mike Parker <aldacron gmail.com> writes:
On Wednesday, 7 March 2018 at 01:07:54 UTC, Mike Parker wrote:
 On Tuesday, 6 March 2018 at 21:09:06 UTC, Jordi Gutiérrez 
 Hermoso wrote:

 Posting to Reddit is easier, but I don't have a recognisable 
 account on Reddit to post it from.
I'll post it. There are good times and bad times to post on /r/programming in terms of getting attention. A good time would be in about ~12 hours or so.
Ah, well. Someone had already submitted it. And completely missed the window :-(
Mar 07 2018
parent reply Jordi =?UTF-8?B?R3V0acOpcnJleg==?= Hermoso <jordigh octave.org> writes:
On Wednesday, 7 March 2018 at 14:02:19 UTC, Mike Parker wrote:
 On Wednesday, 7 March 2018 at 01:07:54 UTC, Mike Parker wrote:
 On Tuesday, 6 March 2018 at 21:09:06 UTC, Jordi Gutiérrez 
 Hermoso wrote:

 Posting to Reddit is easier, but I don't have a recognisable 
 account on Reddit to post it from.
I'll post it. There are good times and bad times to post on /r/programming in terms of getting attention. A good time would be in about ~12 hours or so.
Ah, well. Someone had already submitted it. And completely missed the window :-(
Oh? I only see it here: https://www.reddit.com/r/d_language/comments/82i0s4/advent_of_d/ There don't seem to be duplicate reposts to other subreddits. Where are you seeing it?
Mar 07 2018
parent reply Mike Parker <aldacron gmail.com> writes:
On Wednesday, 7 March 2018 at 14:43:24 UTC, Jordi Gutiérrez 
Hermoso wrote:
 I only see it here:

 https://www.reddit.com/r/d_language/comments/82i0s4/advent_of_d/

 There don't seem to be duplicate reposts to other subreddits. 
 Where are you seeing it?
Sorry, should have pasted the link: https://www.reddit.com/r/programming/comments/82j5m0/advent_of_d_a_good_overview_of_d_programming/
Mar 07 2018
next sibling parent Jordi =?UTF-8?B?R3V0acOpcnJleg==?= Hermoso <jordigh octave.org> writes:
On Wednesday, 7 March 2018 at 14:50:34 UTC, Mike Parker wrote:
 On Wednesday, 7 March 2018 at 14:43:24 UTC, Jordi Gutiérrez 
 Hermoso wrote:
 I only see it here:

 https://www.reddit.com/r/d_language/comments/82i0s4/advent_of_d/

 There don't seem to be duplicate reposts to other subreddits. 
 Where are you seeing it?
Sorry, should have pasted the link: https://www.reddit.com/r/programming/comments/82j5m0/advent_of_d_a_good_overview_of_d_programming/
Ah, I see. Pity. Maybe it'll get rediscovered in a few months and people will post it again.
Mar 07 2018
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 03/07/2018 09:50 AM, Mike Parker wrote:
 On Wednesday, 7 March 2018 at 14:43:24 UTC, Jordi Gutiérrez Hermoso wrote:
 I only see it here:

 https://www.reddit.com/r/d_language/comments/82i0s4/advent_of_d/

 There don't seem to be duplicate reposts to other subreddits. Where 
 are you seeing it?
Sorry, should have pasted the link: https://www.reddit.com/r/programming/comments/82j5m0/advent_of_d_a_good_overvi w_of_d_programming/
The post does not appear on the /r/programming page, so it has been flagged as spam. All: please coordinate social media announcements of your D-related work with Michael Parker for best results. Thanks, Andrei
Mar 07 2018
parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 03/07/2018 09:26 AM, Andrei Alexandrescu wrote:

 The post does not appear on the /r/programming page, so it has been
 flagged as spam.
On the first page right now. Ali
Mar 08 2018
prev sibling next sibling parent Patrick Schluter <Patrick.Schluter bbox.fr> writes:
On Tuesday, 6 March 2018 at 18:09:21 UTC, Jordi Gutiérrez Hermoso 
wrote:
 I wrote a blog post about working on Advent of Code in D. You 
 can read it here:

 http://jordi.inversethought.com/blog/advent-of-d/
Really nice, thank you.
Mar 06 2018
prev sibling next sibling parent reply Steven Schveighoffer <schveiguy yahoo.com> writes:
On 3/6/18 1:09 PM, Jordi Gutiérrez Hermoso wrote:
 I wrote a blog post about working on Advent of Code in D. You can read 
 it here:
 
 http://jordi.inversethought.com/blog/advent-of-d/
I'm enjoying this. One thing jumped out at me: static does not mean execute at compile time (exactly), it really means allocate this data in thread-local storage. What triggers the compile-time execution is the fact that static *initializers* need to be decided at compile time. So while it is executing the regex building at compile time in your example, there are other ways to do it, and in this case, I'd prefer using an enum. You can also use ctRegex. The drawback of using static is that it keeps its value between function calls: int bar() { return 42; } void foo() { static x = bar(); x += 5; writeln(x); } void main() { foo(); // 47 foo(); // 52 } So it may not be what you are looking for. Whereas if you use: void foo() { enum x = bar(); writeln(x + 5); } it will always write the same answer (and not allocate global space for it). BTW, that tour page needs updating, it has a few errors in it. -Steve
Mar 06 2018
next sibling parent Jordi =?UTF-8?B?R3V0acOpcnJleg==?= Hermoso <jordigh octave.org> writes:
On Tuesday, 6 March 2018 at 20:37:34 UTC, Steven Schveighoffer 
wrote:
 On 3/6/18 1:09 PM, Jordi Gutiérrez Hermoso wrote:
 I wrote a blog post about working on Advent of Code in D. You 
 can read it here:
 
 http://jordi.inversethought.com/blog/advent-of-d/
I'm enjoying this. One thing jumped out at me: static does not mean execute at compile time (exactly), it really means allocate this data in thread-local storage.
Thanks for the explanation. I forgot about using enum instead. I think I've only briefly encountered it before. I'm aware of the global storage of static in this context. I like that it's the same keyword for static foreach; that's kind of what I was thinking when I wrote that just adding a static can result in compile-time execution.
 BTW, that tour page needs updating, it has a few errors in it.
You mean the Dlang tour? I've been meaning for a while to be able to generate a url to its Gems section but I've never managed to untangle its Vibe.d structure enough to do so.
Mar 06 2018
prev sibling parent reply Andrea Fontana <nospam example.com> writes:
On Tuesday, 6 March 2018 at 20:37:34 UTC, Steven Schveighoffer 
wrote:
 What triggers the compile-time execution is the fact that 
 static *initializers* need to be decided at compile time.

 So while it is executing the regex building at compile time in 
 your example, there are other ways to do it, and in this case, 
 I'd prefer using an enum. You can also use ctRegex.

 The drawback of using static is that it keeps its value between 
 function calls:
What about static immutable? I think enums exist only for compiler but they're not a l-value, so you can't take a reference, am I wrong? Andrea
Mar 07 2018
parent Steven Schveighoffer <schveiguy yahoo.com> writes:
On 3/7/18 3:20 AM, Andrea Fontana wrote:
 On Tuesday, 6 March 2018 at 20:37:34 UTC, Steven Schveighoffer wrote:
 What triggers the compile-time execution is the fact that static 
 *initializers* need to be decided at compile time.

 So while it is executing the regex building at compile time in your 
 example, there are other ways to do it, and in this case, I'd prefer 
 using an enum. You can also use ctRegex.

 The drawback of using static is that it keeps its value between 
 function calls:
What about static immutable? I think enums exist only for compiler but they're not a l-value, so you can't take a reference, am I wrong?
Static immutable works (and makes sense as a static variable) if you can use it as immutable. I'm not sure regex can do that. enums force the compile time execution, then you need to generate a runtime value from the result. i.e.: enum Xval = someCTFEfunction(); // run at CTFE. auto x = Xval; // no calls, just pastes the result there. -Steve
Mar 07 2018
prev sibling next sibling parent reply JN <666total wp.pl> writes:
On Tuesday, 6 March 2018 at 18:09:21 UTC, Jordi Gutiérrez Hermoso 
wrote:
 I wrote a blog post about working on Advent of Code in D. You 
 can read it here:

 http://jordi.inversethought.com/blog/advent-of-d/
on Day 8, I think the original "verbose" code is better in the end. Mixin at least for me makes it a bit less clear on what exactly is going on. On the other hand the latter version is probably easier to maintain and more copy-paste-error-proof.
Mar 06 2018
parent Jordi =?UTF-8?B?R3V0acOpcnJleg==?= Hermoso <jordigh octave.org> writes:
On Tuesday, 6 March 2018 at 21:03:47 UTC, JN wrote:
 On Tuesday, 6 March 2018 at 18:09:21 UTC, Jordi Gutiérrez 
 Hermoso wrote:
 I wrote a blog post about working on Advent of Code in D. You 
 can read it here:

 http://jordi.inversethought.com/blog/advent-of-d/
on Day 8, I think the original "verbose" code is better in the end. Mixin at least for me makes it a bit less clear on what exactly is going on. On the other hand the latter version is probably easier to maintain and more copy-paste-error-proof.
Yeah, it's mostly the C&P that I wanted to get rid of. I do wish the static foreach had worked, though! It's odd that you can't have compile-time associative arrays.
Mar 06 2018
prev sibling parent reply Russel Winder <russel winder.org.uk> writes:
On Tue, 2018-03-06 at 18:09 +0000, Jordi Guti=C3=A9rrez Hermoso via
Digitalmars-d wrote:
 I wrote a blog post about working on Advent of Code in D. You can=20
 read it here:
=20
 http://jordi.inversethought.com/blog/advent-of-d/
Another blog post deserving of formal publication in an ACCU journal. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Road m: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk
Mar 07 2018
parent reply Jordi =?UTF-8?B?R3V0acOpcnJleg==?= Hermoso <jordigh octave.org> writes:
On Wednesday, 7 March 2018 at 21:35:06 UTC, Russel Winder wrote:
 On Tue, 2018-03-06 at 18:09 +0000, Jordi Gutiérrez Hermoso via 
 Digitalmars-d wrote:
 I wrote a blog post about working on Advent of Code in D. You 
 can read it here:
 
 http://jordi.inversethought.com/blog/advent-of-d/
Another blog post deserving of formal publication in an ACCU journal.
Hm, I quickly looked at what that is. Some sort of informal journal? You think if I adapted the blog post for a print publication, they would take it?
Mar 08 2018
parent Russel Winder <russel winder.org.uk> writes:
On Thu, 2018-03-08 at 21:00 +0000, Jordi Guti=C3=A9rrez Hermoso via
Digitalmars-d wrote:
 On Wednesday, 7 March 2018 at 21:35:06 UTC, Russel Winder wrote:
 On Tue, 2018-03-06 at 18:09 +0000, Jordi Guti=C3=A9rrez Hermoso via=20
 Digitalmars-d wrote:
 I wrote a blog post about working on Advent of Code in D. You=20
 can read it here:
=20
 http://jordi.inversethought.com/blog/advent-of-d/
=20 Another blog post deserving of formal publication in an ACCU=20 journal.
=20 Hm, I quickly looked at what that is. Some sort of informal=20 journal? You think if I adapted the blog post for a print=20 publication, they would take it?
The journals take a mix of articles written for the journal and blog posts adapted for the journal. So yes. I have taken the liberty of cc-ing the editors of the two journals so as to make the connection. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Road m: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk
Mar 09 2018