Vsevolod Domkin
Kyiv, Ukraine
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/9781484264270 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-6427-0 e-ISBN 978-1-4842-6428-7
https://doi.org/10.1007/978-1-4842-6428-7
Vsevolod Domkin 2021
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Distributed to the book trade worldwide by Apress Media, LLC, 1 New York Plaza, New York, NY 10004, U.S.A. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
Acknowledgments
Im very thankful to those who helped me in the work on Programming Algorithms in Lisp by providing support, advice, corrections, and suggestions. First of all, many thanks to my wife, Ksenya, who encouraged me to work on it despite the time that was, in part, taken from my family duties. Micha phoe Herda contributed a very thorough and detail-oriented review that helped correct a couple of significant misunderstandings on my part and pushed me to add more code and explanations where they were lacking. He has also championed the idea of a separate repository with all the books code accompanied by a test suite and helped me in this undertaking.
I am very grateful to Dr. Robert Strandh who humbly volunteered his help as an editor of the initial chapters of the book to make it sound more native (as my English is far from perfect since Im not a native speaker) and point out the mistakes that I made. He and his wife, Kathleen, have contributed lots of improvements to more than half of the chapters, and I tried to follow their advice in the subsequent ones. Thanks to Rainer Joswig for commenting on the Lisp choices. Im also grateful to my father, Dr. Volodymyr Demkine, for reviewing and proofing the book. Thanks to @dzenicv on reddit who posted links to almost all of the chapters there, which triggered some helpful discussions. Thanks to @tom_mellior on Hacker News for pointing a serious deficiency in the explanation of Union-Find. Thanks to all those people who shared the links to the chapters and contributed their comments and attention.
Vsevolod Domkin 2021
V. Domkin Programming Algorithms in Lisp https://doi.org/10.1007/978-1-4842-6428-7_1
1. Introduction
This book started after teaching an intensive course on algorithms to working programmers in Kyiv, in spring 2016. It took more than 3 years to complete, and, meanwhile, I also did three iterations of the course. Its aim is to systematically explain how to write efficient programs and, also, the approaches and tools for determining why the program isnt efficient enough. In the process, it will teach you some Lisp and show in action the technics of algorithmic development. And, even if you wont program in Lisp afterward, youll still be able to utilize the same approaches and tools or be inclined to ask why they arent available in your language of choice from its authors. :)
Why Algorithms Matter
In our industry, currently, there seems to prevail a certain misunderstanding of the importance of algorithms for the working programmer. Theres often a disconnect between the algorithmic questions posed at the job interviews and the everyday essence of the same job. Thats why opinions are voiced that you, actually, dont have to know CS to be successful in the software developers job. Thats true. You dont, but youd better do if you want to be in the notorious top 10% programmers. For several reasons. One is that, actually, you can find room for algorithms almost at every corner of your workprovided you are aware of their existence. To put it simply, the fact that you dont know a more efficient or elegant solution to a particular programming problem doesnt make your code less crappy. The current trend in software development is that, although the hardware becomes more performant, the software becomes slower faster. There are two reasons for that, in my humble opinion:
Most of the application programmers dont know the inner workings of the underlying platforms. And the number of platform layers keeps increasing.
Most of the programmers also dont know enough algorithms and algorithmic development technics to squeeze the most from their code. And often this means a loss of one or more orders of magnitude of performance.
In the book, Ill address, primarily, the second issue but will also try to touch on the first whenever possible.
Besides, learning the art of solving difficult algorithmic problems trains the brain and makes it more apt to solving various other problems, in the course of your day-to-day work.
Finally, you will be speaking the same lingua franca as other advanced programmersthe tongue that transcends the mundane differences of particular programming languages. And youll gain a more detached view of those differences, freeing your mind from the dictate of a particular set of choices exhibiting in any one of them.