Skip to content
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

Hw1 Turnin #21

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[Assignment HOWTO]: https://github.com/hmc-cs111-fall2014/hmc-cs111-fall2014.github.io/wiki/Assignment-HOWTO
[Fowler]: https://sakai.claremont.edu/access/content/group/CX_mtg_80056/Fowler_Chapter2.pdf
[Assignment HOWTO]: https://github.com/hmc-cs111-fall2015/hmc-cs111-fall2015.github.io/wiki/Assignment-HOWTO
[Fowler]: https://sakai.claremont.edu/access/content/group/CX_mtg_85077/Fowler_Chapter2.pdf
[markdown]: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet

# What _is_ a DSL?
###### _Submission deadline: Monday, Sept. 8 at 11:59pm_
###### _Critique deadline: Wednesday, Sept. 10 at noon_
###### _Submission deadline: Sunday, Sept. 6 at 11:59pm_
###### _Critique deadline: Tuesday, Sept. 8 at 11:59pm_

In this assignment, you'll read an introductory chapter about DSLs, which will
give us some shared terminology for talking about DSLs and their
implementations. Then you'll find a DSL "in the wild" and describe its design
and implementation using terminology from the reading. Finally, you'll write a
program in a cool DSL: ContextFree.
program in an interesting DSL: ContextFree.

After this assignment, you should be able to:

Expand All @@ -25,7 +25,7 @@ free to talk about the assignment with anyone). For the critique part of the
assignment, you'll pick a partner and review each other's work.

## Read up on the assignment workflow
This [article][Assignment HOWTO] describes how we'll do our assignments on
[This article][Assignment HOWTO] describes how we'll do our assignments on
GitHub. Be sure to read it before you start working on your assignment.

## Read Fowler's introduction to DSLs
Expand All @@ -41,7 +41,7 @@ _<sup>1</sup> This copy of the reading is for class use only. You should not dis
class is over._

## Find a DSL
Find a DSL---one that you think several other people in the class *won’t* know.
Find a DSL---one that you think most other people in the class *won’t* know.
When picking a DSL, it's good to find one for which you can find a few
example programs, so you can get a good sense of it. Sometimes it's hard to be
sure whether or not a language is actually a DSL. That's okay! If you find a
Expand Down Expand Up @@ -78,6 +78,26 @@ uniquely identifies this version of your program).

4. Answer the questions in `context-free.md`.

## Identify your peer-review partner(s)
Your name is on the left side of this table; the person whose work you should review is on the right side of this table:

| Your name | Your critique partner's name |
| ----------- | --------------------------- |
| Adam | Daniel H. |
| Alex O. | Daniel O. |
| Alex P. | Justis |
| Anna | Matt |
| Ben | Men Cheol |
| Dan W. | Robin |
| Daniel H. | Zoab |
| Daniel O. | Adam |
| Justis | Alex O. |
| Matt | Alex P. |
| Men Cheol | Anna |
| Robin | Ben |
| Zoab | Dan W. |


## Peer-review your partner's work
Once your partner has submitted, you can comment on their work. You should
provide feedback on all aspects of your partner's work, including the
Expand All @@ -96,7 +116,6 @@ might add to your partner's work?

## Tasks

- [ ] Identify a partner for the critique part of the assignment
- [ ] Read the [Assignment HOWTO]
- [ ] Read Fowler's [introduction to DSLs][Fowler]
- [ ] Find a DSL
Expand All @@ -105,4 +124,4 @@ might add to your partner's work?
- [ ] Make and save a pretty picture in `firstname_lastname_variant.png`
- [ ] Answer the questions in `context-free.md`
- [ ] Submit your work
- [ ] Comment on your partner's work
- [ ] Comment on your critique partner's work
139 changes: 139 additions & 0 deletions anna_pinson.cfdg
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/*MissingNo.*/

startshape MO

shape MO
{
RANDSTRIP [[ x 1.75 y 2.74 ]]
RANDSTRIP [[ x 2.25 y 2.74 ]]
ALT_RANDSTRIP_1 [[ x 2.75 y -2.26 ]]
RANDSTRIP [[ x 3.25 y 2.74 ]]
EYETWO [[x 2 y -2.77]]
ALT_RANDSTRIP_2 [[ x 3.75 y 1.74 ]]
EYEONE [[x 3.77 y 2.5]]
RANDSTRIP [[ x 4.25 y 2.74 ]]
TOPWHITE [[]]
RANDSTRIP [[ x 4.75 y 2.74 ]]
RANDSTRIP [[ x 5.25 y 2.74 ]]
RANDSTRIP [[ x 5.75 y 2.74 ]]
RANDSTRIP [[ x 6.25 y 2.74 ]]

}

shape TOPWHITE
{
SQUARE [[ x 2.375 y 0.5 s 1.76 5.1 b 1 ]]
}

shape EYEONE
{
SQUARE [[ b 1 ]]
SQUARE [[ x -0.35 y 0.36 s 0.25 ]]
}

shape EYETWO
{
SQUARE [[ s 1.75 1 b 1 ]]
SQUARE [[ x -0.35 y 0.2 s 0.25 ]]
}

shape RANDSTRIP
{
RANDTILE [[]]
RANDTILE [[x 0 y -0.5]]
RANDTILE [[x 0 y -1]]
RANDTILE [[x 0 y -1.5]]
RANDTILE [[x 0 y -2]]
RANDTILE [[x 0 y -2.5]]
RANDTILE [[x 0 y -3]]
RANDTILE [[x 0 y -3.5]]
RANDTILE [[x 0 y -4]]
RANDTILE [[x 0 y -4.5]]
RANDTILE [[x 0 y -5]]
RANDTILE [[x 0 y -5.5]]
RANDTILE [[x 0 y -6]]
RANDTILE [[x 0 y -6.5]]
RANDTILE [[x 0 y -7]]
RANDTILE [[x 0 y -7.5]]
RANDTILE [[x 0 y -8]]
RANDTILE [[x 0 y -8.5]]
RANDTILE [[x 0 y -9]]
RANDTILE [[x 0 y -9.5]]
RANDTILE [[x 0 y -10]]
RANDTILE [[x 0 y -10.5]]
}

shape ALT_RANDSTRIP_1
{
RANDTILE [[]]
RANDTILE [[x 0 y -0.5]]
RANDTILE [[x 0 y -1]]
RANDTILE [[x 0 y -1.5]]
RANDTILE [[x 0 y -2]]
RANDTILE [[x 0 y -2.5]]
RANDTILE [[x 0 y -3]]
RANDTILE [[x 0 y -3.5]]
RANDTILE [[x 0 y -4]]
RANDTILE [[x 0 y -4.5]]
RANDTILE [[x 0 y -5]]
RANDTILE [[x 0 y -5.5]]
}

shape ALT_RANDSTRIP_2
{
RANDTILE [[]]
RANDTILE [[x 0 y -0.5]]
RANDTILE [[x 0 y -1]]
RANDTILE [[x 0 y -1.5]]
RANDTILE [[x 0 y -2]]
RANDTILE [[x 0 y -2.5]]
RANDTILE [[x 0 y -3]]
RANDTILE [[x 0 y -3.5]]
RANDTILE [[x 0 y -4]]
RANDTILE [[x 0 y -4.5]]
RANDTILE [[x 0 y -5]]
RANDTILE [[x 0 y -5.5]]
RANDTILE [[x 0 y -6]]
RANDTILE [[x 0 y -6.5]]
RANDTILE [[x 0 y -7]]
RANDTILE [[x 0 y -7.5]]
RANDTILE [[x 0 y -8]]
RANDTILE [[x 0 y -8.5]]
RANDTILE [[x 0 y -9]]
RANDTILE [[x 0 y -9.5]]
}

shape RANDTILE
rule {
SQUARE [[ s 0.5 ]]
}
rule {
SQUARE [[ s 0.5 b 0.1 ]]
}
rule {
SQUARE [[ s 0.5 b 0.2 ]]
}
rule {
SQUARE [[ s 0.5 b 0.3 ]]
}
rule {
SQUARE [[ s 0.5 b 0.4 ]]
}
rule {
SQUARE [[ s 0.5 b 0.5 ]]
}
rule {
SQUARE [[ s 0.5 b 0.6 ]]
}
rule {
SQUARE [[ s 0.5 b 0.7 ]]
}
rule {
SQUARE [[ s 0.5 b 0.8 ]]
}
rule {
SQUARE [[ s 0.5 b 0.9 ]]
}
rule {
SQUARE [[ s 0.5 b 1 ]]
}
Binary file added anna_pinson_PCE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions context-free.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,31 @@

## Who is this programming language for?

This is for artists who know how to program, or programmers who know how to do art. Or,perhaps, for programmers who are bored.

## What is easy to do in this language? Why is it easy?

It's easy to add simple shapes, including TITLES - words made of squares - since these things are built in. It's also moderately easy to recursively draw a shape, as this is also a built-in function.

Plus, the 'rule's make it very easy to randomize compared to other languages.

## What is hard to do in this language? Why is it hard?

It would be difficult to generate a complex image with many strokes, such as a self-portrait, or a very complex, realistic landscape, as this language generates images that are built off of squares, circles, and triangles. It would also be difficult to do anything that isn't built in, like add a conditional statement that wasn't based on randomness or a loop that didn't run until the shapes are too small to be seen.

One very difficult thing was getting the images to stack properly. With different user-defined shapes, the order that the sub-shapes are drawn depends on their 'depth.'

## How did you learn how to program in this language?

I looked up 'contextfree tutorial', found the wiki page, went to the main page and did what it said under 'How do I get started?' This included looking at 'lesson' and 'lesson2', which are built-in 'tutorials' with well-commented code explaining how to use its functions. From there it was just trial and error.

## 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._

When the program runs, it renders the shapes one by one. First, the startshape is drawn, then it goes in order; if the next shape is a circle, square, or triangle, it gets drawn; otherwise, the program executes the rules, randomly choosing one when necessary. The shape the rule says to draw it added to the to do list, and this repeats until all shapes have been drawn.

## What do you think is interesting about the ContextFree program you wrote?

Pokemon is awesome! Plus, the image is composed of randomly-generated tiles, with a few overlayed squares. It's (hopefully) recognizable as MissingNo. even when randomized.
48 changes: 48 additions & 0 deletions my-dsl.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,85 @@
_What is the name of the language? Link the name to its webpage
(if appropriate)._

[Lout](http://www.adrianjwells.freeuk.com/lout.pdf) is a high-level markup language, similar to LaTex.

# Domain
_Describe the language's domain in five words._

Typesetting documents, diagrams, and illustrations.

# 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._

Lout is a document formatter, so it reads a line of the Lout document and evaluates the expression(s) to generate a line of formatted text to add to the output document. It uses lazy evaluation to handle expressions, and can format computer program code in multiple languages, including C++, Java, Python, Perl, Ruby and Haskell.

# 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?_

If document formatting is considered to be a tight enough domain, then Lout is very domain-specific, as it was designed solely for this purpose and has practically no use outside of it.

# Internal or external?
_Is the language implemented as an internal or external DSL?
Justify your answer._

This language is mostly external. It draws from Tex in some ways, but overall has its own grammar.

Here is a sample of code from the [Wikipedia page](https://en.wikipedia.org/wiki/Lout_(software)):

```
# This is a comment.

# Use the `doc' document class and its default style.
@SysInclude { doc }

@Document
@InitialFont { Times Base 10p }
//

# Beginning of document contents.
@Text @Begin

@PP
This is a paragraph. One can easily embed @B { bold } or
@I { italic } text. One can also easily change the style of
text, such as { Helvetica Base } @Font { changing the font
being used }.

@BeginSections
@Section @Title { The First Section }
@Begin

@PP
This is the content of a section.

@End @Section
@EndSections

@End @Text
# End of the document.
```

# Host language
_What language(s) was (were) used to implement the DSL?_

Lout was first developed with influence from the eqp equation formatter and the Scribe system, and since then the only non-original extensions and improvements were the optimal paragraph breaking and automatic hyphenation of Tex.

# 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?_

Lout's biggest strangth is its ability to generate complex digrams, as well as its focus on simplicity and availability for a wide spread of users, including those who aren't familiar with programming.
It's quick and easy to learn, which companies in particular would find useful, as would programmers on a tight schedule who need to pick up a markup language and don't wish to spend time learning a more complex one.
It's also very compact taking up only 1MB of space compared to LaTex's 50-300 MB.


# 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?_

The core language is very primitive, consisting of only a few operators. First-class functions aren't provided, and in Lout it would be impossible to, say, take in input data and generate a document by automatically adding in text and formatting.
If a company didn't need to generate complex diagrams or word and textox formatting, they may find it easier to use a simpler markup language, or one that their employees may be more familiar with, like Tex.