On Thursday, August 24, 2017 at 9:42:51 PM UTC+8, Matthias Felleisen wrote:
> 
> Yes, Racket is a good language. But let me point you to the blog of a 
> reflective developer, and I consider reflective developers the best of their 
> kind: 
> 
>   
> https://medium.com/@daveford/80-of-my-coding-is-doing-this-or-why-templates-are-dead-b640fc149e22

None of the work that I do could be described, as the blog author puts it, 
"writing code in one language (say Java or JavaScript) whose sole purpose is to 
generate a different language (say HTML)".  This might affect my view of the 
world...

Sill, if I understand the article correctly, the author suggests that people 
should use DLS's *not* that they should write their own.

I was trying to make the argument that people starting using Racket should not 
be encouraged to solve simple problems by writing their own DSL, so I'm not 
sure the blog post disagrees with this.

For the record, I also agree that DLS's, as written by experienced people, are 
valuable and should be used by everyone.

> If you would like to see a concrete example, fully worked out, see the ICFP 
> paper on constructing a domain-specific language for scripting the production 
> of videos (say RacketCon presentations): 
> 
>  https://www2.ccs.neu.edu/racket/pubs/#icfp17-dnff
>

I admit that I only skimmed the article, it is after all 27 pages long :-), 
however this video DSL is written by experts, not by people who started using 
Racket last week.

Looking at the code example in the paper, it seems to me that the definition of 
a DSL is a bit different than mine.  In particular, it is not clear to me when 
a collection of library functions becomes a DSL.

For example, I have some Racket code that allows me to generate FIT workout 
files for Garmin devices (these are binary files that encode information about 
a structured running or cycling workout).  With the library, I can create 
workouts like this:

    (require "al-workouts.rkt")
    (define (hr/warmup) (hr/bpm 60 163))                  ; Z1 + Z2
    (define (pace/hard) (speed (pace 4 29) (pace 4 0)))   ; Z5 + 
    (define (pace/easy) (speed (pace 7 32) (pace 5 7)))   ; Z1 and Z2 

    (define (wk-daniel-q3)
      (define wk (new fit-workout-file% [name "daniel-q3"] [sport 1]))
      ((workout
        (step (minutes 20) (hr/warmup) warmup)
        (repeat 
         4                                  ; times
         (step (kms 1.2) (pace/hard) active)
         (step (minutes 4) (no-target) recover))
        (step (lap-button) (pace/easy) cooldown))
       wk)
      (send wk get-fit-data))

    (wr "daniel.q1.fit" (wk-daniel-q1)) ; write binary data to file

Is this a DSL?  Its all just objects, functions and function applications 
supported by some library code.  I could write a "#lang workout" with some 
macros to hide the actual mechanism to make it look more "magic", but I don't 
see a value in doing that.

Best Regards,
Alex.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to