ebook img

Seven more languages in seven weeks PDF

312 Pages·2014·5.823 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 more languages in seven weeks

Early praise for Seven More Languages in Seven Weeks I’m tired of learning new programming languages and thought seven additional somewhat esoteric languages wouldn’t be very useful. I couldn’t have been more wrong. I loved it. The languages were suitably interesting and compellingly pre- sented, and I now want to experiment with them. ➤ Brian Sletten President, Bosatsu Consulting, Inc. Languages are not just new syntax, they are new ways of thinking about problems. What is the best way to think about user interfaces or scientific computing or distributed systems or safety guarantees? As you dive into each of the languages in this book you will get a glimpse of new abstractions and principles that will help you write better programs in any language. Do it! ➤ Evan Czaplicki Creator of Elm, Prezi If you think reading a book about programming languages won’t change your thinking about programming, I dare you to read the chapter on Idris—unless the idea of reasoning about your C++ (or C# or Java) code more clearly and reducing hundreds or thousands of lines of code down to two is not appealing to you, of course. ➤ Ted Neward Author, speaker, mentor, Neward and Associates, LLC Just as an artist’s choice of oil, acrylic, or watercolor paint constrains the range of effects they can achieve, the languages we choose constrain the programs we can write. Learning a new language enables you to both conceive new solutions and express them in new ways. Read this book to add seven particularly interesting languages to your repertoire. ➤ Paul Butcher Author of Seven Concurrency Models in Seven Weeks Seven More Languages in Seven Weeks is a well-paced introduction to a set of fascinating languages that will be new to many. This one goes at just the right tempo and provides enough detail to be useful—but not so much as to douse natural curiosity. Definitely a book I would recommend to others wanting to expand their programming horizons. ➤ Matthew Wild Author, Prosody IM XMPP server Seven More Languages in Seven Weeks not only introduces us to a wide spectrum of languages, but also challenges us on how we think about language use and design. Software development is a demanding career and learning new languages will always be essential. That is why the Seven in Seven series is one of the most invaluable reads for any serious programmer. ➤ Daniel Hinojosa Developer, speaker, instructor, author of Testing in Scala Seven More Languages in Seven Weeks Languages That Are Shaping the Future Bruce A. Tate Fred Daoud Ian Dees Jack Moffitt The Pragmatic Bookshelf Dallas, Texas • Raleigh, North Carolina Many of the designations used by manufacturers and sellers to distinguish their products 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, PragProg and the linking g device are trade- marks of The Pragmatic Programmers, LLC. Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein. 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 Pragmatic titles, please visit us at https://pragprog.com. The team that produced this book includes: Jacquelyn Carter (editor) Potomac Indexing, LLC (index) Liz Welch (copyedit) Dave Thomas (layout) Janet Furlow (producer) Ellie Callahan (support) For international rights, please contact [email protected]. Copyright © 2014 The Pragmatic Programmers, LLC. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher. Printed in the United States of America. ISBN-13: 978-1-941222-15-7 Encoded using the finest acid-free high-entropy binary digits. Book version: P2.0—November 2015 Contents Foreword . . . . . . . . . . . . . vii Acknowledgments . . . . . . . . . . . ix Introduction . . . . . . . . . . . . . xv 1. Lua . . . . . . . . . . . . . . . 1 Day 1: The Call to Adventure 2 Day 2: Tables All the Way Down 14 Day 3: Lua and the World 32 Wrapping Up Lua 47 2. Factor . . . . . . . . . . . . . . 49 Day 1: Stack On, Stack Off 50 Day 2: Painting the Fence 61 Day 3: Balancing on a Boat 73 Wrapping Up Factor 86 3. Elm . . . . . . . . . . . . . . . 89 Day 1: Handling the Basics 90 Day 2: Taming Callbacks 100 Day 3: It’s All a Game 111 Wrapping Up Elm 123 4. Elixir . . . . . . . . . . . . . . 125 Day 1: Laying a Great Foundation 126 Day 2: Controlling Mutations 142 Day 3: Spawning and Respawning 158 Wrapping Up Elixir 167 5. Julia . . . . . . . . . . . . . . 171 Day 1: Resistance Is Futile 172 Day 2: Getting Assimilated 183 Contents • vi Day 3: Become One with Julia 195 Wrapping Up Julia 206 6. miniKanren . . . . . . . . . . . . 209 Day 1: Unified Theories of Code 210 Day 2: Mixing the Logical and Functional 220 Day 3: Writing Stories with Logic 228 Wrapping Up miniKanren 240 7. Idris . . . . . . . . . . . . . . 243 Day 1: The Basics 244 Day 2: Getting Started With Dependent Types 253 Day 3: Dependent Types in Action 262 Wrapping Up Idris 274 8. Wrapping Up . . . . . . . . . . . . 277 The Origins 277 The Central Expressway 279 The Frontier 281 The Dirty Map 282 A Final Challenge 284 Bibliography . . . . . . . . . . . . 285 Index . . . . . . . . . . . . . . 287 Foreword Back in 2010, I was deeply troubled. The growing list of difficulties in writing concurrent software was nagging at me. The tools I had at hand were clunky, and none of them provided a mental model that helped me reason about the problems I was facing. I decided it was time for a change. However, out of the hundreds of programming languages out there, how could I possibly find one that fit my criteria? How could I even filter this huge set into a smaller one that I could explore in more detail? Then I found that someone had decided to tell the exact story I wanted to hear: Bruce Tate had just written Seven Languages in Seven Weeks, which explored Ruby, Io, Prolog, Erlang, Scala, Clojure, and Haskell. I was familiar with many of the languages in Seven Languages in Seven Weeks but the book did more than just introduce programming language constructs. It introduced their philosophy, community, and thinking models. To me, the book was telling a story about concurrency, and as I read the book, a very clear picture about immutability, threads, futures, actors, software transac- tional memory, and more was being painted. Once I finished the book, I knew exactly which languages and paradigms I wanted to explore next. I bought a heap of books about Erlang, Clojure, and Haskell and I also started writing code right away. Months later, though, I still hadn’t found one language that fit all my criteria. I wanted the robustness and distribution of the Erlang VM, but I also wanted the metaprogramming and polymorphism from Clojure alongside a syntax I was comfortable with. That’s when I decided to create the Elixir programming language that runs on the Erlang virtual machine. Now, four years later, Elixir is one of the languages covered in Seven More Languages in Seven Weeks. report erratum • discuss Foreword • viii The interesting thing is that the first book was not a story about concurrency but that’s how I read it. Seven Languages in Seven Weeks, as any other excellent book, gives space for the reader to include her own experiences as part of the story, allowing each reader to learn different lessons and, in this particular case, choose other languages to explore next. This is what makes Seven More Languages in Seven Weeks even more ambi- tious. Many of the languages in the book are relatively new and in active development, which brings a whole new range of ideas and lessons to be learned. It also opens up the possibility for readers to pick their next languages and not only master them but become part of the language development itself. Seven Languages in Seven Weeks had a deep impact on my programming career, and I am certain reading this book will do the same for yours. And remember: Reading Seven More Languages in Seven Weeks is just the start of a journey. José Valim Creator of Elixir report erratum • discuss

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.