A Minimalist Approach to Software∗

Total Page:16

File Type:pdf, Size:1020Kb

A Minimalist Approach to Software∗ A Minimalist Approach to Software∗ Ammar H. Hakim March 25th 2021 1. What is minimalism? Minimalism does not mean writing less code, but writing code that counts. Minimalist programs are elegant and have a tight code structure, and do one thing well. 2. Brutal minimalism means removing all features and code that are superfluous and not needed to achieve the minimum viable program (MVP). Some features are “good to have” but if they are not “must have” they should be eliminated if aiming for a brutally minimalistic design. 3. Programming is never about lines of code or less typing or other such superficial measures. (Though all these are typically the outcome of minimalist design). Programming is about expressing executable ideas cleanly. It is a very difficult art and requires removing the fear of (full or partial) rewrites and a sharp, mathematical and axiomatic focus on minimal concepts required to implement features efficiently. 4. In our notation an object is a unit in which related data are kept together. Example: instances of a C struct containing plain-old-data (POD). To achieve a clean design, data and operators on those data must be kept separate. This is the mathematically correct thing to do as it allows constructing different systems of functions to manipulate the same data in an independent and non-intrusive manner. 5. Data in objects should be treated as read-only and not directly modified. Data modification should only happen via functions. 6. Though sometimes flexibility and extensibility are important, very often they are not impor- tant and in such situation only the special case should be handled, but handled well. 7. Flexibility and extensibility should not be based on the existence of common terms in ordinary language to describe two otherwise disparate systems. Ordinary language is not precise enough to express commonality and only through very careful analysis one discovers commonality (or lack thereof). 8. Different systems should not be shoehorned into one without significant analysis. In fact, flexibility usually is increased when systems are cleanly separated, but allow structured communication between them. Consider Unix command-line tools and their simple and elegant chaining mechanisms via pipes and output/input redirection. ∗Updated April 16th 2021 1 9. When flexibility and extensibility are required they should be implemented with an elegant and minimalist design without the need for complicated class hierarchies and fat interfaces. A hierarchical class structure that first suggests itself usually does not work cleanly in practice. Object (data) nesting is fine, class inheritance is usually not as it leads to incestuously shared state. 10. Inheritance should not be used to implement feature extensions as it leads to code bloat and brittle class hierarchies. Some code duplication is fine (and duplicate code should be refactored into functions). 11. Separation of data and operators allows dispatch on multiple object types. That is, func- tions can be written that take two or more objects to perform an action. This removes the incestuous state sharing that occurs when data and operators are mixed. 12. Dependencies should be minimized, and especially dependencies that one does not understand in a deep manner should be avoided. Exponential dependencies (if each dependency adds two more) should be avoided at all costs. If dependency management leads to adoption of a complex package manager that does “magical things” like install everything under the sun from scratch, then the situation should be re-examined very carefully and simplification undertaken. 13. Modern scripting languages are very flexible and powerful. Some like Lua are specially de- signed for embedding in larger applications and have a very tiny footprint. C code (or C APIs) are very easy to bind in multiple languages. Hence a good architectural motif (used in redis, haprox and most games) is to write the low-level performance critical code in C (or a carefully curated subset of C++) and use scripting to provide higher level control. 14. It should be remembered that not all control structures need be possible in C or the Curated- C++. Higher-level scripting languages allow more complex and elegant control structures (like lexical closures or coroutines) even when they are missing from the low-level language used to implement the performance critical aspects of the code. 15. The API exposed to the scripting language should be fine-grained enough to allow use of complex control structures like lexical closure, coroutines and iterators. Allow users the ability to pass structured data between the script and compiled layer. 16. Proper use of C structs and function pointers can lead to surprisingly elegant designs and clean code. Memory management is not the burden it is made out to be. Recall highly robust and reliable software like the Linux kernel, redis, haproxy, sqlite etc are written in C. Static analysis tools and valgrind are your friends. Remember: at first one wants results but very soon one wants control. C and Curated-C++ give you complete control. 17. Last year’s problems should not be papered over with yet another layer of code. Layered soft- ware design is good but layers should be used in the sense of indirections and not bandages. 18. To understand an existing software library/framework popularity should not be used as a metric. Some popular libraries may have high-quality code but more often popularity is simply an indicator of good marketing (funding pressures or corporate greed to establish platform tie-in). Further, popularity, specially when it comes with a promise of quick initial returns, often indicates mediocrity as popularity can only be achieved by targeting people who 2 can’t be bothered to develop a deep understanding and create minimalist programs. Typical minimalist applications do not have extensive enough needs to require including everything- under-the-sun frameworks. In fact, it is a good idea to avoid anything that has the word "framework" or other buzzwords in it. 19. Minimalist and MVPs should be quick to build. Incremental builds should not take more than a few seconds and full system distclean rebuild should not take more than several seconds. Note that using some heavily (infernally) templated C++ libraries slow builds notoriously. These infernal templated libraries (ITLs) should be avoided1. 20. There is no need for the development and deployment build systems to be the same. In fact, it is possible that for deployment a simpler build system (even plain make) is a good option. Recall that at deployment one does not need full dependency tracking and so it is sufficient to simply build everything. Efficient development, on the other hand, requires fast incremental builds and hence a fast minimum-dependency build system (preferably with a nice scripting language) is desirable. 21. Consider sqlite that takes the extreme step of creating a single monster C file that can be simply built with “cc -c -O sqlite3.c”. This is not always possible or desirable for all projects, and perhaps an “amalgamated directory” approach is better. In this approach a script or build target generates a deployment directory, constructs Makefiles and/or shell-scripts to compile all code and tar.gzs everything. Note cmake generated Makefiles are not stand-alone and so can’t be used in amalgamated deployment archives. Obviously, this amalgamation approach does not work for script code but is also not needed: amalgamation should ease builds while scripts do not require building. 22. In summary: creating efficient and innovative software requires a minimalist or even brutally minimalist approach. The goal should be to construct one or more MVPs that have struc- tured data exchange protocols instead of giant monolithic programs. Frequent rewrites and refactoring may be needed before one discovers the correct design of an MVP. Monolithic pro- grams and over-engineered systems are almost invariably slower, harder to maintain (despite their developers having used the latest OOP and “Agile”" fads to make them extensible) and difficult to understand. 1Templates are sometimes needed, but often after first discovering templates one tends to go into an orgiastic frenzy to use templates everywhere. Templating often becomes like a viral infection: once it is introduced it spreads everywhere. Insane use of tempalates should be avoided at all costs. 3.
Recommended publications
  • A Minimalist Global User Interface1
    A Minimalist Global User Interface1 Rob Pike AT&T Bell Laboratories Murray Hill, New Jersey 07974 [email protected] Abstract users from the keyboard-heavy user interfaces that preceded them. Help is a combination of editor, window system, shell, and user interface that provides a novel environment for There are many reasons for this failure one that is the construction of textual applications such as browsers, often overlooked is how uncomfortable most commercially debuggers, mailers, and so on. It combines an extremely lean made mice are to use but the most important might well be user interface with some automatic heuristics and defaults to that the interfaces the machines offer are just not very good. achieve significant effects with minimal mouse and keyboard Spottily integrated and weighed down by layers of software activity. The user interface is driven by a file-oriented pro- that provide features too numerous to catalog and too special- gramming interface that may be controlled from programs or ized to be helpful, a modern window system expends its even shell scripts. By taking care of user interface issues in a energy trying to look good, either on a brochure or on a dis- central utility, help simplifies the job of programming appli- play. What matters much more to a user interface is that it cations that make use of a bitmap display and mouse. feel good. It should be dynamic and responsive, efficient and invisible [Pike88]; instead, a session with X windows some- Keywords: Windows, User Interfaces, Minimalism times feels like a telephone conversation by satellite.
    [Show full text]
  • Storm Clouds Platform: a Cloud Computing Platform for Smart City Applications
    RESEARCH ARTICLE Storm Clouds Platform: a cloud computing platform for smart city applications Marco Battarra, Marco Consonni*, Samuele De Domenico and Andrea Milani Hewlett Packard Italiana S.R.L., 9, Via Di Vittorio Giuseppe – 20063 Cernusco Sul Naviglio, Italy Abstract: This paper describes our work on STORM CLOUDS[1], a project with the main objective of migrating smart-city services, that Public Authorities (PAs) currently provided using traditional Information Technology, to a cloud-based environment. Our organization was in charge of finding the technical solutions, so we designed and im- plemented a cloud computing solution called Storm Clouds Platform (SCP), for that purpose. In principle, the applica- tions we ported could run on a public-cloud service, like Amazon Web ServicesTM[2] or Microsoft® Azure[3], that pro- vide computational resources on a pay-per-use paradigm. However, these solutions have disadvantages due to their proprietary nature: vendor lock-in is one of the issues but other serious problems are related to the lack of full control on how data and applications are processed in the cloud. As an example, when using a public cloud, the users of the cloud services have very little control on the location where applications run and data are stored, if there is any. This is identi- fied as one of the most important obstacles in cloud computing adoption, particularly in applications manage personal data and the application provider has legal obligation of preserving end user privacy[4]. This paper explains how we faced the problem and the solutions we found. We designed a cloud computing platform — completely based on open-software components — that can be used for either implementing private clouds or for porting applications to public clouds.
    [Show full text]
  • Notions of Minimalism and the Design of Interactive Systems
    Where »less« is »more« – notions of minimalism and the design of interactive systems: A constructive analysis of products & processes of human-computer-interaction design from a minimalist standpoint Dissertation zur Erlangung des Doktorgrades an der MIN-Fakultät Department Informatik der Universität Hamburg vorgelegt von Hartmut Obendorf Hamburg 2007 Genehmigt von der MIN-Fakultät Department Informatik der Universität Hamburg auf Antrag von Prof. Dr. Horst Oberquelle Erstgutachter(in)/Doktorvater Prof. Dr. Horst Oberquelle Zweitgutachter(in) Hamburg, den _______________ Datum der Disputation 4.4.2007 Prof. Dr. ____________________________ Leiter Department Informatik (Prof. Dr. N. Ritter) OVERVIEW 1 Designing for an Age of Complexity 11 Computing has added complexity to our lives. The search for machine beauty motivates the transfer of the notion of minimalism from art and music to the design of interactive systems, trying to explain simplicity, and to differentiate paths of reduction. For a concise example, four notions of minimalism are presented and discussed. 2 In Search of ‚Minimalism‘ – Roving in art history, music and elsewhere 21 Examples of works in art, music and literature that were collectively described with the label of Minimalism by contemporary criticism and art history are revisited. This chapter follows a historical rather than a conceptual order and aims not at a single definition of Minimalism, but instead tries to illustrate both the breadth of concepts underlying works characterized as minimal, and the recurrence of attributes of minimal art in different disciplines. 3 A Role for Minimalism in the Use-Centered Design of Interactive Systems 61 Based on these shared aspects of minimalism, four principles, namely functional, structural, constructional and compositional minimalism, are introduced.
    [Show full text]
  • AIT Haproxy.Key
    HEIG-VD | TIC – Technologies de l’Information et de la Communication HAProxy (C) 2015 Marcel Graf HEIG-VD | TIC – Technologies de l’Information et de la Communication HAProxy ■ HAProxy (High Availability Proxy) is a load balancer implemented in software ■ Available as Open Source (GPL/LGPL license) (http://www.haproxy.org) ■ Available as commercial product (http://www.haproxy.com) ■ Also available as appliance: ALOHA ■ Runs on FreeBSD, Linux, OpenBSD and Solaris ■ Written by Willy Tarreau in 2000 ■ Willy is the maintainer of the Linux 2.4 kernel ■ Lives in Fontenay aux Roses ■ Used by high-profile websites: GitHub, Bitbucket, Stack Overflow, Reddit, Tumblr, Twitter 2 Administration IT | HAProxy | Année 2015/16 (C) 2015 Marcel Graf HEIG-VD | TIC – Technologies de l’Information et de la Communication HAProxy Features ■ HAProxy can be used for ■ Load balancing on TCP layer and HTTP layer ■ Normalization / filtering of TCP and HTTP traffic ■ HTTP rewriting ■ SSL offloading ■ HTTP compression offloading ■ Traffic regulation ■ Protection against DDoS and service abuse ■ … 3 Administration IT | HAProxy | Année 2015/16 (C) 2015 Marcel Graf HEIG-VD | TIC – Technologies de l’Information et de la Communication HAProxy operations ■ Health checks ■ HAProxy periodically sends probes to servers to check if they are still operational. A probe can be superficial or go deeper: ■ ping to server’s IP address (TCP mode) ■ TCP connection to server’s HTTP port (TCP mode) ■ HTTP request to server (HTTP mode) ■ Based on health checks HAProxy sets a server’s state to UP or DOWN ■ Server administrative state ■ The administrator can set a server into one of three administrative states ■ READY — Server is in normal mode, accepting requests ■ DRAIN — Removes server from load balancing, but still allows it to be health-checked and accept new persistent connections.
    [Show full text]
  • Cloud Onload Haproxy Cookbook
    Cloud Onload® HAProxy Cookbook The information disclosed to you hereunder (the “Materials”) is provided solely for the selection and use of Xilinx products. To the maximum extent permitted by applicable law: (1) Materials are made available "AS IS" and with all faults, Xilinx hereby DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and (2) Xilinx shall not be liable (whether in contract or tort, including negligence, or under any other theory of liability) for any loss or damage of any kind or nature related to, arising under, or in connection with, the Materials (including your use of the Materials), including for any direct, indirect, special, incidental, or consequential loss or damage (including loss of data, profits, goodwill, or any type of loss or damage suffered as a result of any action brought by a third party) even if such damage or loss was reasonably foreseeable or Xilinx had been advised of the possibility of the same. Xilinx assumes no obligation to correct any errors contained in the Materials or to notify you of updates to the Materials or to product specifications. You may not reproduce, modify, distribute, or publicly display the Materials without prior written consent. Certain products are subject to the terms and conditions of Xilinx’s limited warranty, please refer to Xilinx’s Terms of Sale which can be viewed at https://www.xilinx.com/legal.htm#tos; IP cores may be subject to warranty and support terms contained in a license issued to you by Xilinx.
    [Show full text]
  • Updates from the Open Quantum Safe Project
    Updates from the Open Quantum Safe Project Open Quantum Safe core team: Michael Baentsch Vlad Gheorghiu, evolutionQ & University of Waterloo Basil Hess, IBM Research Christian Paquin, Microsoft Research John Schanck, University of Waterloo Douglas Stebila, University of Waterloo Goutam Tamvada, University of Waterloo April 23, 2021 Abstract The Open Quantum Safe (OQS) project is an open-source project that aims to support the development and prototyping of quantum-resistant cryptography. This short note provides an update on the tools OQS makes available. 1 Introduction The Open Quantum Safe (OQS) project1 is an open-source project that aims to support the develop- ment and prototyping (of applications) of quantum-resistant cryptography. OQS consists of the following main lines of work: liboqs, an open source C library for quantum- resistant cryptographic algorithms, and prototype integrations into protocols and applications, including a fork of the widely used OpenSSL library. These tools support research by ourselves and others. To reduce the hurdle for getting started and to aid the uptake and use of these components, our tools are also available as ready-to-use binaries in the form of Docker images and test servers. In this short note, we provide an update on the Open Quantum Safe project. 2 liboqs liboqs is an open source C library for quantum-safe cryptographic algorithms. liboqs makes accessible a collection of open-source implementations of quantum-safe key encapsulation mechanism (KEM) and digital signature algorithms through a common API. liboqs builds on Linux, macOS, and Windows, on Intel, AMD, and ARM platforms. Some of the implementations of these algorithms have been directly contributed to liboqs by members of the NIST submission teams; others are incorporated from the PQClean project.
    [Show full text]
  • Modeling Linguistic Theory on a Computer: from GB to Minimalism
    Modeling Linguistic Theory on a Computer: From GB to Minimalism Sandiway Fong Dept. of Linguistics Dept. of Computer Science 1 MIT IAP Computational Linguistics Fest, 1/14/2005 Outline • Mature system: PAPPI • Current work – parser in the principles-and- – introduce a left-to-right parser parameters framework based on the probe-goal model – principles are formalized and from the Minimalist Program declaratively stated in Prolog (MP) (logic) – take a look at modeling some – principles are mapped onto data from SOV languages general computational mechanisms • relativization in Turkish and Japanese – recovers all possible parses • psycholinguistics (parsing – (free software, recently ported preferences) to MacOS X and Linux) – (software yet to be released...) – (see http://dingo.sbs.arizona.edu/~sandi way/) 2 MIT IAP Computational Linguistics Fest, 1/14/2005 3 PAPPI: Overview sentence • user’s viewpoint syntactic represent ations parser operations corresponding to linguistic principles (= theory) 3 MIT IAP Computational Linguistics Fest, 1/14/2005 PAPPI: Overview • parser operations can be – turned on or off – metered • syntactic representations can be – displayed – examined • in the context of a parser operation – dissected • features displayed 4 MIT IAP Computational Linguistics Fest, 1/14/2005 PAPPI: Coverage • supplied with a basic set of principles – X’-based phrase structure, Case, Binding, ECP, Theta, head movement, phrasal movement, LF movement, QR, operator-variable, WCO – handles a couple hundred English examples from Lasnik and
    [Show full text]
  • Red Hat Codeready Containers 1.19 Getting Started Guide
    Red Hat CodeReady Containers 1.19 Getting Started Guide Quick-start guide to using and developing with CodeReady Containers Last Updated: 2020-12-04 Red Hat CodeReady Containers 1.19 Getting Started Guide Quick-start guide to using and developing with CodeReady Containers Kevin Owen [email protected] Legal Notice Copyright © 2020 Red Hat, Inc. The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/ . In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version. Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law. Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries. Linux ® is the registered trademark of Linus Torvalds in the United States and other countries. Java ® is a registered trademark of Oracle and/or its affiliates. XFS ® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries. MySQL ® is a registered trademark of MySQL AB in the United States, the European Union and other countries. Node.js ® is an official trademark of Joyent.
    [Show full text]
  • Capabilities of Rationalism and Minimalism for Contemporary
    International Journal of Scientific & Engineering Research, Volume 7, Issue 1, January-2016 339 ISSN 2229-5518 Capabilities of Rationalism and Minimalism for Contemporary Graffiti and Environmental Graphic: A Descriptive, Analytical and Comparative Case Study Seyed Maziar Mohsenian* Enghelab–e Eslami Technical College (EITTC), Tehran, Iran Abstract— In early centuries, human created some magical and ritual artworks on the wall of caves, with the limited facilities, to achieve some goals. During time and by developing of sciences and technologies, factors such as change in material, variety of tastes, ideas and so on allow art to be applicable in various fields. One of the art branches which have a wide and multi–dimensional applicability from definition and performance points of view is graffiti. In the current time, graffiti is a symbol of urban and popular art. Although use of paintings, colors and decorative elements for decoration of architecture has been common since ancient era, graffiti is changed due to changing in urban structures and establishing new urbanism concepts in recent years. For creating graffiti in the current time, it has not confine to performing on a vertical wall using tools such as brush and color but we can see different artworks sometimes are comparable to the artworks of various art branches such as minimal art and utilize the characteristics of such art branches to create new graffiti. The current research aims to describe the capabilities of contemporary graffiti and environmental graphic of Iran and it can be used to calm urban space, which its critical foundation, decorative purposes and constitutional concepts of minimal art.
    [Show full text]
  • Openstack Installation
    TECH GUIDE OpenStack Installation: A Practitioner’s Guide Introduction TECH GUIDE: OpenStack Installation: A Practitioner’s Guide One of the great things about OpenStack is all the options you have for deploying it – from homebrew to hosted OpenStack to vendor appliances to OpenStack-as-a-service. Previously, Platform9 published a tech guide comparing various OpenStack deployment models. If you opt for a do- it-yourself (DIY) approach, then you face the question of which tool to use. This guide will familiarize you with the landscape of OpenStack installation tools, including an overview of the most popular ones: DevStack, RDO Packstack, OpenStack-Ansible, Fuel and TripleO. OpenStack Architecture Overview If you’re new to OpenStack it may be helpful to review the OpenStack components. (Skip this section if you’re already familiar with OpenStack.) OpenStack’s design, inspired by Amazon Web Services (AWS), has well-documented REST APIs that enable a self-service, elastic Infrastructure-as-a Service (IaaS) cloud. In addition, OpenStack is fundamentally agnostic to the underlying infrastructure and integrates well with various compute, virtualization, network and storage technologies. Heat Clarity UI CLI / Tools Scripts (orchestration) Nova Compute Scheduler (images) Cinder Keystone Glance (identity) Basic Storage Basic Network Neutron Network Block Controller Storage Figure 1: OpenStack architecture is loosely coupled, and extensible to support any hypervisor / container, storage, and network system 2 Plan to get NO help to install & manage
    [Show full text]
  • Lighthouse Documentation Release 1.0.0
    lighthouse Documentation Release 1.0.0 William Glass March 07, 2016 Contents 1 Overview 3 2 Development 5 3 License 7 3.1 Getting Started..............................................7 3.2 Configuration...............................................8 3.3 Examples................................................. 17 3.4 Writing Plugins.............................................. 24 3.5 Source Docs............................................... 28 3.6 Release Notes.............................................. 41 Python Module Index 45 i ii lighthouse Documentation, Release 1.0.0 Lighthouse is a service node discovery system written in python, built with resilience, flexibility and ease- of-use in mind and inspired by Airbnb’s SmartStack solution. Out of the box it supports discovery via Zookeeper with cluster load balancing handled by an automatically configured HAProxy. To jump right in see the Getting Started page, or if you’d like to see it in action check out the Examples page. Contents 1 lighthouse Documentation, Release 1.0.0 2 Contents CHAPTER 1 Overview A lighthouse setup consists of three parts running locally on each node: a load balancer, the lighthouse-writer script and (usually) the lighthouse-reporter script. In a Lighthouse setup, no node’s application code is aware of the existence of other nodes, they talk to a local port handled by an instance of the load balancer which in turn routes traffic among the various known other nodes. This local load balancer is automatically updated when nodes come and go via the lighthouse-writer script, which talks to the discovery method (e.g. Zookeeper) to keep track of which nodes on which clusters are up. The lighthouse-reporter script likewise talks to the discovery method, it is responsible for running health checks on any services on the local node and reports to the discovery method that the healthy services are up and the unhealthy ones are down.
    [Show full text]
  • Oracle® Openstack Configuration Guide for Release 4.0
    Oracle® OpenStack Configuration Guide for Release 4.0 E90982-03 February 2018 Oracle Legal Notices Copyright © 2018, Oracle and/or its affiliates. All rights reserved. This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable: U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, shall be subject to license terms and license restrictions applicable to the programs. No other rights are granted to the U.S. Government. This software or hardware is developed for general use in a variety of information management applications.
    [Show full text]