• date post

24-Feb-2016
• Category

## Documents

• view

23

1

Embed Size (px)

description

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: - PowerPoint PPT Presentation

### Transcript of Language Research Paper

Language Research Paper

Language Research PaperJamie GordonLATEX(lay-tek) Documents!

LATEXLATEX2 is the current versionwww.latex-project.org/ftp.htmlproTeXt for Windows ~1.6GBGives TeX, LaTeX through MikTeX 2.9 (with PDF conversion)Includes GUI TeXstudioIf you hate GUIs:latex foo.texxdvi foo.dviyap foo.dviCreates DVIView DVI (UNIX)View DVI (Windows)Support Requirements StableLinux, OSX, and WindowsYou can either get proTeXt or get the individual Parts:TEX/LATEX program for processing LATEX into PDF or DVI documentsText Editor or IDEPDF/DVI viewing programProgram to handle PostScript files and images for inclusion into documents (if necessary)What is LATEX2 ?A Markup Language for typesetting documentsVery useful for scientific or mathematical documentsStill useful for any other kind of paperIs built on top of TEX by Leslie LamportTeX was a program & language designed by Donald E. Knuth (1977)Primarily for mathematical equations and formulas at firstDesigned to unlock the potential of digital printingPros & ConsAdvantagesExcels at typesettingMath formulasConsistent formatting for professional lookProvides many layoutsComplex structures (footnotes, etc.) can be easily generatedFree, as are add-onsDisadvantagesCode is not very reusableTime consuming to create new layoutMany external packages are not well documentedLaTeX CommandsEverything in LaTeX is either a command, environment, or text.Commands and environments are case sensitive.

CommandsTwo formats:Starts with a \ and a name consisting of lettersStarts with a \ and one non-letterThere are also starred (*) variants of many commandsWhitespace after a command is ignored if there are no parametersTo get a space after a command, always leave an empty parameter when none is requiredParametersTwo flavors of parameters:{ } required[ ] optionalCombine all your knowledge:\command[optional]{required}{required2}Everything in LATEX defines the documentSo the file structure is arguably the most important part of the language

EnvironmentsA space where a new formatting style can be appliedThere are environments for:Lists (itemize, enumerate)Code listings (lstlisting)Comments (comment)Tables (tabular)An environment surrounds content:\begin{environment}Content\end{environment}EnvironmentsCan also be defined in the preamble.

This code is inserted by compiler where \begin{smalldoubleitemize} isThis code is inserted by compiler where \end{smalldoubleitemize} isDocument ClassThe document class helps define the default values for document stylingSome (like book) provide new commands that would not otherwise be available (like chapter)http://en.wikibooks.org/wiki/LaTeX/Document_Structure#Document_classesarticleFor articles in scientific journals, presentations, short reports, program documentation, invitations, ...IEEEtranFor articles with the IEEE Transactions format.procA class for proceedings based on the article class.minimalIs 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, ...bookFor real books.slidesFor slides. The class uses big sans serif letters.memoirFor changing sensibly the output of the document. It is based on thebookclass, but you can create any kind of document with it[1]letterFor writing letters.beamerFor writing presentations (seeLaTeX/Presentations).Math!You can write equations! Fancy ones even!Inline: surround by $...$Multiline:$$x^n + y^n = z^n, n\leq{}2$$

EfficiencyCompiledCompilation to DVI is quickConversion to PDF is slowerDepending on the amount of code that has changed, the process can take between 1 and 5 secondsSimplicityCode is very simple to writeMost of it is text, after allThe purpose of code can be easily inferred form the names or the context of useEases readability and writabilityThere are many available commands and environments, probably near impossible to know all of themOrthogonalityThere are only three basic constructs: commands, environments, and textThe combinations between them are also relatively smallCommands can be within environments, but commands cannot surround environmentsDefinitenessSyntax is quite simpleEverything that is not explicitly related to content is included in the preambleContent within the preamble is very well definedAll commands follow the same format as do environmentsAn exception which is not well documented:\command||I believe this takes an environment and converts it to be inlineSemantics can be easily inferred from namesReliability/Program Verification/PortabilityCompilation requires code to be correct before any output will be createdThis means program verification is always requiredBecause the language is built on TeX (believed to be one of the most stable language implementations) the current version is especially stableCode can be used on almost any computing systemScalaConcurrency, Object-Oriented, FunctionalIntro to ScalaScalable LanguageSupposed to grow with you; as you become more powerful with the languageClaimed to be both an Object-oriented and functionalRuns on the JVM (can also use all Java libraries)Open SourceSupport Requirementswww.scala-lang.org/downloadJVMUnix-based or Windows systemsThere is an Eclipse PluginCompile:scalac HelloWorld.scalaRun:scala HelloWorldTry in browser www.simplyscala.comPros/ConsAdvantagesRuns on JVM (portability, Java libraries)ScalableConcurrency and parallelism are readily supportedOpen-source project, consistently being improvedMission critical server systemsDisadvantagesA language without a clear visionWants to be both object-oriented and functionalDifficult readability and writabilityTerse documentationScala Special SyntaxThe object-oriented part of Scala is based on Java syntax, for the most partMuch of the difference comes from the compiler inferring things on behalf of the programmerScala documentation insists that you can start writing Scala programs as you would writing Java programsScala 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 definitionsScala has no static members and return type is inferred to be voidParameter syntax arrays are explicitly referred to as a classEverything is an Object(1).+(((2).*(3))./(x))Numbers are objects, and any operand is actually a method from an objectActually, functions are also objectsFunctions can be passed as parametersThis is why Scala can be used as a functional language

Inference:1 + 2 * 3 / x(also legal syntax)SemicolonsThe Scala compiler attempts to infer a lot about what you are codingThis means that semicolons are (usually) not requiredHowever, sometimes they are requiredPossibly from ambiguity in the grammar, I was not able to find any documentation for why this is the casedef not(x: MyBool) = x negate; // semicolon required heredef xor(x: MyBool, y: MyBool) = (x or y) and not(x and y)VariablesNames are given using keywords: val and varval immutable valuesvar variablesStatically typedGiven types at compile-timeSometimes compiler will not be able to infer data type from context, then you will have to explicitly tell the compiler using an annotationHowever, you will not be able to tell this until the compiler throws an error at youInferenceProponents of Scala insist that type inference both reduces the amount of typing that must be done and that it gives code more clarityIt does reduce the amount of typing doneIt also hurts readabilityScala InconsistencyScala boasts of its inferencesHowever, overridden methods have to be preceded by override, as in the belowThe two methods re & im are defined without parameters, this means that they can be called without parenthesesHowever, this makes them resemble variables more than methodsclass Complex(real: Double, imaginary: Double) { def re = real def im = imaginary override def toString() = "" + re + (if (im < 0) "" else "+") + im + "i"}EfficiencyCompiledThere are complaints of the compiler being slowThe more of Scalas features that are used, the slower the compilation is (also affects testing)Efficiency of execution is tied to efficiency of JVMJust-in-time compilation, low optimization and bytecode is interpretedSimplicityInferences decreases readability and writabilityPerhaps after careful study, the ins and outs of inferences can make code easier to write, however, readability will always be affectedReadability is affected by how much functional and object-oriented code is mixedReadability can be enhanced by parameter inference; code looks more like standard EnglishUnderscore Orthogonalityimport 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 (_ _ + * - % ^ $~ | . : , ;# ! / \[ ] { }" ` @ & ?( )' J Likes EnglishWord Group of characters form the alphabet with meaningSentence Group of words that form a complete instructionVerb 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 infinityNegative begins with _ and not -. - is a verb instead. __ (double underscore) is also a number meaning negative infinity.Terminology (Contd)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 ExamplesOperatorAffect1 AdverbEffect2 AdverbsEffect+Addition+/Summation+./OR or GCD*Multiplication*/pi product*./AND or LCM./Array MaximumTerminology DiscussionMany languages use a similar character setHowever, 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 usedMost system verbs in J are associated with graphical symbolsNamed Verbs in JMost 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.VerbsVerbs are arguably the most important part of Jhttp://www.jsoftware.com/help/dictionary/contents.htmVerbs 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)Syntax for AssignmentTwo different verbs for assignment=.=:The first is used to define local namesThe second is used to define names in the global scopeLocalesAll code in J Is executed in a localeA locale is a section of memory in the J systemThree special Localesj the default locale, always definedbase whatever the current locale isz parent locale of all other localesYou may define the locale in which code should be executed usingname_locale_Verb DefinitionsMany ways to make verbsYou already saw oneLets define a monad using multiple linesverb1=: 3 : 0What 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 : 0if. y > 0 do. y * factorial (y 1) else. 1 end.) ALTERNATIVELY usefactorial =: verb define ALSO, YOU MAY USE single linenegate =: 3 : -yWhat about Dyads?For a dyad, use 4 instead of three.How to define Monad & Dyad Concurrentlyminus =: 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, respectivelyAll About ArraysEvery noun is an arrayThere are:0-dimensional arrays called atoms (1)1-dimensional arrays called lists (1 2 3 4 OR i. 10)2-dimensional arrays called tablesHigher order arraysAll integers up to 10TablesDefined using$2 5 $88 8 8 8 88 8 8 8 82 3$ 7 8 9 10 11 12 7 8 910 11 12i. 2 51 2 3 4 56 7 8 9 10Design of VerbsMuch work has been done by J designers to make sure that all verbs can be used with lists:1 2 3 + 4 5 65 7 91 + 2 3 43 4 5EfficiencyJ is interpretedWritten in scriptsWritten with extension .ijsExecution time is based on how well you choose your verbs, a single keystroke in a J sentence can summon billions of calculationsNo compile time.SimplicityIssues with complexityNumber of operations is staggeringAbout 170 different verbs, each one can be modified by adverbsSymbolic nature of most verbs (oftentimes not related to operation at all) makes readability hardCode can be writable, you can perform a lot of calculations with relatively few instructionsCode has been worked on straight for 23 years, amount of knowledge needed is staggeringCombine this with the lack of explicit parameters, means that readability and writability are heavily affectedOrthogonalityThe number of entities is rather smallHowever, the number of operations that can be performed on each is extremeDefinitenessSyntax and semantics of the program are soundHowever, verbs can be aliasedSome special words are only keywords that can be overrode, like verb and defineSyntax allows for tacit programmingReliability/Program Verification/Portability/AbstractionCode is very reliable and stableJ is interpreted, program verification is very difficultFor the most part, any error reports you get are unhelpfulAliasing reduces reliabilityMost operations have been defined on all entities in the language, which does mean that exceptions are avoidedCode is not portable at all, J is very high-level and abstractedNo types, variables, or parametersComparisonFeatureLaTeX2eScalaJParadigmMarkupO-O/FunctionalFunction-levelDistributionOpen-SourceOpen-SourceGPL3/CommercialSuited ForDocumentsConcurrencyMath, AnalysisAge198520031990ExecutionCompiledCompiledInterpretedAdvantageTypesettingJVM and PackagesComplex AnalysisDisadvantagePortabilitySlow CompilationComplexity