Python (Programming Language)

Total Page:16

File Type:pdf, Size:1020Kb

Python (Programming Language) Python (programming language) Python is a widely used general-purpose, high-level pro- gramming language.[17][18][19] Its design philosophy em- phasizes code readability, and its syntax allows program- mers to express concepts in fewer lines of code than would be possible in languages such as C++ or Java.[20][21] The language provides constructs intended to enable clear programs on both a small and large scale.[22] Python supports multiple programming paradigms, in- cluding object-oriented, imperative and functional pro- gramming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive standard library.[23] Python interpreters are available for installation on many operating systems, allowing Python code execution on a wide variety of systems. Using third-party tools, such as Py2exe or Pyinstaller,[24] Python code can be pack- aged into stand-alone executable programs for some of the most popular operating systems, allowing for the dis- tribution of Python-based software for use on those en- vironments without requiring the installation of a Python interpreter. CPython, the reference implementation of Python, is free and open-source software and has a community-based development model, as do nearly all of its alternative im- plementations. CPython is managed by the non-profit Python Software Foundation. Guido van Rossum, the creator of Python 1 History be closed, but I had a home computer, and not much else on my hands. I decided to write Main article: History of Python an interpreter for the new scripting language I had been thinking about lately: a descendant of Python was conceived in the late 1980s[25] and its im- ABC that would appeal to Unix/C hackers.I plementation was started in December 1989[26] by Guido chose Python as a working title for the project, van Rossum at CWI in the Netherlands as a successor to being in a slightly irreverent mood (and a big the ABC language (itself inspired by SETL)[27] capable fan of Monty Python’s Flying Circus). of exception handling and interfacing with the Amoeba operating system.[5] Van Rossum is Python’s principal au- thor, and his continuing central role in deciding the direc- Python 2.0 was released on 16 October 2000, and in- tion of Python is reflected in the title given to him by the cluded many major new features including a full garbage Python community, benevolent dictator for life (BDFL). collector and support for Unicode. With this release the development process was changed and became more About the origin of Python, Van Rossum wrote in transparent and community-backed.[29] 1996:[28] Python 3.0 (also called Python 3000 or py3k), a ma- Over six years ago, in December 1989, jor, backwards-incompatible release, was released on I was looking for a “hobby” programming 3 December 2008[30] after a long period of testing. project that would keep me occupied during the Many of its major features have been backported to the week around Christmas. My office ... would backwards-compatible Python 2.6 and 2.7.[31] 1 2 3 SYNTAX AND SEMANTICS 2 Features and philosophy at the cost of clarity.[41] When speed is important, Python programmers use PyPy, a just-in-time compiler, or move Python is a multi-paradigm programming language: time-critical functions to extension modules written in object-oriented programming and structured program- languages such as C. Cython is also available which trans- ming are fully supported, and there are a number of lates a Python script into C and makes direct C level API language features which support functional program- calls into the Python interpreter. ming and aspect-oriented programming (including by An important goal of the Python developers is making metaprogramming[32] and by magic methods).[33] Many Python fun to use. This is reflected in the origin of the other paradigms are supported using extensions, includ- name which comes from Monty Python,[42] and in an oc- ing design by contract[34][35] and logic programming.[36] casionally playful approach to tutorials and reference ma- Python uses dynamic typing and a combination of terials, for example using spam and eggs instead of the [43][44] reference counting and a cycle-detecting garbage collec- standard foo and bar. tor for memory management. An important feature of A common neologism in the Python community is Python is dynamic name resolution (late binding), which pythonic, which can have a wide range of meanings re- binds method and variable names during program execu- lated to program style. To say that code is pythonic is tion. to say that it uses Python idioms well, that it is natural The design of Python offers only limited support for or shows fluency in the language, that it conforms with functional programming in the Lisp tradition. The Python’s minimalist philosophy and emphasis on read- language has map(), reduce() and filter() functions; ability. In contrast, code that is difficult to understand or comprehensions for lists, dictionaries, and sets; as well reads like a rough transcription from another program- as generator expressions.[37] The standard library has two ming language is called unpythonic. modules (itertools and functools) that implement func- Users and admirers of Python—most especially those tional tools borrowed from Haskell and Standard ML.[38] considered knowledgeable or experienced—are often re- [45][46] The core philosophy of the language is summarized by the ferred to as Pythonists, Pythonistas, and Pythoneers. document “PEP 20 (The Zen of Python)", which includes aphorisms such as:[39] 3 Syntax and semantics • Beautiful is better than ugly Main article: Python syntax and semantics • Explicit is better than implicit • Simple is better than complex Python is intended to be a highly readable language. It is designed to have an uncluttered visual layout, frequently • Complex is better than complicated using English keywords where other languages use punc- • Readability counts tuation or keywords. Furthermore, Python has a smaller number of syntactic exceptions and special cases than C or Pascal.[47] Rather than requiring all desired functionality to be built into the language’s core, Python was designed to be highly extensible. Python can also be embedded in existing ap- 3.1 Indentation plications that need a programmable interface. This de- sign of a small core language with a large standard library Main article: Python syntax and semantics § Indentation and an easily extensible interpreter was intended by Van Rossum from the very start because of his frustrations with ABC (which espoused the opposite mindset).[25] Python uses whitespace indentation, rather than curly braces or keywords, to delimit blocks; this feature is While offering choice in coding methodology, the Python also termed the off-side rule. An increase in indentation philosophy rejects exuberant syntax, such as in Perl, in comes after certain statements; a decrease in indentation favor of a sparser, less-cluttered grammar. As Alex signifies the end of the current block.[48] Martelli put it: “To describe something as clever is not considered a compliment in the Python culture.”[40] Python’s philosophy rejects the Perl "there is more than 3.2 Statements and control flow one way to do it" approach to language design in favor of “there should be one—and preferably only one—obvious Python’s statements include (among others): way to do it”.[39] Python’s developers strive to avoid premature optimiza- • The if statement, which conditionally executes a tion, and moreover, reject patches to non-critical parts of block of code, along with else and elif (a contrac- CPython which would offer a marginal increase in speed tion of else-if). 3.3 Expressions 3 • The for statement, which iterates over an iterable ob- • Addition, subtraction, and multiplication are the ject, capturing each element to a local variable for same, but the behavior of division differs (see use by the attached block. Mathematics for details). Python also added the ** operator for exponentiation. • The while statement, which executes a block of code as long as its condition is true. • In Python, == compares by value, in contrast to Java, where it compares by reference. (Value compar- • The try statement, which allows exceptions raised in isons in Java use the equals() method.) Python’s is its attached code block to be caught and handled by operator may be used to compare object identities except clauses; it also ensures that clean-up code in (comparison by reference). Comparisons may be a finally block will always be run regardless of how chained, for example a <= b <= c. the block exits. • Python uses the words and, or, not for its boolean • The class statement, which executes a block of code operators rather than the symbolic &&, ||, ! used in and attaches its local namespace to a class, for use Java and C. in object-oriented programming. • Python has a type of expression termed a list compre- • The def statement, which defines a function or hension. Python 2.4 extended list comprehensions method. into a more general expression termed a generator expression.[37] • The with statement (from Python 2.5), which en- • closes a code block within a context manager (for Anonymous functions are implemented using example, acquiring a lock before the block of code lambda expressions; however, these are limited in is run and releasing the lock afterwards, or opening that the body can only be a single expression. a file and then closing it), allowing RAII-like behav- • Conditional expressions in Python are written as x if ior. c else y[54] (different in order of operands from the ?: operator common to many other languages). • The pass statement, which serves as a NOP.
Recommended publications
  • Review Thanks!
    CS 242 Thanks! Review Teaching Assistants • Mike Cammarano • TJ Giuli • Hendra Tjahayadi John Mitchell Graders • Andrew Adams Tait Larson Final Exam • Kenny Lau Aman Naimat • Vishal Patel Justin Pettit Wednesday Dec 8 8:30 – 11:30 AM • and more … Gates B01, B03 Course Goals There are many programming languages Understand how programming languages work Early languages Appreciate trade-offs in language design • Fortran, Cobol, APL, ... Be familiar with basic concepts so you can Algol family understand discussions about • Algol 60, Algol 68, Pascal, …, PL/1, … Clu, Ada, Modula, • Language features you haven’t used Cedar/Mesa, ... • Analysis and environment tools Functional languages • Implementation costs and program efficiency • Lisp, FP, SASL, ML, Miranda, Haskell, Scheme, Setl, ... • Language support for program development Object-oriented languages • Smalltalk, Self, Cecil, … • Modula-3, Eiffel, Sather, … • C++, Objective C, …. Java General Themes in this Course Concurrent languages Language provides an abstract view of machine • Actors, Occam, ... • We don’t see registers, length of instruction, etc. • Pai-Lisp, … The right language can make a problem easy; Proprietary and special purpose languages wrong language can make a problem hard • Could have said a lot more about this • TCL, Applescript, Telescript, ... Language design is full of difficult trade-offs • Postscript, Latex, RTF, … • Expressiveness vs efficiency, ... • Domain-specific language • Important to decide what the language is for Specification languages • Every feature
    [Show full text]
  • Ironpython in Action
    IronPytho IN ACTION Michael J. Foord Christian Muirhead FOREWORD BY JIM HUGUNIN MANNING IronPython in Action Download at Boykma.Com Licensed to Deborah Christiansen <[email protected]> Download at Boykma.Com Licensed to Deborah Christiansen <[email protected]> IronPython in Action MICHAEL J. FOORD CHRISTIAN MUIRHEAD MANNING Greenwich (74° w. long.) Download at Boykma.Com Licensed to Deborah Christiansen <[email protected]> For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. Sound View Court 3B fax: (609) 877-8256 Greenwich, CT 06830 email: [email protected] ©2009 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15% recycled and processed without the use of elemental chlorine.
    [Show full text]
  • Ubuntu Kung Fu
    Prepared exclusively for Alison Tyler Download at Boykma.Com What readers are saying about Ubuntu Kung Fu Ubuntu Kung Fu is excellent. The tips are fun and the hope of discov- ering hidden gems makes it a worthwhile task. John Southern Former editor of Linux Magazine I enjoyed Ubuntu Kung Fu and learned some new things. I would rec- ommend this book—nice tips and a lot of fun to be had. Carthik Sharma Creator of the Ubuntu Blog (http://ubuntu.wordpress.com) Wow! There are some great tips here! I have used Ubuntu since April 2005, starting with version 5.04. I found much in this book to inspire me and to teach me, and it answered lingering questions I didn’t know I had. The book is a good resource that I will gladly recommend to both newcomers and veteran users. Matthew Helmke Administrator, Ubuntu Forums Ubuntu Kung Fu is a fantastic compendium of useful, uncommon Ubuntu knowledge. Eric Hewitt Consultant, LiveLogic, LLC Prepared exclusively for Alison Tyler Download at Boykma.Com Ubuntu Kung Fu Tips, Tricks, Hints, and Hacks Keir Thomas The Pragmatic Bookshelf Raleigh, North Carolina Dallas, Texas Prepared exclusively for Alison Tyler Download at Boykma.Com Many of the designations used by manufacturers and sellers to distinguish their prod- ucts are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers, LLC.
    [Show full text]
  • SETL for Internet Data Processing
    SETL for Internet Data Processing by David Bacon A dissertation submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy Computer Science New York University January, 2000 Jacob T. Schwartz (Dissertation Advisor) c David Bacon, 1999 Permission to reproduce this work in whole or in part for non-commercial purposes is hereby granted, provided that this notice and the reference http://www.cs.nyu.edu/bacon/phd-thesis/ remain prominently attached to the copied text. Excerpts less than one PostScript page long may be quoted without the requirement to include this notice, but must attach a bibliographic citation that mentions the author’s name, the title and year of this disser- tation, and New York University. For my children ii Acknowledgments First of all, I would like to thank my advisor, Jack Schwartz, for his support and encour- agement. I am also grateful to Ed Schonberg and Robert Dewar for many interesting and helpful discussions, particularly during my early days at NYU. Terry Boult (of Lehigh University) and Richard Wallace have contributed materially to my later work on SETL through grants from the NSF and from ARPA. Finally, I am indebted to my parents, who gave me the strength and will to bring this labor of love to what I hope will be a propitious beginning. iii Preface Colin Broughton, a colleague in Edmonton, Canada, first made me aware of SETL in 1980, when he saw the heavy use I was making of associative tables in SPITBOL for data processing in a protein X-ray crystallography laboratory.
    [Show full text]
  • The Essentials of Stackless Python Tuesday, 10 July 2007 10:00 (30 Minutes)
    EuroPython 2007 Contribution ID: 62 Type: not specified The Essentials of Stackless Python Tuesday, 10 July 2007 10:00 (30 minutes) This is a re-worked, actualized and improved version of my talk at PyCon 2007. Repeating the abstract: As a surprise for people who think they know Stackless, we present the new Stackless implementation For PyPy, which has led to a significant amount of new insight about parallel programming and its possible implementations. We will isolate the known Stackless as a special case of a general concept. This is a Stackless, not a PyPy talk. But the insights presented here would not exist without PyPy’s existance. Summary Stackless has been around for a long time now. After several versions with different goals in mind, the basic concepts of channels and tasklets turned out to be useful abstractions, and since many versions, Stackless is only ported from version to version, without fundamental changes to the principles. As some spin-off, Armin Rigo invented Greenlets at a Stackless sprint. They are some kind of coroutines and a bit of special semantics. The major benefit is that Greenlets can runon unmodified CPython. In parallel to that, the PyPy project is in its fourth year now, and one of its goals was Stackless integration as an option. And of course, Stackless has been integrated into PyPy in a very nice and elegant way, much nicer than expected. During the design of the Stackless extension to PyPy, it turned out, that tasklets, greenlets and coroutines are not that different in principle, and it was possible to base all known parallel paradigms on one simple coroutine layout, which is as minimalistic as possible.
    [Show full text]
  • A Practical Solution for Scripting Language Compilers
    A Practical Solution for Scripting Language Compilers Paul Biggar, Edsko de Vries, David Gregg Department of Computer Science, Trinity College Dublin, Dublin 2, Ireland Abstract Although scripting languages are becoming increasingly popular, even mature script- ing language implementations remain interpreted. Several compilers and reimplemen- tations have been attempted, generally focusing on performance. Based on our survey of these reimplementations, we determine that there are three important features of scripting languages that are difficult to compile or reimplement. Since scripting languages are defined primarily through the semantics of their original implementations, they often change semantics between releases. They provide C APIs, used both for foreign-function interfaces and to write third-party extensions. These APIs typically have tight integration with the original implementation, and are used to providelarge standard libraries, which are difficult to re-use, and costly to reimplement. Finally, they support run-time code generation. These features make the important goal of correctness difficult to achieve for compilers and reimplementations. We present a technique to support these features in an ahead-of-time compiler for PHP. Our technique uses the original PHP implementation through the provided C API, both in our compiler, and in our generated code. We support all of these impor- tant scripting language features, particularly focusing on the correctness of compiled programs. Additionally, our approach allows us to automatically support limited fu- ture language changes. We present a discussion and performance evaluation of this technique. Key words: Compiler, Scripting Language 1. Motivation Although scripting languages1 are becoming increasingly popular, most scripting language implementations remain interpreted. Typically, these implementations are slow, between one and two orders of magnitude slower than C.
    [Show full text]
  • How to Access Python for Doing Scientific Computing
    How to access Python for doing scientific computing1 Hans Petter Langtangen1,2 1Center for Biomedical Computing, Simula Research Laboratory 2Department of Informatics, University of Oslo Mar 23, 2015 A comprehensive eco system for scientific computing with Python used to be quite a challenge to install on a computer, especially for newcomers. This problem is more or less solved today. There are several options for getting easy access to Python and the most important packages for scientific computations, so the biggest issue for a newcomer is to make a proper choice. An overview of the possibilities together with my own recommendations appears next. Contents 1 Required software2 2 Installing software on your laptop: Mac OS X and Windows3 3 Anaconda and Spyder4 3.1 Spyder on Mac............................4 3.2 Installation of additional packages.................5 3.3 Installing SciTools on Mac......................5 3.4 Installing SciTools on Windows...................5 4 VMWare Fusion virtual machine5 4.1 Installing Ubuntu...........................6 4.2 Installing software on Ubuntu....................7 4.3 File sharing..............................7 5 Dual boot on Windows8 6 Vagrant virtual machine9 1The material in this document is taken from a chapter in the book A Primer on Scientific Programming with Python, 4th edition, by the same author, published by Springer, 2014. 7 How to write and run a Python program9 7.1 The need for a text editor......................9 7.2 Spyder................................. 10 7.3 Text editors.............................. 10 7.4 Terminal windows.......................... 11 7.5 Using a plain text editor and a terminal window......... 12 8 The SageMathCloud and Wakari web services 12 8.1 Basic intro to SageMathCloud...................
    [Show full text]
  • Goless Documentation Release 0.6.0
    goless Documentation Release 0.6.0 Rob Galanakis July 11, 2014 Contents 1 Intro 3 2 Goroutines 5 3 Channels 7 4 The select function 9 5 Exception Handling 11 6 Examples 13 7 Benchmarks 15 8 Backends 17 9 Compatibility Details 19 9.1 PyPy................................................... 19 9.2 Python 2 (CPython)........................................... 19 9.3 Python 3 (CPython)........................................... 19 9.4 Stackless Python............................................. 20 10 goless and the GIL 21 11 References 23 12 Contributing 25 13 Miscellany 27 14 Indices and tables 29 i ii goless Documentation, Release 0.6.0 • Intro • Goroutines • Channels • The select function • Exception Handling • Examples • Benchmarks • Backends • Compatibility Details • goless and the GIL • References • Contributing • Miscellany • Indices and tables Contents 1 goless Documentation, Release 0.6.0 2 Contents CHAPTER 1 Intro The goless library provides Go programming language semantics built on top of gevent, PyPy, or Stackless Python. For an example of what goless can do, here is the Go program at https://gobyexample.com/select reimplemented with goless: c1= goless.chan() c2= goless.chan() def func1(): time.sleep(1) c1.send(’one’) goless.go(func1) def func2(): time.sleep(2) c2.send(’two’) goless.go(func2) for i in range(2): case, val= goless.select([goless.rcase(c1), goless.rcase(c2)]) print(val) It is surely a testament to Go’s style that it isn’t much less Python code than Go code, but I quite like this. Don’t you? 3 goless Documentation, Release 0.6.0 4 Chapter 1. Intro CHAPTER 2 Goroutines The goless.go() function mimics Go’s goroutines by, unsurprisingly, running the routine in a tasklet/greenlet.
    [Show full text]
  • Faster Cpython Documentation Release 0.0
    Faster CPython Documentation Release 0.0 Victor Stinner January 29, 2016 Contents 1 FAT Python 3 2 Everything in Python is mutable9 3 Optimizations 13 4 Python bytecode 19 5 Python C API 21 6 AST Optimizers 23 7 Old AST Optimizer 25 8 Register-based Virtual Machine for Python 33 9 Read-only Python 39 10 History of Python optimizations 43 11 Misc 45 12 Kill the GIL? 51 13 Implementations of Python 53 14 Benchmarks 55 15 PEP 509: Add a private version to dict 57 16 PEP 510: Specialized functions with guards 59 17 PEP 511: API for AST transformers 61 18 Random notes about PyPy 63 19 Talks 65 20 Links 67 i ii Faster CPython Documentation, Release 0.0 Contents: Contents 1 Faster CPython Documentation, Release 0.0 2 Contents CHAPTER 1 FAT Python 1.1 Intro The FAT Python project was started by Victor Stinner in October 2015 to try to solve issues of previous attempts of “static optimizers” for Python. The main feature are efficient guards using versionned dictionaries to check if something was modified. Guards are used to decide if the specialized bytecode of a function can be used or not. Python FAT is expected to be FAT... maybe FAST if we are lucky. FAT because it will use two versions of some functions where one version is specialised to specific argument types, a specific environment, optimized when builtins are not mocked, etc. See the fatoptimizer documentation which is the main part of FAT Python. The FAT Python project is made of multiple parts: 3 Faster CPython Documentation, Release 0.0 • The fatoptimizer project is the static optimizer for Python 3.6 using function specialization with guards.
    [Show full text]
  • Proseminar Python - Python Bindings
    Proseminar Python - Python Bindings Sven Fischer Student an der TU-Dresden [email protected] Abstract Diese Arbeit beschaftigt¨ sich damit, einen Einblick in die Benut- zung von externen Bibliotheken in Python zu geben und fuhrt¨ den Leser in das Schreiben von eigenen Erweiterungen ein. Daruber¨ hinaus wird darauf eingegangen, wie Projekte in anderen Program- miersprachen Python benutzen konnen.¨ Weiterhin wird kurz auf verschiedene andere Moglichkeiten¨ eingegangen, Python oder Py- thons Benutzung zu erweitern und zu verandern:¨ durch Kompilati- on, Mischen“ mit oder Ubersetzen¨ in anderen Sprachen, oder spe- ” zielle Interpreter. Abbildung 1. Vergleich der Moglichkeiten¨ Python zu erwei- tern (links) und Python einzubetten (rechts). Categories and Subject Descriptors D.3.3 [Programming Lan- guages]: Language Constructs and Features—Modules, packages 1. Daten von C nach Python konvertieren General Terms Languages, Documentation 2. Python Funktion mit konvertierten Werten aufrufen Keywords Python, Extension, Embedding, Library 3. Ergebnis von Python zuruck¨ nach C konvertieren 1. Einfuhrung¨ Diese Konvertierung ist auch das großte¨ Hindernis beim Ver- 1 Python wird mit einer umfangreichen Standartbibliothek ausgelie- knupfen¨ von Python und C , zumindest ist es mit einigem Aufwand fert. Trotzdem gibt es Grunde,¨ warum man Python um verschiedene verbunden. externe Bibliotheken erweitern mochte.¨ Ein Beispiel dafur¨ ware¨ die Es gibt einige Projekte, die sich mit dem Verandern¨ und Erwei- ¨ Geschwindigkeit, die bei Python als interpretierter Sprache nicht tern der Sprache Python beschaftigen.¨ Einen kurzen Uberblick uber¨ immer den Anforderungen entspricht. Weiterhin gibt es genugend¨ einige Moglichkeiten¨ gebe ich in Abschnitt4. Dort gehe ich auf Software von Drittanbietern, welche man in Python nutzbar ma- zwei Python-Interpreter neben dem in der Standard-Distribution chen will - ohne sie in Python zu ubersetzen.¨ Darauf gehe ich in enthaltenen ein und zeige Moglichkeiten¨ auf, Python in andere Abschnitt2 ein.
    [Show full text]
  • The Community Is the Infrastructure: a Short Discussion of the Petsc Community
    The Community is the Infrastructure: A Short Discussion of the PETSc Community Mark Adams1, Jed Brown2, Satish Balay3, Victor Eijkhout4, Jacob Faibussowitsch5, Fande Kong6, Matthew Knepley7, Scott Kruger8, Oana Marin3, Richard Tran Mills3, Todd Munson3, Patrick Sanan9, Barry F. Smith10, Hong Zhang11, Hong Zhang3, and Junchao Zhang3 1Lawrence Berkeley National Laboratory 2University of Colorado at Boulder 3Argonne National Laboratory 4The University of Texas at Austin 5University of Illinois at Urbana-Champaign 6Idaho National Laboratory 7University of New York at Buffalo 8Tech-X Corporation 9ETH Zurich 10Argonne Associate, Argonne National Laboratory 11Illinois Institute of Technology July 5, 2021 Abstract Hard and soft infrastructure work in tandem to accomplish a particular enterprise. Soft infras- tructure { the formal and informal culture, institutions, standards, practices, and procedures that support an enterprise { is often more important to human endeavors than hard infrastructure. For example, a highway system's hard infrastructure (e.g., the roads) could not satisfy its enterprise { effective transportation | without the corresponding soft infrastructure of regulations, policing, driver habits, maintenance crews, and so forth. The relative cost and importance of the different aspects of infrastructure evolves, particularly during the development stages, from planning, to construction, to commissioning, operation, maintenance, and upgrading. The design, development, support, and dissemination of computer software is an archetypal example of soft infrastructure, regularly being the tail that wags the dog of computer hardware (prototypical hard infrastructure). Quantifying soft infrastructure is more difficult than hard in- frastructure. Thus, it is often ignored or under-emphasized when analyzing or proposing changes to human-developed systems. In particular, government understanding and funding of scientific soft infrastructure lags well behind that of hard infrastructure (for example, experimental devices such as accelerators).
    [Show full text]
  • Intermediate Representation and LLVM
    CS153: Compilers Lecture 6: Intermediate Representation and LLVM Stephen Chong https://www.seas.harvard.edu/courses/cs153 Contains content from lecture notes by Steve Zdancewic and Greg Morrisett Announcements •Homework 1 grades returned •Style •Testing •Homework 2: X86lite •Due Tuesday Sept 24 •Homework 3: LLVMlite •Will be released Tuesday Sept 24 Stephen Chong, Harvard University 2 Today •Continue Intermediate Representation •Intro to LLVM Stephen Chong, Harvard University 3 Low-Level Virtual Machine (LLVM) •Open-Source Compiler Infrastructure •see llvm.org for full documentation •Created by Chris Lattner (advised by Vikram Adve) at UIUC •LLVM: An infrastructure for Multi-stage Optimization, 2002 •LLVM: A Compilation Framework for Lifelong Program Analysis and Transformation, 2004 •2005: Adopted by Apple for XCode 3.1 •Front ends: •llvm-gcc (drop-in replacement for gcc) •Clang: C, objective C, C++ compiler supported by Apple •various languages: Swift, ADA, Scala, Haskell, … •Back ends: •x86 / Arm / PowerPC / etc. •Used in many academic/research projects Stephen Chong, Harvard University 4 LLVM Compiler Infrastructure [Lattner et al.] LLVM llc frontends Typed SSA backend like IR code gen 'clang' jit Optimizations/ Transformations Analysis Stephen Chong, Harvard University 5 Example LLVM Code factorial-pretty.ll define @factorial(%n) { •LLVM offers a textual %1 = alloca %acc = alloca store %n, %1 representation of its IR store 1, %acc •files ending in .ll br label %start start: %3 = load %1 factorial64.c %4 = icmp sgt %3, 0 br %4, label
    [Show full text]