Programming: A Primer
Coding for Beginners
ICP Primers in Electronics and Computer Science (ICPPECS)
ISSN: 2054-4537
Series Editor: Mark S. Nixon (University of Southampton, UK)
Published
Vol. 1 | Digital Electronics: A Primer Introductory Logic Circuit Design by Mark S. Nixon |
Vol. 2 | Programming: A Primer Coding for Beginners by Tom Bell |
Programming: A Primer
Coding for Beginners
Tom Bell
University of Southampton, UK
Published by
Imperial College Press
57 Shelton Street
Covent Garden
London WC2H 9HE
Distributed by
World Scientific Publishing Co. Pte. Ltd.
5 Toh Tuck Link, Singapore 596224
USA office: 27 Warren Street, Suite 401-402, Hackensack, NJ 07601
UK office: 57 Shelton Street, Covent Garden, London WC2H 9HE
Library of Congress Cataloging-in-Publication Data
Bell, Tom (Electronic engineer)
Programming : a primer coding for beginners / by Tom Bell (University of Southampton, UK).
pages cm -- (ICP primers in electronics and computer science)
Includes bibliographical references and index.
ISBN 978-1-78326-706-4 (alk. paper) ISBN 978-1-78326-707-1 (alk. paper)
1. Computer programming. 2. MicrocomputersProgramming. I. Title.
QA76.6.B4367 2015
005.1dc23
2015011283
British Library Cataloguing-in-Publication Data
A catalogue record for this book is available from the British Library.
Copyright 2016 by Imperial College Press
All rights reserved. This book, or parts thereof, may not be reproduced in any form or by any means, electronic or mechanical, including photocopying, recording or any information storage and retrieval system now known or to be invented, without written permission from the Publisher.
For photocopying of material in this volume, please pay a copying fee through the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, USA. In this case permission to photocopy is not required from the publisher.
In-house Editors: Thomas Stottor/Dipasri Sardar
Typeset by Stallion Press
Email:
Printed in Singapore
Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young.
Henry Ford
Founder of Ford Motoring Company
To my friends and family
Acknowledgements
Many thanks to all the people who have helped me write this book. First, to Jasmine Brown and James Sharkey who have spent countless hours before publication reading drafts and refining them. They have given their time and effort to proofreading this book, and their kindness is hugely appreciated.
Secondly, to Jenna Watt, Hollie James, James Patterson, Gareth Clarridge and my father Steve Bell who have supported me in filtering the content for clarity and helpfulness, and their contributions are much appreciated.
Thirdly, to my parents, who have taught me to value work highly and to help others in what I do. My family have been incredible examples to me of people who serve each other and the local community through practical love and hospitality.
Finally, to my friends at Christ Church Southampton who supported me throughout the many months I spent writing. They encouraged me to work diligently and have been a joy to know, love and grow with over the past few years.
Contents
Read Me First
Over the past few decades, computers have radically changed the way we run our lives. They have affected the availability of information, our methods of communication with friends and family, education, business, healthcare and our study of the universe. With the availability of technology and the immense power at the fingertips of anyone who can use it, programming literacy has become one of the most sought-after skills on the planet.
Only recently has computer science become a core aspect of the school curriculum. This is great news for children and young people, but what about those whove already finished those stages in life? What about those whove missed the boat? To the vast majority of us who fall into this category, its our task to begin the journey of gaining a functional understanding of programming, while acquiring the confidence and commitment to put our ideas into code.
I still remember how I began my journey. A few simple searches on Google during my time at high school, such as How to program, How do I become an iOS developer? or How to be Mark Zuckerberg. It was the same place that it starts for many programmers, and its a legitimate place to start. Search for Learning to code in C and youll find some well-written online tutorials, or for Which programming language should I learn first? and youll find some critical and interesting articles comparing JavaScript with Python as a starting point. This form of learning is great for answering those specific questions you have as a beginner, but it lacks something essential it wont teach you the broader context or the technical framework into which findings from your own learning will fit. If you pick up a hefty 500-page textbook on Python for beginners, it will teach you Python, but it wont make you an agile programmer, able to adapt quickly to solve new problems.
An alternative to this self-study approach is to undertake some kind of formal education in programming. Study Computer Science at degree level, or go to college to study Software Development. These can be fantastic courses, and I greatly valued my time at university, but this option is not available to many of us. With jobs, families, and/or financial constraints it can be impossible to spend three years learning to code. Or maybe youre at university already, but you chose a different degree and are already half way through a course in Geography or Fine Arts. Besides, a degree isnt by any means necessary for equipping you to solve the vast majority of programming challenges out there in fact, youre free and able to do it yourself, just as you are.
Programming: A Primer addresses this situation. In writing this book, my goal is to inspire you, and to help you harness your urge to invent, to build and to circulate your own ideas, through teaching you the fundamental concepts behind modern programming. I want to help you understand the powerful tools at your disposal, and to offer you a glimpse at the vast ocean of possibilities for changing the world for the better though programming. My assumption, therefore, is that your approach is practical, not academic and that you actually want yourself or others to benefit in some way from what youll able to do. So if youre approaching coding with a cut out the nonsense and tell me only what I need to know outlook, youve got the right book.
This is primarily an introduction to the fundamental concepts in computer programming and not a step-by-step tutorial for simply learning a particular programming language. As such there wont be detailed instructions on what to do in order to get your development environment set up on a range of platforms, nor will there be a comprehensive coverage of all the features of the relevant programming languages. On the contrary, this book is a journey from alienation to familiarity with the ideas behind programming. Youll be introduced to the basic concepts of various programming languages, so that you can go away and learn a few for yourself with ease. Youll find out about what the different languages are used for, and how to write powerful programs quickly. Languages for designing powerful websites will be introduced. Database languages, and a selection of popular algorithms will be explained. In later chapters, well take a look at where technology is heading, and how developers can benefit.
Next page