0% found this document useful (0 votes)
1 views

Go For Java Programmers Learn The Google Go Programming Language 1st Edition Barry Feigenbaum Phd instant download

The document is about the book 'Go For Java Programmers: Learn the Google Go Programming Language' by Barry Feigenbaum, which aims to teach Java programmers the Go programming language. It includes comparisons between Go and Java, key aspects of Go, and various programming concepts. Additionally, it provides links to other related resources and books for further learning.

Uploaded by

atotcheban
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Go For Java Programmers Learn The Google Go Programming Language 1st Edition Barry Feigenbaum Phd instant download

The document is about the book 'Go For Java Programmers: Learn the Google Go Programming Language' by Barry Feigenbaum, which aims to teach Java programmers the Go programming language. It includes comparisons between Go and Java, key aspects of Go, and various programming concepts. Additionally, it provides links to other related resources and books for further learning.

Uploaded by

atotcheban
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 85

Go For Java Programmers Learn The Google Go

Programming Language 1st Edition Barry


Feigenbaum Phd download

https://ebookbell.com/product/go-for-java-programmers-learn-the-
google-go-programming-language-1st-edition-barry-feigenbaum-
phd-35235816

Explore and download more ebooks at ebookbell.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Go For Java Programmers Learn The Google Go Programming Language 1st


Edition Barry Feigenbaum

https://ebookbell.com/product/go-for-java-programmers-learn-the-
google-go-programming-language-1st-edition-barry-feigenbaum-35192312

Beginning Bazel Building And Testing For Java Go And More 1st Edition
Pj Mcnerney

https://ebookbell.com/product/beginning-bazel-building-and-testing-
for-java-go-and-more-1st-edition-pj-mcnerney-53001846

Grpc Up Running Building Cloud Native Applications With Go And Java


For Docker And Kubernetes Kasun Indrasiri Danesh Kuruppu

https://ebookbell.com/product/grpc-up-running-building-cloud-native-
applications-with-go-and-java-for-docker-and-kubernetes-kasun-
indrasiri-danesh-kuruppu-22077240

Go For Devops Learn How To Use The Go Language To Automate Servers The
Cloud Kubernetes Github Packer And Terraform John Doak David Justice

https://ebookbell.com/product/go-for-devops-learn-how-to-use-the-go-
language-to-automate-servers-the-cloud-kubernetes-github-packer-and-
terraform-john-doak-david-justice-49119422
Go For The Company Carnival Of Mysteries Ander C Lark

https://ebookbell.com/product/go-for-the-company-carnival-of-
mysteries-ander-c-lark-51356722

Go For No Yes Is The Destination No Is How You Get There Fenton

https://ebookbell.com/product/go-for-no-yes-is-the-destination-no-is-
how-you-get-there-fenton-7185910

Go For The Gold Atalanta 1st Edition Kate Mcmullan

https://ebookbell.com/product/go-for-the-gold-atalanta-1st-edition-
kate-mcmullan-58917338

Go For Gold Inspiration To Increase Your Leadership Impact John C


Maxwell

https://ebookbell.com/product/go-for-gold-inspiration-to-increase-
your-leadership-impact-john-c-maxwell-46390882

Go For The Green Jeff Hopper

https://ebookbell.com/product/go-for-the-green-jeff-hopper-48930310
Go for Java
Programmers
Learn the Google Go Programming
Language

Barry Feigenbaum, Ph.D.
Go for Java Programmers
Learn the Google
Go Programming Language

Barry Feigenbaum, Ph.D.


Go for Java Programmers: Learn the Google Go Programming Language

Barry Feigenbaum, Ph.D.


Austin, TX, USA

ISBN-13 (pbk): 978-1-4842-7198-8 ISBN-13 (electronic): 978-1-4842-7199-5 


https://doi.org/10.1007/978-1-4842-7199-5
Copyright © 2022 by Barry 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: Steve Anglin
Development Editor: Matthew Moodie
Coordinating Editor: Mark Powers
Cover designed by eStudioCalamar
Cover image by Ricardo Gomez on Unsplash (www.unsplash.com)
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 [email protected], 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.
For information on translations, please e-mail [email protected]; for reprint,
paperback, or audio rights, please e-mail [email protected].
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 via the book’s product page, located at www.apress.com/9781484271988. For more
detailed information, please visit http://www.apress.com/source-­code.
Printed on acid-free paper
To my wife Martha who sustains me.

Thank you for putting up with all the time


I spent working on this book.

This book was developed during the Covid-19 pandemic.


Many thanks and kudos to all the health-care workers that served so
many that became ill and to the essential workers that keep the country
going during this time of crisis. My heart goes out to the many who lost
friends and loved ones due to Covid-19. May time reduce your pain.
Personally, the stay-at-home nature of this crisis offered me the time
needed to author this book, so in some way is it a, hopefully, positive
by-product of the pandemic.
Table of Contents
About the Author��������������������������������������������������������������������������������������������������� xiii

About the Technical Reviewer���������������������������������������������������������������������������������xv


Acknowledgments�������������������������������������������������������������������������������������������������xvii

Introduction������������������������������������������������������������������������������������������������������������xix

Assessments�������������������������������������������������������������������������������������������������������xxxv

Part I: First Look at Go������������������������������������������������������������������������������������ 1


Chapter 1: A Brief Look at Go vs. Java��������������������������������������������������������������������� 5
Go Is a Compiled (vs. Interpreted, As Java Is) Language�������������������������������������������������������������� 6
Go and Java Share Similar Program Structure����������������������������������������������������������������������������� 7
Go and Java Have Some Code Style Differences That Influence How Code Is Structured������������ 7
Both Go and Java Are Procedural Languages������������������������������������������������������������������������������� 8
Java Is an Object-Oriented (OO) Language, While Go Is Not Fully OO������������������������������������������� 9
Java Is a Highly Functional Language, Go Is Less So������������������������������������������������������������������ 10
Java Is a Highly Declarative Language, Go Is Less So���������������������������������������������������������������� 10
Many Java Features Are Annotation Driven�������������������������������������������������������������������������������� 10
Go Does Not Support Exceptions������������������������������������������������������������������������������������������� 11
Both Java and Go Use Managed Memory (Garbage Collectors)�������������������������������������������������� 11
Go and Java Both Support Concurrency but in Different Ways��������������������������������������������������� 12
Go’s Runtime Is Simpler Than the JRE���������������������������������������������������������������������������������������� 12
The Go Program Build Process Is Different��������������������������������������������������������������������������������� 13
Go and Java Have Similar Release Cycles���������������������������������������������������������������������������������� 13

v
Table of Contents

Chapter 2: What Java Has That Go Does Not���������������������������������������������������������� 15


Multiple Assignments������������������������������������������������������������������������������������������������������������������ 15
Statements and Operators���������������������������������������������������������������������������������������������������������� 15
Assert Statement������������������������������������������������������������������������������������������������������������������������ 16
While and Do Statements������������������������������������������������������������������������������������������������������������ 16
Throw Statement/Throws Clause������������������������������������������������������������������������������������������������ 17
Strictfp, transient, volatile, synchronized, abstract, static���������������������������������������������������������� 17
Objects and Classes (OOP) and Inner Classes, Lambdas, this, super, Explicit Constructors������� 17
Generic Types and Methods�������������������������������������������������������������������������������������������������������� 20
Extensive Functional Programming Capabilities������������������������������������������������������������������������� 20
Boxing of Primitive Values���������������������������������������������������������������������������������������������������������� 21
Source Annotations��������������������������������������������������������������������������������������������������������������������� 21
Multiple Visibilities���������������������������������������������������������������������������������������������������������������������� 22
Overloaded/Overridden Functions����������������������������������������������������������������������������������������������� 22
Formal Enums����������������������������������������������������������������������������������������������������������������������������� 22
Built-in Binary Data Self-Serialization���������������������������������������������������������������������������������������� 23
Concurrent Collections���������������������������������������������������������������������������������������������������������������� 23

Chapter 3: A Deeper Comparison of Go and Java��������������������������������������������������� 25

Part II: The Go Language������������������������������������������������������������������������������� 31


Chapter 4: Key Go Aspects������������������������������������������������������������������������������������� 33
Simple Go Program Example������������������������������������������������������������������������������������������������������ 35
Go Packages������������������������������������������������������������������������������������������������������������������������������� 41
Go Comments������������������������������������������������������������������������������������������������������������������������������ 44
Go Build/Run Process������������������������������������������������������������������������������������������������������������������ 45
Go Playground����������������������������������������������������������������������������������������������������������������������� 46
Go Integrated Development Environments���������������������������������������������������������������������������� 50
Running Go Programs������������������������������������������������������������������������������������������������������������ 55
Building Go Programs������������������������������������������������������������������������������������������������������������ 56
Bytecode vs. Real Code��������������������������������������������������������������������������������������������������������� 59

vi
Table of Contents

Go Command-Line Tools������������������������������������������������������������������������������������������������������������� 61
Tools Bundled in the Go Command���������������������������������������������������������������������������������������� 62
Other Tools����������������������������������������������������������������������������������������������������������������������������� 64
Go Runs Programs Instead of Classes���������������������������������������������������������������������������������������� 64
Go Memory Management������������������������������������������������������������������������������������������������������������ 66
Go Identifiers������������������������������������������������������������������������������������������������������������������������������� 71
Go Scopes����������������������������������������������������������������������������������������������������������������������������������� 73
Go Scopes vs. Go Source Files���������������������������������������������������������������������������������������������� 76
Initializing Go Variables��������������������������������������������������������������������������������������������������������������� 78
Lifetimes of Go Identifiers����������������������������������������������������������������������������������������������������������� 80
Go Module Summary������������������������������������������������������������������������������������������������������������������� 81
Go Assignments and Expressions����������������������������������������������������������������������������������������������� 87
Text Formatting in Go������������������������������������������������������������������������������������������������������������������ 89
Goroutines����������������������������������������������������������������������������������������������������������������������������������� 94
Issues with Concurrency������������������������������������������������������������������������������������������������������� 94
Go Concurrency��������������������������������������������������������������������������������������������������������������������� 97
Goroutines by Example�������������������������������������������������������������������������������������������������������� 100

Chapter 5: Go Basic Features������������������������������������������������������������������������������� 111


Language Keywords������������������������������������������������������������������������������������������������������������������ 111
Operators and Punctuation������������������������������������������������������������������������������������������������������� 114
Go Operator Precedence����������������������������������������������������������������������������������������������������������� 119
Go Built-in Functions����������������������������������������������������������������������������������������������������������������� 120

Chapter 6: Go Types���������������������������������������������������������������������������������������������� 123


Primitive/Built-in Types������������������������������������������������������������������������������������������������������������� 123
Numbers������������������������������������������������������������������������������������������������������������������������������ 123
Characters and Strings�������������������������������������������������������������������������������������������������������� 125
Reference vs. Pointer Types������������������������������������������������������������������������������������������������ 126
Drill Down on Basic Data Types������������������������������������������������������������������������������������������� 129
Methods As Functions��������������������������������������������������������������������������������������������������������� 152
Any Declared Type Can Have Custom Functions����������������������������������������������������������������� 153

vii
Table of Contents

Functions As Values������������������������������������������������������������������������������������������������������������� 155


Structure Fields������������������������������������������������������������������������������������������������������������������� 162
Structure Literals����������������������������������������������������������������������������������������������������������������� 164
Nested Structures���������������������������������������������������������������������������������������������������������������� 165
Structure Field Alignment���������������������������������������������������������������������������������������������������� 167
Application of Interfaces������������������������������������������������������������������������������������������������������ 171
Composite Interfaces����������������������������������������������������������������������������������������������������������� 174
Variable Declarations���������������������������������������������������������������������������������������������������������������� 179
Constant Declarations��������������������������������������������������������������������������������������������������������������� 182
Type Casting������������������������������������������������������������������������������������������������������������������������������ 184
Type Testing������������������������������������������������������������������������������������������������������������������������������ 185
Derived Type Declarations��������������������������������������������������������������������������������������������������������� 188

Chapter 7: Errors and Panics�������������������������������������������������������������������������������� 193


Go Errors����������������������������������������������������������������������������������������������������������������������������������� 193
Go Panics���������������������������������������������������������������������������������������������������������������������������������� 195
Errors and Panics Illustrated����������������������������������������������������������������������������������������������������� 199

Chapter 8: Go Statements������������������������������������������������������������������������������������� 207


Package and Import Statements����������������������������������������������������������������������������������������������� 208
Assignment Statements������������������������������������������������������������������������������������������������������������ 209
Declaring Variables������������������������������������������������������������������������������������������������������������������� 211
Declaring Named Constants����������������������������������������������������������������������������������������������������� 213
If/Else Statements��������������������������������������������������������������������������������������������������������������������� 214
Switch Statement��������������������������������������������������������������������������������������������������������������������� 217
While Statement������������������������������������������������������������������������������������������������������������������������ 220
Do-While Statement������������������������������������������������������������������������������������������������������������������ 221
For with Index Statement���������������������������������������������������������������������������������������������������������� 221
For over a Collection Statement������������������������������������������������������������������������������������������������ 222
Forever Statement�������������������������������������������������������������������������������������������������������������������� 224
Break and Continue Statements����������������������������������������������������������������������������������������������� 225
Goto Statement������������������������������������������������������������������������������������������������������������������������� 226

viii
Table of Contents

Return Statement���������������������������������������������������������������������������������������������������������������������� 227


Defer Statement������������������������������������������������������������������������������������������������������������������������ 228
Go Statement���������������������������������������������������������������������������������������������������������������������������� 229
Select Statement���������������������������������������������������������������������������������������������������������������������� 230

Chapter 9: Applications for Interfaces������������������������������������������������������������������ 233


An Interface Is the Key�������������������������������������������������������������������������������������������������������������� 233
On Dependency Injection���������������������������������������������������������������������������������������������������������� 236
On Aspect-Oriented Programming�������������������������������������������������������������������������������������������� 244

Chapter 10: Go Unit Tests and Benchmarks��������������������������������������������������������� 249


Test Cases and Benchmarks in Go�������������������������������������������������������������������������������������������� 250
Test Cases in Java��������������������������������������������������������������������������������������������������������������������� 262

Chapter 11: Going into the Future������������������������������������������������������������������������� 267


Improved Error Handling����������������������������������������������������������������������������������������������������������� 267
Go Generics������������������������������������������������������������������������������������������������������������������������������� 269
Capstone Game of Life Example����������������������������������������������������������������������������������������������� 275
Game of Life Go Source������������������������������������������������������������������������������������������������������������ 280
Capstone Project in Java����������������������������������������������������������������������������������������������������� 281
Capstone Project in Go�������������������������������������������������������������������������������������������������������� 326
API Outputs������������������������������������������������������������������������������������������������������������������������������� 355
Game Outputs��������������������������������������������������������������������������������������������������������������������������� 359

Part III: Go Library Survey�������������������������������������������������������������������������� 363


Chapter 12: Key Package Comparison������������������������������������������������������������������ 375
Java Lang Packages����������������������������������������������������������������������������������������������������������������� 375
Java IO Package������������������������������������������������������������������������������������������������������������������������ 380
Java Text Package��������������������������������������������������������������������������������������������������������������������� 383
Java Time Packages����������������������������������������������������������������������������������������������������������������� 385
Java Util Packages�������������������������������������������������������������������������������������������������������������������� 386

ix
Table of Contents

Chapter 13: Key Method/Function Comparison���������������������������������������������������� 393

Chapter 14: Go Package Survey��������������������������������������������������������������������������� 399


File Access with Go������������������������������������������������������������������������������������������������������������������� 399
Compression Services�������������������������������������������������������������������������������������������������������������� 402
Archive Packages���������������������������������������������������������������������������������������������������������������� 402
Compression Packages������������������������������������������������������������������������������������������������������� 405
Image���������������������������������������������������������������������������������������������������������������������������������������� 406
Input/Output (I/O)���������������������������������������������������������������������������������������������������������������������� 409
Bytes Package�������������������������������������������������������������������������������������������������������������������������� 415
Format Package������������������������������������������������������������������������������������������������������������������������ 419
Data Collections������������������������������������������������������������������������������������������������������������������������ 421
Sorting�������������������������������������������������������������������������������������������������������������������������������������� 424
Context Package����������������������������������������������������������������������������������������������������������������������� 426
Cryptography and Hashing and Data Encoding������������������������������������������������������������������������� 430
Encoding Packages������������������������������������������������������������������������������������������������������������������� 431
Unicode Encoding Packages����������������������������������������������������������������������������������������������� 433

Chapter 15: SQL Database Access������������������������������������������������������������������������ 437

Chapter 16: Client and Server Support����������������������������������������������������������������� 449


MIME Packages������������������������������������������������������������������������������������������������������������������������� 449
Network Packages�������������������������������������������������������������������������������������������������������������������� 449
The Net Package����������������������������������������������������������������������������������������������������������������������� 450
The HTTP Template Package����������������������������������������������������������������������������������������������������� 462
The Net.HTTP Package�������������������������������������������������������������������������������������������������������������� 467
URL Package����������������������������������������������������������������������������������������������������������������������������� 477

Chapter 17: Go Runtime���������������������������������������������������������������������������������������� 479


Errors Package�������������������������������������������������������������������������������������������������������������������������� 479
Flag Package���������������������������������������������������������������������������������������������������������������������������� 480
Log Package����������������������������������������������������������������������������������������������������������������������������� 485
Math Package��������������������������������������������������������������������������������������������������������������������������� 492

x
Table of Contents

Operating System Support Packages��������������������������������������������������������������������������������������� 507


Reflection Package������������������������������������������������������������������������������������������������������������������� 515
Regular Expression Package����������������������������������������������������������������������������������������������������� 517
Go Runtime Packages��������������������������������������������������������������������������������������������������������������� 519
String Processing Packages����������������������������������������������������������������������������������������������������� 520
Concurrency and Goroutines����������������������������������������������������������������������������������������������������� 525
Testing Package������������������������������������������������������������������������������������������������������������������������ 528
Time and Date Package������������������������������������������������������������������������������������������������������������ 533

Appendix A: Installing Go������������������������������������������������������������������������������������� 541

Appendix B: Some Go FAQs����������������������������������������������������������������������������������� 553

Appendix C: Go Gotchas to Look Out For�������������������������������������������������������������� 561

Appendix D: Mark-Sweep Pseudocode����������������������������������������������������������������� 567

Appendix E: ASCII vs. UTF-8��������������������������������������������������������������������������������� 571

Index��������������������������������������������������������������������������������������������������������������������� 575

xi
About the Author
Barry Feigenbaum, Ph.D., has decades of software engineering experience. During his
career, he has worked for major industry-leading companies, such as IBM and Amazon,
and is currently at Dell where he is 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 such as C/C++/C#, Python, JavaScript,
Java, and now Go. He has extensive experience in the full software development life
cycle. Most recently, he has committed himself to leading teams developing mission-­
critical microservices, most often written in Go, that operate in large clustered
environments.
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 and the SAMBA
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 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 other degrees in Electrical Engineering. He
has published multiple articles in technical magazines and juried journals. He has
coauthored several books on IBM PC-DOS. He has spoken at numerous technical
conferences, such as JavaOne. He has served on industry standard bodies. He has 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 US patents.
He is married, has one son, and lives in Austin, TX.

xiii
About the Technical Reviewer
Ronald Petty, M.B.A., M.S., is 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.

xv
Acknowledgments
To my son Barry, Jr., for his careful review of the drafts of this book. He provided a
perfect example of the book’s target audience: a professional Java programmer wanting
to learn Go.
A hearty thanks to all the other reviewers that made helpful comments, suggested
additional content, and/or made errata corrections: Charles Stein, Divya Khatnar, Rosish
Shakya, and Sharath Hegde.
I especially want to thank Ronald Petty for his thorough technical review of this text.
Also, for his numerous suggested content improvements and code samples, several of
which were included.
I wish to thank Jason Isaacs at Dell who supported me during the creation of this text
and allowed me to go forward with this effort.
To the developers of Go and to the Go community in general, many thanks for
building such a powerful tool. I learned much from the extensive Go documentation and
the many articles, blogs, wikis, tutorials, and books provided by the community.

xvii
Introduction
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 over time 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 subsetting and the Graal2 Virtual Machine, but typical Java code,
for the same functionality, often uses more resources than typical Go code does.
As time is passing, the Java language and runtime is no longer an optimal fit for many
modern, especially cloud-based, applications. Also, the Java language is continuously
growing and can be a challenge to fully master. Go is deliberately a simple, thus easy to
master, language.
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, Kotlin5 or Scala6 JVM

1
https://en.wikipedia.org/wiki/Object-oriented_programming
2
www.graalvm.org/java/
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
www.scala-lang.org/

xix
Introduction

(both available as Java Virtual Machine–based languages) might be the more expected
language to use, but often Go is winning out over them. As an example of a redo into
Go, Khan Academy7 is using Go to reengineer8 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, Rob Pike, and Ken Thompson, 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. It also offers a one-stop shopping
toolchain. It has widespread high 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 nonstatically typed languages like Python. Often, the
language is opinionated (sort of take it or leave it).

• Go uses memory garbage collection (GC) which reduces programmer


effort and makes for more reliable programs.

• 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; helps with high reliability and long duration
execution critical for servers.

• Runtime efficiency – The code efficiently uses the processors it runs


on, comparable to what is achievable in C/C++9 applications.

7
www.khanacademy.org/
8
https://blog.khanacademy.org/half-a-million-lines-of-go/
9
https://en.wikipedia.org/wiki/C%2B%2B

xx
Introduction

• 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.
Robert Pike summarized10 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 impor-
tant that the result be suitable for large systems software development on
modern, networked, multicore hardware.
The Go Brand Book11 (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 & readable
• Has a vibrant, welcoming community, spanning open-source
developers, startups, large companies, and universities
• The language for the Cloud
And these benefits for experienced programmers:
• Solves big engineering problems
• Backed by Google, who understands and supports needs specific to
open source communities and Go
• High demand for Go programmers

10
www.red-gate.com/simple-talk/opinion/geek-of-the-week/rob-pike-geek-of-the-week/
11
https://storage.googleapis.com/golang-assets/Go-brand-book-v1.9.5.pdf
xxi
Introduction

In many ways, Go is a lot like Node.js,12 a popular JavaScript13-based application


development platform. Node.js makes it easy to develop lightweight servers very
quickly and thus is popular as a microservices platform. Node.js and Go have
similar capabilities, history, and community support. Go, because of its type safety
and goroutines (vs. Node.js’s event loop), is likely to be able to provide more
scaled and reliable solutions than Node.js can. In the author’s opinion, Go will also
consume a significant number of the Node.js use cases.

As a result, many applications previously done in Java can instead be implemented


in Go with some advantages, especially in cloud environments.
So, in summary, here are some Go advantages relative to Java:

• Go is a smaller language that is clean, maintainable, and easy to


learn.

• Go is better suited to support multi-core processors and high levels of


concurrency.

• Go has a smaller but strong set of standard libraries, especially for


building servers, that comes bundled with the standard installation.

• Go is well suited to cloud execution, especially in a containerized


environment.

• Go is well suited to any constrained environments where large code


and runtime footprint can be issues.
Go is open source, has an active developer community, and is sponsored by Google;
it will not go away. Future Go evolution will retain backward compatibility;14 this is a Go
community promise. This makes Go a great language for commercial development.
Hackernoon15 says: “Go is on a trajectory to become the next enterprise programming
language.”

12
https://en.wikipedia.org/wiki/Node.js, https://nodejs.org/en/
13
https://en.wikipedia.org/wiki/JavaScript
14
https://golang.org/doc/go1compat
15
https://hackernoon.com/go-is-on-a-trajectory-to-become-the-next-enterprise-
programming-language-3b75d70544e

xxii
Introduction

They further say:

Go — a programming language designed for large-scale software develop-


ment — provides a robust development experience and avoids many issues
that existing programming languages have. These factors make it one of the
most likely candidates to succeed Java as the dominating enterprise soft-
ware platform in the future. … Taken as a whole, they (Go’s design choices)
position Go as an excellent choice for large development projects looking
for a modern programming language beyond Java.
InfoWorld16 says:

Google’s Go programming language has certainly made a name for itself.


Lightweight and quick to compile, Go has stirred significant interest due to
its generous libraries and abstractions that ease the development of concur-
rent and distributed (read: cloud) applications. … But the true measure of
success of any programming language is the projects that developers create
with it. Go has proven itself as a first choice for fast development of network
services, software infrastructure projects, and compact and powerful tools
of all kinds.
Open source projects they mention that use Go include Docker, Kubernetes, Fedora
CoreOS, InfluxDB, Istio, Traefik, Hugo, Terraform, CockroachDB, and Gravitational
Teleport.
Note that Docker and Kubernetes are the foundation technologies for the
containerization of many modern applications. Many organizations depend on them to
be rock solid and performant. This is a testament to the maturity of the Go language and
its runtime.
Brainhub17 list some major companies using Go and the advantages they see:
• Simple code

• Created for large projects

• Easy to learn

• One problem – one solution

• Ease of maintenance

16
www.infoworld.com/article/3442978/10-open-source-projects-proving-the-power-of-
google-go.html
17
https://brainhub.eu/library/companies-using-golang/

xxiii
Introduction

• Similar to C

• Designed for multi-core processors

• Designed for the Internet

• Quick compilation

• Small application size

• Open source model


They mention companies using Go including Google (of course), Uber, Twitch,
Dailymotion, SendGrid, Dropbox, and SoundCloud.
Awesome Open Source18 lists over 15,000 (and growing) projects that use Go.
Sandra Parker19 projects20 Go has a winning future where she emphasizes: “Because
it is made by Google.”
She indicates why it’s currently popular: “Go is different from other languages. It is
young but so powerful that it was able to bring up geek’s engagement from the very start.”
In summary:

• It is convenient, fast, and secure to write code with Golang, and it


provides cross-platform support…

• Google cares about the user.

• Golang has cloud infrastructure.

• Google has money.

And why it is going to get more popular as time passes:


Applications written on Go are highly performant. Golang is very efficient
like C/C++, handling parallelisms like Java, and has easy code readability
like Python, Perl, and Erlang. … This is why many companies migrate to
Golang from other languages. Golang is the future.

18
https://awesomeopensource.com/projects/go
19
www.quora.com/profile/Sandra-Parker-34
20
https://medium.com/@Sandra_Parker/why-golang-is-the-future-part-1-ed7dd4f419d and
https://medium.com/@Sandra_Parker/why-golang-is-the-future-part-2-1f984ae8f1a4

xxiv
Introduction

In 2020, Ziff Davis21 showed that Go is the most desired new language to learn, as
shown in Figure 1.

Programming languages that working professionals would like to learn:

40% Working professionals

32%

30%

25%
24%
21%
20%
20%
18%
16%
15%
15% 14%

10%

5%

0%

Go Python Kotlin Javascript Bash/Shell Typescript Scala R (Rscript)


(Node.js) /PowerShell

Figure 1. Programming languages professionals want to learn

Other sources extol the virtues of Go and indicate it has a growing future. For
example, Towards Data Science22 states these as key features for Go’s success:
1. Go has language-level support for Concurrency. It offers a CSP23
based message-passing concurrency via Goroutine (lightweight
Green thread) and Channel.

21
https://en.wikipedia.org/wiki/Ziff_Davis, www.zdnet.com/article/developers-
say-googles-­go-is-most-sought-after-programming-language-of-2020/, and www.
hackerearth.com/recruit/developer-survey/
22
https://towardsdatascience.com/top-10-in-demand-programming-languages-to-learn-
in-2020-4462eb7d8d3e
23
Communicating sequential processes – https://en.wikipedia.org/wiki/
Communicating_sequential_processes

xxv
Introduction

2. The biggest USP24 of Go is its language design and simplicity. It has


successfully combined the simplicity and productivity of Python
and the power of C.

3. Go has embedded Garbage Collector (albeit not as mature as JVM


garbage collector). Go developers can write system programming
with the safety of Java, Python.

Go is ranked as one of the top five most loved languages by GeeksforGeeks,25 which
describes Go as follows:
Go is a statically typed, open-source programming language designed at
Google that makes programmers more productive and helps to build simple,
reliable, and efficient software very easily. This language … is syntactically
similar to C, but with memory safety, garbage collection, structural typing,
and CSP-style concurrency. Go is well known for its high-performance in
networking and multiprocessing.
They cite these key virtues:

1. Concurrency: provides greater concurrency with the help of


goroutine which makes it extremely easy to implement in a
concurrent system. …

2. Simplicity and Consistency: This language was designed with a


very minimalistic approach and it is well known for its simplicity.
… The standard library and the packages are consistent.

3. Object-oriented: Go is an Object-oriented programming language


and supports the useful features of OOPs. …

4. Tools: Go provides many useful tools for building, testing, and


analyzing code…

5. Compiler: Its compiler is super-fast and easily compiles a large go


program within a few seconds. …

24
Unique selling proposition – https://en.wikipedia.org/wiki/Unique_selling_proposition
25
www.geeksforgeeks.org/top-5-most-loved-programming-languages-in-2020/

xxvi
Introduction

Note that this author disagrees with point 3. In his opinion, Go is object-based,26 not
object-oriented.
The popular TIOBE27 index shows that Go use is growing at a fast rate. A late 2020
survey shows this:

• Current Year Rank: 13

• Previous Year Rank: 20

• Growth Rate: High

Few languages have seen such high year-over-year growth. TIOBE twice named
Go as the “language of the year.” The future need for Go programmers is expected to
continue to grow rapidly.
A look at Go Users28 shows hundreds of organizations, including some of the world’s
largest companies, using Go around the world. This list is likely to omit many actual
users.
Go is used, and in many ways proven effective, in many complex programs. The
Docker29 container system and the Kubernetes30 container orchestrator are prime
examples of industry-leading programs written in Go. Also, the Go compiler, builder,
and most of the standard libraries are written in Go.31 They are an important test case in
themselves.
In 2020, StackOverflow has ranked (https://insights.stackoverflow.com/
survey/2020) the most loved languages. Go is among the top of the top 25 listed well-known
languages, and it ranks higher in that list on the desired (“loved”) scale than Java. Note how
well it compares to Python; this is remarkable for a compiled language.

26
https://en.wikipedia.org/wiki/Object-based_language
27
The Importance of Being Earnest – https://en.wikipedia.org/wiki/TIOBE_index
28
https://github.com/golang/go/wiki/GoUsers
29
www.docker.com/
30
https://kubernetes.io/
31
Originally bootstrapped from a C version of these tools.

xxvii
Introduction

Table 1. Most Loved Languages Survey


Language Loved Percentage (Using and Want
to Continue Using)

Rust 86.1%
TypeScript 67.1%
Python 66.7%
Kotlin 62.9%
Go 62.3%
Julia 62.2%
Dart 62.1%
C# 59.7%
Swift 59.5%
JavaScript 58.3%
SQL 56.6%
Bash/Shell/PowerShell 53.7%
HTML/CSS 53.5%
Scala 53.2%
Haskell 51.7%
R 44.5%
Java 44.1%
C++ 43.4%
Ruby 42.9%
PHP 37.3%
C 33.1%
Assembly 29.4%
Perl 28.6%
Objective-C 23.4%
VBA 19.6%

xxviii
Introduction

All this should make learning to program in Go highly interesting to experienced Java
developers looking to broaden their skills and marketability. In the author’s opinion, Go
will emerge as the go-to language for multi-core computing over networks, especially for
servers.
Of course, for a complete analysis, we need to contrast the mascots of Go and Java.
In the author’s opinion, Go’s mascot is both simpler and cuddlier, as, arguably, is the
language itself.
Figure 2 shows the Go logo and Gopher mascot. 32

Figure 2. Go mascot and logo32

Figure 3 shows the Java mascot (Duke).33

Figure 3. Java mascot33

32
The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/) and is
licensed under the Creative Commons 3.0 Attributions license.
33
https://wiki.openjdk.java.net/display/duke/Main

xxix
Introduction

Gophers, welcome aboard! In this book, we will briefly explore the concepts behind
Go and why it was created. This overview will be followed by an introduction to Go’s
various features and a look at if/how they differ from Java. Then comes a presentation
of most of the Go language statements and data types. This is followed by a brief look
at some potential future Go enhancements. A capstone example Go program is then
presented to unify the Go experience. Next comes a review of the Go standard libraries
as they compare to similar Java libraries. Finally comes a survey of a subset of the various
Go standard libraries as an introduction to their usage. Deeper and more comprehensive
descriptions are available at the Go site.
More precisely, this book’s content is broken down into three parts with several
chapters within each part.
Some background on Go:

• A brief look at Go vs. Java comparing key features of both languages

• Summary of features Java has that Go does not have

A description of the Go language and its key features with a look at using Go in
practice:

• A brief side-by-side comparison of Go features with Java

• A survey of Go key features

• A more detailed view of important Go characteristics (like Go


keywords, etc.)

• A detailed view of Go data types


• A discussion of Go’s error reporting mechanism

• A broader discussion on Go’s interface data type and how it is applied

• A description of each Go statement

• A more detailed discussion on applying Go data types

• A look at testing Go vs. Java programs

• A brief look at possible future Go enhancements

• A capstone program illustrating many Go and Go library features

xxx
Introduction

An introduction to the Go standard libraries in comparison with Java libraries


combined with a survey of key Go standard libraries:

• A discussion of key Java library packages with similar Go packages.

• A brief side-by-side comparison of commonly used Java methods


with similar Go functions.

• A brief discussion of formatting data values in Go.

• A brief discussion of file input/output in Go.

• This part includes chapters covering compression/decompression,


image processing, input/output, cryptography, relational database
access, network access, and Go runtime access.

• It is intended to bring awareness of the various Go libraries and not a


complete understanding of all the available functions.

• This is the largest part of the book.

In addition, there are five appendixes with supplementary information such as how
to install Go, as well as some summary and reference information.

Note In some of the code examples in this book, long source lines are wrapped
into multiple lines. This wrapping may not be allowed in actual Go source.

The source for the capstone programs, as well as for some of the other listing
samples in this book, is available at the book website: www.github.com/apress/
go-­for-java-­programmers.
Before we dive into Go, let us consider why Go exists. Rob Pike summarized34 the
language and why it was created this way:
The Go programming language was conceived in late 2007 as an answer
to some of the problems we were seeing developing software infrastruc-
ture at Google. The computing landscape today is almost unrelated to
the environment in which the languages being used, mostly C++, Java,
and Python, had been created. The problems introduced by multicore

34
https://talks.golang.org/2012/splash.article

xxxi
Introduction

processors, networked systems, massive computation clusters, and


the web programming model were being worked around rather than
addressed head-on. Moreover, the scale has changed: today's server
programs comprise tens of millions of lines of code, are worked on
by hundreds or even thousands of programmers, and are updated
literally every day. To make matters worse, build times, even on large
compilation clusters, have stretched to many minutes, even hours.

Go was designed and developed to make working in this environment


more productive. Besides its better-known aspects such as built-in concur-
rency and garbage collection, Go's design considerations include rigorous
dependency management, the adaptability of software architecture as sys-
tems grow, and robustness across the boundaries between components.
Go is a compiled, concurrent, garbage-collected, statically typed
language developed at Google. It is an open source project: Google imports
the public repository rather than the other way around.
Go is efficient, scalable, and productive. Some programmers find it fun
to work in; others find it unimaginative, even boring. In this article we will
explain why those are not contradictory positions. Go was designed to
address the problems faced in software development at Google, which led
to a language that is not a breakthrough research language but is nonethe-
less an excellent tool for engineering large software projects.
Wikipedia35 defines Go as follows: “Go is a statically typed, compiled programming
language…. Go is syntactically similar to C, but with memory safety, garbage collection,
structural typing, and CSP-style concurrency.”
Wikipedia36 describes Java as follows:
Java is a class-based, object-oriented programming language …. It is a gen-
eral-purpose programming language intended to let application developers
write once, run anywhere (WORA), meaning that compiled Java code can
run on all platforms that support Java without the need for recompilation.
The syntax of Java is similar to C and C++, but has fewer low-level facilities
than either of them. The Java runtime provides dynamic capabilities (such
as reflection and runtime code modification) that are typically not available
in traditional compiled languages.

35
https://en.wikipedia.org/wiki/Go_(programming_language)
36
https://en.wikipedia.org/wiki/Java_(programming_language)

xxxii
Introduction

These descriptions cover some of the key similarities and differences. In the
author’s opinion, the relative brevity of the Go description reflects the relative
simplicity of Go vs. Java.
Go addresses the needs of modern system and application software development in
cloud environments on modern multi-core machines. In the author’s opinion, it meets
these goals very well. As you explore Go more within these pages, you will see its features
and functions and how they match and support the goals stated earlier. By the time you
finish this book, perhaps you will also agree.
Go was not designed to replace (cover all use cases of ) Java. It is more targeted
toward the use cases of the C (and to some extent C++) language. It is primarily a system
programming language well suited toward implementing servers and tools such as
compilers. Java also supports these types of programs.
One of the reasons Go is popular is it is lightweight relative to many other languages.
Go is arguably more lightweight than Java in many areas. This is one of its most attractive
attributes.
Go’s threading model, provided by goroutines and channels, certainly is lighter
weight. Because it lacks Object-Oriented Programming (OOP) features, its data model
and error processing are also more lightweight. Even more lightweight is the set of
standard libraries. Perhaps most critically, Go’s single executable (vs. a JRE and many
JARs) deployments and resulting fast program launching are most attractive.
Go is also arguably easier to master than Java. The language is simpler and has fewer
constructs to learn. The runtime libraries are, while functional, generally more basic and
approachable.
This is not to say that Go is necessarily better than Java (or the reverse), but that
it is often more approachable and easier to master and use. Both languages and their
runtimes will extend over time; Go is more likely to continue its more approachable style.

xxxiii
Assessments
Divya Khatnar: If one knows Java, they will surely enjoy learning Go using this book. The
author makes sure that each topic uses Java as a baseline to explain Go. Not only does this
book teach you Go, but it also sharpens your understanding about Java.
Charles Stein: As Go becomes a staple language, Java users need a clear guide to help
them make the transition. This book thoroughly covers the basics and exciting applications
of Go from a Java-analogous perspective.
Sharath Hedge: This book covers all the comparisons of Java and Go exhaustively.
Also, it covers important packages provided by Go. As a developer if I want to start a
project in Go, this book will offer ready reckoner for the many questions I have. This book
offers examples for the majority of the cases, which helps a lot.

xxxv
PART I

First Look at Go
Welcome, future Gophers! Prepare for a journey of discovery and enrichment.
This is a book to help you learn the Go (aka Golang1) programming language
and many of the Go standard libraries in order to become successful Gophers. This
text assumes no prior knowledge of Go and is oriented for use by experienced Java
programmers. This book is generally organized using a comparison between Java
features and if/how these similar features exist in Go.
This book assumes the reader knows Java already; it is not a Java tutorial. This book
also assumes the reader has basic competence in fundamental programming concepts
and procedural programming techniques.
As it is generally the case for any programming language, it is nearly impossible to
introduce language topics/features in a strictly linear order (all topics fully described
before any are used). Most languages interdepend on their features in such a way as
to make this impossible. Go is no exception; in fact, such interdependence between
features is a key Go design aspect.
This book does not achieve such a perfect topic order. Topics will sometimes be
mentioned before they are fully described. Some background information will be
provided at the point of reference, but it may sometimes be necessary to jump ahead
to scan the more detailed presentations that come later. This ordering can result in
limited repetition of content throughout the book. Limited repetition is also employed
throughout the text to help reinforce key concepts.
Learning by comparison and by example are powerful and effective techniques.
In this book, we will be comparing Go and some of its standard libraries to Java and
some of its standard libraries to teach basic Go programming. The book will often use
examples to illustrate both similarities and differences. This is the major purpose of this
book.

1
As apart from the Go game and other uses. Also, the official website: www.golang.org
Part I First Look at Go

This book will not cover every detail or option of the Go language, but most of its
features are described or at least shown in examples. Certainly, Go will be described
at a useful level of detail. The Go Language Specification can be used to get a full and
complete description. The same goes for many of the standard Go libraries.
Most references and comparisons will be against Java. But, as the Go language and
runtime are targeted strongly to the use cases of the C language and the C standard
library, this book will also compare Go to C at times. Since C++ is a derivative and
superset of C, at times this book may compare Go to C++ as well. In no case will
knowledge of either C or C++ be a prerequisite to use this book effectively. Occasionally,
this book will compare Go to other languages.
While typically what the term “Go” means, Go is more than a language, a set of
runtime libraries, and a set of developer tools. “Go” also represents a community of
users and contributors. Like with Java, the community is a rich source of functions
beyond the standard Go capabilities as well as a vast source of training and support for
Go developers. Many of these extensions are easily accessible via the Go toolchain and
repositories such as GitHub.
Go was first announced in November 2009. Release 1.0 came in September 2012.
Prior to version 1.0, the language and runtime changed often, sometimes incompatibly.
Post 1.0, there is much more stability.
Each release after 1.0 has a goal of complete backward compatibility (all older source
programs continue to compile and run after being rebuilt), but there have been a few
exceptions. The change in the default for GO111MODULE environment option from
auto to on in Go 1.16 is an example. Such version-to-version incompatibilities are rapidly
reducing over time.
As of the date of this book’s publication, Go has had more than a dozen major
(XX of 1.XX) releases and numerous point (yy of 1.XX.yy) releases. Each major release
introduces new tools, language and/or library features, performance improvements, and
often bug fixes. Detailing them in a book is a form of planned obsolescence and thus
will not be done. A detailed summary can be found at https://golang.org/doc/devel/
release.html.
Before we begin learning Go, we will first look at some key features of the Java
language that Go does not provide. On the surface, this may make Go look inferior
compared to Java, but as you go further into the text, the author believes you will see that
this is not the case.

2
Part I First Look at Go

The first part of this text has a few samples of Go code; it is mostly background
information. That will change in the subsequent parts of this text.
Note in the text, especially in the capstone sections, source file names are
mentioned. Often, these names are not the literal operating system file names but may
be shown in different cases. Some operating systems require file names to be entered in
their exact case, and others do not.

3
CHAPTER 1

A Brief Look at
Go vs. Java
There are many obvious and subtle differences between Java and Go. They can be
compared as a language and as a runtime. This survey concentrates mostly on a
language comparison. It is intended to present a broad-stroke comparison. Much deeper
comparisons are done throughout the text.
Some of the text in this chapter might be read as disparaging Go. That is not the
intent. Go is a powerful language, and it can easily hold its own against Java. But Java
does have features Go does not, and they will be summarized later.
Note the descriptions here can require deeper knowledge of Go that has been
presented so far for a full understanding. You may want to revisit this chapter after
becoming more familiar with Go later in this text.
The Go language and its associated runtime have both many similarities and many
differences from the Java language and its associated Java Runtime Environment (JRE).
This chapter will attempt to summarize them at a high level. These similarities and
differences will be discussed in greater detail later in this text.
Both Go and Java are Turing-complete1 environments, which means (almost) any
possible program can be written in either of them. It is just a matter of the relative
development effort expended and the resulting program size and performance.
It should be noted that the Go language and the Go development experience more
closely matches that of C than it does of Java. The style and semantics of the Go language
more closely resemble that of C than Java. The standard Go libraries also more closely
resemble those that come with C.

1
Alan Turing described a universal computing engine, now called a Turing Machine, that can
compute any possible calculation. Any programming language that can be used to author a
Turing Machine is referred to as “Turing Complete.”

5
© Barry Feigenbaum 2022
B. Feigenbaum, Go for Java Programmers, https://doi.org/10.1007/978-1-4842-7199-5_1
Chapter 1 A Brief Look at Go vs. Java

One exception with the comparison to C is that of the Go program building


experience. In C, this is typically driven by the Make2 (or a variant) utility. In Go, it is
driven by the Go builder tool. In the author’s opinion, the Go approach is superior and
easier to use (no make files are needed).
Note some Go developers use make file–like approaches, especially in complex
projects that have more than just Go source files as components and thus need other
artifacts to also be constructed. Make files are often used to script multistep processes
beyond what the Go builder can do. This is similar to using Ant3 or Maven4 in Java.

 o Is a Compiled (vs. Interpreted, As Java Is)


G
Language
Like C and C++, Go programs are completely built before execution begins. All source is
compiled into the machine language of the target computer architecture. Also, all code
is compiled to the target operating system. In contrast, Java is compiled into a virtual
machine language (aka bytecode), and that is interpreted by the Java Virtual Machine
(JVM). For improved performance, that bytecode is often compiled into machine
language dynamically at runtime. The JVM itself is built for a particular operating system
and hardware architecture.
Once built, Go programs require only an operating system to run them. Java
programs require, in addition, that a JRE (of the required version) exist on the computer
before they can be run. Many Java programs may also require additional third-party code
to be present.
The Go approach often results in faster program startup and a more self-contained
program, both of which make it more suitable for containerized deployments.

2
https://en.wikipedia.org/wiki/Make_(software)
3
https://en.wikipedia.org/wiki/Apache_Ant
4
https://en.wikipedia.org/wiki/Apache_Maven

6
Chapter 1 A Brief Look at Go vs. Java

Go and Java Share Similar Program Structure


Both languages support the notion of data structures that contain methods and fields.
In Go, they are called Structs, while in Java they are called Classes. These structures are
collected into groupings called Packages. In both languages, packages can be arranged
hierarchically (i.e., have nested packages).
Java packages contain only type declarations. Go packages can contain base
declarations like variables, constants, functions, as well as derived type declarations.
Both languages access code in different packages by importing it. In Java, imported
types can be optionally used unqualified (String vs. java.lang.String). In Go, all
imported names must always be qualified.

 o and Java Have Some Code Style Differences


G
That Influence How Code Is Structured
• Java declarations put the type first, while in Go the type comes last.
For example:

Java – int x, y z;

Go – var x, y, z int

• Java methods can return only a single value. Go functions can return
many values.

• Java methods and fields must be declared inside the type that they
belong to. Go methods are defined outside the owning type. Go
supports functions and variables that are independent of any type.
Java has no true static shared variables; static fields are just fields of
some class (vs. an instance). Go supports true static (global) variables
that are allocated in the executable image.

• Go has full closures (can capture mutable data), while Java only
supports partial closures (can capture only immutable data). This can
make first-class functions in Go more powerful.

7
Chapter 1 A Brief Look at Go vs. Java

• Go lacks user-defined generic types. Some built-in types


(e.g., slices and maps) are generic. Java supports generic types
of any reference type.

Note there is an approved proposal to add generic types to Go in


the future.

• Java allows type extension of only other types (classes, enums,


and interfaces), while Go can base new types on any existing type,
including primitive types (such as integers and floats) and other user-­
defined types. Go can support methods on any of these custom types.

• Go and Java interfaces work very differently. In Java, a class (or enum)
must explicitly implement an interface if it is used (methods called)
through that interface. In Go, any type can implement an interface
simply by implementing the methods of that interface; no declaration
of intent to implement the interface is needed, it just happens as a
side effect of the methods being present. Many standard (inherited)
behaviors in Java (such as the toString() method) are provided in
Go by a type implementing a common interface (equivalently the
String() method of the Stringer interface).

Both Go and Java Are Procedural Languages


Imperative programs are those that work by explicitly changing state over time and
testing that state. They are a direct reflection of the ubiquitous von Neumann5 computer
architecture. Procedural programs are imperative programs that are composed of
procedures (aka functions in Go and methods in Java). Each language provides the
following key capabilities of procedural languages:

• Can execute an expression, often with an assignment to a variable.

• Can execute a sequence (0+) of statements (often called a


basic block).

• Often also a single statement can implicitly act as a block.

5
https://en.wikipedia.org/wiki/Von_Neumann_architecture

8
Chapter 1 A Brief Look at Go vs. Java

• Can make one-way (if), two-way (if/else), or n-way (if/else if/


else, switch) conditional branches in code flow.

• Can loop over statements.

• Java has while, do, and for statements; Go combines them all into
just for.

• Can define reusable code that can be invoked from


multiple locations.

• Java has methods; Go has functions, some of which are methods.

All6 programs can be written using only these constructs.

J ava Is an Object-Oriented (OO) Language, While


Go Is Not Fully OO
As is true of all OO languages, Java is a class-based language. All code (methods) and
data (fields) are encapsulated in some class implementation. Java classes support
inheritance in that they can extend a super-class (starting at Object). Go allows
composition (a struct can be embedded in another struct) that can often get some of the
code reuse benefits of inheritance, but not all.
Java provides full control over the encapsulation (through visibility: public/
protected/package private/private) of methods and fields. Go does not provide all these
options. Go structs are like classes in how they have fields and can have associated
methods, but they do not support subclassing. Also, Go only supports the equivalent of
public and package private visibilities.
In Java, both classes and interfaces support polymorphic method dispatch. In Go,
only interfaces do polymorphic method dispatch. Go has no equivalent of an abstract
base class. Again, composition can provide a subset of this feature.
Note Java, while generally considered to be OO, is not a perfect example of the OO
style of programming. For example, it has primitive data types. But this text is not about
being critical of Java’s design.

6
https://en.wikipedia.org/wiki/Structured_programming#Elements

9
Chapter 1 A Brief Look at Go vs. Java

Java Is a Highly Functional Language, Go Is Less So


Java, since version 8, has well supported functional programming (FP). FP is
programming with only functions that have local data; no global and mutable state
exists. Java supports the ability to create first-class function literals (called Lambdas)
and pass them to other code to be invoked. Java also allows external (or explicit) looping
(while, for, etc.) to be replaced by internal looping (inside methods). For example, the
Java Streams support provides this.
Go also has first-class function literals, but it lacks similar support for internal
looping; looping is typically external. First-class functions supply lambda-like functions,
often in a superior way. The lack of internal looping is considered a virtue in Go as it
produces more obvious code.
Java FP support strongly depends on generic types. Currently, Go lacks these.

J ava Is a Highly Declarative Language, Go Is


Less So
Through a combination of Annotations and features such as Streams, Java code can
be written in a declarative style. This means the code says what is to be done, but not
explicitly how it is to be done. The runtime converts the declarations into behaviors that
achieve the intended results. Go does not promote an equivalent style of programming;
code must be written to explicitly say how to achieve a behavior. As a result, Go code is
more obvious but sometimes larger and more repetitive than typical Java code is.

Many Java Features Are Annotation Driven


Many Java libraries (especially those called frameworks), such as Spring, make strong use
of Java’s Annotations. The annotations provide metadata, typically consumed at runtime,
to modify the behaviors provided by the libraries. Go does not have annotations, so
this capability is missing. As a result, Go code is often more explicit; this is generally
considered a virtue. Go can use code generation to get similar results to annotations. Go
does have a simple form of annotation, called a tag, that can be used to customize some
library behavior, such as JSON or XML formatting.

10
Chapter 1 A Brief Look at Go vs. Java

The use of annotations can bind configuration decisions to the source code.
Sometimes, this is a disadvantage as the decision needs to be delayed until runtime.
When this is so, Go and Java often use similar approaches (such as command-line or
configuration file parameters).

Go Does Not Support Exceptions


Java has Exceptions (really Throwables which are Exceptions or Errors) that can be raised
to report unusual conditions. Exception usage is widespread in Java and often used to
report both predictable and unpredictable failures. Error returns as values from methods
are rare.
Go makes a stronger separation of these roles. All failures are reported by function
return values that a caller must explicitly test for. This works well because Go functions
can more easily return multiple values, such as a result and an error.
Go has Panics that have a similar role as Java Errors. They are raised much less
frequently. Unlike in Java, panic values are not a hierarchy of types, just a wrapper on
a value of the developer’s choice, but often an instance of the error type. One never
declares the type of a panic value that a function can raise (i.e., there is no equivalent to
Java’s throws clause). This often means less verbose code. Much Java code follows this
pattern by only throwing instances of RuntimeException that do not need to be declared.

 oth Java and Go Use Managed Memory (Garbage


B
Collectors)
Both languages use a stack and a heap to hold data. The stack is mostly used for function
local variables, the heap for other dynamically created data. In Java, all objects are
allocated on the heap. In Go, only data that can be used beyond the lifetime of a function
are allocated on the heap. In both Java and Go, the heap is garbage collected; heap
objects are explicitly allocated by code but are always reclaimed by the garbage collector.
Java has no notion of pointers to an object, only references to objects located in the
heap. Go allows a pointer (or address of ) to any data value to be accessed. In most cases,
Go’s pointers can be used like Java references.
Go’s implementation of garbage collection is simpler than Java’s. Unlike with Java,
there are a few options available to tune it, it just works.

11
Chapter 1 A Brief Look at Go vs. Java

 o and Java Both Support Concurrency


G
but in Different Ways
Java has the notion of Threads, which are paths of execution provided by libraries.
Go has the notion of Goroutines (GRs), which are paths of execution provided by the
language itself. GRs can be looked at as lightweight threads. The Go runtime can support
using many more (many 1000s) GRs than the JRE can support threads.
Java supports synchronization controls in the language. Go has library functions
that are similar. Both Go and Java support the notion of atomic values that can safely be
updated across threads/GRs. Both support explicit locking libraries.
Go offers the notion of Communicating Sequential Processes (CSP) as a major way for
GRs to interact without explicit synchronization and locking. Instead, GRs communicate
over Channels which are effectively pipes (FIFO queues) combined with the select
statement to query them.
There are other differences in concurrency approaches that will be discussed later
in this text. GRs and threads are typically managed in different ways, as is passing state
between them.

Go’s Runtime Is Simpler Than the JRE


Go has a much smaller runtime than that provided by the JRE. There is no JVM
equivalent, but similar components, such as a garbage collection, exist in both. Go has
no bytecode interpreter.
Go has a large set of standard libraries. The Go community provides many more. But
the Java standard and community libraries arguably far exceed the current Go libraries
in both breadth and depth of function. Still the Go libraries are rich enough to develop
many useful applications, especially application servers.
All used libraries (and nothing more) are embedded into the Go executable.
The executable is everything needed to run the program. Java libraries are loaded
dynamically upon first use. This makes Go program binaries (as files) generally larger
than Java binaries (a single “main” class), but when the JVM and all dependent classes
are loaded, the total memory footprint of Java is often larger.

12
Chapter 1 A Brief Look at Go vs. Java

As Java is interpreted, it is possible to dynamically create bytecode and then


execute it. This can be done by writing the bytecode at runtime or dynamically loading
prewritten bytecode (i.e., classes). This brings great flexibility. Go, being prebuilt, cannot
do this.

The Go Program Build Process Is Different


Java programs are an amalgamation of classes, often from multiple sources (vendors),
that are constructed at runtime. This makes Java programs very flexible, especially when
downloaded across a network, a prime Java use case. Go programs are built statically
and in advance of execution. All code is available in the executable image at startup. This
provides greater integrity and predictability at the cost of some flexibility. This makes Go
more suitable for containerized deployments.
Go programs are typically built by the “go builder” which is a tool that combines a
compiler, a dependency manager, a linker, and an executable builder tool, among others.
It is included with the standard Go installation. Java classes are compiled separately
(by the javac tool, provided with a Java Development Kit (JDK)) and are then often
assembled into archives (JAR/WAR) that hold related classes. Programs are loaded
from one or more of these archives. The creation of archives, especially including any
dependencies, is generally done by programs (e.g., Maven) available independently from
the standard JRE.

Go and Java Have Similar Release Cycles


Go has adopted a biannual release cycle7 for 1.xx releases. It is best summarized in
Figure 1-1 (from the Go site).

7
https://github.com/golang/go/wiki/Go-Release-Cycle

13
Chapter 1 A Brief Look at Go vs. Java

Nov-Jan
Development Freeze

RC1 Release
Beta Release Final Release

Dec

Jan
No
v b
Fe
Feb-Apr
Oct Development
Mar
Work

Apr
Aug-Oct Sep
Development
Work g

Ma
Au

y
Jun
Jul
Final Release Beta Release
RC1 Release

May-Jul
Development Freeze

Figure 1-1. Go biannual release cycle

The Go team supports the last two releases.


Java has adopted a similar biannual cycle8 for 1.xx releases. Java has an additional
notion of Long-Term Support (LTS) releases. Non-LTS releases are supported until the
next release (LTS or not) is offered; LTS releases are supported at least until the next LTS
is offered. LTS often come every 18–24 months. Java also has the notion of experimental
features that are released but subject to change (or withdrawal) in future releases; they
provide previews of future support. Go has less of this, but, for example, the generic type
feature is being previewed in a similar way.

8
https://dzone.com/articles/welcoming-the-new-era-of-java

14
CHAPTER 2

What Java Has That


Go Does Not
Java has some features Go does not and vice versa. So, before we look at the Java features
that have some equivalent in Go, let us look briefly at the ones Go does not have. Not
every possible feature Java has that Go does not have can be listed, but some key ones
are summarized in the following.
Note that many of the Go “missing” features were omitted deliberately to keep the
language simple and efficient, not because they were hard to provide. This is considered
a virtue.

M
 ultiple Assignments
Java can assign multiple variables to the same value in a single statement. For example:

int x, y, z;
x = y = z = 10;

The closest Go can do is

var x, y, z int = 10, 10, 10

In Go, the assigned types and values can be different.

S
 tatements and Operators
Go and Java operators have different precedence. Go has fewer, and in the author’s
opinion, more natural precedence levels. When in doubt, use parentheses around an
expression to be sure.

15
© Barry Feigenbaum 2022
B. Feigenbaum, Go for Java Programmers, https://doi.org/10.1007/978-1-4842-7199-5_2
Chapter 2 What Java Has That Go Does Not

A key difference is that in Go x++ (means: x = x + 1) and x-- (means: x = x - 1) are


statements, not operators. And there is no --x or ++x expressions at all.
Go does not support Ternary Expressions. The use of the if/else statement is required.
For example, the Java expression, which gets the larger value

var z = x > y ? x : y;

needs to be something like the following in Go:

var z = y
if x > y {
   z = x
}

which is similar but not the same. You can also do something like this:

var z int
if x > y { z = <some expensive int expression> }
else { z = <some other expensive int expression>}

Note the preceding if/else must be entered on one source line.


Go does not support assignment expressions, only assignment statements.

Assert Statement
Go has no assert statement. Generally, Go has panics which can be used to achieve
a similar function, but they cannot be disabled at compile time like asserts can be.
Because of this, such use of panics is discouraged.

While and Do Statements


The Java while statement is replaced by the Go for statement (i.e., for acts like while).
There is no direct equivalent of the Java do statement, but the for statement can be used
to replace it.
Note that the Java for statement can be used as a while statement too.
For example:

var x = 0; for(; x < 10;) { ... ; x++; }

16
Chapter 2 What Java Has That Go Does Not

is the same as

var x = 0; while(x < 10) { ... ; x++; }

Throw Statement/Throws Clause


Go has no throw statement (or throws clause). The Go panic(...) function serves a
similar role as the throw action.

 trictfp, transient, volatile, synchronized, abstract,


S
static
Go has no equivalent of these Java modifiers. Most are not needed as the issues that
made them necessary in Java are solved in different ways in Go. For example, the
equivalent of a static value is achieved by making the declared value a top-level (aka
package) value.

 bjects and Classes (OOP) and Inner Classes,


O
Lambdas, this, super, Explicit Constructors
Go does not fully support Object-Oriented Programming (OOP) as Java does. As a result,
it does not support these Java constructs. Go has features described later in this text
that can be used similarly to most of these OOP features. As such, Go is better described
as an object-based language. Go does allow one to achieve the key goals of OOP, but in
different ways than a strictly OOP language normally would do them.
Go does not support true Classes (i.e., the Java class declaration). Go does support
Structs which are like classes but without inheritance. Go does allow nested structs,
which are somewhat like inner classes.
Go has no extends or implements clauses on type declarations. Go has no
inheritance as these clauses provide. Go does have an implied form of implements for its
interface types.

17
Chapter 2 What Java Has That Go Does Not

Go does not support Java Lambdas (function signatures compiled into class
instances). Instead, Go supports first-class functions (often literals) that may be passed as
parameters. Go does not support Method References (simple names for lambdas passed
as parameters).
Go supports interfaces in a different way than Java. Go’s interfaces allow Duck Typing.
Go’s interfaces do not require that they be implemented explicitly (no implements clause
is needed in Go); any type that has methods that match all the methods of the interface
implicitly implements the interface. In general, Go’s approach is more flexible.
Java 8 and beyond allows implemented (concrete) methods in interfaces. Go does
not. Java allows constants to be declared in interfaces; Go does not. Java allows subtypes
to be declared in interfaces. Go does not.
Consider these tenants of OOP:

1. An object has an identity (it can be distinguished from all other


objects).

2. An object may (typically does) have state (aka instance data,


properties, or fields).

3. An object may (typically does) have behavior (aka member


functions or methods).

4. An object is described/defined by a template, called a class.

5. Classes can be arranged in an (inheritance) hierarchy; instances


are compositions of the classes in the hierarchy.

6. Object instances are encapsulated; the state is typically visible


only through methods.

7. Variables can be declared at any level in the class hierarchy;


instances of subclasses can be assigned to these variables
(polymorphism).

Java supports (but not necessarily enforces) all the preceding tenants. Go does not.
Go supports these tenants as follows:

1. A struct instance has an address, which can generally serve as its


identity (but may not always be distinct); a struct instance is like
but not identical to an object instance.

2. A struct instance may (typically does) have state.

18
Chapter 2 What Java Has That Go Does Not

3. A struct instance may (often does) have behavior.

4. Like a class, a struct instance is described/defined by a template,


called a struct type.

5. Not directly supported; structs can embed other structs offering


similar composition.

6. Supported but often not used (struct fields are very often public).

7. Not supported.

Historically, OOP languages grew out of computer simulation1 and a desire to


improve man/machine interactions.2 OOP languages were conceived to implement
message passing between simulated objects to effect behavior. As the improved behavior
reuse possibilities (i.e., inheritance) of OOP became well known, it grew in popularity as
a style of programming. Most modern languages provide this capability.
To many, Go’s lack of full OOP is probably its greatest shortcoming. But the author
expects that once you get used to doing idiomatic Go programming, you will not miss the
OOP features as much as you would first think. Go is a well-designed and functionally
rich language with characteristics that make it support the goals of OOP without
including all the complex OOP characteristics of other languages, such as Java.
Please consider that OOP is not required to write good programs. All the existing
C programs, some large and rich, such as operating systems3 and web browsers, prove
otherwise. In fact, at times OOP thinking can force inappropriate structure on a program.
Again, Go is a C-like language.
OOP is not required to achieve high levels of reuse. Functions can fill that role well,
especially if they are first class as they are in Go.

1
https://en.wikipedia.org/wiki/Simula
2
https://en.wikipedia.org/wiki/Smalltalk; Smalltalk introduced the Graphical User
interface (GUI).
3
www.toptal.com/c/after-all-these-years-the-world-is-still-powered-by-c-programming

19
Chapter 2 What Java Has That Go Does Not

Generic Types and Methods


Go currently does not support Generic types and methods on arbitrary types. Here,
generic means being able to hold/use multiple types. In Java, a variable of the Object
type is generic in that it can hold a value of any reference type. In Go, a variable of the
interface{} type is generic in that it can hold a value of any type.
Java 5 refined this concept in that a declared type (say a container class) can be
specified to support only specific (vs. all) types (say just strings or numbers) as a
modifier on a container type, for example, a List<String> (vs. just List) type. Go’s built-­
in collection types (slices, maps, and channels) are generic in this way.
Originally, Java did not support type-specific Generic types. They were introduced
in Java 5, mostly to ease certain usability issues with collections that existed in the
language. Java’s generic design has some undesirable characteristics/compromises
forced on it by backward compatibility.
Currently, there is an approved proposal for adding Generics to Go for much the
same reasons as it was added to Java. It looks like Go will follow in Java’s footsteps here.
Generic types as Java (and Go) defines them are mostly syntactic sugar to remove
repetitive coding. In Java, they do not impact the runtime code at all (because of runtime
type erasure). In Go, they may cause more binary code to exist in an executable, but not
any more than if manually emulated.

Extensive Functional Programming Capabilities


Go does support first-class functions but not the typical generalized utility functions
(map, reduce, select, exclude, forEach, find, etc.) that most functional (strongly
supports the Functional Programming paradigm) languages and Java (via its Lambdas
and Streams support) provide. This omission was a deliberate decision by the Go
language designers. Go will likely add some of these utility functions when generics
are included.

20
Chapter 2 What Java Has That Go Does Not

Boxing of Primitive Values


Java collections (arrays excepted) cannot contain primitive values, only Objects. So, Java
provides wrapper types for each primitive type. To make collections easier to use, Java
will automatically wrap (box) a primitive into a wrapper type to insert it into a collection
and unwrap (unbox) that value when taking it from a collection. Go supports collections
that can hold primitives, so such boxing is not needed. Note the need to use boxing is an
area where Java is less efficient at memory use than Go is.

S
 ource Annotations
Go has no Annotations. Go Struct fields can have tags, which serve a similar but much
more limited role.
Annotations, along with function streams and lambdas, make Java (at least partially)
a declarative language.4 Go is almost purely an imperative language.5 This is by choice.
This tends to make Go code both more obvious and more verbose.
Note Go has a similar concept to Java compile-time annotations where a source
file can include special comments (called build constraints) that the builder interprets
to change how code is processed. For example, the target operating system to generate
code for can be specified by a comment like this at the very start of a source file:

// +build linux,386

that will cause the file to only build for the Linux operating system (OS) and 386-based
architectures.
There is an alternate (and generally preferred) syntax; the previous comment can
also be written as

//go:build linux,386

Note some constraints, such as the target OS and/or hardware architecture, can be
embedded in the Go file names. For example

xxx_windows.go

will only be built for a Windows OS.

4
https://en.wikipedia.org/wiki/Declarative_programming
5
https://en.wikipedia.org/wiki/Imperative_programming

21
Discovering Diverse Content Through
Random Scribd Documents
puissant auprès de ses femmes, même si tu le déclares menteur et
lâche, tu dois employer le mot noble.
—Tu m'enseigneras donc les mots nobles,» répondit l'étranger
avec douceur. Haamanihi réfléchit, le temps de pagayer trois ou
quatre fois; puis, sentant éveillé le bon vouloir de l'autre, il songeait
à lui glisser une habile requête, à propos de ce mousquet... Mais on
accostait le navire. Le chef étranger monta rapidement. La pirogue
Arc-en-ciel louvoyait avec méfiance à quelques longueurs. On lui fit
signe, elle vint ranger le flanc élevé: le grand Arii s'apprêtait à bondir
vers le ciel, quand un bruit étonnant l'étourdit. Il retomba sur le
balancier, stupéfait comme le manant frappé d'un coup de massue. Il
se tenait tout prêt à sauter à l'eau, à fuir. La personne sacrée
soufflait de peur.
Haamanihi le rassura, en criant que c'était là salut de bienvenue
des étrangers vers le grand Arii:—«Ils disent que dans leurs îles on
s'adresse de la sorte aux grands chefs, par la voix des gros
mousquets.
—Bien! Bien!» reprit Pomaré. La crainte envolée, il s'enorgueillit
d'être traité, par les arrivants, comme un maître en leur pays.
Néanmoins il observa qu'un salut de ce genre—un seul—lui serait
satisfaisant. Puis il monta pesamment à bord.
La troupe curieuse se répandait partout. On admira vivement que
les profondeurs du navire pussent contenir tant de choses et tant
d'hommes.—Mais, où donc se cachaient les femmes étrangères?
Elles n'apparurent que de loin, se distinguant aisément de leurs tané
par les vêtements d'abord, leurs chevelures et leur maigreur.
Immobile et grave, Pomaré considérait tous ces gens avec
indifférence. Le chef étranger lui offrit de descendre dans le creux du
bateau. L'Arii ne parut point y mettre de hâte. Il se refusait, sans
doute, à courber sa tête sous des planches assemblées... Mais son
épouse, par un autre passage, l'avait précédé. Il entendait ses rires
et ses paroles satisfaites, et se résolut à la rejoindre.
Pour fêter la présence de Pomaré, les étrangers répandaient avec
largesse cette boisson qui brûle et rend joyeux. Eux-mêmes
prétendaient s'abstenir. Peut-être en réservaient-ils l'usage à leurs
rites solennels et secrets. Haamanihi n'ignorait point les merveilleux
effets qu'on pouvait attendre de ce áva, plus rude et plus âcre que
tous les áva maori; et il supplia pour en obtenir encore:
—«J'ai besoin de courage!» affirmait-il, «de beaucoup de
courage: j'ai deux, hommes à tuer pour le sacrifice de cette nuit.»
Les étrangers frémirent en manifestant une stupide horreur. Mais
Pomaré, gaîment, s'était emparé du vase allongé contenant la
précieuse boisson:
—«Donnez-moi votre áva piritané... Nous sommes fétii,
maintenant!» On répondit:
—«Cette boisson-là n'est pas bonne pour les chefs; elle rend
malade; elle trouble la vue et la démarche...
—Pas bonne pour les chefs? Pas bonne pour les autres? Je la
boirai donc à moi tout seul, comme ceci.» Et Pomaré s'en emplit la
bouche. Ses yeux roulaient et larmoyaient. Il toussa beaucoup, et
soudain, frappa violemment de sa tête—semblable au faîte d'un
mont—les poutres du navire! Or, ses gens, le considérant avec
scandale, s'apprêtaient à calmer sa digne violence... le chef riait au
contraire! Puis il reprit une grande majesté, et gravit les degrés de
bois—taillés pour un enfant—qui menaient au toit du bateau. Alors il
désira danser un peu et commença le ori dans lequel on chante:
Aué! la femme est... mais Haamanihi l'arrêta:
—«Les Piliers de ton corps ne te porteraient pas! Tu as bu le áva
des étrangers. Prends garde! Et dirige bien, où tu marches, les
Eclairs de tes yeux! Eha! l'Arc-en-ciel!» Déjà le chef avait sauté au
hasard dans un pahi de manant, et il réclamait à voix forte:
—«Le salut! Le salut! comme aux Arii Piritané!»
Il attendit avec défiance et fierté que la voix du gros mousquet
tonnât de nouveau. Alors il s'étendit, comme ensommeillé, dans le
creux de la pirogue. Son épouse pleurait de dépit: elle voulait dormir
avec un prêtre étranger. Haamanihi, seul, qui n'avait pas bu selon la
soif de son gosier, implorait encore, en s'en allant, «la boisson qui
donne le courage...»

Puis, l'Arc-en-ciel, poussé par les pagayeurs du chef, gagna


rapidement la terre. Le grand-prêtre, pour la seconde fois, s'irritait
de ce navire mystérieux, inquiétant et paisible, où l'on n'obtenait
même pas le áva brûlant; il s'étonnait de ces prêtres à qui suffisait
une épouse, et des atua inconnus dont ils se disaient les
annonciateurs. Il les jugea néanmoins d'une puissance neuve, et
capables de l'aider en la reconquête de ses biens: il résolut de les
servir.

ORO
Le temps des pluies prenait fin. Oro, par sa présence au
firmament de l'île, avait fécondé la grande Hina-terrestre, et s'en
allait, imperturbable, avec son cortège de nues, vers d'autres terres,
ses autres femelles, pour les féconder aussi. Il convenait de pleurer
sa retraite; car le Resplendissant, jaloux d'hommages, aurait pu
s'attacher à des pays plus dévots, et tarder en son retour.—Ainsi
jadis, affirmaient les gens de Nuú-Hiva: le soleil-mâle n'avait point
reparu. Mais l'homme Mahui, plus fort que tous les hommes,
poursuivant l'atua vagabond jusque par les confins du monde, avait
saisi les cheveux de lumière, et fort heureusement ramené le soleil
dans le ciel Maori,—où il le fixa par des nœuds.
C'était aux Arioï, issus de Oro, que revenait le soin de ces
lamentations d'absence. Ils sanglotaient donc, pendant les nuits
prescrites, avec une grande dignité. Néanmoins, comme le
fécondateur, en s'éloignant, dispensait à ses fidèles de
surabondantes récoltes, on pouvait, sans l'irriter, mêler à la tristesse
rigoureuse cette joie des sens agréée par lui en guise des plus riches
offrandes: on pouvait s'éjouir sans scrupules. Et Térii prenait pitié de
ses frères dans les autres îles, qui, de ce double rite, se réservaient
les seules douleurs.
Il attendait ces fêtes avec hâte, se flattant d'y obtenir enfin, par
son impeccable diction, le rang quatrième entre les haèré-po—ce
rang que distingue le tatu de l'épaule: car il négligeait, maintenant,
comme inutiles à sa mémoire assurée, les faisceaux, les baguettes,
et les tresses que l'on accorde aux nouveaux récitants. Parfois,
malgré l'incantation, des craintes indécises le harcelaient, comme
des moustiques importuns. Voici qui l'irritait par dessus tout: le
maraè de Papara n'était point, cette saison-là, désigné pour
l'assemblée. Les prêtres d'Atahuru s'étant faussement prévalus d'une
majesté plus grande, Pomaré, dont ils étaient le meilleur appui,
n'avait pu les récuser. Mauvais présage, et nouveaux sortilèges! Térii
n'entrevit donc pas sans inquiétude le véa-des-fêtes, envoyé par
l'Arii vers le cercle de l'île, passer en proclamant aux chefs, aux
possesseurs de terres, aux manants, la célébration, sur la rive
Atahuru, des adieux solennels aux esprits.

Ceint du maro jaune, l'annonciateur courait sans trêve. A son


approche, on flairait le sol, en tombant, visage bas. Nul ne hasardait
un murmure aussi longtemps que s'entendaient craquer, sous ses
pieds, les feuilles sèches. Mais le vêtement divin empêtrait l'homme
dans son élancée: il l'avait jeté sur ses épaules: rapide et nu, il levait
haut les palmes messagères qui frissonnaient au vent de sa course.

Dès l'aube de fête descendaient de l'horizon, sur la mer, les


pirogues houleuses, pressées, déchirant les vagues. Des banderolles
tendues entre des perches claquaient dans la brise. Les chants des
femmes, les cris des pagayeurs, les aboiements des chefs de nage
excitant à forcer, les clameurs des riverains partis à la rencontre,
bruissaient au loin parmi d'autres rumeurs plus graves: l'invocation
d'arrivée, entonnée par les prêtres de Oro. Leur flotille, sainte par
excellence, était partie, voici trois nuits, de la terre Raïatéa: elle
accourait; mais leur pirogue maîtresse devait, avant toute autre
pirogue, entrer dans les eaux-du-récif.
En ces lieux déconcertants, la ceinture de corail se coude
brusquement vers la terre. Les flots du large, roulant sans obstacle,
viennent crever sur le sable brun et s'épanouir en arcs d'écume
jusqu'au pied du maraè. Cela désappointait Térii, plus familier des
lagons silencieux. Son trouble s'accrut. Il parcourait d'un regard
craintif les terres élevées environnantes: rien encore, sinon des
présages hostiles: la Punaàru, invisible dans son creux, cheminait
péniblement, à demi desséchée. Les deux mornes qui l'enserraient
n'étaient pas également couverts de nuages. Il pleuvait dans la
vallée. Mais la brume détrempée au large découvrait, plus
menaçante encore, la terre Mooréa, mordant le ciel horizontal.
La grande pirogue doublait de vitesse. Elle vint, avec un
crissement sec, enfoncer dans le sable ses deux coins de bois
acérés. Les proues jumelles fouillaient le sol comme des groins de
cochons mâles, cependant que la mer, battant leurs flancs, les
soulevait de secousses haletantes. On sauta sur le rivage pour
étayer le pahi: les porteurs d'idoles, avec de grands respects,
débarquaient à travers l'embrun les images des dieux. Les autres
atterrissaient en jetant des saluts, des souhaits, des rires. Seuls
demeuraient au large les quatre navires d'offrandes qui réclamaient,
sans toucher le sol, d'être portés jusqu'au parvis réservé.
Aussitôt, les veilleurs dans la montagne avaient, à grands cris,
dénoncé la marche du cortège. A leurs voix, les hauteurs dominant
la rivière se couvraient de longues files de gens. Ils débouchaient
par les ravins et, pour plus grande hâte, cheminaient au milieu
même des ruisseaux. Alors ils vacillaient sur les galets arrondis. La
vallée, qui, longtemps avant le corail, s'épanouit largement, les
vomissait en flots sur la plage. Pour la plupart, c'étaient ces manants
d'épaisse carrure, voûtés par les fardeaux quotidiennement soulevés
et que le port des gros régimes de féï a bossués aux épaules et à la
nuque de proéminences molles. Ils portaient, en présents pour les
atua, de plantureuses grappes rouges, des bananes, des racines
mûres de taro. Les mieux avisés, cependant, n'avaient choisi que
d'immangeables fruits verts. Ils diraient, avec astuce, en les dédiant
au fécondateur: «C'est tout ce qu'il nous est possible, Oro, de t'offrir.
Mais reviens promptement parmi nous; donne-nous une autre
récolte, et abondante: nous pourrons alors te repaître plus
dignement!» Ainsi, sans privation de soi-même, on inciterait le dieu
pour les saisons à venir.
En même temps, de tous les coins des vents, irruaient les
peuplades foraines venues des îles sœurs, et que l'attrait des belles
fêtes attire et englue comme l'huile nono les mouches de marais.
Tous ces gens étaient divers de tailles, d'allures, de cheveux et de
couleurs de peaux. Agiles et bruyants, les hommes de Nuú-Hiva en
imposaient aux autres par le belliqueux de leurs gestes. De
farouches rayures de tatu bleu, barrant toute la face, leur
enfonçaient les paupières et démesuraient le rictus qui fait peur à
l'ennemi. Ils agitaient avec prestesse d'énormes massues habilement
entaillées. Chaque figure incrustée sur leurs membres signifiait un
exploit.—Plus bruns, desséchés par l'eau salée, les marins d'Anaa,
l'île basse, se tenaient à l'écart, et défiants un peu. Leurs femmes
étaient fortes, dont les torses musculeux tombaient sur des jambes
petites. Comme elles partageaient les rudes travaux des hommes,
pêchant et plongeant aussi, la salure marine avait parsemé leurs
peaux d'écailles miroitantes, et leurs yeux, gonflés et rouges, brûlés
par les reflets du corail, s'abritaient mal sous des cils endoloris.
Beaucoup de ces gens, mutilés par les voraces atua-requins,
balançaient gauchement des moignons sanieux. Sevrés de bonne
chère, ils admiraient tous les merveilleuses provendes inconnues à
leurs appétits. Chez eux, sur les récifs ras comme un pont de
pirogue, sans rivières, sans flaques d'eau pour la soif, on se
contentait des fruits du haari, et de poissons. Ici, les plaisirs du
manger semblaient chose coutumière. Des mets extravagants, que
l'on supposait nourriture divine et seulement exister dans les récits
d'aventures, emplissaient de nombreux paniers, pendaient aux mâts,
aux branches, aux épaules; on en tirait aussi des cachettes
souterraines. Le pays était bon!—D'autres voyageurs, encore, se
pressaient, mais ceux-là venus des îles froides. Les plus grêles
d'entre eux, les plus blêmes, avaient, depuis cinq nuits, débarqué
d'un navire étranger pêcheur de baleines. Ils s'émerveillaient des
grands arbres et des faré hautement charpentés, et ne concevaient
point que l'on pût, dans un seul tronc, creuser un pahi tout entier.
Mais ils souriaient de mépris vers les tii aux yeux plats, aux torses
roides, qui jalonnent les vallées:—«Ce sont des petits d'atua! Nous
avons, sur notre terre, des images taillées dans des blocs de
montagne. Elles sont très énormes. Cent hommes ne pourraient
maintenant les dresser. Il y en a des milliers. Nous les jetons à bas».
Ils ajoutaient avec orgueil: «Notre île se nomme: Nombril-du-
monde.» On ignorait ce pays.
Et ces peuples errants, accourus par les chemins des eaux de
derrière le firmament visible, s'entendaient néanmoins comme des
frères séparés par aventure, et qui se retrouveraient. Tous les mots
dont ils désignaient les êtres autour d'eux, le ciel, les astres, le culte
et les tapu, ces mots étaient frères aussi. Chacun sans doute les
disait à sa manière: le rude prononcer des gens d'Anaá et de Nuú-
Hiva—qu'ils appelaient Nuku-Hiva—heurtait les molles oreilles des
Tahitiens beaux parleurs. Ceux-ci roulaient volontiers sur la langue
les syllabes qui frétillent. D'autres glapissaient avec le creux de leur
gosier. Mais on oubliait ces discords, et, de part et d'autre, on
échangeait de longs appels de bienvenue.

Un silence lourd comme le ciel nuageux tomba soudain sur la


foule. Les clameurs des hommes fléchirent, et la triple sonorité
sainte—voix du récif, voix du vent, voix des prêtres,—s'épanouit
seule dans la vallée. Le cortège se mit en route: les Maîtres-du-jouir,
et devant eux Haamanihi, le menaient avec une grande majesté.
Derrière marchaient les chefs, les promeneurs-de-nuit, les
sonneurs de conque marine, les sacrificateurs et les gardiens-des-
images. Bien haut sur la marée des épaules se balançaient les
Plumes Rouges, simulacre du dieu;—et si prestigieuses, que Hiro
jadis avait couru le monde à les poursuivre, que Hina pleura durant
cinq nuits leur envolée, que l'on passait une vie de vieillard à guetter,
sans le tuer, le surprenant oiseau qui leur prêtait naissance! Tous
ensemble, les prêtres et les Plumes, accédèrent à l'enceinte sacrée.
Le peuple se rua sur les barrières, et le rite annuel déroula ses
gestes immuables.
Pomaré le jeune, sauté à bas de son porteur, s'écartait des autres
chefs; et l'on remarqua vite que ses gens, nombreux, dissimulaient
sous leurs nattes épaisses des armes aux manches frottés de résine:
ils semblaient plus prêts aux batailles qu'à honorer les dieux. Perdu
parmi ceux-là, sans insignes, sans pouvoirs, le père de l'Arii n'était
rien autre que le premier serviteur de son fils. Même, un grand
homme tout branlant s'avança vers le chef, le torse dépouillé par
respect. Sa barbe jaune, qu'il taillait parfois pour en tresser les
touffes et les offrir aux prêtres, s'ébroussaillait sur sa poitrine. On
s'étonnait de son âge avancé. Certains disaient quarante années;
d'autres cent. Nul n'affirmait rien là-dessus, ni lui-même, plus
insouciant encore des saisons passées. C'était l'aïeul de Pomaré. Il
s'arrêta sur les plus bas degrés et rendit hommage à son jeune
descendant.—L'autre considérait sans répondre, avec indifférence, le
vieillard débile. Car «l'enfant en naissant», disent les Récits,
«devient le chef de son vrai père et le père de ses ancêtres».—
L'homme chevrotant vacilla sur ses jambes et disparut dans la foule.
Cependant, les sourdes voix des maîtres Arioï achevaient le chant
originel où l'on proclame:

«Arioï! Je suis Arioï! et ne dois plus, en ce monde, être père.


Arioï! Je suis Arioï! mes douze femmes seront stériles; ou bien
j'étoufferai mon premier-né, dans son premier souffle.»

Une troupe de desservants entoura l'autel. Ils présentaient les


plus disparates offrandes: des féï roux et luisants; des poissons crus
à la chair appétissante, et d'innombrables cochons, qui, les pattes
ligottées, grognaient en s'agitant par petits bonds sur le dos.
Plusieurs des nobles animaux avaient les flancs rougeâtres: des Nuú-
Hiviens crièrent au sacrilège; car Témoana, grand-prêtre dans leur
île, avait jadis échangé sa personnalité pour celle d'un cochon rouge.
Dès lors, tous les rouges leur devenant tapu, ils réclamaient pour
qu'on déliât ces parents à quatre pieds. Leurs murmures se perdirent
dans la rumeur envahissante. On amenait enfin, pompeusement, des
chiens maigres, au long poil, les avant-bras liés derrière les oreilles,
et que des gens forçaient à marcher à la manière des hommes. Tous
ces dons, jetés par des milliers de mains plus haut que l'enceinte,
volaient sur les têtes et tombaient devant Haamanihi. D'un geste il
distribuait à son gré. Les victimes négligeables, aussitôt égorgées
par les bas sacrificateurs, suffisaient aux petits autels. Les plus
dignes, les plus grasses, disparaissaient derrière le faré des prêtres:
on ne les entendait point hurler sous le couteau. Haamanihi choisit
une truie pleine qu'il fit déposer sur l'autel culminant. Les Arioï
chantaient:

«La truie Orotétéfa mit bas sept petits:


Cochon du sacrifice,
Cochon du maro rouge,
Cochon pour les étrangers,
Et cochon pour la fête en l'honneur de l'amour...»

Armé d'une coquille tranchante, le grand-prêtre s'approcha de la


bête dédiée. Il lui ouvrit péniblement la gorge. Les Arioï chantaient:

«Cochon pour être mangé,


Deux cochons pour conserver la race.
Tels furent les présents divins portés à Vaïraümati, la femme
grasse et belle, choisie comme épouse par Oro-atua.»

Les haèré-po considéraient l'agonie de la bête. Elle mourut


oreilles dressées: c'était signe de guerre malheureuse. On observa le
chef: Pomaré gardait sa nonchalante attitude.—Un remous courut
dans la foule: deux étrangers, des hommes au nouveau-parler,
s'approchaient avec quelque défiance, et les gardiens de l'enceinte
les pressaient de se dévêtir, comme tous, par respect pour le dieu.
On disputait, on s'agitait. Mais Haamanihi expliqua au peuple que
ces gens étaient aussi des prêtres et de grands sacrificateurs dans
leur pays; qu'ils servaient des dieux forts et complaisants: nul ne
gagnerait à les inquiéter.
Le peuple déjà, flairait le moment des ripailles. Car, sitôt les atua
repus, les desservants devaient lancer, par-dessus les barrières, le
surplus des offrandes. Ils commencèrent: poissons et chiens rôtis
passaient, en nombre merveilleux, au-dessus des faces tendues à
suivre leur vol. Des mains plus nombreuses les happaient avant la
chute et se crispaient dans les proies. Ils s'acharnaient plus que
tous, les rudes vagabonds des montagnes, privés de chairs et
ignorants des choses de la mer: l'un d'eux, s'emparant d'une tortue,
crut l'étrangler avec ses doigts: la tête disparut sous la coquille: on
se moqua de son dépit. Cependant, les Tahitiens du rivage, replets
et satisfaits, somnolaient sur le ventre en attendant l'heure des
beaux discours.

Soudain, les gardes écartèrent la racaille, et, dans un galop


alourdi par leurs charges ballottantes, des porteurs-de-victimes
traversèrent le parvis. Trois corps, cerclés de bandelettes, tombèrent
avec un clappement mou. On les hissa jusqu'au sommet de l'autel.
Les têtes roulaient sur la pierre, et tous les yeux morts, ouverts plus
que nature, regardaient au hasard. C'étaient trois malfaiteurs que
l'on avait, à l'improviste, assommés sur le choix d'Haamanihi. Le
grand-prêtre, d'un coup d'ongle, fit sauter, de chacun des orbites, les
yeux, qu'il sépara sur deux larges feuilles. La première, il l'éleva tout
près des simulacres divins. Il tendit l'autre à Pomaré, disant avec
force:
—«Mangeur-d'Œil, Aï-Mata, sois nommé, chef, comme tes
ancêtres et comme tes fils. Repais-toi de la nourriture des dieux.
Mange aussi du courage et de la férocité.»
L'Arii, ouvrant la bouche, feignit d'avaler les yeux. A cette vue, les
étrangers commencèrent à glapir, on ne sait pourquoi, sans aucun
souci de la majesté du lieu et du rite. L'un d'eux, le plus petit,
montrant à la fois sa mâchoire et les corps étendus, pressait de
questions ses voisins:—«Vous n'allez pas...—Non! non!» protestaient
avec dégoût les riverains de l'île. Mais les pêcheurs Paümotu et
quelques hommes de la terre Nuú-Hiva considéraient avec un regret
des entrailles les trois cadavres qu'on précipitait au charnier. Ils se
moquèrent des étrangers: ceux-ci, dans leur terre Piritania, ne
mangeaient donc pas la chair des ennemis? Même pas les cœurs?
Mais quel autre moyen de se débarrasser, une fois pour toutes, des
rancuniers esprits-errants?—Un long hurlement, aigre et sans sexe,
fit taire les querelles. On se précipita:
Un homme nu, les yeux retournés, le visage suintant et tout le
corps agité de secousses hoquetantes, franchit l'enceinte. Nul n'osait
l'écarter: son bras gauche entouré de tapa blanche le défendait
contre la foule, et marquait un inspiré. Son nom d'homme se disait
Tino, et son corps habitait misérablement la grotte froide Mara. Mais
quand soufflait l'âme du dieu, alors il devenait Oro lui-même: ses
gestes étaient gestes de Oro: son parler, parler de Oro; ses désirs et
ses ruts se manifestaient divins: alors des femmes exultantes
venaient s'offrir et l'entraînaient avec elles.—Or, cette fois, la
présence souveraine s'affirmait indiscutable, éclatante, irrésistible, et
passait en rafale: sous l'emprise, le vivant fléchit, vacilla, croula; son
échine ployait comme un arc tendu à rebours; sa voix sifflait, ses
dents craquaient; sa tête martelait les dalles, en sonnant. Seuls
l'entourèrent les porteurs-d'idoles, habiles à manier impunément les
dieux—et tous les êtres équivoques. Ils l'étendirent sur l'autel, et
voici que Tino, soudain, se transfigura: les paupières béantes et
paisibles, le front asséréné, les narines molles, et tout le visage paré
d'un charme solennel, il se dressa près des poteaux sacrés, et parla.
Il disait sans effort, avec les mots qu'on attribue aux dieux-
supérieurs, d'admirables récits ignorés. Il disait aussi des choses à
venir:—une guerre insidieuse; la mort d'un Arii; des sortilèges
nouveaux par-dessus l'île...—La foule frémit. Les disputes et les
rumeurs pour manger s'apaisèrent. Chacun tira des plis de son maro
le bambou dans lequel on promène les petits dieux domestiques,
pour les honorer, parfois, de prières. Beaucoup de femmes, les yeux
fixes, considéraient l'inspiré sans pouvoir en détourner leurs visages;
puis, tombant en arrière avec un cri rauque, elles imitaient ses
postures, et l'on disait qu'à travers le corps vulgaire de Tino, elles
avaient aperçu l'atua. Des hommes aussi, dévêtus, bondirent dans
l'enceinte, proclamant que Tané ou Fanaütini les pénétraient, les
possédaient... Mais on dénonça la fraude: ils espéraient, par cette
ruse, voler le culte des prêtres et la faveur des épouses! Des
gardiens les chassèrent à coups de massue. Puis Tino tomba sur lui-
même, épuisé par l'âme dévorante du dieu.

Haamanihi avait subi, non sans une impatience, l'intervention de


l'inspiré dont les fâcheuses prophéties disloquaient parfois ses
propres desseins. Il se hâta de faire crier l'heure des grands Parlers,
en laissant défiler d'abord quelques haèré-po du commun. Mais nul
n'écoutait ceux-là. Le grand-prêtre se réservait un discours plus
ingénieux. Assis, les jambes repliées, sur la pierre-du-récitant, il
commença de narrer, dans un silence, l'atterrissage à Tahiti-nui de la
grande pirogue sans balancier ni rameurs dont le chef se nommait
Uari. Elle précédait, de deux années, le navire de Tuti[2], et c'était,
vraiment, la première de son espèce: des aventures étonnantes s'en
suivirent:

[2] Uari: Wallis, 1767.


Tuti: Cook.

—«Cette pirogue parut lourde et chevelue. Les hommes de


Matavaï pensèrent à l'arrivée d'une île voyageuse.
»Ainsi jadis avait flotté, vers Tahiti-nui, la terre Taïarapu, que les
gens du rivage, munis des fortes tresses du roa, purent tenir et
amarrer à la grande Tahiti.
»Comme les riverains pagayaient vers la haute pirogue pour y
jeter des feuillages de paix, l'on entendit un bruit de tonnerre: sur le
récif, un homme tomba.
»Il n'avait pas reçu de pierre; pas de lance à travers le corps. On
le soutint par le dos: il fléchit comme un cadavre. Les pêcheurs de
Matavaï redoublèrent leurs présents.
»Les étrangers descendirent au rivage. Ils étaient pâles, et
parfois on les voyait enlever leurs chevelures.»
Fier de savoir, Haamanihi s'enthousiasmait à répéter ces Dires.
Avec noblesse et vivacité, et par d'admirables gestes des épaules, de
la tête, de toute sa personne, il évoquait les autres gestes, accomplis
par d'autres hommes, jadis, durant d'autres saisons. Il attachait tous
les regards. Son haleine était longue, sa langue agile, ses bras et ses
épaules exercés à scander son discours. C'était un beau parleur.
Puis vint le tour de Térii à Paraürahi. La foule, repue, prêtait aux
discoureurs une attention plus frémissante, et son éveil tumultueux
inquiéta le haèré-po qui montait à l'épreuve. La chevelure jaunie de
safran, le torse peint de lignes d'ocre, les jambes enduites de la
terre jaune des fêtes solennelles, Térii gagna la pierre-du-récitant.
Fléchissant les genoux, étendant les mains pour cadencer le dire
monotone, les paupières fermées à demi, la tête relevée, la gorge
tendue, il commença le récit depuis longtemps répété:

«Dormait Té Tumu avec une femme inconnue: De ceux-là naquit


Tahito-Fénua.
Dormait Tahito-Fénua avec une femme inconnue: De ceux-là
naquit Atéa-Nui.
Dormait Atéa-Nui avec la femme...»

Pendant que d'elles-mêmes s'évoquaient les paroles premières,


Térii songeait combien ce Dire devait plaire à Pomaré, jusque-là
traité comme un usurpateur, et dont nul ne s'était mis en peine,
jamais, de publier les aïeux.

«... De ceux-là naquit Taaroa Manahuné.


Dormait Taaroa Manahuné avec la femme Tétua é Huri du maraè
Téraüpoo:
De ceux-là naquit Téü...»

—D'autant mieux que Térii, parmi les nombreuses lignées


conservées dans la mémoire des prêtres, avait habilement choisi la
plus flatteuse, par laquelle s'affiliait le chef au façonneur des cieux,
de la mer et des terres, par laquelle il se reliait, en quatorze
générations, à l'origine des êtres.

«Dormait Téü avec la femme Tétupaïa du maraè Raïatéa:


De ceux-là naquit Vaïraatoa, qui est dit Pomaré.
Dormait Vaïraatoa avec la femme Tétua-nui Réia, du maraè
Raïatéa:
De ceux-là naquirent Térii Navahoroa vahiné, puis Tunui é aï i té
Atua, qui est dit aussi Pomaré, qui est l'Arii-rahi.»

Le dernier de ces noms, il le prononça en regardant le chef. L'Arii,


ennobli de la sorte, ne cachait pas son agrément. Cette ascendance
affirmait ses droits sur les îles Paümotu, dont son ancêtre Taároa
Manahuné avait été possesseur.
Térii poursuivait. Afin d'étaler toutes les prérogatives, il
dénombrait les genèses, fort douteuses, à dire vrai, qui rattachaient
Pomaré aux Arii de Papara:

«Dormait le chef Tavi, du maraè Taütira, avec la femme Taürua,


puis avec la femme Tüitéraï du maraè Papara:
De ceux-là naquit Tériitahia i Marama.
Dormait Téritahia i Marama avec la femme Tétuaü Méritini, du
maraè Vaïrao...»

Il disait tout d'une haleine les beaux noms ancestraux, marquant


d'un geste mesuré du bras chacun des accouplements éternels. Un
bruissement montait de la foule emmenée par le rythme, par le
balancement des mots, et qui récitait, elle aussi, les séries originelles
interminablement redoublées.

«... De ceux-là naquirent Aromaïtéraï, du maraè Papara; et


Tuitéraï, qui dormait avec Téroro.
Dormait Aromaïtéraï, avec Téraha-Tétua:
De ceux-là naquit Tévahitua, dit Amo, dit...»

Un silence énorme écrasa brusquement le murmure des


écouteurs surpris: le récitant avait changé les noms! Térii sursauta,
et sa voix un instant chancela, qui semblait s'étayer sur les rumeurs
environnantes. Il reprit:

«... De ceux-là naquit Aromaïtéraï...


Dormait Aromaïtéraï avec...»

Le vide muet persistait à l'entour. On ne suivait plus, des lèvres,


le parleur égaré. On le dévisageait. On attendait. Les Arioï, interdits,
cessèrent d'avaler les mets présentés. Les desservants se tinrent
immobiles. De proche en proche le silence gagnait, étouffant les
innombrables bruissements dont pétillait l'enceinte. Il semblait qu'un
grand filet de palmes se fût abattu sur les clameurs des hommes; et
dans l'air immobile et tendu monta, de nouveau, la triple sonorité
sainte: voix du vent dans les arbres-aïto, voix du récif hurlant au
large, voix du haèré-po, mais grêle et hoquetante.—Cette voix, la
sienne, familière quand il l'épandait dans la sérénité de ses prières
d'études, Térii la crut venir d'une autre bouche, lointaine et
maléficieuse. Il se raidit, crispa la main pour chercher, du geste
accoutumé, les nœuds secourables de la tresse-origine, et hasarda:

«... dormait Aromaïteraï avec la femme...»

Le nom s'obstina dans la gorge. Térii pencha son regard, et


vacilla de peur sur la pierre haute: les têtes, en bas, comme elles
étaient petites, et toutes rondes! Et chacune dardait sur lui des yeux
malfaisants... Il lui parut aussi que Haamanihi triomphait. Térii
chercha ses maîtres. Il ne vit en leur place que les deux étrangers
hostiles, aux vêtements sombres parmi les peaux nues et les
peintures de fête: cette fois, le sortilège était manifeste. L'incanté
proféra bien vite les formules qui dissolvent les sorts. Il balbutiait
davantage. Enfin, les yeux grands ouverts, les lèvres tremblantes, il
se tut.
Alors, dans l'abîme de silence, soudain frémit, roula, creva le
torrent tumultueux des injures, des cris, des imprécations
outrageantes qu'on hurlait dans tous les langages, avec les grimaces
guerrières réservées à l'ennemi: l'erreur du récitant méritait la colère
de Oro: qui donc apaiserait les dieux, si les prêtres eux-mêmes en
venaient à les exaspérer! C'était à de telles erreurs, non pas aux
étrangers,—criait Haamanihi,—qu'on redevait les calamités
dernières! Il entraîna les gens d'Atahuru à répéter les mêmes
paroles. Les hommes des îles voisines, amusés du spectacle,
suivaient l'exemple et invectivaient au hasard. On se pressait de
proche en proche, et la houle des épaules, déferlant sur l'enceinte
de bois, la disloqua dans un remous. Malgré les gardiens indignés,
malgré le tapu du lieu, une ruée de gens, dont chaque homme n'eût
osé même effleurer un poteau d'offrande, se haussa vers le parvis
sacré. Chacun s'étayait sur son compagnon, s'étonnait de sa propre
audace, et avançait en piétinant de rage. On enserrait, sans issue, le
prêtre exécrable.
Térii n'avait point quitté la pierre-du-récitant où le liait une
attente épouvantée du châtiment tout proche. Il bondit enfin. Des
mains se crispèrent dans sa peau, et des haches de jade,
entrechoquées, cliquetaient très haut, à bout de bras. La mêlée
pressée empêchait de les abattre: on profiterait du premier recul.—
Mais un appel strident, celui qui désigne aux coups le plus
dangereux adversaire, détourna les gens acharnés: Paofaï avait
sauté sur la pierre élevée: de la voix, des yeux, des mains tendues, il
montrait les véritables ennemis, les jeteurs de sortilèges, les
empoisonneurs de sa race: les hommes au nouveau-parler. On
oublia Térii qui tomba de crainte, ou de ruse.—Où donc les autres?
On les entourait. Alors Haamanihi lança des serviteurs, qui,
s'emparant avec feinte des étrangers, les dérobèrent au tumulte; et
pour mieux égarer encore la rancune de la foule, il insultait
violemment son rival:
—«Paofaï! Paofaï Tériifataü! Père! Tu es Père et Arioï malgré tes
promesses! Eha! l'homme qui a perdu la parole est ton fils! Pourquoi
l'as-tu laissé vivre, quand sa mère a mis bas?»
Pomaré, cependant, ne tentait rien pour apaiser le peuple.
Couvert par ses gens, il observait que l'erreur du haèré-po insultait à
ses ancêtres, et présageait mal. En expiation de la faute, il dépêcha
deux envoyés-de-mort vers un autre maraè.
Puis les vagues soulevées dans la foule irritée tombèrent. Les
rumeurs devinrent confuses et lasses. Car Oro, cheminant sur le
ventre du ciel au lieu le plus élevé de sa route quotidienne,
alourdissait les gestes et abaissait les paupières. Ses regards
pénétraient d'une torpeur les êtres vivants. Son haleine desséchait la
terre grasse et humait la buée de la mer. Les esprits du dormir-le-
jour voletaient dans les souffles d'air lent. L'île accablée, que seule
affraîchissait la brise accourant du large, ayant assourdi ses
tumultes, apaisé ses haines, oublié ses guerres et repu ses entrailles,
s'assoupit.

Comme le jour tombait, l'on s'étira pour les danses. Alors des
prêtres de haut rang s'inquiétèrent; et ils haranguaient la foule: quoi
donc! on allait s'éjouir quand les atua, les chefs et la terre Atahuru
supportaient cette insulte et toutes ces profanations: l'oubli d'un
haèré-po, la ruée du peuple à toucher l'autel?—Mais le bon sommeil
avait passé: les dieux, n'avaient-ils point dormi de même, puisque
rien ne se manifestait dans les nuages ou sur les eaux... Et pour la
faute, on s'en prendrait au coupable,—quelques riverains, sans hâte,
se mirent à sa recherche,—ou bien à d'autres, ou bien à personne.
Les atua se taisaient toujours, l'Arii restait indifférent, et la fête, à
peine suspendue, reprit tous ses ébats: vite, on ménageait des
places rondes où préparer la boisson rassurante, le áva de paix et de
joie,—que les Nuú-Hiviens, dans leur rude langage, appellent kava.
Autour du bassin à quatre pieds creusé dans un large tronc de
tamanu, s'assemblaient par petits groupes les gras possesseurs-de-
terres, leurs fétii, leurs manants, leurs femmes. Une fille, au milieu
du cercle, écorçait à pleines dents la racine au jus vénérable, puis,
sans y mêler de salive, la mâchait longuement. Sur la pulpe broyée,
crachée du bout des lèvres avec délicatesse dans la concavité du
tronc, elle versait un peu d'eau. On brassait avec un faisceau de
fibres souples qui se gonflaient de liquide, et que la fille étreignait
au-dessus des coupes de bois luisantes. A l'entour, les tané buvaient
alors la trouble boisson brune, amère et fade, qui brise les membres,
mais excite aux nobles discours.
Les cercles s'agrandirent. Des torches de bambous desséchés
craquaient avec des éclats rouges. Déjà les gens du rivage Taütira,
parés de couronnes, la figure peinte, le corps enroulé de fines
étoffes longuement battues, lançaient des cris et s'agitaient. Durant
vingt nuits ils avaient redit avec soin chaque part de leur chant. Les
femmes, au milieu des groupes, jetaient un appel prolongé, perdu,
qui retombait sur les mugissements des hommes. Ceux-ci
entrechoquaient d'un battement égal de petits cailloux cliquetants,
et ils cadençaient leurs soubresauts. Les voix montaient avec charme
sur des contours habilement apprêtés, et les paroles, enjolivées de
beaux sons étendus, s'improvisaient, comme il convient, au hasard
des lèvres.
Or, les Nuú-Hiviens scrupuleux redoutaient à mélanger leurs
chants aux ébats du peuple en liesse. La joie pérennelle de la terre
Tahiti leur pesait; surtout lorsque le kava, aiguisant les esprits,
réveillait en eux le respect des atua et du culte. Alors ils se
rémémoraient les Dires impérissables, et si réservés que l'homme
mort Pukéhé avait dû reparaître tout exprès pour les enseigner aux
autres hommes. Alors tressaillaient leurs appétits guerriers. Ils
attendaient, au retour dans leurs îles, ces festins héroïques où il
importe de mâcher le cœur de l'ennemi le plus audacieux. On les vit
se retirer dans la montagne. Et bientôt, de leur repaire, descendit un
murmure qui s'enflait, se perdait, puis se gonflait de petites
clameurs, enrouées d'abord, débonnaires, satisfaites et menaçantes
enfin: les Nuú-Hiviens entonnaient ce péhé où s'expriment, après un
signal, la faim, la chasse, le rut et la mort du cochon propitiatoire.

Sur la plage on entourait une estrade où de jeunes hommes,


habiles à simuler des gestes, et à figurer d'amusantes histoires,
s'ébattaient pour la joie des spectateurs. L'un d'eux cria, en langue
vulgaire, qu'ils allaient feindre l'aventure de l'«Homme bien-avisé.»
On riait à l'avance: cette parade était pleine d'enseignements.—
D'abord se montra un gros chef-terrien. Il portait de très précieux
objets: deux haches de fer, un collier de coquilles, des plumes
rouges pour le maro divin. Ces plumes, on les savait fausses,—
feuilles découpées et peintes. Mais les petits parmi les dieux s'en
contenteraient: pourquoi paraître plus exigeant? L'homme entoura ce
trésor d'une tapa luisante, puis de plusieurs nattes fines, et appela
des serviteurs. Les maigres manants avancèrent. Le maître déclara
partir pour d'autres îles, et montrant son inestimable fardeau,
menaça de grands châtiments si, pendant son absence, la moindre
part s'en escamotait. Il disparut.
Les autres se consultèrent: la meilleure garde à tenir autour du
trésor était de s'endormir dessus: ils s'endormirent.—Survint un
homme qui s'annonça «prêtre de Hiro-subtil». Il épia les serviteurs,
avisa la natte, sortit, et rentra en apportant une autre semblable. Il
s'accroupit derrière les dormeurs, et, d'une paille de bambou,
effleura la nuque du premier. Le manant geignit, s'ébroua, chassa
d'un coup d'ongle le moustique importun: mais sa tête avait glissé.
Même jeu pour l'autre: le trésor était libre. Prestement, le prêtre
substitua les nattes vides, et s'enfuit, emportant le magot, au milieu
d'un enthousiasme d'envie. On célébra le dieu Hiro, père de telles
ruses.
Mais le plaisir des yeux s'annonçait plus vif encore. Pomaré,
montant sur l'estrade, y venait recevoir, dans les formes prescrites,
l'hommage de ses fétii d'Atahuru: trois femmes, élevées sur les
épaules des porteurs-d'offrandes, furent déposées devant lui. Elles
avaient tout le corps enroulé de tapa; et cela, qui doublait leur
embonpoint, les rendaient plus désirables. Les trois femmes
saluèrent le chef et commencèrent à danser.
D'abord, leurs pas étaient lents, car les étoffes lourdes. Puis trois
jeunes hommes, saisissant le coin flottant des parures, tirèrent. Les
filles tournoyaient sur elles-mêmes. Les nattes longues
démesurément se déroulaient en changeant de couleur: blanches,
rouges, blanches et rouges encore. On les dévidait à grandes
brasses. Le dernier pli vola: les filles, nues, dansaient plus vite. Le
chef agréa l'offrande, et s'emparant des précieuses tapa, laissa les
femmes à ses gens.

Des battements sourds, roulant dans les rumeurs, grondèrent:


les tambours appelaient aux danses. Un frémissement courut dans
toutes les cuisses, à leur approche. Leurs sonneurs,—vieillards aux
yeux morts,—palpaient avec adresse, du bout des doigts, les peaux
de requins tendues sur les troncs creux: et leurs mains écaillées
voletaient, comme de jeunes mains vives sur un ventre d'épouse.
Aussitôt, les couples se dressèrent. Les femmes—poitrines
échevelées sous les fibres jaunes du révaréva, tempes cerclées de
couronnes odorantes—avaient noué étroitement leurs hanches d'une
natte mince, afin d'étrangler, sous le torse immobile, ces
tressaillements dont sursautent les genoux. Les tané se paraient de
coquillages miroitants, d'agrafes nacrées, de colliers mordant la
nuque. Ils tenaient leur souffle, tendaient les reins et écarquillaient
leurs oreilles: un coup de tambour les décocha.
Tous, d'abord tournés vers le meneur-de-danses, imitaient ses
gestes,—dépliant les bras, balançant le corps, inclinant la tête et la
relevant avec mesure. Puis, à tout petits pas précis et vifs, comme
s'ils piétinaient sur les orteils, ils approchèrent jusqu'à se flairer. Les
visages restaient impassibles; les paupières des femmes, baissées: il
convient, pour un temps, de cacher ses désirs. Brusquement, sur un
batté bref, tout se tut; tout cessa.
Une femme sortit de la foule, ajusta ses fleurs, secoua la tête
pour les mieux fixer, fit glisser sa tapa roulée, et cria. Les battements
recommencèrent. Jambes fléchies, ouvertes, désireuses, bras
ondulant jusqu'aux mains et mains jusqu'au bout des ongles, elle
figura le ori Viens t'enlacer vite à moi. Ainsi l'on répète, avec
d'admirables jeux du corps,—des frissons du dos, des gestes menus
du ventre, des appels de jambes et le sourire des nobles parties
amoureuses,—tout ce que les dieux du jouir ont révélé dans leurs
ébats aux femelles des tané terrestres: et l'on s'exalte, en sa joie, au
rang des êtres tapu. A l'entour, les spectateurs frappaient le rythme,
à coups de baguettes claquant sur des bambous fendus. Les
tambours pressaient l'allure. Les poings, sonnant sur les peaux de
requins, semblaient rebondir sur la peau de femme. La femme
précipitait ses pas. Des sursauts passaient. La foule, on eût dit,
flairait des ruts et brûlait. Les reins, les pieds nus, s'agitaient avec
saccades. Les hommes, enfiévrés, rampaient vers des compagnes.
Parfois, les torches, secouées, jetaient, en pétillant, un grand éclat
rouge. Leurs lueurs dansaient aussi. Soudain la femme se cambra,
disparut. Des gens crièrent de plaisir. Dans la nuit avancée, des
corps se pénétrèrent. Les flammes défaillaient; l'ombre s'épancha.

Alors, la confusion des nuits sans Hina devint effarante. Au


hasard, dans les ténèbres, vaguaient des chants dispersés, des
appels, des sanglots et des rires repus. Tous les peuples, dans tous
leurs langages, poussaient d'incertaines rumeurs: sur la rive sourdait
la colère des Paümotu réclamant on ne savait quels esclaves. Un
parti d'Arioï déplorait avec gémissements l'en-allée sans retour de
Tupaïa, l'Arii des prêtres; et leurs mots désolés roulaient, comme des
pleurs, de toute la hauteur des voix. Les femmes, durement
secouées, exhalaient des plaintes ambiguës. Un chien hurla. Mais les
haleines fléchissaient. Les poitrines s'épuisaient. Les hanches
secouées retombèrent. La nuit se prit à désirer l'aube. Sur les
vivants abreuvés de jouir, descendit, des montagnes endormies, un
grand souffle affraîchissant.

Un silence. Un tumulte: des cris rauques, bondissant dans la


vallée, emplirent toute la plage. Pesamment des gens se dressèrent
pour écouter: et des Nuù-Hiviens parurent dont les hurlements sans
nom faisaient ce nouveau vacarme. Ils couraient comme des crabes
de terre, et les torches qu'ils agitaient semblaient folles elles-mêmes.
On reconnut: c'étaient ces hommes qu'un navire d'étrangers avait
munis de la boisson brûlante... Ils se heurtaient, s'injuriaient. L'un
d'eux se mit à larmoyer. Les autres se moquèrent. Il se précipita, et,
d'un coup de hache, fendit une mâchoire. On s'écartait. Il revint,
s'acharna, écrasa une tête. Il pleurait toujours.
—Eha! qu'était donc cette ivresse inconnue qui, loin d'apaiser les
membres comme l'ivresse du áva maori, pousse au meurtre et rend
stupide et fou?
Mais tous les yeux, lassés, s'abandonnèrent. L'homme furieux
s'allongea parmi ses compagnons, paisiblement. Le matin parut.

LE PRODIGE
Térii fuyait sur le récif. Il avait à grand'peine échappé à la foule
hargneuse. Hagard et haletant, il détalait sans trêve. Des balafres
brûlantes, poudrées de safran, coupaient son visage. Ses couronnes
flétries glissaient de la tête aux épaules. Son maro déchiré dénudait
ses cuisses, et, trempé d'eau de mer, collait aux genoux qui s'en
embarrassaient. Une vague s'épaula, frémit, et lui vint crever sur la
tête: il roula, piqué par les mille pointes de corail vivant qui
craquaient dans sa peau. Se redressant, et sautant pour esquiver
une autre vague, il s'effrayait: c'était là jadis un châtiment de prêtre
impie!... Des haèré-po, même des sacrificateurs, avaient dû, pour
des fautes moindres, courir tout le cercle de l'île. On les voyait,
assaillis par la houle, franchir en nageant les coupures du récif,
reprendre pied et s'élancer encore, harcelés de gens en pirogues qui
brandissaient des lances. Térii sentit que sa fuite douloureuse était
une première vengeance des dieux rancuniers;—mais il trouva bon
qu'elle offrit, à la fois, un moyen d'échapper aux poursuites: nul ne
se risquait, derrière lui, dans la mer obscure.
Le récif, après un grand détour, revenait côtoyer les terres. Le
fugitif interrogea la nuit: tous les chants étaient morts,—mangés par
le vent, peut-être? Des lueurs éparses vacillaient seules par instant.
Alors, il souffla. Puis, incertain, lourd de dépit et défiant l'ombre, il
vint rôder aux abords de la fête, parmi les couples endormis.
Le firmament nocturne blêmissait. Dans l'imprécise clarté
nouvelle, Térii heurta des corps étendus. Pas un ne s'éveilla: il
reconnut les guerriers Nuú-Hiviens et s'étonna de les voir appesantis
et veules: le áva maori ne donne point, aux vivants qui sommeillent,
ces faces de cadavres ni cet abêtissement... L'un d'eux, le front
ouvert, n'était plus qu'un mort en vérité. Un autre qui se vautrait à
son flanc, le tenait serré comme un fétii.—Rien à redouter de ceux-
là! Térii les enjamba. Il piétinait des monceaux de vivres à demi
dévorés, des cochons dépouillés, prêts pour la cuisson, des noix de
haàri éventrées, des colliers et des parures pour la danse.
Un clair rayon de jour éveillé dansa sur les cimes. Dans la
fraîcheur du matin, des femmes se dressèrent. Leurs yeux étaient
pesants; leurs gestes endoloris de fièvres amoureuses. Mêlées aux
hommes qui, cette nuit-là, les avaient enlacées, et nues sous les
fleurs souillées, elles étendaient les bras, s'écrasaient le nez et la
bouche de leurs paumes humides, et joyeuses dans l'air froid,
frissonnaient en courant à la rivière. Térii se souvint que sa dernière
épouse avait paru dans la fête: elle reposait près d'un façonneur-de-
pirogues. Il la secoua. Tous deux coururent s'ébrouer dans les eaux
de la grande Punaáru. Puis, vêtus d'étoffes abandonnées, ils
marchaient vers ce coin du ciel d'où souffle le maraàmu-sans-trêve,
pour regagner, comme on regagne un asile, la terre sacrée Papara.

Ils cheminaient sans paroles. Le sentier ondulait selon la forme


du rivage. Soudain, il fonça vers la montagne comme s'il pénétrait
en elle. Les rochers broussailleux proéminaient sur la grève, et la
base du mont, excavée d'une arche béante, semblait s'ouvrir vers le
ventre de la terre. Des franges de fougères humides comblaient la
bouche immense d'où s'exhalaient des souffles froids. Nul bruit, que
le clapotement rythmé de gouttelettes claquant sur des eaux
immobiles. Térii connut alors qu'on frôlait, de tout près cette fois,
non plus du lointain de la mer-extérieure, la grotte redoutable Mara:
mais ce lieu, frappé de tapu, réservait un refuge possible: le fuyard,
malgré sa peur, creva les feuillées: la caverne parut.
Les yeux emplis de soleil, il ne vit rien, d'abord, que le grand arc
sombre enveloppant des profondeurs basses perdues au loin dans
une nuit. Il frissonna quand l'eau, plus froide que celle des torrents,
lui mordit les pieds. Ses yeux raffermis discernaient lentement des
formes dans l'ombre: des rochers; d'autres encore, plus lointains, et,
vers l'extrême reculée de la grotte, un pli obscur où la muraille allait
rejoindre la face de l'eau. Autour de lui claquaient toujours les
gouttelettes répétées, régulières, qui suintaient de la voûte. La
colline, chargée d'eau, suait par toute son assise, et son flux
mystérieux, disaient les prêtres, balançait les gonflements du lac
Vaîhiria, perdu très haut dans sa coupe de montagnes...—«Reste-
là», cria une voix.
Térii aperçut parmi des rocs dont les contours figuraient un
homme, un homme qui s'efforçait à imiter ces rocs, par son
immobilité. On eût dit l'image droite et dure d'un tii taillé dans la
montagne. Et il se souvint: la grotte Mara faisait la demeure de Tino
l'inspiré; et celui-ci, pour la rendre inaccessible, répandait de
terrifiants discours. Tino avait sans doute abandonné la fête avant
que survint la nuit de l'aube, et, sitôt passé le souffle du dieu,
ressaisi l'asile terrestre.
—«Que fais-tu, toi?» hasarda le voyageur.
L'autre ne parut point entendre, ni bouger, ni parler même.
Cependant, on répondit:
—«J'obéis à Oro-atua. Je me change en pierre.» La voix roulait,
grondait, rebondissait plusieurs fois avant de s'éteindre.
Térii voulut toucher et flairer le faiseur-de-prodiges. Il entra dans
l'eau gluante et se mit à nager. L'ombre s'approfondit autour de lui.
Le fond de la caverne reculait à chaque brasse. L'homme au rocher
restait très proche, à la fois, et très lointain. Un coup d'œil en
arrière, et Térii mesura la clarté du jour qui s'éloignait: la voûte tout
entière parut peser sur ses épaules, et clore, ainsi qu'une paupière
insupportable, le regard du ciel. Angoissé, le nageur se retourna,
hâtivement, vers le bord. La voix ricanait:
—«Eha! l'homme qui pagaie avec ses mains, sous la grotte Mara!
l'homme qui veut serrer l'eau dans ses bras et compter les poissons
sur ses doigts! La fierté même! Prends une pirogue!»
Térii oublia tous les tapu, et qu'un dieu, peut-être, habitait là. Il
saisit une pierre. Elle vola, parut effleurer la voûte, et puis creva
l'eau tout près de la rive: elle n'avait pas couru la moitié d'un jet de
flèche.
—«Hiè!» se moquait encore la voix. «Les souffles dans la grotte
sont plus forts que tes cailloux... Voici ma parole: la grotte Mara est
tapu: les souffles sont lourds et mauvais: les souffles sont lourds...»
Et après un silence: «Va-t'en, toi! Va-t'en, toi! je me change en
pierre...»
Térii regagna le sentier. Rêveur, il essuyait dans l'herbe ses pieds
chargés de fange. Puis il reprit sa route dans la grande lumière.
Tétua cheminait toujours à son côté; et le récif, l'éternel compagnon
des marches sacrées, le châtiment des prêtres oublieux, grondait
avec une longue menace. Le soir venait. Les crabes de terre,
effrayés par les pas, fonçaient dans leurs trous en y traînant des
palmes sèches qui craquaient.—Les errants allaient encore: à la nuit
tombée ils s'arrêtèrent: la vallée Papara ouvrait son refuge devant
eux. Mais le haèré-po n'en venait point à s'apaiser: la voix entendue
sonnait encore à ses oreilles.

Des nuits nombreuses avaient fui, et Térii n'osait plus reprendre,


auprès des sacrificateurs, sa place au maraè. Il ne s'aventurait plus
en allées nocturnes, et ne franchissait même pas sans effroi le seuil
de sa demeure. Tous les jours il se désappointait. Ses rêves
ambitieux: l'accueil des Arioï, les offrandes du peuple dévôt, la
montée triomphale à ces terrasses dont il frôlait à peine les derniers
degrés, tout cela s'était enfui de son espoir en même temps que les
mots rebelles échappaient à ses lèvres, sur la pierre-du-récitant! Il
sentait un autre homme surgir en lui, et se lamenter sans cesse: un
homme malheureux et las. Auparavant, ses peines, il les recouvrait
de pensers joyeux, et elles s'endormaient; ou bien elles mouraient
d'elles-mêmes en son esprit. Maintenant son chagrin était plus
tenace, ses regrets constants. Il ne pouvait plus les jeter par-dessus
l'épaule comme font les pêcheurs d'une pêche empoisonnée. Mais
ces regrets pesaient sur lui, le harcelaient et s'enfonçaient jusque
dans ses entrailles. Il sursautait durant le temps du sommeil,
déclarant l'obscurité trop grande, et retournait, en quête de rêves
apaisants, sa tête douloureuse sur le coussin de bois qui lui
meurtrissait la nuque. Le jour, il languissait, appesanti, sans désirs,
sans joies d'aucune sorte. Par-dessus tout la crainte lui vint que
Pomaré, dont il avait irrité l'orgueil en confondant l'histoire des
Ancêtres, ne lui dépêchât, par son véa-de-mort, ces pierres
arrondies et noires qui désignent les victimes. Alors, on
l'assommerait à l'improviste d'un coup de massue, et son corps,
traîné par les porteurs-d'offrandes, tomberait du haut de l'autel dans
le charnier mangeur de cadavres.
Chaque matin, sortant d'un assoupissement équivoque, il
retrouvait sa tristesse assise au bord de sa natte et plus fidèle
qu'une épouse. Il s'indignait qu'elle ne fût pas envolée: c'est le
propre des étrangers seuls, de se plaindre plusieurs nuits sans répit;
de verser des larmes durant des lunaisons entières! Les hommes de
Tahiti ne succombent pas, d'habitude, à ces sortes de fièvres. Il est
vrai que les étrangers recourent, pour s'en guérir, à d'incroyables
remèdes: voici qu'un marin Piritané, ayant pris un grand chagrin à
voir s'enfuir la femme qui dormait avec lui, ne parlait plus, et ne
voulait pas d'autres compagnes. Un jour, on le trouva suspendu à la
grosse poutre de son faré, le cou serré dans sa ceinture d'étoffe, le
visage bleu. «Il est fou», songeait Térii, «de vouloir s'en aller de la
vie parce que l'on n'est point satisfait des jours qui passent et qui
s'en iront, certes, d'eux-mêmes!» Et il s'efforçait d'imaginer d'autres
fêtes, encore, et d'autres épreuves, dont il sortirait, cette fois,
triomphant. Mais il retombait plus lourdement dans le dépit du
passé. Il y décelait la malfaisance des hommes au nouveau langage:
leurs dieux avaient surpris ses menées: ils accablaient l'incantateur!

Des échos le hantaient aussi de sa rencontre, sous la grotte, avec


l'inspiré de Oro. «Je me change en pierre», avait proclamé la voix.
Térii se souvint que les hommes, sous le secours des dieux, peuvent
dévêtir la forme humaine et se parer de telle autre image. Ainsi,
disait-on, pendant une saison de dure famine, le vieux Téaé, prêtre
et Arioï, s'était offert à sauver son peuple. Oro l'avait transfiguré,
après des rites, en un grand arbre fécond. Des paroles rythmées
contant l'histoire prodigieuse, et que l'on disait sur un mode
enthousiaste, venaient chanter sur les lèvres du haèré-po:

«Or, Téaé, comme l'île avait faim, réunit les hommes de sa terre,
les hommes maigres et desséchés; les femmes aux mamelles taries;
et les enfants pleurant pour manger.
—E aha! Téaé.
Téaé leur dit:—Je vais monter dans la vallée. Je dirai vers Té Fatu
le maître, des parlers puissants. Allons ensemble dans la vallée.
—E rahi! Téaé.
Ils le suivirent. Les torrents avaient soif, et la grande Punaáru
descendait, goutte à goutte, dans son creux de cailloux secs.
Derrière eux venaient des cochons maigres, réservés pour la faim
des derniers jours.
—Ahé! Téaé.»

Voilà qui n'était point trop hasardeux à tenter! Térii, s'imagina,


par avance, guider allègrement lui-même quelque foule espérante. Il
prolongea sa rêverie:

«Comme ils arrivaient au mont Tamanu, qui est le ventre de l'île,


Téaé leur dit: creusez dans la terre un trou pour y plonger un grand
arbre.
—A rahi! Téaé.
Et Téaé descendit dans ce trou. Il invoqua Té Fatu le maître avec
des parlers suppliants. Il se tenait immobile, bras levés, jambes
droites.
—Ahé! Téaé.»

Térii se répéta: «bras levés, jambes droites...» Etait-ce une


posture d'ancien inspiré? sans doute, et favorable au prodige: car le
prodige se manifestait:
«Voici que le torse nu se durcit autant qu'un gros arbre. La peau
devint écorce rude. Les pieds, divisés, s'enracinèrent dans le sol
ingrat. Plus que tout homme le vieillard grandissait.
—E ara! Téaé.
Ses deux bras devinrent dix bras. Puis vingt, puis cent, puis des
centaines. Pour ses mains qui étaient mille, c'étaient mille feuilles
palmées offrant aux affamés de beaux fruits inconnus.
—Ataé! Téaé.
Les gens de Tahiti s'en rassasièrent, disant: cela est bon. Car cet
arbre fut le Uru[3], qui depuis lors nourrit la grande île, et la
presqu'île, et les terres au-dessous de l'horizon.
—Aué! Téaé.»

[3]Arbre-à-pain.

Pourquoi donc, espérait Térii, ne pas tenter aussi quelque


aventure prestigieuse, et se remettre en grâce auprès du peuple
toujours accueillant aux faiseurs de prodiges?—Quant aux prêtres,
qui regardent d'un mauvais œil les exploits divins accomplis sans
leur aide, on mépriserait leur ressentiment.
«Je me change en pierre», avait crié la voix sous la caverne. Il
désira se changer en arbre. Cette pensée lui semblait parfois désir
d'insensé ou de petit enfant qui se croit, dans ses jeux, transformé
en chien ou en chèvre. Mais un tel espoir, seul de tous les autres,
l'assérénait un peu; il s'y raccrochait comme aux pirogues défoncées
qui surnagent à peine, et qu'on sent couler sous le poids. Il lui
devenait décidément insupportable d'être en butte aux railleries des
porteurs-d'idoles, des manants; et qu'on le désignât de l'un à l'autre
pour celui qui avait «oublié les Mots».
Il dit à sa femme son dessein d'accomplir un prodige. Elle s'en
égaya beaucoup:—«Je veux bien de toi comme tané», reprit-elle
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookbell.com

You might also like