0% found this document useful (0 votes)
41 views

Programming Pearls

This document discusses little languages and their uses. It defines little languages as mechanisms for expressing intent through formatted input files that are passed through compilers to produce outputs. Some benefits of little languages are that they can be specialized for specific tasks and used to create chains of languages. Principles for designing little languages include keeping them simple, using abstract data types, choosing linguistic formats, and separating analysis from functionality. Overall, the document provides an overview of little languages and design principles for creating them.

Uploaded by

mcmcsoto
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Programming Pearls

This document discusses little languages and their uses. It defines little languages as mechanisms for expressing intent through formatted input files that are passed through compilers to produce outputs. Some benefits of little languages are that they can be specialized for specific tasks and used to create chains of languages. Principles for designing little languages include keeping them simple, using abstract data types, choosing linguistic formats, and separating analysis from functionality. Overall, the document provides an overview of little languages and design principles for creating them.

Uploaded by

mcmcsoto
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Programming Pearls

Little Languages

Article Written By
y Jon Bently
y

Presenter: Rorik Henrikson


Class: CSC2125
Date: October 3rd, 2012
Background & Notes
 Written in 1986
 U
Uses languages
l such
h as:
 BASIC
 FORTRAN

 COBOL

 Pascal

 AWK

 Legibility notes:
 Page 714-715 is an insert
 Page 721 “Further Reading” is an insert

2
Overview
 Examines the concept of “Little
Languages”
◦ What they are
◦ How they are used
◦ Philosophy of the approach

 Principles for creating little languages


◦ High-level overview of key points

 Finishes with “exercises” to try

3
Definition
Language is defined as:

“any mechanism to express intent”

Further states:

“the input to many programs can be


[viewed] as statements in a language
language”

4
“Little
Little Languages
Languages”
• Text in a formatted input file can be
viewed as a language

• Take input file, pass it through a compiler

• Output from compiler is result and/or


next input
p

C
Compiler
il

5
Compiler

Simple View

More Detailed View

6
Three Approaches
Three approaches to drawing a picture:

• Interactive

• Calling Library Subroutines (functions)


ellipse(0.3,
lli (0 3 0,
0 0.6,
0 6 0.4)
0 4)

• “Little Languages”

7
Three Approaches
Three approaches to drawing a picture:

• Interactive

• Calling Library Subroutines (functions)


ellipse(0.3,
lli (0 3 0,
0 0.6,
0 6 0.4)
0 4)

• “Little Languages”

8
Why Little Languages?
• Try drawing this quickly on a computer –
using
g your
y mouse:

• Can be specialized for the needed task

9
Example Languages
Some of the “little languages” that are referred to
in paper include:
•PIC •LEX
•SCATTER •YACC
GRAP
•GRAP MAKE
•MAKE
•CHEM •TROFF

10
PIC - Examples

11
Other Examples
• Regular Expressions:

• Unix Commands:

• Graphics Shaders

12
Multi--Language Problem
Multi
A compiler changes one source file to one object file (1-to-1)

5 llanguages, 5 computers
t ->
> 25 compilers
il

Solution: Create an intermediate language

13
Language Chains
• Small languages are ideal for creating an
input/output chain

• Due to specialization – easy to increase utility

14
Language Chains
• Small languages are ideal for creating an
input/output chain

• Due to specialization – easy to increase utility

15
Other Picture Types
• Circumstances require languages to be
extended or new ones to be created

Led to the creation of


CHEM

16
Designing a little language
Formula:
1) Figure out design goals
2) Keep it simple
3) Create abstract data types from key players
4) Choose format of linguistics
5) Design with set of specific principles
6) Allow program to “grow”
grow
7) Keep language analysis and functionality separate

17
Designing a little language
Formula:
1) Figure out design goals
2) Keep it simple
3) Create abstract data types from key players
4) Choose format of linguistics
5) Design with set of specific principles
6) Allow program to “grow”
grow
7) Keep language analysis and functionality separate

18
Figure out design goals
• Study the problem
• Ensure
E you shouldn’t
h ld ’t jjustt b
build
ild a subroutine
b ti lib library

Reuse Old? Create New

19
Keep it Simple
Easier to:
• Design
• Build
• Document
• a a
Maintain
• Learn

20
Abstract data types

• Figure out key players in system


• These players are the programs abstract
types
(i.e. CHEM – the molecule is basic abstract
type,
yp , PIC – g
graphic
p object
j is abstract type)
yp )
• Operations are the key subroutines

21
Choose linguistic
• What format should input use?
For example:
•2 +3*4
• 234*+
• plus(2, times(3,4))
• Ensure to allow for indentation and
comments

22
Specific Principles – “Yardstick”
Yardstick
1) Orthogonality – unrelated features unrelated
2) Generality – use an operation for many purposes
What do you
3) Parsimony think isunneeded
– delete meant by operations
“many purposes”?

4) Completeness – describe all objects of interest?


5) Similarity – suggestive as possible
“Similarity” correct
6) Extensibility term?
– can grow
Isn’tt this one
Isn
7) Openness of the
– let the user
major“escape”
principles
escape to use related tools
What is meant by “escape”?

23
Allow program to “grow”
grow

“Little languages are grown, not built”

• Add features iteratively


• Add features according to needs of real use

24
Keep analysis separate
Having an analysis front end and processing backend
• Keeps it simple to build & maintain
• Keeps it simple to port

25
Conclusion
• We have seen what is meant by “little
language
language”

• We have seen some benefits of “little


languages”

• Basic principles for building a “little language”

26
Conclusion
• The exercises you can do on your own time!

27

You might also like