Upload
jennifer-cook
View
233
Download
4
Embed Size (px)
Citation preview
Language Research Paper
Jamie Gordon
LATEX(lay-tek) Documents!
LATEX LATEX2ε is the current version www.latex-project.org/ftp.html proTeXt for Windows ~1.6GB
o Gives TeX, LaTeX through MikTeX 2.9 (with PDF conversion)o Includes GUI TeXstudio
If you hate GUIs:o latex foo.texo xdvi foo.dvio yap foo.dvi
Creates DVI
View DVI (UNIX)
View DVI (Windows)
Support Requirements Stable Linux, OSX, and Windows You can either get proTeXt or get the individual
Parts:o TEX/LATEX program for processing LATEX into PDF or DVI
documentso Text Editor or IDEo PDF/DVI viewing programo Program to handle PostScript files and images for
inclusion into documents (if necessary)
What is LATEX2ε ? A Markup Language for typesetting documents Very useful for scientific or mathematical
documents Still useful for any other kind of paper Is built on top of TEX by Leslie Lamport
o TeX was a program & language designed by Donald E. Knuth (1977)
o Primarily for mathematical equations and formulas at first
o Designed to unlock the potential of digital printing
Pros & Cons
Advantages Excels at typesetting Math formulas Consistent formatting
for professional look Provides many layouts Complex structures
(footnotes, etc.) can be easily generated
Free, as are add-ons
Disadvantages Code is not very
reusable Time consuming to
create new layout Many external
packages are not well documented
LaTeX Commands Everything in LaTeX is either a command,
environment, or text. Commands and environments are case sensitive.
Commands Two formats:
o Starts with a \ and a name consisting of letterso Starts with a \ and one non-letter
There are also starred (*) variants of many commands
Whitespace after a command is ignored if there are no parameterso To get a space after a command, always leave an empty
parameter when none is required
Parameters Two flavors of parameters:1. { } – required2. [ ] – optional Combine all your knowledge:
o \command[optional]{required}{required2}
Everything in LATEX defines the document
So the file structure is arguably the most important part of the language
Environments A space where a new formatting style can be
applied There are environments for:
o Lists (itemize, enumerate)o Code listings (lstlisting)o Comments (comment)o Tables (tabular)
An environment surrounds content:o \begin{environment}o Content…o \end{environment}
Environments Can also be defined in the preamble.
This code is inserted by compiler where \begin{smalldoubleitemize} is
This code is inserted by compiler where \end{smalldoubleitemize} is
Document Class The document
class helps define the default values for document styling
Some (like book) provide new commands that would not otherwise be available (like chapter)
http://en.wikibooks.org/wiki/LaTeX/Document_Structure#Document_classes
article
For articles in scientific journals, presentations, short reports, program documentation, invitations, ...
IEEEtran For articles with the IEEE Transactions format.
proc A class for proceedings based on the article class.
minimal
Is as small as it can get. It only sets a page size and a base font. It is mainly used for debugging purposes.
reportFor longer reports containing several chapters, small books, thesis, ...
book For real books.
slides For slides. The class uses big sans serif letters.
memoir
For changing sensibly the output of the document. It is based on the book class, but you can create any kind of document with it [1]
letter For writing letters.
beamer For writing presentations (see LaTeX/Presentations).
Math! You can write equations! Fancy ones even! Inline: surround by $...$ Multiline:
o \begin{equation}o x^n + y^n = z^n, n\leq{}2o \end{equation}
Efficiency Compiled Compilation to DVI is quick Conversion to PDF is slower Depending on the amount of code that has
changed, the process can take between 1 and 5 seconds
Simplicity Code is very simple to write
o Most of it is text, after all The purpose of code can be easily inferred form
the names or the context of useo Eases readability and writability
There are many available commands and environments, probably near impossible to know all of them
Orthogonality There are only three basic constructs: commands,
environments, and text The combinations between them are also
relatively small Commands can be within environments, but
commands cannot surround environments
Definiteness Syntax is quite simple Everything that is not explicitly related to content
is included in the preamble Content within the preamble is very well defined All commands follow the same format as do
environments An exception which is not well documented:
o \command|…|o I believe this takes an environment and converts it to be
inline Semantics can be easily inferred from names
Reliability/Program Verification/Portability
Compilation requires code to be correct before any output will be created
This means program verification is always required
Because the language is built on TeX (believed to be one of the most stable language implementations) the current version is especially stable
Code can be used on almost any computing system
ScalaConcurrency, Object-Oriented, Functional
Intro to Scala “Scalable Language” Supposed to grow with you; as you become
“more powerful” with the language Claimed to be both an Object-oriented and
functional Runs on the JVM (can also use all Java libraries) Open Source
Support Requirements www.scala-lang.org/download JVM Unix-based or Windows systems There is an Eclipse Plugin Compile:
o scalac HelloWorld.scala Run:
o scala HelloWorld Try in browser www.simplyscala.com
Pros/Cons
Advantages Runs on JVM (portability,
Java libraries) Scalable Concurrency and
parallelism are readily supported
Open-source project, consistently being improved
Mission critical server systems
Disadvantages A language without a
clear visiono Wants to be both
object-oriented and functional
Difficult readability and writability
Terse documentation
Scala Special Syntax The object-oriented part of Scala is based on Java
syntax, for the most part Much of the difference comes from the compiler
“inferring” things on behalf of the programmer Scala documentation insists that you can start
writing Scala programs as you would writing Java programs
Scala Syntax Analysisobject HelloWorld {
def main(args: Array[String]){println("Hello, world!")
}}
Note the use of the reserved word “object,” means this is a singleton object (instead of class)
No explicit data encapsulation, return type, or static modifier definitions
Scala has no static members and return type is inferred to be void
Parameter syntax arrays are explicitly referred to as a class
Everything is an Object(1).+(((2).*(3))./(x)) Numbers are objects, and any operand is actually
a method from an object Actually, functions are also objects
o Functions can be passed as parameterso This is why Scala can be used as a functional language
Inference:1 + 2 * 3 / x(also legal syntax)
Semicolons The Scala compiler attempts to infer a lot about
what you are coding This means that semicolons are (usually) not
required However, sometimes they are required Possibly from ambiguity in the grammar, I was
not able to find any documentation for why this is the case
def not(x: MyBool) = x negate; // semicolon required heredef xor(x: MyBool, y: MyBool) = (x or y) and not(x and y)
Variables Names are given using keywords: val and var val – immutable values var – variables Statically typed
o Given types at compile-time Sometimes compiler will not be able to infer data
type from context, then you will have to explicitly tell the compiler using an annotationo However, you will not be able to tell this until the
compiler throws an error at you
Inference Proponents of Scala insist that type inference
both reduces the amount of typing that must be done and that it gives code more clarity
It does reduce the amount of typing done It also hurts readability
Scala Inconsistency Scala boasts of its inferences However, overridden methods have to be
preceded by override, as in the below The two methods re & im are defined without
parameters, this means that they can be called without parentheseso However, this makes them resemble variables more
than methods
class Complex(real: Double, imaginary: Double) { def re = real def im = imaginary override def toString() = "" + re + (if (im < 0) "" else "+") + im + "i"}
Efficiency Compiled There are complaints of the compiler being slow The more of Scala’s features that are used, the
slower the compilation is (also affects testing) Efficiency of execution is tied to efficiency of JVM Just-in-time compilation, low optimization and
bytecode is interpreted
Simplicity Inferences decreases readability and writability Perhaps after careful study, the ins and outs of
inferences can make code easier to write, however, readability will always be affected
Readability is affected by how much functional and object-oriented code is mixed
Readability can be enhanced by parameter inference; code looks more like standard English
Underscore Orthogonality
import scala._ // Wild card -- all of Scala is importedimport scala.{ Predef => _, _ } // Exception, everything except Predefdef f[M[_]] // Higher kinded type parameterdef f(m: M[_]) // Existential type_ + _ // Anonymous function placeholder parameterm _ // Eta expansion of method into method valuem(_) // Partial function application_ => 5 // Discarded parametercase _ => // Wild card pattern -- matches anythingval (a, _) = (1, 2) // same thingfor (_ <- 1 to 10) // same thingf(xs: _*) // Sequence xs is passed as multiple parameters to f(ys: T*)case Seq(xs @ _*) // Identifier xs is bound to the whole matched sequencevar i: Int = _ // Initialization to the default valuedef abc_<>! // An underscore must separate alphanumerics from symbols on identifierst._2 // Part of a method name, such as tuple getters
Orthogolality Leaves much to be desired Many symbols are pulling double-duty, and often
in ways that do not make a lot of sense Standard operations can be overridden by the
programmer
Reliability/Program Verification/Portability
Reliability is in many ways tied to the JVM This makes it highly portable Static typing Problems with typing can be found at compile
time However, verification of whether or not the
compiler can compile inferred code cannot be decided at design-time
Abstraction Anonymous functions Anonymous variables Traits (interfaces with code, basically an abstract
class) Implicit classes Pass functions as arguments Case classes
JFunction-level, Math, Stat, Logical Analysis
What About J? Developed in 1990 by Kenneth E. Iverson and
Roger Hui Combination of APL and function-level languages http://www.jsoftware.com/ Can get it for free, commercial license is available Current version is j701 J is a function-level language maintained by
Jsoftware, inc. Uses tacit programming and the basic ASCII
character set
Function-level Language?
Not a functional language, more constrained Hierarchy of types:
o Atomso Functions (process atoms into other atoms)o High-order functions (process functions into other
functions)
Pros/Cons
Advantages Primarily designed to tackle
“mathematical, statistical, and logical analysis of data
Has many other capabilities:o Databaseo 3D Graphicso Plottingo GUIo J Web Serverso And Language Interfaces
Concise code Useful utilities
Disadvantages Small amount of
datatypes Not readable Confusing operators Implicit parameters No operator
precedence Operators are
computed right to left
J Weirdness Tacit/Point-free style – explicit arguments for
functions are not usually used avg=: +/ % # A function that takes an array, sums the items,
and then divides that by the number of items in the array
No precedence, right-to-left (parentheses can still be used)
10 – 4 – 3 = 9
J Alphabet 26 lowercase letters (a to z)
26 uppercase letters (A to Z)0 1 2 3 4 5 6 7 8 9 = < > _ + * - % ^ $ ~ | . : , ;# ! / \[ ] { }" ` @ & ?( )'
J Likes English Word – Group of characters form the alphabet with
meaning Sentence – Group of words that form a complete
instruction Verb – Word that expresses action (function/method) Noun – Things that verbs are done to (parameters) Number – Cannot begin with a period; can be
expressed in scientific notation using “e.” The underscore (_) is a number, meaning infinity
Negative – begins with _ and not -. - is a verb instead. __ (double underscore) is also a number meaning negative infinity.
Terminology (Cont’d) Primitive – A Word defined by the system,
usually uses a graphic character; possibly modified by an adverb. They are also expressed with one or more letters followed by a period or colon (if. or i.).
Name – Word defined by a user. You may use either =. or =: (v =. 23). You may also give verbs a name (plus=.+).
Adverb – Changes the effect a verb has. Some examples are ., :, /. Specially / tells J to use the verb between all terms of the argument.
Verb ExamplesOperator Affect 1 Adverb Effect 2
AdverbsEffect
+ Addition +/ Summation
+./ OR or GCD
* Multiplication
*/ “pi product”
*./ AND or LCM
< Less than <. Minimum <./ Array minimum
> Greater than
>. Maximum >./ Array Maximum
Terminology Discussion Many languages use a similar character set However, most are not so dependent on mostly
using symbols for all operations.o Most of the time, if a symbol is not associated with an
operation, a named function is used Most system verbs in J are associated with
graphical symbols
Named Verbs in J Most associated with control structuresif. T do. B end.if. T do. B else. B1 end.if. T do. B elseif. T1 do. B1 elseif. T2 do. B2 end.try. B catch. B1 end.while. T do. B end.whilst. T do. B end.for. T do. B end.for_i. T do. B end.select. T case. T0 do. B0 case. T1 do. B1 fcase.T2 do. B2 case. T3 do. B3end.
Verbs Verbs are arguably the most important part of J http://www.jsoftware.com/help/dictionary/content
s.htm Verbs come in two flavors:1. Monad – only uses a right argument (-7=_7 or
%2=0.5)2. Dyad uses both a left and right argument (5-3=2
or 6%3=2)
Syntax for Assignment Two different verbs for assignment1. =.2. =: The first is used to define local names The second is used to define names in the global
scope
Locales All code in J Is executed in a “locale” A locale is a section of memory in the J system Three special Locales1. j – the default locale, always defined2. base – whatever the current locale is3. z – parent locale of all other locales You may define the locale in which code should
be executed using name_locale_
Verb Definitions Many ways to make verbs You already saw one Let’s define a monad using multiple linesverb1=: 3 : 0 What this means is that you want to define a
monad (3) on the subsequent lines (0). To show where a verb definition ends, use a closing parenthesis, )
Examplefactorial =: 3 : 0
if. y > 0 do. y * factorial (y – 1) else. 1 end.)
ALTERNATIVELY usefactorial =: verb define
ALSO, YOU MAY USE single linenegate =: 3 : ‘-y’
What about Dyads? For a dyad, use 4 instead of three.
How to define Monad & Dyad Concurrently
minus =: verb define-y:x-y)
You separate the monad and the dyad using :. The undefined names x and y correspond to the nouns preceding and following the verb, respectively
All About Arrays Every noun is an array There are:1. 0-dimensional arrays called atoms (1)2. 1-dimensional arrays called lists (1 2 3 4 OR i.
10)3. 2-dimensional arrays called tables4. Higher order arrays
All integers up to 10
TablesDefined using $
2 5 $ 88 8 8 8 88 8 8 8 8
2 3 $ 7 8 9 10 11 12 7 8 910 11 12
i. 2 51 2 3 4 56 7 8 9 10
Design of Verbs Much work has been done by J designers to make
sure that all verbs can be used with lists:1 2 3 + 4 5 6
5 7 91 + 2 3 4
3 4 5
Efficiency J is interpreted Written in scripts Written with extension .ijs Execution time is based on how well you choose
your verbs, a single keystroke in a J sentence can summon billions of calculations
No compile time.
Simplicity Issues with complexity Number of operations is staggering About 170 different verbs, each one can be modified by
adverbs Symbolic nature of most verbs (oftentimes not related
to operation at all) makes readability hard Code can be writable, you can perform a lot of
calculations with relatively few instructions Code has been worked on straight for 23 years, amount
of knowledge needed is staggering Combine this with the lack of explicit parameters,
means that readability and writability are heavily affected
Orthogonality The number of entities is rather small However, the number of operations that can be
performed on each is extreme
Definiteness Syntax and semantics of the program are sound However, verbs can be aliased Some special words are only keywords that can
be overrode, like verb and define Syntax allows for tacit programming
Reliability/Program Verification/Portability/Abstracti
on Code is very reliable and stable J is interpreted, program verification is very
difficult For the most part, any error reports you get are
unhelpful Aliasing reduces reliability Most operations have been defined on all entities
in the language, which does mean that exceptions are avoided
Code is not portable at all, J is very high-level and abstractedo No types, variables, or parameters
ComparisonFeature LaTeX2e Scala J
Paradigm Markup O-O/Functional Function-level
Distribution Open-Source Open-Source GPL3/Commercial
Suited For Documents Concurrency Math, Analysis
Age 1985 2003 1990
Execution Compiled Compiled Interpreted
Advantage Typesetting JVM and Packages
Complex Analysis
Disadvantage Portability Slow Compilation
Complexity