-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assignment 1 - Nick Carter #17
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,44 @@ | ||
# 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? | ||
_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). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How are nondeterministic grammars handled? |
||
|
||
|
||
## 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. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A little more detail on how this sort of thing is specified would be nice (e.g. how would I do something every 5 minutes vs every minute?) |
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pedanticism]Any executable works; I can run a bash script, a c program, python on a file, etc[/pedanticism] |
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. YES! It's so nice having a scheduling system that doesn't try to be anything else. |
||
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the inherent randomness?