1 / 63

Language Research Paper

Language Research Paper. Jamie Gordon. L A T E X. (lay- tek ) Documents!. L A T E X. L A T E X2 ε is the current version www.latex-project.org/ftp.html proTeXt for Windows ~1.6GB Gives TeX , LaTeX through MikTeX 2.9 (with PDF conversion) Includes GUI TeXstudio If you hate GUIs:

bat
Download Presentation

Language Research Paper

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Language Research Paper Jamie Gordon

  2. LATEX (lay-tek) Documents!

  3. LATEX • LATEX2ε is the current version • www.latex-project.org/ftp.html • proTeXt for Windows ~1.6GB • Gives TeX, LaTeX through MikTeX 2.9 (with PDF conversion) • Includes GUI TeXstudio • If you hate GUIs: • latex foo.tex • xdvifoo.dvi • yap foo.dvi Creates DVI View DVI (UNIX) View DVI (Windows)

  4. Support Requirements • Stable • Linux, OSX, and Windows • You can either get proTeXt or get the individual Parts: • TEX/LATEX program for processing LATEX into PDF or DVI documents • Text Editor or IDE • PDF/DVI viewing program • Program to handle PostScript files and images for inclusion into documents (if necessary)

  5. 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 • TeX was a program & language designed by Donald E. Knuth (1977) • Primarily for mathematical equations and formulas at first • Designed to unlock the potential of digital printing

  6. Pros & Cons Advantages Disadvantages Code is not very reusable Time consuming to create new layout Many external packages are not well documented • 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

  7. LaTeX Commands • Everything in LaTeX is either a command, environment, or text. • Commands and environments are case sensitive.

  8. Commands • Two formats: • Starts with a \ and a name consisting of letters • 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 parameters • To get a space after a command, always leave an empty parameter when none is required

  9. Parameters • Two flavors of parameters: • { } – required • [ ] – optional • Combine all your knowledge: • \command[optional]{required}{required2}

  10. Everything in LATEX defines the document So the file structure is arguably the most important part of the language

  11. Environments • A space where a new formatting style can be applied • There are environments for: • Lists (itemize, enumerate) • Code listings (lstlisting) • Comments (comment) • Tables (tabular) • An environment surrounds content: • \begin{environment} • Content… • \end{environment}

  12. 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

  13. 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

  14. Math! • You can write equations! Fancy ones even! • Inline: surround by $...$ • Multiline: • \begin{equation} • x^n + y^n = z^n, n\leq{}2 • \end{equation}

  15. 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

  16. Simplicity • Code is very simple to write • Most of it is text, after all • The purpose of code can be easily inferred form the names or the context of use • Eases readability and writability • There are many available commands and environments, probably near impossible to know all of them

  17. 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

  18. 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: • \command|…| • I believe this takes an environment and converts it to be inline • Semantics can be easily inferred from names

  19. 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

  20. Scala Concurrency, Object-Oriented, Functional

  21. 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

  22. Support Requirements • www.scala-lang.org/download • JVM • Unix-based or Windows systems • There is an Eclipse Plugin • Compile: • scalacHelloWorld.scala • Run: • scalaHelloWorld • Try in browser www.simplyscala.com

  23. Pros/Cons Advantages Disadvantages A language without a clear vision Wants to be both object-oriented and functional Difficult readability and writability Terse documentation • Runs on JVM (portability, Java libraries) • Scalable • Concurrency and parallelism are readily supported • Open-source project, consistently being improved • Mission critical server systems

  24. 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

  25. Scala Syntax Analysis object 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

  26. 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 • Functions can be passed as parameters • This is why Scala can be used as a functional language • Inference: 1 + 2 * 3 / x (also legal syntax)

  27. 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 here defxor(x: MyBool, y: MyBool) = (x or y) and not(x and y)

  28. Variables • Names are given using keywords: val and var • val – immutable values • var – variables • Statically typed • 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 annotation • However, you will not be able to tell this until the compiler throws an error at you

  29. 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

  30. 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 parentheses • However, this makes them resemble variables more than methods class Complex(real: Double, imaginary: Double) { def re = real defim = imaginary override deftoString() = "" + re + (if (im < 0) "" else "+") + im + "i" }

  31. 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

  32. 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

  33. 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 valuedefabc_<>! // An underscore must separate alphanumerics from symbols on identifierst._2 // Part of a method name, such as tuple getters

  34. 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

  35. 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

  36. Abstraction • Anonymous functions • Anonymous variables • Traits (interfaces with code, basically an abstract class) • Implicit classes • Pass functions as arguments • Case classes

  37. J Function-level, Math, Stat, Logical Analysis

  38. 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

  39. Function-level Language? • Not a functional language, more constrained • Hierarchy of types: • Atoms • Functions (process atoms into other atoms) • High-order functions (process functions into other functions)

  40. Pros/Cons Advantages Disadvantages Small amount of datatypes Not readable Confusing operators Implicit parameters No operator precedence Operators are computed right to left • Primarily designed to tackle “mathematical, statistical, and logical analysis of data • Has many other capabilities: • Database • 3D Graphics • Plotting • GUI • J Web Servers • And Language Interfaces • Concise code • Useful utilities

  41. 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

  42. J Alphabet • 26 lowercase letters (a to z)26 uppercase letters (A to Z)0 1 2 3 4 5 6 7 8 9 = < > _ + * - % ^ $ ~ | . : , ;# ! / \[ ] { }" ` @ & ?( )'

  43. 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.

  44. 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.

  45. Verb Examples

  46. Terminology Discussion • Many languages use a similar character set • However, most are not so dependent on mostly using symbols for all operations. • 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

  47. Named Verbs in J • Most associated with control structures if. 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.

  48. Verbs • Verbs are arguably the most important part of J • http://www.jsoftware.com/help/dictionary/contents.htm • Verbs come in two flavors: • Monad – only uses a right argument (-7=_7 or %2=0.5) • Dyad uses both a left and right argument (5-3=2 or 6%3=2)

  49. Syntax for Assignment • Two different verbs for assignment • =. • =: • The first is used to define local names • The second is used to define names in the global scope

  50. Locales • All code in J Is executed in a “locale” • A locale is a section of memory in the J system • Three special Locales • j – the default locale, always defined • base – whatever the current locale is • z – parent locale of all other locales • You may define the locale in which code should be executed using • name_locale_

More Related