Programming Pearls
Programming Pearls
Little Languages
Article Written By
y Jon Bently
y
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
3
Definition
Language is defined as:
Further states:
4
“Little
Little Languages
Languages”
• Text in a formatted input file can be
viewed as a language
C
Compiler
il
5
Compiler
Simple View
6
Three Approaches
Three approaches to drawing a picture:
• Interactive
• “Little Languages”
7
Three Approaches
Three approaches to drawing a picture:
• Interactive
• “Little Languages”
8
Why Little Languages?
• Try drawing this quickly on a computer –
using
g your
y mouse:
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
13
Language Chains
• Small languages are ideal for creating an
input/output chain
14
Language Chains
• Small languages are ideal for creating an
input/output chain
15
Other Picture Types
• Circumstances require languages to be
extended or new ones to be created
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
19
Keep it Simple
Easier to:
• Design
• Build
• Document
• a a
Maintain
• Learn
20
Abstract data types
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”?
23
Allow program to “grow”
grow
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”
26
Conclusion
• The exercises you can do on your own time!
27