Re: Three Cool Things about D
Some of the template support code is still in the app.d file. And I mean to rename some of the functions etc. You can access all the output in current_output.txt and the template used is index.jade. github.com/rjmcguire/jaded On 08 Jan 2016 04:45, "Jack Stouffer via Digitalmars-d-announce" < digitalmars-d-announce@puremagic.com> wrote: > On Friday, 8 January 2016 at 00:32:05 UTC, Rory McGuire wrote: > >> On Mon, Dec 28, 2015 at 5:24 PM, Rory McGuire >> wrote: >> >> >>> On 27 Dec 2015 6:25 PM, "Andrei Alexandrescu via Digitalmars-d-announce" >>> < digitalmars-d-announce@puremagic.com> wrote: >>> > >>> > On 12/27/15 1:27 AM, Rory McGuire via Digitalmars-d-announce > wrote: >>> [snip] >>> >> Vibe.d had a template engine called diet which is almost >> like >>> Jade. It is also completed so you might prefer that as >> an example. >>> > >>> > >>> > Either or both would be awesome to express with Pegged. -- > Andrei >>> > >>> >>> I'm working on the output part now while it's the holidays. Will share >>> once I've got my test template translating to html as a demo. >>> >>> A little teaser, this is the output of the app and runtime >> > > Can you post all of the D code on github as well, seeing as the forum > strips your code formatting, making it very hard to read. >
Re: Three Cool Things about D
On Friday, 8 January 2016 at 00:32:05 UTC, Rory McGuire wrote: On Mon, Dec 28, 2015 at 5:24 PM, Rory McGuire wrote: On 27 Dec 2015 6:25 PM, "Andrei Alexandrescu via Digitalmars-d-announce" < digitalmars-d-announce@puremagic.com> wrote: > > On 12/27/15 1:27 AM, Rory McGuire via Digitalmars-d-announce > wrote: [snip] >> Vibe.d had a template engine called diet which is almost >> like Jade. It is also completed so you might prefer that as >> an example. > > > Either or both would be awesome to express with Pegged. -- > Andrei > I'm working on the output part now while it's the holidays. Will share once I've got my test template translating to html as a demo. A little teaser, this is the output of the app and runtime Can you post all of the D code on github as well, seeing as the forum strips your code formatting, making it very hard to read.
Re: Three Cool Things about D
On Mon, Dec 28, 2015 at 5:24 PM, Rory McGuire wrote: > > On 27 Dec 2015 6:25 PM, "Andrei Alexandrescu via Digitalmars-d-announce" < > digitalmars-d-announce@puremagic.com> wrote: > > > > On 12/27/15 1:27 AM, Rory McGuire via Digitalmars-d-announce wrote: > [snip] > >> Vibe.d had a template engine called diet which is almost like Jade. It > >> is also completed so you might prefer that as an example. > > > > > > Either or both would be awesome to express with Pegged. -- Andrei > > > > I'm working on the output part now while it's the holidays. Will share > once I've got my test template translating to html as a demo. > A little teaser, this is the output of the app and runtime and/or compile time: Index of Demobody { margin: 0px; background-color: #eee; } This is the index.jade paragraph thattest continues on multiplelines goto https://github.com/jadejs/jade/blob/master/docs/views/reference/interpolation.jade";>Jade Reference to see examples of interpolationas2dfas3dfas3dfThis is the text in footer blockYou are logged in3: three2: two1: one123you have 42 friendsfoobarbazfoobarbazcatdogpigHello worldNo content providedHello worldThis is myAmazing articlefoofoo1234If you take a look at this page's source https://github.com/jadejs/jade/blob/master/docs/views/reference/interpolation.jade";>on GitHub, you'll see several places where the tag interpolation operator is used like so. .quote // this is raw text so the .quote means nothing to jade, only string and tag interpolation works here p Joel: riskyThis is supposed to just be text inside a p tag.This is NOT MY INSIDE VOICE <- upper case characters Translated from these files: *=* extends second_layout.jade block title title Index of Demo block content // this is the actual displayed content p(id="", p-form-hook=some_d_var ? "yes" :"no", marked) This is the index.jade #[i paragraph] that | #[b test] continues #[i on] multiple | lines goto #[a(target="_blank", href=" https://github.com/jadejs/jade/blob/master/docs/views/reference/interpolation.jade";) Jade Reference] // TODO: should allow empty lines in PipedText or at least show an error //| | to see examples of interpolation ul(isit=some_other_d_var == "woot") li.one-css.two-css: a(href!="#"): a(href!="#")!= clickme2 .img-holder img.image(src="logo2.gif", style={background: "red", padding: "0px"})/ ** extends second_layout.jade block title title Index of Demo block content // this is the actual displayed content p(id="", p-form-hook=some_d_var ? "yes" :"no", marked) This is the index.jade #[i paragraph] that | #[b test] continues #[i on] multiple | lines goto #[a(target="_blank", href=" https://github.com/jadejs/jade/blob/master/docs/views/reference/interpolation.jade";) Jade Reference] // TODO: should allow empty lines in PipedText or at least show an error //| | to see examples of interpolation ul(isit=some_other_d_var == "woot") li.one-css.two-css: a(href!="#"): a(href!="#")!= clickme2 .img-holder img.image(src="logo2.gif", style={background: "red", padding: "0px"})/ rmcguire@rmcguire-hx:~/Projects/jade$ cat views/second_layout.jade extends base_layout.jade block footer p This is the text in footer block *===* doctype html - auto currentUrl = "/"; - auto riskyBusiness = "risky"; - bool some_d_var = true; - string some_other_d_var = "woot"; html(lang="en") head block title title Page Title Here style include style.css body.base-css(ng-app="MyApp", ng-controller="CtrlII") block content // this is the displayed content p(id="", p-form-hook=some_d_var ? "yes" :"no", marked) This is a paragraph | That continues on | multiple lines ul(isit=some_other_d_var == "woot") li.one-css.two-css: a(href!="#"): a(href!="#")!= clickme .img-holder img.image(src="logo.gif", style={background: "red", padding: "0px"})/ woot#content1 as2df #woot2(class=["c1", "c2"]) as3dfas3df woot3(class={active: currentUrl == "/about"}) block footer p Placeholder footer block - var host = "remotehost"; - var user = var.emptyObject; if "localhost" == host div#foo(data-bar="foo", goot-one)&attributes({"data-cew": "baer", "ng-show": 1234}) //- include:markdown ./includes/footer.jade else merrrt unless user.isAnonymous p You are logged in //- :markdown //- ### Markdown Need dedent support to parse this //- I often like including markdown documents. ul - import std.conv; each index, val in [1:"one",2:"two",3:"three"] li= to!string(index) ~": "~ val - int n=1; while n < 4 li= n++ - auto friends = 42; case friends when 0 when 1 p you have very few friends default: p you have #{friends} friends //- Declaration mixin list ul li foo li bar li baz //- Use +list +list mixin pet(name) li.pet= name ul +pet("cat") +pet("dog") +pet("pig") mixin article(title) .article .article-wrapper h1= title if block block else p No content provided +article("Hello world") +article("Hello world") p This is my p Amazing article mixin link(href, name) //- attributes == {class: "btn"
Re: Three Cool Things about D
On 27 Dec 2015 6:25 PM, "Andrei Alexandrescu via Digitalmars-d-announce" < digitalmars-d-announce@puremagic.com> wrote: > > On 12/27/15 1:27 AM, Rory McGuire via Digitalmars-d-announce wrote: [snip] >> Vibe.d had a template engine called diet which is almost like Jade. It >> is also completed so you might prefer that as an example. > > > Either or both would be awesome to express with Pegged. -- Andrei > I'm working on the output part now while it's the holidays. Will share once I've got my test template translating to html as a demo.
Re: Three Cool Things about D
On 2015-12-27 17:23, Andrei Alexandrescu wrote: That looks pretty cool! -- Andrei It's based on Haml which is pretty well known as well. -- /Jacob Carlborg
Re: Three Cool Things about D
On 12/26/15 4:17 PM, Daniel Kozak via Digitalmars-d-announce wrote: https://strongloop.com/strongblog/compare-javascript-templates-jade-mustache-dust/ Andrei Alexandrescu via Digitalmars-d-announce napsal So, pro 26, 2015 v 8∶58 : On 12/26/15 1:35 PM, Rory McGuire via Digitalmars-d-announce wrote: I have a full Jade template parser in Pegged that I just need to finish the d code gen part, could it be an interesting example? Yes. How well-known is Jade? -- Andrei That looks pretty cool! -- Andrei
Re: Three Cool Things about D
On 12/27/15 1:27 AM, Rory McGuire via Digitalmars-d-announce wrote: On 26 Dec 2015 22:00, "Andrei Alexandrescu via Digitalmars-d-announce" mailto:digitalmars-d-announce@puremagic.com>> wrote: > > On 12/26/15 1:35 PM, Rory McGuire via Digitalmars-d-announce wrote: >> >> I have a full Jade template parser in Pegged that I just need to finish >> the d code gen part, could it be an interesting example? > > > Yes. How well-known is Jade? -- Andrei It is well known. I thought handlebars was used more but those github numbers say different. Vibe.d had a template engine called diet which is almost like Jade. It is also completed so you might prefer that as an example. Either or both would be awesome to express with Pegged. -- Andrei
Re: Three Cool Things about D
On 26 Dec 2015 22:00, "Andrei Alexandrescu via Digitalmars-d-announce" < digitalmars-d-announce@puremagic.com> wrote: > > On 12/26/15 1:35 PM, Rory McGuire via Digitalmars-d-announce wrote: >> >> I have a full Jade template parser in Pegged that I just need to finish >> the d code gen part, could it be an interesting example? > > > Yes. How well-known is Jade? -- Andrei It is well known. I thought handlebars was used more but those github numbers say different. Vibe.d had a template engine called diet which is almost like Jade. It is also completed so you might prefer that as an example.
Re: Three Cool Things about D
https://strongloop.com/strongblog/compare-javascript-templates-jade-mustache-dust/ Andrei Alexandrescu via Digitalmars-d-announce napsal So, pro 26, 2015 v 8∶58 : On 12/26/15 1:35 PM, Rory McGuire via Digitalmars-d-announce wrote: I have a full Jade template parser in Pegged that I just need to finish the d code gen part, could it be an interesting example? Yes. How well-known is Jade? -- Andrei
Re: Three Cool Things about D
On 12/26/15 1:35 PM, Rory McGuire via Digitalmars-d-announce wrote: I have a full Jade template parser in Pegged that I just need to finish the d code gen part, could it be an interesting example? Yes. How well-known is Jade? -- Andrei
Re: Three Cool Things about D
I have a full Jade template parser in Pegged that I just need to finish the d code gen part, could it be an interesting example? On 26 Dec 2015 20:10, "Andrei Alexandrescu via Digitalmars-d-announce" < digitalmars-d-announce@puremagic.com> wrote: > On 12/26/15 12:29 AM, Joakim wrote: > >> >> 1. Saying "Anywho" to segue to a new topic seems to be a verbal tic of >> Andrei's now. >> >> 2. It's claimed that scoped imports sped up D compilation: has this been >> measured? It would help if measurements were cited, as done for >> compile-time regex performance at the end. >> >> 3. It's better that you show usage examples of a PEGGED grammar now, as >> opposed to a previous talk that ended with the mixin slide, but I think >> it'd be best if you actually worked a toy example out and showed the >> generated D code, to really drive the point home. Even better if it >> wasn't something you could trivially write in D itself, like the >> arithmetic example you gave. >> > > Thanks for the feedback! I'll keep it in mind. -- Andrei >
Re: Three Cool Things about D
On 12/26/15 12:29 AM, Joakim wrote: 1. Saying "Anywho" to segue to a new topic seems to be a verbal tic of Andrei's now. 2. It's claimed that scoped imports sped up D compilation: has this been measured? It would help if measurements were cited, as done for compile-time regex performance at the end. 3. It's better that you show usage examples of a PEGGED grammar now, as opposed to a previous talk that ended with the mixin slide, but I think it'd be best if you actually worked a toy example out and showed the generated D code, to really drive the point home. Even better if it wasn't something you could trivially write in D itself, like the arithmetic example you gave. Thanks for the feedback! I'll keep it in mind. -- Andrei
Re: Three Cool Things about D
On Monday, 21 December 2015 at 17:28:51 UTC, Andrei Alexandrescu wrote: https://www.reddit.com/r/programming/comments/3xq2ul/codedive_2015_talk_three_cool_things_about_d/ https://www.facebook.com/dlang.org/posts/1192267587453587 https://twitter.com/D_Programming/status/678989872367988741 Andrei Just watched the whole video, even though I've seen a prior version of this talk. It was different enough in the jokes and delivery that I still enjoyed it. Some notes: 1. Saying "Anywho" to segue to a new topic seems to be a verbal tic of Andrei's now. 2. It's claimed that scoped imports sped up D compilation: has this been measured? It would help if measurements were cited, as done for compile-time regex performance at the end. 3. It's better that you show usage examples of a PEGGED grammar now, as opposed to a previous talk that ended with the mixin slide, but I think it'd be best if you actually worked a toy example out and showed the generated D code, to really drive the point home. Even better if it wasn't something you could trivially write in D itself, like the arithmetic example you gave.
Re: Three Cool Things about D
On 12/23/2015 09:06 AM, Abdulhaq wrote: A clip of the comedian that Andrei refers to can be seen here: https://www.youtube.com/watch?v=uEY58fiSK8E I love that bit! -- Andrei
Re: Three Cool Things about D
On Monday, 21 December 2015 at 17:28:51 UTC, Andrei Alexandrescu wrote: https://www.reddit.com/r/programming/comments/3xq2ul/codedive_2015_talk_three_cool_things_about_d/ https://www.facebook.com/dlang.org/posts/1192267587453587 https://twitter.com/D_Programming/status/678989872367988741 Andrei A clip of the comedian that Andrei refers to can be seen here: https://www.youtube.com/watch?v=uEY58fiSK8E
Re: Three Cool Things about D
On Wednesday, 23 December 2015 at 01:07:57 UTC, Walter Bright wrote: On 12/22/2015 10:29 AM, David Nadlinger wrote: Not sure about how it arrives at the crazily unrolled loop, but no recursion in sight anymore. It's doing tail recursion optimization, which turns the recursion into a loop. Then the loop is unrolled 8 times. You can't to tail recursion in it's basic form because there is a multiplication at the end.
Re: Three Cool Things about D
On Monday, 21 December 2015 at 17:28:51 UTC, Andrei Alexandrescu wrote: https://www.reddit.com/r/programming/comments/3xq2ul/codedive_2015_talk_three_cool_things_about_d/ https://www.facebook.com/dlang.org/posts/1192267587453587 https://twitter.com/D_Programming/status/678989872367988741 Andrei Interesting talk :-) Watched it while cooking.
Re: Three Cool Things about D
On Wednesday, 23 December 2015 at 01:07:57 UTC, Walter Bright wrote: On 12/22/2015 10:29 AM, David Nadlinger wrote: Not sure about how it arrives at the crazily unrolled loop, but no recursion in sight anymore. It's doing tail recursion optimization, which turns the recursion into a loop. The recursive call is not quite a tail call by itself, which is what Andrei pointed out using that example. But yes, that's what happens. Then the loop is unrolled 8 times. Sure thing. I was rather surprised to see that happen given that I only compiled with -O1, though, as it seems to be quite an aggressive optimization. — David
Re: Three Cool Things about D
On 12/21/2015 09:28 AM, Andrei Alexandrescu wrote: https://www.reddit.com/r/programming/comments/3xq2ul/codedive_2015_talk_three_cool_things_about_d/ https://www.facebook.com/dlang.org/posts/1192267587453587 https://twitter.com/D_Programming/status/678989872367988741 Andrei Two unnecessary pedantic corrections: - One of the earlier slides has "Voldermort" with an extra 'r'. It should be Voldemort. - At the end of one of the optimization presentations you said that the behaviour of unsigned integer overflow and *underflow* are well defined. Although what you meant is clear and that I've been using "underflow" in the same meaning until very recently, I now know that underflow is a condition only for floating point types. Copying from Wikipedia, "Arithmetic underflow can occur when the true result of a floating point operation is smaller in magnitude (that is, closer to zero) than the smallest value representable as a normal floating point number in the target datatype." Ali
Re: Three Cool Things about D
On 12/22/2015 10:29 AM, David Nadlinger wrote: Not sure about how it arrives at the crazily unrolled loop, but no recursion in sight anymore. It's doing tail recursion optimization, which turns the recursion into a loop. Then the loop is unrolled 8 times.
Re: Three Cool Things about D
On Tuesday, 22 December 2015 at 19:07:55 UTC, Steven Schveighoffer wrote: Am I missing some new feature here? What does the 'this' mean? I have no idea, this must have been some sort of weird copy/paste or auto-correct mistake on my side. It's supposed to be "uint", as in Andrei's talk. — David
Re: Three Cool Things about D
On 12/22/15 1:29 PM, David Nadlinger wrote: --- ulong factorial(this n) { return n <= 1 ? 1 : n * factorial(n - 1); } --- Am I missing some new feature here? What does the 'this' mean? -Steve
Re: Three Cool Things about D
On Monday, 21 December 2015 at 17:28:51 UTC, Andrei Alexandrescu wrote: https://www.reddit.com/r/programming/comments/3xq2ul/codedive_2015_talk_three_cool_things_about_d/ By the way, even though I wholeheartedly share your sentiment regarding those "functional" examples, I found it to be an interesting example for the power of modern optimizers that LDC manages to compile this --- ulong factorial(this n) { return n <= 1 ? 1 : n * factorial(n - 1); } --- to this: --- __D4test9factorialFkZm: mov eax, 1 cmp edi, 2 jb LBB0_7 mov ecx, edi lea edx, [rdi + 7] add edi, -2 mov eax, 1 testdl, 7 je LBB0_4 and edx, 7 neg edx mov eax, 1 .align 4, 0x90 LBB0_3: imulrax, rcx dec rcx inc edx jne LBB0_3 LBB0_4: cmp edi, 7 jb LBB0_7 add rcx, -3 .align 4, 0x90 LBB0_6: lea rdx, [rcx + 3] imulrdx, rax lea rax, [rcx + 2] lea rsi, [rcx + 1] imulrax, rsi imulrax, rdx lea rdx, [rcx - 1] imulrdx, rcx lea rsi, [rcx - 2] imulrsi, rdx imulrsi, rax lea rax, [rcx - 3] lea rdx, [rcx - 4] imulrax, rdx imulrax, rsi add rcx, -8 lea edx, [rcx + 3] cmp edx, 1 ja LBB0_6 LBB0_7: ret --- Not sure about how it arrives at the crazily unrolled loop, but no recursion in sight anymore. — David
Re: Three Cool Things about D
On Monday, 21 December 2015 at 17:28:51 UTC, Andrei Alexandrescu wrote: https://www.reddit.com/r/programming/comments/3xq2ul/codedive_2015_talk_three_cool_things_about_d/ Great motivation as always! Thx!
Re: Three Cool Things about D
On Monday, 21 December 2015 at 17:28:51 UTC, Andrei Alexandrescu wrote: https://www.reddit.com/r/programming/comments/3xq2ul/codedive_2015_talk_three_cool_things_about_d/ https://www.facebook.com/dlang.org/posts/1192267587453587 https://twitter.com/D_Programming/status/678989872367988741 Andrei In the future, you should put your name in the title as it will probably get more votes that way.
Three Cool Things about D
https://www.reddit.com/r/programming/comments/3xq2ul/codedive_2015_talk_three_cool_things_about_d/ https://www.facebook.com/dlang.org/posts/1192267587453587 https://twitter.com/D_Programming/status/678989872367988741 Andrei
Re: Talk: Three cool things about D
Andrei Alexandrescu wrote: > On 11/29/10 6:01 PM, Ali Çehreli wrote: >> Here is the announcement of the talk that I just sent out: > [snip] > > Thanks, Ali. Let's see who's coming! I am dragging some C++ (and C) people from where I work. I am looking forward to meeting other D people too. Perhaps we will start a loosely once a month meeting, which should become "The Bay Area D Interest Group" or something like that. :) > P.S. Will you be around by any chance? Yes, Yes! I hope you will bring a pen to sign my Andrei Alexandrescu books... ;) Ali
Re: Talk: Three cool things about D
On 11/29/10 6:01 PM, Ali Çehreli wrote: Here is the announcement of the talk that I just sent out: [snip] Thanks, Ali. Let's see who's coming! Andrei P.S. Will you be around by any chance?
Re: Talk: Three cool things about D
Andrei Alexandrescu wrote: ACCU Silicon Valley invited me to give a talk on December 8, 7:00 at Symantec in Mountain View, CA. Attendance is free and open. Hope to see some of you there! http://www.facebook.com/event.php?eid=142541435798096 Andrei Here is the announcement of the talk that I just sent out: ACCU: Wednesday, December 8 - Andrei Alexandrescu, "Three cool things about D" When: Wednesday, December 8, 2010 Topic: Three cool things about D Speaker: Andrei Alexandrescu Time: 6:30pm doors open 7:00pm meeting begins Where: Symantec VCAFE building 350 Ellis Street (near E. Middlefield Road) Mountain View, CA 94043 Map: <http://tinyurl.com/334rv5> Directions: VCAFE is accessible from the semicircular courtyard between Symantec buildings <http://tinyurl.com/2dccgc> Cost: Free More Info: <http://www.accu-usa.org> The D programming language is sometimes traditional and sometimes innovative, but mostly it's all around a cool language to code in. This talk substantiates that claim by focusing on three hot topics: program correctness, generic programming, and concurrency. No prior knowledge of D is necessary - you'll even see "hello, world", just with an unexpected twist. Andrei Alexandrescu coined the colloquial term "modern C++", used today to describe a collection of important C++ styles and idioms. His eponymous book on the topic, Modern C++ Design (Addison-Wesley, 2001), revolutionized C++ programming and produced a lasting influence not only on subsequent work on C++, but also on other languages and systems. Andrei's work has garnered appreciation in both industrial and academic circles through is work on C++ and on Machine Learning applied to natural language. Since 2006, Andrei has been second-in-command to Walter Bright, the D programming language inventor and initial implementer. Andrei co-designed many important features of D and authored a large part of D's standard library, as well as the recent book "The D Programming Language". Andrei holds a PhD in Computer Science from the University of Washington and a BS in Electrical Engineering from University "Politehnica" Bucharest. He works as a Research Scientist for Facebook. Andrei has set up a Facebook RSVP page for this talk at <http://www.facebook.com/event.php?eid=142541435798096> Meetings are open to the public and are free of charge. - The ACCU meets monthly. Meetings are always open to the public and are free of charge. If you would like to receive announcements about the Silicon Valley ACCU talks (which are generally not on D), just e-mail me to be added to the list. The list of talks are available at: http://accu-usa.org/ Ali
Talk: Three cool things about D
ACCU Silicon Valley invited me to give a talk on December 8, 7:00 at Symantec in Mountain View, CA. Attendance is free and open. Hope to see some of you there! http://www.facebook.com/event.php?eid=142541435798096 Andrei