ebook img

Seven languages in seven weeks : a pragmatic guide to learning programming languages PDF

336 Pages·6.86 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Seven languages in seven weeks : a pragmatic guide to learning programming languages

What Readers Are Saying About Seven Languages in Seven Weeks Knowing multiple paradigms greatly influences our design abilities, so I’m always on the lookout for good books that’ll help me learn them. This book nicely brings prominent paradigms together. Bruce has experience learning and using multiple languages. Now you can gain from his experience through this book. I highly recommend it. Dr. Venkat Subramaniam Award-winning author and founder, Agile Developer, Inc. As a programmer, the importance of being exposed to new program- ming languages, paradigms, and techniques cannot be overstated. This book does a marvelous job of introducing seven important and diverse languages in a concise—but nontrivial—manner, revealing their strengths and reasons for being. This book is akin to a dim-sum buffet for any programmer who is interested in exploring new horizons or evaluating emerging languages before committing to studying one in particular. Antonio Cangiano Software engineer and technical evangelist, IBM Fasten your seat belts, because you are in for a fast-paced journey. This book is packed with programming-language-learning action. Bruce puts it all on the line, and the result is an engaging, reward- ing book that passionate programmers will thoroughly enjoy. If you love learning new languages, if you want to challenge your mind, if you want to take your programming skills to the next level—this book is for you. You will not be disappointed. Frederic Daoud Author, Stripes...andJavaWebDevelopmentIsFunAgain and Getting StartedwithApacheClick Do you want seven kick starts into learning your “language of the year”? Do you want your thinking challenged about programming in general? Look no further than this book. I personally was taken back in time to my undergraduate computer science days, coasting through my programming languages survey course. The difference is that Bruce won’t let you coast through this course! This isn’t a leisurely read—you’ll have to work this book. I believe you’ll find it both mind- blowing and intensely practical at the same time. Matt Stine Group leader, Research Application Development at St. Jude Children’s Research Hospital I spent most of my time as a computer sciences student saying I didn’t want to be a software developer and then became one anyway. Seven LanguagesinSevenWeeks expanded my way of thinking about prob- lems and reminded me what I love about programming. Travis Kaspar Software engineer, Northrop Grumman I have been programming for 25 years in a variety of hardware and software languages. After reading SevenLanguagesinSevenWeeks, I am starting to understand how to evaluate languages for their objec- tive strengths and weaknesses. More importantly, I feel as if I could pick one of them to actually get some work done. Chris Kappler Senior scientist, Raytheon BBN Technologies Seven Languages in Seven Weeks A Pragmatic Guide to Learning Programming Languages Bruce A. Tate The Pragmatic Bookshelf Raleigh,NorthCarolina Dallas,Texas Many of the designations used by manufacturers and sellers to distinguish their prod- uctsareclaimedastrademarks.Wherethosedesignationsappearinthisbook,andThe 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 PragmaticProgrammer,PragmaticProgramming,PragmaticBookshelfandthelinkingg devicearetrademarksofThePragmaticProgrammers,LLC. Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibilityfor errorsor omissions, or for damages that may result from theuseofinformation(includingprogramlistings)containedherein. Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatictitles,pleasevisitusathttp://www.pragprog.com. Theteamthatproducedthisbookincludes: Editor: JackieCarter Indexing: PotomacIndexing,LLC Copyedit: KimWimpsett Layout: StevePeter Production: JanetFurlow Customersupport: EllieCallahan International: JulietBenda Copyright©2010PragmaticProgrammers,LLC. Allrightsreserved. Nopartofthispublicationmaybereproduced,storedinaretrievalsystem,ortransmit- ted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise,withoutthepriorconsentofthepublisher. PrintedintheUnitedStatesofAmerica. ISBN-10:1-934356-59-X ISBN-13:978-1-934356-59-3 Printedonacid-freepaper. P1.0printing,October2010 Version:2010-10-28 Contents Dedication 9 Acknowledgments 11 Foreword 14 1 Introduction 17 1.1 Method to the Madness . . . . . . . . . . . . . . . . . . 17 1.2 The Languages . . . . . . . . . . . . . . . . . . . . . . . 19 1.3 Buy This Book . . . . . . . . . . . . . . . . . . . . . . . . 21 1.4 Don’t Buy This Book . . . . . . . . . . . . . . . . . . . . 22 1.5 A Final Charge. . . . . . . . . . . . . . . . . . . . . . . . 24 2 Ruby 25 2.1 Quick History . . . . . . . . . . . . . . . . . . . . . . . . 26 2.2 Day 1: Finding a Nanny . . . . . . . . . . . . . . . . . . 28 2.3 Day 2: Floating Down from the Sky . . . . . . . . . . . 35 2.4 Day 3: Serious Change . . . . . . . . . . . . . . . . . . . 48 2.5 Wrapping Up Ruby . . . . . . . . . . . . . . . . . . . . . 56 3 Io 60 3.1 Introducing Io . . . . . . . . . . . . . . . . . . . . . . . . 60 3.2 Day 1: Skipping School, Hanging Out . . . . . . . . . . 61 3.3 Day 2: The Sausage King . . . . . . . . . . . . . . . . . 74 3.4 Day 3: The Parade and Other Strange Places . . . . . . 83 3.5 Wrapping Up Io . . . . . . . . . . . . . . . . . . . . . . . 92 4 Prolog 95 4.1 About Prolog . . . . . . . . . . . . . . . . . . . . . . . . . 96 4.2 Day 1: An Excellent Driver . . . . . . . . . . . . . . . . . 97 4.3 Day 2: Fifteen Minutes to Wapner . . . . . . . . . . . . 109 4.4 Day 3: Blowing Up Vegas. . . . . . . . . . . . . . . . . . 120 4.5 Wrapping Up Prolog. . . . . . . . . . . . . . . . . . . . . 132 CONTENTS 8 5 Scala 135 5.1 About Scala . . . . . . . . . . . . . . . . . . . . . . . . . 135 5.2 Day 1: The Castle on the Hill . . . . . . . . . . . . . . . 139 5.3 Day 2: Clipping Bushes and Other New Tricks . . . . . 153 5.4 Day 3: Cutting Through the Fluff . . . . . . . . . . . . . 167 5.5 Wrapping Up Scala . . . . . . . . . . . . . . . . . . . . . 176 6 Erlang 181 6.1 Introducing Erlang . . . . . . . . . . . . . . . . . . . . . 181 6.2 Day 1: Appearing Human . . . . . . . . . . . . . . . . . 185 6.3 Day 2: Changing Forms . . . . . . . . . . . . . . . . . . 195 6.4 Day 3: The Red Pill . . . . . . . . . . . . . . . . . . . . . 207 6.5 Wrapping Up Erlang . . . . . . . . . . . . . . . . . . . . 219 7 Clojure 223 7.1 Introducing Clojure . . . . . . . . . . . . . . . . . . . . . 224 7.2 Day 1: Training Luke . . . . . . . . . . . . . . . . . . . . 225 7.3 Day 2: Yoda and the Force . . . . . . . . . . . . . . . . . 243 7.4 Day 3: An Eye for Evil . . . . . . . . . . . . . . . . . . . 256 7.5 Wrapping Up Clojure . . . . . . . . . . . . . . . . . . . . 264 8 Haskell 268 8.1 Introducing Haskell . . . . . . . . . . . . . . . . . . . . . 268 8.2 Day 1: Logical . . . . . . . . . . . . . . . . . . . . . . . . 269 8.3 Day 2: Spock’s Great Strength . . . . . . . . . . . . . . 285 8.4 Day 3: The Mind Meld . . . . . . . . . . . . . . . . . . . 294 8.5 Wrapping Up Haskell . . . . . . . . . . . . . . . . . . . . 309 9 Wrap-Up 313 9.1 Programming Models . . . . . . . . . . . . . . . . . . . . 313 9.2 Concurrency . . . . . . . . . . . . . . . . . . . . . . . . . 317 9.3 Programming Constructs . . . . . . . . . . . . . . . . . 319 9.4 Finding Your Voice . . . . . . . . . . . . . . . . . . . . . 321 A Bibliography 322 Index 323 Reporterratum thiscopyis(P1.0printing,October2010) Dedication The five months from December 2009 through April 2010 were among themostdifficultofmylife.Mybrother,notyet47yearsold,hademer- gency bypass surgery. No one had any clue that anything was wrong at all. (He came through the surgery without further incident and is doing well.) In late March, my sister was diagnosed with breast cancer. ThebiggestshockofallcameinearlyMarch.Mymotherwasdiagnosed with terminal cancer. A few short weeks later, she was gone. As you would expect, I am left to struggle with the grief of a jarring and unexpected loss because of a brutally efficient disease. I would not be human otherwise. But strangely, this experience has not been an entirely negative one. You see, my mother was at peace with the remarkable life she lived, her relationships with her family were strong and fulfilling, and she was exactly where she wanted to be with her faith. Lynda Lyle Tate put her creative energy into painting with watercolors. She shared her art primarily through her Madison Avenue Art Gallery and her classes. Before I left home, I had the opportunity to take a few lessons from her. For someone from a technical profession, the experi- ence was always a little disorienting. I would visualize the masterpiece on my blank canvas. As the actual image took shape, it drifted further and further from my original vision. When I despaired that things were beyond my ability to fix, Mom looked over my shoulder and told me what she saw. After a few flicks of her talented wrist added darks to accentuate depth and highlights to add clarity and detail, I would real- ize thatI hadnotbeentoo far astrayatall. It justtooka giftedtouchto bring back my creation from the brink of disaster. Then, I would throw my excited arms up in victory and tell everyone in the class about this thingIhadcreated,notyetrealizingthateachmemberoftheclasswas going through their own private burst of joy. DEDICATION 10 After a little while, I learned that Mom was working on another canvas as well. Through her church and through her profession, she’d find broken people. Encountering a lost spouse here or a troubled marriage there,mymotherwouldbringthemintoclasswhereshewouldusethe paint and paper to slightly open a door that had been slammed shut. As we spent our last week together, person after person would come throughherroomdevastatedatthethoughtoflosingtheirteacher,but Mom would tell the perfect joke or offer the right word of kindness, comforting those who came to comfort her. I got to meet the human canvaseswhohadbeenputrightbythemasterandgoneontodogreat things. It was a humbling experience. When I told my mother that I would dedicate this book to her, she said that she would like that, but she had nothing to do with com- puters. That is true enough. The very thought of Windows would leave her helpless. But Mom, you have had everything to do with me. Your well-timed words of encouragement inspired me, your love of creativity shaped me, and your enthusiasm and love of life guide me even now. As I think about these experiences, I can’t help but feel a little better and a little stronger because I, too, am a canvas shaped by the master. This book is dedicated with love to Lynda Lyle Tate, 1936–2010. Reporterratum thiscopyis(P1.0printing,October2010)

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.