diff --git a/Nick_Carter.cfdg b/Nick_Carter.cfdg new file mode 100644 index 0000000..3acfb89 --- /dev/null +++ b/Nick_Carter.cfdg @@ -0,0 +1,50 @@ +// Nick Carter +// DSLs Fall 2014 +// Extensively referenced documentation on contextfreeart.org +// Inspiration for tree design in context-free from +// http://www.contextfreeart.org/phpbb/viewtopic.php?t=581 + + +startshape WORLD + +background {b -1} + +rule WORLD { + + SUN {size 10 x 15 y 50} + // forest + 100* {s 0.9 x -4 y 4 h 10} ROW {h 114.86 sat 1.0000 b 1.0000} +} + +rule ROW { + 100* {s 0.9 x 4 y 4 b -.1} SEED {} +} + +// tree +rule SEED {BRANCH {}} + +rule BRANCH { + LINE {y 0 r 0} + FORK {y 6 size 0.7} +} + +rule FORK { + BRANCH {size 0.7 y 0.1 rotate 30} + BRANCH {size 0.7 y 0.1 rotate -30} +} + +rule LINE { + TRIANGLE [ s 1 20 y 0.26 ] +} + +rule SUN { + TRIANGLE [ r 30 x 0.5 s 1 0.5 h 7.21 sat 0.9744 b 1.0000] + TRIANGLE [ r 90 x 0.5 s 1 0.5 h 36.87 sat 1.0000 b 1.0000] + TRIANGLE [ r 150 x 0.5 s 1 0.5 h 7.21 sat 0.9744 b 1.0000] + TRIANGLE [ r 210 x 0.5 s 1 0.5 h 36.87 sat 1.0000 b 1.0000] + TRIANGLE [ r 270 x 0.5 s 1 0.5 h 7.21 sat 0.9744 b 1.0000] + TRIANGLE [ r 330 x 0.5 s 1 0.5 h 36.87 sat 1.0000 b 1.0000] + + CIRCLE [ s 0.75 b 1 h 60.60 sat 0.9055 b 1.0000] +} + diff --git a/Nick_Carter_POL.png b/Nick_Carter_POL.png new file mode 100644 index 0000000..072e693 Binary files /dev/null and b/Nick_Carter_POL.png differ diff --git a/context-free.md b/context-free.md index 8d9c470..c834e47 100644 --- a/context-free.md +++ b/context-free.md @@ -1,15 +1,28 @@ # Context Free ## Who is this programming language for? +This programming language seems like it is mostly targeted at people who need to create graphics in a very structured way. +Those that just want to draw or paint may be better served by a digital tablet. However, I think there is a use case for needing a +highly rigid, editable description for what you are creating. Perhaps art for boxes or items that could change size could +make good use of this type of quickly editable description. ## What is easy to do in this language? Why is it easy? +It is easy to adapt elements and to reuse ideas. The concept of rules makes it very easy to take one idea and use +it a lot of times. It is also very easy to take an element and change it in a subtle way and see how the change +affects the outcome. These are easy because of the encapsulation of shape parts into separate function like elements. +These can then be used together to compose the full image. ## What is hard to do in this language? Why is it hard? +It is hard to build complicated computations. Multi dimensional loops are possible, but it is hard to do operations much more complicated +than addition and subtraction. I created some trees in my program, but when I looked into more complicated fractals it didn't seem +feasible. It seems like they have purposely restricted the function set away from more mathematical ideas to preserve simplicity and ease of use. ## How did you learn how to program in this language? +I looked at sample programs and code in the documentation, the `welcome` program, and some +forum posts that discussed tricks in the language. ## What is the underlying _computational model_ for this programming language? @@ -17,6 +30,15 @@ _We don't yet have a great definition of the term "computational model". For now, try to come up with the clearest, most concise explanation of what happens when a ContextFree program runs._ +A ContextFree program seems very declarative. By this I mean that it seems like programs in context free are executed as +following a tree of rules. The program begins at the root `startshape` and follows all possible rule paths until there are +no more paths available or the paths get to small to be rendered reasonably (so recursive operations end when the recursion gets down +to the sub-pixel level). + ## What do you think is interesting about the ContextFree program you wrote? +I really liked exploring the gradient abilities in ContextFree. I used a multi-dimensional +loop to create a forest that changed hue along one axis and changed brightness along the +second axis. I set the size such that the viewer is left with the impression that the +forest might extend to infinity. diff --git a/my-dsl.md b/my-dsl.md index 3bbac9a..ef83560 100644 --- a/my-dsl.md +++ b/my-dsl.md @@ -2,37 +2,74 @@ _What is the name of the language? Link the name to its webpage (if appropriate)._ +The language is called `crontab`. [crontab.org](http://crontab.org/) + # Domain _Describe the language's domain in five words._ +Expressing when to execute commands. + # Computational model _What is the underlying computational model of this language? To answer this question, provide a high-level description (no more than 100 words) of the computation that occurs when someone executes a program in this language._ +When someone executes a crontab program, the program parses each line from first to last. Each line +is an expression that translates to a encoded time interval (anywhere from every few years to every minute) +and a command. The time encoding specifies when and with what frequency the command should be executed. +The program then runs the command each time the specified interval elapses. So, the computational model +likely looks like a priority queue in which as each task's time comes up, it is executed and put back in +the queue for its next time. + # DSL-ness _Fowler writes about a spectrum of languages, from general-purpose languages to "purely" domain-specific. Where does the DSL you chose fall on this spectrum, and why?_ +I believe this language is very close to the "purely" domain specific side. +In this language, it is only possible to express when to do commands. The commands are written in a different language (bash). So, the +expressiveness of crontab is limited to when and what. There is no general purpose loop or conditionals built into the language, although +there is an ability to create variables. +It is a language that feels like a programming language with the "terseness" that Fowler seems to like. The syntax is extremely light +weight -- a given statement has a interval +specification and a command. + # Internal or external? _Is the language implemented as an internal or external DSL? Justify your answer._ +This is an external DSL. It has its own syntax that is not very similar to other languages. +Although it makes use of other languages in its execution, those languages are not part of the DSL. + # Host language _What language(s) was (were) used to implement the DSL?_ +The cron utility, the main (and perhaps only) user of the crontab syntax, is implemented in `c`. # Benefits _Identify one potential benefit of the DSL: how is a programmer's life or a company's bottom line made easier by the existence of this language?_ +This DSL makes it very easy to specify a task that needs to occur in a repeated manner. +Instead of having to write a program +that has some form of daemon that runs continuously, +waiting for a given interval to elapse +before running a command, this DSL can be used to accomplish the same thing using a +pre-written architecture. + # Drawbacks _Identify one potential drawback of the DSL: what does a programmer or company lose by using this DSL instead of a general-purpose language?_ + +A general-purpose language is still necessary to make use of this language. It is not +possible to specify what, exactly, to do at a given time without making use of another language. +However, this is less of a drawback than an indicator that this is a very specific language. +One more definitive drawback in the domain of scheduling events is that this DSL lacks an ability to specify triggers for +an event outside of time intervals. There is no +manner in which to specify that an action should occur when another event occurs.