Digital Library

Go for Java Programmers, Second Edition Learn Googles Go Programming Language (Barry A. Feigenbaum) (z-library.sk, 1lib.sk, z-lib.sk)

Barry A. Feigenbaum

Go for Java Programmers, Second Edition Learn Googles Go Programming Language (Barry A. Feigenbaum) (z-library.sk, 1lib.sk, z-lib.sk)

Author Barry A. Feigenbaum

java

Overview • Pioneers as the first book for learning and using Go for Java programmers • Teaches Go to Java coders using their existing knowledge, allowing them to be more competent in Go much faster • Provides steps to become competent with Go so you can improve your ability to compete for Go-based projects About this Book Get an in-depth introduction to the Go programming language and its associated standard runtime libraries. This book is tailored for Java programmers to utilize their existing knowledge to learn Go. You will get a deep understanding of the Go language and obtain a good introduction to the extensive Go standard libraries. The Second Edition is updated for new and enhanced APIs in both Java and Go, including revised discussions on modules and Go generics. Through clear descriptions of Go features, contrasted with similar Java features and new extensive code examples, you will possess enough knowledge of Go's libraries to begin doing effective programming in the language. Go for Java Programmers is structured more like a tutorial than a reference document. It covers key features of Go, but not every little detail as a reference might. Its goal is to get you competent enough in Go and its runtime that you can begin to effectively write Go programs. What You Will Learn • Examine the key Go Runtime libraries and how they compare to Java libraries • See when it is appropriate to use the Go language instead of the Java language • Read and understand programs written in Go • Write many programs in Go • Determine when Go is an appropriate language to develop applications in • Discover how the Go and Java languages and development experience compare and contrast Who This Book Is For Primarily existing professional Java programmers or students that already know something about Java. A basic understanding of Java is expected. Some basic programming experience with imperative languages is expected.

Format PDF
Size 5.2 MB
11
Views
0
Downloads
0.00
Total Donations
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
Go for Java Programmers Learn Google’s Go Programming Language — Second Edition — Barry A. Feigenbaum
Page 2
Go for Java Programmers Learn Google’s Go Programming Language Second Edition Barry A. Feigenbaum
Page 3
Go for Java Programmers: Learn Google’s Go Programming Language, Second Edition ISBN-13 (pbk): 979-8-8688-1906-3 ISBN-13 (electronic): 979-8-8688-1907-0 https://doi.org/10.1007/979-8-8688-1907-0 Copyright © 2025 by Barry A. Feigenbaum 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. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Melissa Duffy Coordinating Editor: Gryffin Winkler Copy Editor: Kezia Endsley Cover designed by eStudioCalamar Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza, New York, NY 10004. 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 Delaware LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail booktranslations@springernature.com; for reprint, paperback, or audio rights, please e-mail bookpermissions@springernature.com. Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub (https://github.com/Apress). For more detailed information, please visit https://www.apress.com/gp/services/source-code. If disposing of this product, please recycle the paper Barry A. Feigenbaum Cedar Park, TX, USA
Page 4
This second edition to Go for Java Programmers covers the recent changes to the Go language and its standard libraries. In particular, it covers the addition of Go Generic user-defined types. This text also contrasts the various Go additions with the recent additions to the Java language and runtime. This revision was created after I retired as a professional software developer. My retirement was strongly motivated by my wife’s illness. Unfortunately, she died from it in June 2024. I miss her immensely.
Page 5
v Table of Contents About the Author xiii About the Technical Reviewer xv Introduction xvii Hello to Go xxxiii Part I: First Look at Go 1 Chapter 1: A Brief Look at Go vs Java 3 Go Is a Compiled (vs. Interpreted, As Java Is) Language .............................................................. 4 Go and Java Share a Similar Program Structure .......................................................................... 5 Go and Java Have Some Code Style Differences That Influence How Code Is Structured ............ 5 Go and Java Are Both Procedural Languages ............................................................................... 7 Java Is an Object-Oriented (OO) Language, While Go Is Not Fully OO ........................................... 7 Java Is a Highly Functional Language, Go Is Less So .................................................................... 8 Java Is a Highly Declarative Language, Go Is Less So .................................................................. 8 Many Java Features Are Annotation Driven .................................................................................. 9 Go Does Not Support Exceptions .................................................................................................. 9 Both Java and Go Use Managed Memory (Garbage Collectors) .................................................. 10 Go and Java Both Support Concurrency but in Different Ways ................................................... 10 Go’s Runtime Is Simpler Than the JRE ........................................................................................ 11 The Go Program Build Process Is Different ................................................................................. 12 Go and Java Have Similar Release Cycles .................................................................................. 12 Chapter 2: What Java Has That Go Does Not 15 Multiple Assignments .................................................................................................................. 15 Statements and Operators .......................................................................................................... 16 Assert Statement ........................................................................................................................ 16
Page 6
vi While and Do Statements ............................................................................................................ 17 Throw Statement/Throws Clause ................................................................................................ 17 Strictfp, transient, volatile, synchronized, abstract, and static.................................................... 17 Objects and Classes (OOP), Inner Classes, Lambdas, this, super, and Explicit Constructors ...... 17 Generic Types and Methods ........................................................................................................ 20 Extensive Functional Programming Capabilities ......................................................................... 21 Boxing of Primitive Values........................................................................................................... 21 Source Annotations ..................................................................................................................... 22 Multiple Visibilities ...................................................................................................................... 22 Overloaded/Overridden Functions ............................................................................................... 23 Formal Enums ............................................................................................................................. 23 Record Classes ........................................................................................................................... 24 Built-in Binary Data Self-Serialization ........................................................................................ 24 Concurrent Collections ................................................................................................................ 25 Chapter 3: A Deeper Comparison of Go and Java 27 Part II: The Go Language 33 Chapter 4: Key Go Aspects 35 Simple Go Program Example ...................................................................................................... 38 Go Packages ............................................................................................................................... 43 Go Comments .............................................................................................................................. 46 Go Build/Run Process .................................................................................................................. 47 Go Playground ....................................................................................................................... 48 Go Integrated Development Environments ............................................................................ 54 Running Go Programs ............................................................................................................ 59 Building Go Programs ............................................................................................................ 60 Bytecode vs. Real Code ......................................................................................................... 63 Go Command-Line Tools ............................................................................................................. 65 Tools Bundled in the Go Command ........................................................................................ 66 Other Tools ............................................................................................................................. 68 Table of ConTenTs
Page 7
vii Go Runs Programs Instead of Classes ........................................................................................ 69 Go Memory Management ............................................................................................................ 71 Go Identifiers ............................................................................................................................... 76 Go Scopes ................................................................................................................................... 77 Go Scopes vs. Go Source Files .............................................................................................. 81 Initializing Go Variables ............................................................................................................... 83 Lifetimes of Go Identifiers ........................................................................................................... 86 Go Module Summary ................................................................................................................... 87 Go Assignments and Expressions ............................................................................................... 93 Text Formatting in Go .................................................................................................................. 95 Goroutines ................................................................................................................................. 100 Issues with Concurrency ..................................................................................................... 100 Go Concurrency ................................................................................................................... 102 Goroutines by Example ........................................................................................................ 106 Chapter 5: Go Basic Features 119 Language Keywords .................................................................................................................. 119 Operators and Punctuation ....................................................................................................... 123 Go Operator Precedence ........................................................................................................... 127 Go Built-in Functions ................................................................................................................. 128 Chapter 6: Go Types 131 Primitive/Built-in Types ............................................................................................................. 131 Numbers .............................................................................................................................. 132 Characters and Strings ........................................................................................................ 133 Reference vs. Pointer Types ................................................................................................ 134 Drill Down on Basic Data Types ........................................................................................... 137 Methods as Functions ......................................................................................................... 159 Any Declared Type Can Have Custom Functions ................................................................. 161 Functions as Values ............................................................................................................. 162 Structure Fields ................................................................................................................... 169 Structure Literals ................................................................................................................. 172 Table of ConTenTs
Page 8
viii Nested Structures ................................................................................................................ 173 Structure Field Alignment .................................................................................................... 175 Application of Interfaces ...................................................................................................... 178 Composite Interfaces ........................................................................................................... 181 Variable Declarations ................................................................................................................ 187 Constant Declarations ............................................................................................................... 189 Type Casting .............................................................................................................................. 191 Type Testing .............................................................................................................................. 193 Derived Type Declarations ......................................................................................................... 195 Chapter 7: Errors and Panics 199 Go Errors ................................................................................................................................... 199 Go Panics .................................................................................................................................. 201 Errors and Panics Illustrated ..................................................................................................... 205 Chapter 8: Go Statements 213 Type Statement ......................................................................................................................... 214 Package and Import Statements ............................................................................................... 215 Assignment Statements ............................................................................................................ 217 Declaring Variables ................................................................................................................... 218 Declaring Named Constants...................................................................................................... 220 If/Else Statements ..................................................................................................................... 222 Switch Statement ..................................................................................................................... 225 While Statement ........................................................................................................................ 228 Do-While Statement .................................................................................................................. 229 For with Index Statement .......................................................................................................... 230 For Over a Collection Statement ............................................................................................... 231 Forever Statement .................................................................................................................... 234 Break and Continue Statements ............................................................................................... 234 Goto Statement ......................................................................................................................... 235 Return Statement ...................................................................................................................... 236 Defer Statement ........................................................................................................................ 237 Table of ConTenTs
Page 9
ix Go Statement ............................................................................................................................ 239 Select Statement ...................................................................................................................... 239 Chapter 9: Applications for Interfaces 241 An Interface Is the Key .............................................................................................................. 241 On Dependency Injection .......................................................................................................... 244 On Aspect-Oriented Programming ............................................................................................ 252 Chapter 10: Go Unit Tests and Benchmarks 257 Test Cases and Benchmarks in Go ............................................................................................ 258 Test Cases in Java ..................................................................................................................... 270 Chapter 11: Go Generic Types and Functions and Example Programs 277 Go Generics ............................................................................................................................... 277 Enhanced Iteration .................................................................................................................... 286 A Generic Example .................................................................................................................... 287 Generics in the Go Playground .................................................................................................. 289 Generic Related Libraries .......................................................................................................... 289 Go vs. Java Sample Programs .................................................................................................. 295 Hello World .......................................................................................................................... 300 Sleep ................................................................................................................................... 301 Generic Index ....................................................................................................................... 301 Clear Screen ........................................................................................................................ 302 Http Server .......................................................................................................................... 303 Tree Comparison .................................................................................................................. 304 Fibonacci Numbers .............................................................................................................. 308 Peano Numbers ................................................................................................................... 309 Concurrent PI ....................................................................................................................... 311 Peg Solitare ......................................................................................................................... 313 Display Image ...................................................................................................................... 318 Generate Primes Concurrently ............................................................................................. 320 Game of Life ........................................................................................................................ 322 Table of ConTenTs
Page 10
x Part III: Go Library Survey 329 Chapter 12: Key Package Comparison 331 Java Lang Packages ................................................................................................................. 331 Interface Summary .............................................................................................................. 331 Class Summary ................................................................................................................... 332 System Class ............................................................................................................................ 334 Static Field Summary .......................................................................................................... 334 Method Summary ................................................................................................................ 334 The Runtime Class ............................................................................................................... 336 Java IO Package ........................................................................................................................ 337 Interface Summary .............................................................................................................. 337 Class Summary ................................................................................................................... 337 Java Text Package ..................................................................................................................... 340 Interface Summary .............................................................................................................. 340 Class Summary ................................................................................................................... 340 Java Time Packages ................................................................................................................. 341 Interface Summary .............................................................................................................. 341 Class Summary ................................................................................................................... 342 Java Util Packages .................................................................................................................... 343 Interface Summary .............................................................................................................. 343 Class Summary ................................................................................................................... 344 Class Summary ................................................................................................................... 347 Chapter 13: Key Method/Function Comparison 351 Chapter 14: Go Package Survey 359 File Access with Go ................................................................................................................... 359 Compression Services .............................................................................................................. 362 Archive Packages ................................................................................................................ 362 Compression Packages ....................................................................................................... 366 Image Package .................................................................................................................... 367 Format Package .................................................................................................................. 369 Table of ConTenTs
Page 11
xi Data Collections ........................................................................................................................ 372 Sorting Package ........................................................................................................................ 375 Input/Output (I/O) Package ........................................................................................................ 377 Context Package ....................................................................................................................... 383 Cryptography, Hashing, and Data Encoding .............................................................................. 387 Unique Package ........................................................................................................................ 389 Bytes Package .......................................................................................................................... 389 Encoding Packages ................................................................................................................... 393 Unicode Encoding Packages ............................................................................................... 396 Chapter 15: SQL Database Access 399 Database Access Example ........................................................................................................ 404 List of SQL Drivers .................................................................................................................... 410 Chapter 16: Client and Server Support 415 MIME Packages ......................................................................................................................... 415 Network Packages .................................................................................................................... 415 The Net Package ................................................................................................................. 416 The HTTP Template Package ..................................................................................................... 428 The Net.HTTP Package .............................................................................................................. 433 URL Package ............................................................................................................................. 444 Chapter 17: Go Runtime 447 Errors Package .......................................................................................................................... 447 Flag Package............................................................................................................................. 449 Log Package.............................................................................................................................. 454 Math Package ........................................................................................................................... 460 Rand Package ........................................................................................................................... 475 Operating System Support Packages........................................................................................ 478 Regular Expression Package ............................................................................................... 487 Go Runtime Packages ............................................................................................................... 490 Weak Pointer Package .............................................................................................................. 491 Table of ConTenTs
Page 12
xii Version Package........................................................................................................................ 492 Coverage Package .................................................................................................................... 492 String Processing Packages ..................................................................................................... 492 Concurrency and Goroutines ..................................................................................................... 499 Reflection Package ................................................................................................................... 503 Testing Package ........................................................................................................................ 504 Time and Date Package ............................................................................................................ 511 Unsafe Package ........................................................................................................................ 517 Appendix A: Installing Go 521 Appendix B: Some Go FAQs 535 Appendix C: Go Gotchas to Look Out For 543 Appendix D: Mark-Sweep Pseudocode 549 Appendix E: ASCII vs UTF-8 553 Appendix F: Go Playground Examples 557 Appendix G: Java Examples Source 577 Index 603 Table of ConTenTs
Page 13
xiii About the Author Barry A. Feigenbaum, Ph.D., now retired, has decades of professional software engineering experience. During his career, he has worked for major industry-leading companies, such as IBM and Amazon, and most recently at Dell, where he was a senior principal software engineer. He has worked on mainframe and midrange servers and many applications for personal computers. He has developed software products, such as assemblers for multiple hardware architectures, in many key industry languages, including various assemblers, FORTRAN, PL/I, C/C++/C#, Python, JavaScript, Java, and most recently Go. He has extensive experience in the full software development lifecycle. Most recently, he was a lead on teams developing mission-critical microservices, most often written in Go and C++, that operate in large, clustered environments, often managed by Kubernetes. He led the early development of the LAN support inside Microsoft Windows. He defined the SMB protocol that is the basis for both the CIFS (Windows) and the SAMBA (UNIX and Linux) technologies. He has served as a software tester, developer, and designer as well as a development team lead, architect, and manager on multiple occasions. He was a key contributor as a developer, architect, and manager to several releases of PC-DOS (also MS-DOS) and OS/2. In these roles, he worked extensively with Microsoft on joint requirements, design, and implementation. Dr. Feigenbaum has a Ph.D. in computer engineering with a concentration in object-oriented (OO) software design and bachelor and master's degrees in electrical engineering. He has published multiple articles in technical magazines and juried journals. He coauthored several books on IBM PC-DOS. He has spoken at numerous technical conferences, such as JavaOne. He served on industry standard bodies and taught multiple college-level courses on data structures, software engineering, and distributed software as an adjunct professor at several universities. He has over 20 issued U.S. patents. He is widowed, has one son, and lives in Cedar Park, TX.
Page 14
xv Ronald Petty, M.B.A., M.S., is the founder of Minimum Distance LLC, a management consulting firm based in San Francisco. He spends his time helping technology-based startups do the right thing. He is also an instructor at UC Berkeley Extension. About the Technical Reviewer
Page 15
xvii Introduction Since the first edition of this book, the balance of web applications (especially for servers) has become even more container based. While Java can run in containers, Go is arguably optimized for them. Also, Go usage has spread beyond its core roles of server-side and tool development. In the author's opinion, this makes Go (vs. Java) an even more compelling use case. The benefits of using Go over Java are discussed in this section and throughout this text. Go itself has also evolved since the first edition. A major addition/change to the language was the addition of programmer defined generics. Generics allow for functions and types to have associated type parameters. These parameters allow the code to be adapted (by the compiler vs. repeated by the coder) for different types. This is a major enhancement to the language ,as it can significantly reduce code duplication. There are several other, smaller enhancements to the language that improve its useability and performance. The Go runtime types and the standard tooling have also both been enhanced. Since its debut in the mid-1990s, Java has enjoyed huge success. Arguably more so than other languages, Java is a major player in the web application space and key data processing areas such as Big Data tools, among others. Among other aspects, Java’s high level of portability across operating systems and hardware architectures, its rich and improving language and library of functions, as well as its good performance contributed to this success. But Java comes with some drawbacks. Java was created at a time when object- oriented programming1 was the norm and network delivery of code was advantageous. The resulting Java runtime footprint is quite large, and it is resource intensive. The Java developers are trying to address this to some degree with the use of Java modules along with standard library sub-setting and the Graal2 virtual machine, but typical Java code, for the same functionality, often uses more resources than typical Go code does. 1 https://en.wikipedia.org/wiki/Object-oriented_programming 2 https://www.graalvm.org/java/
Page 16
xviii As time is passing, the Java language and runtime is no longer an optimal fit for many modern applications, especially cloud-based ones. Also, the Java language is continuously growing and can be a challenge to fully master. Go is deliberately a simple language, and thus is easy to master. The Go language and runtime is relatively new and designed to meet the needs of modern cloud computing systems and other system3 programming tasks. It is considered by many to be a “better C than C” and thus a potential replacement for the C4 programming language, the language it most closely resembles. Go is also likely to take over a large fraction of the Java server and application space. Thus, it is the raison d'etre for this book. Many new applications and reengineering of existing applications are now being developed in Go. For applications previously written in Java, Kotlin,5 or Scala6 JVM (all available as Java Virtual Machine–based languages) might be the more expected language to use, but often Go is winning out over them. Go is a very adaptable language. Go usage is widespread (and growing) and crosses many domains. Some examples of modern applications using Go are listed here.7 Go usage can be found in multiple disciplines and industries. For example, here are some companies8 that are using Go in various industries (not an exhaustive list): • Project management: Timesheets • Live-streaming: Twitch • Streaming: Netflix • File-sharing: Dropbox • Financial: PayPal • Banking: Monzo 3 Oriented to operating the computer system rather than achieving business tasks. 4 https://en.wikipedia.org/wiki/C_(programming_language) 5 https://kotlinlang.org/ 6 https://www.scala-lang.org/ 7 https://www.miquido.com/blog/top-golang-apps-best-apps-made-with-golang/ 8 https://www.miquido.com/blog/top-golang-apps-best-apps-made-with-golang/ InTroduCTIon
Page 17
xix • eCommerce: Allegro • Ridesharing: Uber • Music: SoundCloud • Dating: Badoo Go is particularly good for applications or services in these important (sometimes overlapping) areas: • Containerized functions • Any type of web API using many protocols, such as GraphQL, gRPC, and REST • Web-site building • Cryptocurrency • Command-line applications and tools • Development operations (DevOps) • Web Assembly (WASM) support • High-performance and scalable database implementations • Virtually any server-side service Go programs can span from small command-line programs to large, often distributed, servers. Some examples (again not exhaustive) of significant programs across multiple domains include:9 • https://github.com/minio/minio : S3-compatible storage system • https://github.com/docker/docker: Container builder, runner, and manager • https://github.com/prometheus/prometheus: Monitoring system and time series database • https://github.com/nsqio/nsq: Distributed messaging platform 9 https://blog.kowalczyk.info/article/9afe3485f2204f1bb43217d70f7b87d4/big-projects- written-in-go.html InTroduCTIon
Page 18
xx • https://github.com/influxdata/influxdb: Scalable datastore for real-time analytics, metrics, or events • https://github.com/cockroachdb/cockroach: A SQL-like database • https://github.com/kubernetes/kubernetes: Container scheduling and management • https://github.com/coreos/etcd: Distributed key-value store • https://github.com/juju/juju: Orchestration engine • https://github.com/hashicorp/nomad: Workload orchestrator • https://github.com/hashicorp/terraform: Infrastructure automation • https://github.com/gogits/gogs: Git hosting similar to GitHub • https://github.com/mholt/caddy: Web server • https://github.com/golang/go : Go compiler • https://github.com/harness/gitness : Provides source control management, continuous integration, and continuous delivery • https://github.com/grafana/grafana : Observability and data visualization platform • https://github.com/etcd-io/bbolt : Embedded key/value database • https://github.com/dgraph-io/dgraph : Graph database • https://github.com/pingcap/tidb : Distributed database • https://github.com/blevesearch/bleve : Text/numeric/ geo-spatial/vector indexing library • https://github.com/Shopify/go-lua : Lua in Go • https://github.com/robertkrimen/otto : JavaScript interpreter • https://github.com/gopherjs/gopherjs : Transpiler from Go to JavaScript • https://github.com/bosun-monitor/bosun : Time series framework InTroduCTIon
Page 19
xxi Many teams are redeveloping/reengineering applications in Go. As an example of a redo (vs. original development) into Go, Khan Academy10 used Go to reengineer11 its previous Python site implementation. This often happens because Go exhibits many of the ease-of-use features common to scripting languages with the efficiency of compiled languages. The original Go lead designers, Robert Griesemer,12 Rob Pike,13 and Ken Thompson,14 all at Google, wanted to define a language and associated runtime with these key features (some also provided by Java): • High developer productivity: Go offers a consumable and reasonably complete runtime, especially for tools and servers. It also offers a one-stop shopping toolchain. It has widespread community support. • High readability and developer usability: The language itself is small, so it is easy to learn, and its code is both easy to read and understand (vs. easiest/fastest to write). It has a targeted ease of use comparable to non-statically typed languages like Python. Often, the language is opinionated (sort of take it or leave it). • Garbage collection: Go uses memory garbage collection (GC), which reduces programmer effort and makes for more reliable programs. • Statically linked: Go is statically linked (vs. dynamically linked, as Java is); this makes it easier to manage deployment and execution of Go programs. • Static typing: Generally supports safer, more performant, and more predictable programs; this helps with high reliability and long duration execution critical for servers. 10 https://www.khanacademy.org/ 11 https://blog.khanacademy.org/half-a-million-lines-of-go/ 12 https://en.wikipedia.org/wiki/Robert_Griesemer 13 https://en.wikipedia.org/wiki/Rob_Pike 14 https://en.wikipedia.org/wiki/Ken_Thompson InTroduCTIon
Page 20
xxii • Runtime efficiency: The code efficiently uses the processors it runs on, comparable to what is achievable in C/C++15 applications. • High network performance: Distributed/cloud use cases are now common, and the code needs to be performant for them. For the same level of function, Go is often less resource intensive than Java typically is; this helps with reducing resource footprint and improving scale in modern cloud distributions. • High utilization of multi-processor systems: The code needs to allow easy and safe exploitation of multi-processor (core) systems that have become the norm. Go excels at this. Its support for Goroutines (vs. operating system threads) and channels allows for easy (relative to Java) and large-scale use of parallel processing. Robert Pike summarized16 this as follows: … we wanted a language with the safety and performance of statically compiled languages such as C++ and Java, but the lightness and fun of dynamically typed interpreted languages such as Python. It was also important that the result be suitable for large systems software development on modern, networked, multicore hardware. The Go Brand Book17(GBB) states: Go is an open-source programming language that enables the production of simple, efficient and reliable software at scale. The GBB further states that Go has these benefits for new programmers: • Developer productivity of a dynamic language with the speed, safety, and reliability of a static language • Easy to learn and readable • Has a vibrant, welcoming community, spanning open-source developers, startups, large companies, and universities • The language for the cloud 15 https://en.wikipedia.org/wiki/C%2B%2B 16 https://www.red-gate.com/simple-talk/opinion/geek-of-the-week/ rob-pike-geek-of-the-week/ 17 https://storage.googleapis.com/golang-assets/Go-brand-book-v1.9.5.pdf InTroduCTIon
The above is a preview of the first 20 pages. Register to read the complete e-book.

Support Author

0.00
Total Amount (¥)
0
Donation Count
Please enter an amount Minimum ¥1

You will be redirected to Alipay to complete payment, then return here.

Recommended for You

Loading recommended books...
Failed to load, please try again later
Back to List