0% found this document useful (0 votes)
3 views55 pages

Modern Programming Made Easy Using Java Scala Groovy and JavaScript Second Edition Adam L Davis instant download

The document is a promotional text for the book 'Modern Programming Made Easy: Using Java, Scala, Groovy, and JavaScript' by Adam L. Davis, which is available for download. It includes links to additional programming resources and books related to Java, Scala, Groovy, and JavaScript. The book covers various programming concepts and techniques across multiple languages, aiming to simplify modern programming for readers.

Uploaded by

pdbbhceify4438
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)
3 views55 pages

Modern Programming Made Easy Using Java Scala Groovy and JavaScript Second Edition Adam L Davis instant download

The document is a promotional text for the book 'Modern Programming Made Easy: Using Java, Scala, Groovy, and JavaScript' by Adam L. Davis, which is available for download. It includes links to additional programming resources and books related to Java, Scala, Groovy, and JavaScript. The book covers various programming concepts and techniques across multiple languages, aiming to simplify modern programming for readers.

Uploaded by

pdbbhceify4438
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/ 55

Modern Programming Made Easy Using Java Scala

Groovy and JavaScript Second Edition Adam L


Davis download

https://textbookfull.com/product/modern-programming-made-easy-
using-java-scala-groovy-and-javascript-second-edition-adam-l-
davis/

Download full version ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Modern Programming Made Easy: Using Java, Scala,


Groovy, and JavaScript 2nd Edition Adam L. Davis

https://textbookfull.com/product/modern-programming-made-easy-
using-java-scala-groovy-and-javascript-2nd-edition-adam-l-davis/

Learning concurrent programming in Scala learn the art


of building intricate modern scalable and concurrent
applications using Scala Second Edition Prokopec

https://textbookfull.com/product/learning-concurrent-programming-
in-scala-learn-the-art-of-building-intricate-modern-scalable-and-
concurrent-applications-using-scala-second-edition-prokopec/

Object Orientation Abstraction and Data Structures


Using Scala Second Edition Lacher

https://textbookfull.com/product/object-orientation-abstraction-
and-data-structures-using-scala-second-edition-lacher/

Beginning Functional JavaScript. Functional Programming


with JavaScript using EcmaScript 6 1st Edition Anto
Aravinth

https://textbookfull.com/product/beginning-functional-javascript-
functional-programming-with-javascript-using-ecmascript-6-1st-
edition-anto-aravinth/
Beginning Functional JavaScript: Functional Programming
with JavaScript Using EcmaScript 6 1st Edition Anto
Aravinth

https://textbookfull.com/product/beginning-functional-javascript-
functional-programming-with-javascript-using-ecmascript-6-1st-
edition-anto-aravinth-2/

Head First JavaScript Programming, 2nd Edition: A


Learner’s Guide to Modern JavaScript Eric Freeman

https://textbookfull.com/product/head-first-javascript-
programming-2nd-edition-a-learners-guide-to-modern-javascript-
eric-freeman/

Head First JavaScript Programming, 2nd Edition: A


Learner’s Guide to Modern JavaScript Eric Freeman

https://textbookfull.com/product/head-first-javascript-
programming-2nd-edition-a-learners-guide-to-modern-javascript-
eric-freeman-2/

U S Immigration Made Easy 19th Edition US Immigration


Made Easy Ilona Bray

https://textbookfull.com/product/u-s-immigration-made-easy-19th-
edition-us-immigration-made-easy-ilona-bray/

Eloquent Javascript A Modern Introduction to


Programming Marijn Haverbeke

https://textbookfull.com/product/eloquent-javascript-a-modern-
introduction-to-programming-marijn-haverbeke/
Modern
Programming
Made Easy
Using Java, Scala, Groovy,
and JavaScript

Second Edition

Adam L. Davis
Modern Programming
Made Easy
Using Java, Scala, Groovy,
and JavaScript
Second Edition

Adam L. Davis
Modern Programming Made Easy: Using Java, Scala, Groovy, and
JavaScript
Adam L. Davis
Oviedo, FL, USA

ISBN-13 (pbk): 978-1-4842-5568-1 ISBN-13 (electronic): 978-1-4842-5569-8


https://doi.org/10.1007/978-1-4842-5569-8

Copyright © 2020 by Adam L. Davis


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 author 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 designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media, 1 New York Plaza,
New York, NY 10004, U.S.A.. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@
springer-­sbm.com, or visit www.springeronline.com. Apress Media, LLC is a 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 email [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/9781484255681. For
more detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
Dedicated to all teachers.
Thank you for teaching!
Table of Contents
About the Author��������������������������������������������������������������������������������xv
About the Technical Reviewer����������������������������������������������������������xvii

Chapter 1: Introduction������������������������������������������������������������������������1
Problem-Solving���������������������������������������������������������������������������������������������������1
About This Book����������������������������������������������������������������������������������������������������2

Chapter 2: Software to Install���������������������������������������������������������������3


Java/Groovy����������������������������������������������������������������������������������������������������������3
Trying It Out�����������������������������������������������������������������������������������������������������������4
Others�������������������������������������������������������������������������������������������������������������������5
Code on GitHub�����������������������������������������������������������������������������������������������������5

Chapter 3: The Basics���������������������������������������������������������������������������7


Coding Terms��������������������������������������������������������������������������������������������������������7
Primitives and Reference��������������������������������������������������������������������������������������8
Strings/Declarations���������������������������������������������������������������������������������������������9
Statements����������������������������������������������������������������������������������������������������������10
Assignment���������������������������������������������������������������������������������������������������������10
Class and Object�������������������������������������������������������������������������������������������������11
Fields, Properties, and Methods��������������������������������������������������������������������12
Groovy Classes����������������������������������������������������������������������������������������������13
JavaScript Prototypes������������������������������������������������������������������������������������14
Scala Classes������������������������������������������������������������������������������������������������14

v
Table of Contents

Creating a New Object�����������������������������������������������������������������������������������14


Comments�����������������������������������������������������������������������������������������������������������15
Summary������������������������������������������������������������������������������������������������������������15

Chapter 4: Math����������������������������������������������������������������������������������17
Adding, Subtracting, etc.�������������������������������������������������������������������������������������17
More Complex Math��������������������������������������������������������������������������������������������19
Random Numbers�����������������������������������������������������������������������������������������������20
Summary������������������������������������������������������������������������������������������������������������22

Chapter 5: Arrays, Lists, Sets, and Maps��������������������������������������������23


Arrays������������������������������������������������������������������������������������������������������������������23
Lists��������������������������������������������������������������������������������������������������������������������25
Groovy Lists���������������������������������������������������������������������������������������������������26
Scala Lists�����������������������������������������������������������������������������������������������������26
JavaScript Arrays������������������������������������������������������������������������������������������27
Sets���������������������������������������������������������������������������������������������������������������������28
Maps�������������������������������������������������������������������������������������������������������������������29
Groovy Maps��������������������������������������������������������������������������������������������������30
Scala Maps����������������������������������������������������������������������������������������������������30
JavaScript Maps��������������������������������������������������������������������������������������������30
Summary������������������������������������������������������������������������������������������������������������31

Chapter 6: Conditionals and Loops�����������������������������������������������������33


If, Then, Else��������������������������������������������������������������������������������������������������������33
Switch Statements����������������������������������������������������������������������������������������������34
Boolean Logic�����������������������������������������������������������������������������������������������������36
Looping���������������������������������������������������������������������������������������������������������������37
Summary������������������������������������������������������������������������������������������������������������39

vi
Table of Contents

Chapter 7: Methods����������������������������������������������������������������������������41
Call Me����������������������������������������������������������������������������������������������������������������41
Non-Java�������������������������������������������������������������������������������������������������������42
Break It Down�����������������������������������������������������������������������������������������������������43
Return to Sender�������������������������������������������������������������������������������������������������43
Static�������������������������������������������������������������������������������������������������������������������44
Varargs����������������������������������������������������������������������������������������������������������������45
Main Method�������������������������������������������������������������������������������������������������������45
Exercises�������������������������������������������������������������������������������������������������������������46
Summary������������������������������������������������������������������������������������������������������������46

Chapter 8: Inheritance������������������������������������������������������������������������47
Objectify��������������������������������������������������������������������������������������������������������������48
JavaScript������������������������������������������������������������������������������������������������������49
Parenting 101������������������������������������������������������������������������������������������������������49
JavaScript������������������������������������������������������������������������������������������������������51
Packages������������������������������������������������������������������������������������������������������������52
Public Parts���������������������������������������������������������������������������������������������������������53
JavaScript������������������������������������������������������������������������������������������������������53
Interfaces������������������������������������������������������������������������������������������������������������54
Abstract Class�����������������������������������������������������������������������������������������������������55
Enums�����������������������������������������������������������������������������������������������������������������56
Annotations���������������������������������������������������������������������������������������������������������57
Autoboxing����������������������������������������������������������������������������������������������������������58
Autoboxing�����������������������������������������������������������������������������������������������������58
Unboxing��������������������������������������������������������������������������������������������������������58
Summary������������������������������������������������������������������������������������������������������������58

vii
Table of Contents

Chapter 9: Design Patterns�����������������������������������������������������������������59


Observer�������������������������������������������������������������������������������������������������������������59
MVC���������������������������������������������������������������������������������������������������������������������61
DSL����������������������������������������������������������������������������������������������������������������������63
Closures���������������������������������������������������������������������������������������������������������63
Overriding Operators�������������������������������������������������������������������������������������65
Actors������������������������������������������������������������������������������������������������������������������66
Chain of Responsibility���������������������������������������������������������������������������������������67
Facade����������������������������������������������������������������������������������������������������������������68
Summary������������������������������������������������������������������������������������������������������������69

Chapter 10: Functional Programming������������������������������������������������71


Functions and Closures���������������������������������������������������������������������������������������72
Map, Filter, etc.����������������������������������������������������������������������������������������������������74
Immutability��������������������������������������������������������������������������������������������������������78
Java��������������������������������������������������������������������������������������������������������������������80
Groovy�����������������������������������������������������������������������������������������������������������������81
Scala�������������������������������������������������������������������������������������������������������������������82
Summary������������������������������������������������������������������������������������������������������������84

Chapter 11: Refactoring����������������������������������������������������������������������85


Object-Oriented Refactoring�������������������������������������������������������������������������������85
Functional Refactoring����������������������������������������������������������������������������������������86
Refactoring Examples�����������������������������������������������������������������������������������������86
Renaming a Method��������������������������������������������������������������������������������������87
Moving a Method from One Class to Another (Delegation)����������������������������87
Replacing a Bunch of Literals (Strings or Numbers)
with a Constant (Static Final)������������������������������������������������������������������������88

viii
Table of Contents

Renaming a Function�������������������������������������������������������������������������������������88
Wrapping a Function in Another Function and Calling It�������������������������������88
Inline a Function Wherever It Is Called����������������������������������������������������������89
Extract Common Code into a Function (the Opposite of the Previous)����������89

Chapter 12: Utilities����������������������������������������������������������������������������91


Dates and Times�������������������������������������������������������������������������������������������������91
Java Date-Time���������������������������������������������������������������������������������������������92
Groovy Date���������������������������������������������������������������������������������������������������92
JavaScript Date���������������������������������������������������������������������������������������������94
Java DateFormat�������������������������������������������������������������������������������������������94
Currency��������������������������������������������������������������������������������������������������������������96
TimeZone������������������������������������������������������������������������������������������������������������96
Scanner���������������������������������������������������������������������������������������������������������������97

Chapter 13: Building���������������������������������������������������������������������������99


Ant�����������������������������������������������������������������������������������������������������������������������99
Maven���������������������������������������������������������������������������������������������������������������100
Using Maven������������������������������������������������������������������������������������������������101
Starting a New Project��������������������������������������������������������������������������������101
Life Cycle�����������������������������������������������������������������������������������������������������102
Executing Code��������������������������������������������������������������������������������������������103
Gradle����������������������������������������������������������������������������������������������������������������105
Getting Started with Gradle�������������������������������������������������������������������������105
Projects and Tasks���������������������������������������������������������������������������������������105
Plugins���������������������������������������������������������������������������������������������������������106
Dependencies����������������������������������������������������������������������������������������������107
Do First and Last�����������������������������������������������������������������������������������������108

ix
Table of Contents

Chapter 14: Testing���������������������������������������������������������������������������111


Types of Tests����������������������������������������������������������������������������������������������������111
JUnit������������������������������������������������������������������������������������������������������������������112
Hamcrest�����������������������������������������������������������������������������������������������������113
Assumptions������������������������������������������������������������������������������������������������114
Spock����������������������������������������������������������������������������������������������������������������115
Spock Basics�����������������������������������������������������������������������������������������������115
A Simple Test�����������������������������������������������������������������������������������������������116
Mocking�������������������������������������������������������������������������������������������������������117
Lists or Tables of Data���������������������������������������������������������������������������������118
Expecting Exceptions����������������������������������������������������������������������������������119
Other Test Frameworks�������������������������������������������������������������������������������������120
Summary����������������������������������������������������������������������������������������������������������120

Chapter 15: Input/Output������������������������������������������������������������������121


Files������������������������������������������������������������������������������������������������������������������121
Reading Files����������������������������������������������������������������������������������������������������122
Writing Files������������������������������������������������������������������������������������������������������123
Downloading Files���������������������������������������������������������������������������������������������125
Summary����������������������������������������������������������������������������������������������������������126

Chapter 16: Version Control��������������������������������������������������������������127


Subversion��������������������������������������������������������������������������������������������������������128
Git����������������������������������������������������������������������������������������������������������������������128
Mercurial�����������������������������������������������������������������������������������������������������������130

Chapter 17: The Interweb�����������������������������������������������������������������131


Web 101������������������������������������������������������������������������������������������������������������132
My First Web App����������������������������������������������������������������������������������������������133

x
Table of Contents

The Holy Grails��������������������������������������������������������������������������������������������������135


Quick Overview��������������������������������������������������������������������������������������������135
Plug-ins�������������������������������������������������������������������������������������������������������139
Cloud�����������������������������������������������������������������������������������������������������������������140
The REST�����������������������������������������������������������������������������������������������������������141
Using Maven Archetypes�����������������������������������������������������������������������������142
Using Grails JSON Views�����������������������������������������������������������������������������142
Summary����������������������������������������������������������������������������������������������������������143

Chapter 18: Swinging Graphics��������������������������������������������������������145


Hello Window����������������������������������������������������������������������������������������������������145
Push My Buttons�����������������������������������������������������������������������������������������������148
Fake Browser����������������������������������������������������������������������������������������������������149
Griffon���������������������������������������������������������������������������������������������������������������152
Advanced Graphics�������������������������������������������������������������������������������������������153
Graphics Glossary���������������������������������������������������������������������������������������������154
Summary����������������������������������������������������������������������������������������������������������155

Chapter 19: Creating a Magical User Experience�����������������������������157


Application Hierarchy����������������������������������������������������������������������������������������157
Consider Your Audience������������������������������������������������������������������������������������158
Choice Is an Illusion������������������������������������������������������������������������������������������159
Direction������������������������������������������������������������������������������������������������������������159
Skeuomorphism������������������������������������������������������������������������������������������������160
Context Is Important������������������������������������������������������������������������������������������160
KISS������������������������������������������������������������������������������������������������������������������160
You Are Not the User�����������������������������������������������������������������������������������������161
Summary����������������������������������������������������������������������������������������������������������161

xi
Table of Contents

Chapter 20: Databases���������������������������������������������������������������������163


SQL (Relational) Databases�������������������������������������������������������������������������������164
SQL��������������������������������������������������������������������������������������������������������������165
Foreign Keys������������������������������������������������������������������������������������������������167
Connections�������������������������������������������������������������������������������������������������168
NoSQL (Non-relational) Databases��������������������������������������������������������������������169
Redis������������������������������������������������������������������������������������������������������������169
MongoDB�����������������������������������������������������������������������������������������������������170
Cassandra����������������������������������������������������������������������������������������������������170
VoltDB����������������������������������������������������������������������������������������������������������170
Summary����������������������������������������������������������������������������������������������������������171

Appendix A: Java/Groovy������������������������������������������������������������������173
No Java Analog�������������������������������������������������������������������������������������������������174

Appendix B: Java/Scala��������������������������������������������������������������������175
No Java Analog�������������������������������������������������������������������������������������������������176
Null, Nil, etc.������������������������������������������������������������������������������������������������������176

Appendix C: Java/JavaScript������������������������������������������������������������177
No Java Analog�������������������������������������������������������������������������������������������������178

Appendix D: Resources���������������������������������������������������������������������179

Appendix E: Free Online Learning�����������������������������������������������������181


The Death of College?���������������������������������������������������������������������������������������181
Sustainability����������������������������������������������������������������������������������������������������182
More Online Resources�������������������������������������������������������������������������������������182

xii
Table of Contents

Appendix F: Java������������������������������������������������������������������������������185

Afterword������������������������������������������������������������������������������������������187

Index�������������������������������������������������������������������������������������������������189

xiii
About the Author
Adam L. Davis makes software. He’s spent
many years developing in Java (since Java 1.2)
and has enjoyed using Spring and Hibernate
for more than a decade. Since 2006 he’s
been using Groovy, Grails, HTML, CSS, and
JavaScript, in addition to Java, to create SaaS
web applications that help track finances for
large institutions (among other things).
Adam has a master’s and a bachelor’s
degree in Computer Science from Georgia
Tech. He is also the author of Reactive Streams in Java (Apress, 2019) and
Learning Groovy 3, Second Edition (Apress, 2019). You can check out his
web site at https://github.adamldavis.com/.

xv
About the Technical Reviewer
Manuel Jordan Elera is an autodidactic
developer and researcher who enjoys learning
new technologies for his own experiments and
creating new integrations. Manuel won the
Springy Award—Community Champion and
Spring Champion 2013. In his little free time,
he reads the Bible and composes music on his
guitar. Manuel is known as dr_pompeii. He
has tech-reviewed numerous books for Apress,
including Pro Spring Boot 2 (2019), Rapid
Java Persistence and Microservices (2019), Java Language Features (2018),
Spring Boot 2 Recipes (2018), and Java APIs, Extensions and Libraries
(2018). Read his 13 detailed tutorials about many Spring technologies,
contact him through his blog at www.manueljordanelera.blogspot.com,
and follow him on his Twitter account, @dr_pompeii.

xvii
CHAPTER 1

Introduction
In my experience, learning how to program (in typical computer science
classes) can be very difficult. The curriculum tends to be boring, abstract,
and unattached to “real-world” coding. Owing to how fast technology
progresses, computer science classes tend to teach material that is very
quickly out of date and out of touch. I believe that teaching programming
could be much simpler, and I hope this book achieves that goal.

Note There’s going to be a lot of tongue-in-cheek humor


throughout this book, but this first part is serious. Don’t worry, it gets
better.

P
 roblem-Solving
Before you learn to program, the task can seem rather daunting, much like
looking at a mountain before you climb it. However, over time, you will
realize that programming is really about problem-solving.
On your journey toward learning to code, as with so much in life, you
will encounter many obstacles. You may have heard it before, but it really is
true: the path to success is to try, try, and try again. People who persevere
the most tend to be the most successful people.

© Adam L. Davis 2020 1


A. L. Davis, Modern Programming Made Easy,
https://doi.org/10.1007/978-1-4842-5569-8_1
Chapter 1 Introduction

Programming is fraught with trial and error. Although things will get
easier over time, you’ll never be right all the time. So, much as with most
things in life, you must be patient, diligent, and curious to be successful.

About This Book


This book is organized into several chapters, beginning with the most basic
concepts. If you already understand a concept, you can safely move ahead
to the next chapter. Although this book concentrates on Java, it also refers
to other languages, such as Groovy, Scala, and JavaScript, so you will gain a
deeper understanding of concepts common to all programming languages.

Tips Text styled like this provides additional information that


you may find helpful.

Info Text styled this way usually refers the curious reader to
additional information.

Warnings Text such as this cautions the wary reader. Many


have fallen along the path of computer programming.

Exercises This is an exercise. We learn best by doing, so it’s


important that you try these out.

2
CHAPTER 2

Software to Install
Before you begin to program, you must install some basic tools.

J ava/Groovy
For Java and Groovy, you will have to install the following:

• JDK (Java Development Kit), such as OpenJDK 11. You


can install OpenJDK by following the instructions at
adoptopenjdk.net.1
• IDE (Integrated Development Environment), such as
NetBeans 11.

• Groovy: A dynamic language similar to Java that runs


on the JVM (Java Virtual Machine).

1
https://adoptopenjdk.net/installation.html
© Adam L. Davis 2020 3
A. L. Davis, Modern Programming Made Easy,
https://doi.org/10.1007/978-1-4842-5569-8_2
Chapter 2 Software to Install

Install Java and NetBeans 11 or higher. Download and install the


Java JDK and NetBeans.2 Open NetBeans and select File ➤ New
Project… ➤ Java with Gradle, Java Application. When asked, provide
the group “test,” version “0.1,” and package such as “com.
gradleproject1”. Click “Finish,” then “OK.”
Install Groovy: Go to the Groovy web site and install Groovy.3

Trying It Out
After installing Groovy, you should use it to try coding. Open a command
prompt (or terminal), type groovyConsole, and hit Enter to begin.

In groovyConsole, type the following and then hit Ctrl+r to run


the code.
1 print “hello”

Because most Java code is valid Groovy code, you should keep the
Groovy console open and use it to try out all of the examples from this
book.
You can also easily try out JavaScript in the following way:

• Just open your web browser and go to jsfiddle.net.

2
h ttps://netbeans.apache.org/download/index.html
3
https://groovy.apache.org/download.html

4
Chapter 2 Software to Install

O
 thers
Once you have the preceding installed, you should eventually install the
following:
• Scala4: An object-oriented language built on the JVM
• Git5: A version control program

• Maven6: A modular build tool

Go ahead and install these, if you’re in the mood. I’ll wait.


To try out Scala, type scala in your command prompt or terminal once
you have installed it.

C
 ode on GitHub
A lot of the code from this book is available on github.com/modernprog.7
You can go there at any time to follow along with the book.

4
w ww.scala-lang.org/
5
https://git-scm.com/
6
https://maven.apache.org/
7
https://github.com/modernprog

5
CHAPTER 3

The Basics
In this chapter, we’ll cover the basic syntax of Java and similar languages.

C
 oding Terms
Source file refers to human-readable code. Binary file refers to computer-­
readable code (the compiled code). In Java, this binary code is called
bytecode which is read by the Java Virtual Machine (JVM).
In Java, the source files end with .java, and binary files end with
.class (also called class files). You compile source files using a compiler,
which gives you binary files or bytecode.
In Java, the compiler is called javac; in Groovy it is groovyc; and it is
scalac in Scala (see a trend here?). All three of these languages can be
compiled to bytecode and run on the JVM. The bytecode is a common
format regardless of which programming language it was generated from.
However, some languages, such as JavaScript, don’t have to be
compiled. These are called interpreted languages. JavaScript can run in
your browser (such as Firefox or Google Chrome), or it can run on a server
using Node.js, a JavaScript runtime built on Chrome’s V8 JavaScript engine.

© Adam L. Davis 2020 7


A. L. Davis, Modern Programming Made Easy,
https://doi.org/10.1007/978-1-4842-5569-8_3
Chapter 3 The Basics

Primitives and Reference


Primitive types in Java refer to different ways to store numbers and have
practical significance. The following primitives exist in Java:
• char: A single character, such as A (the letter A).

• byte: A number from -128 to 127 (8 bits1). Typically, a


way to store or transmit raw data.

• short: A 16 bits signed integer. It has a maximum of


about 32,000.

• int: A 32 bits signed integer. Its maximum is about 2 to


the 31st power.

• long: A 64 bits signed integer. Maximum of 2 to the 63rd


power.

• float: A 32 bits floating-point number. This format


stores fractions in base two and does not translate
directly to base ten numbers (how numbers are usually
written). It can be used for things such as simulations.

• double: Like float but with 64 bits.


• boolean: Has only two possible values: true and false
(much like 1 bit).

See Java Tutorial—Data Types2 for more information.

1
 bit is the smallest possible amount of information. It corresponds to a 1 or 0.
A
2
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.
html

8
Chapter 3 The Basics

GROOVY, SCALA, AND JAVASCRIPT

Groovy types are much the same as Java’s. In Scala, everything is an object,
so primitives don’t exist. However, they are replaced with corresponding value
types (Int, Long, etc.). JavaScript has only one type of number, Number,
which is similar to Java’s float.

A variable is a value in memory referred to by a name. In Java you can


declare a variable as a primitive by writing the type then any valid name.
For example, to create an integer named price with an initial value of 100,
write the following:

1  int price = 100;

Every other type of variable in Java is a reference. It points to some


object in memory. This will be covered later on.
In Java, each primitive type also has a corresponding class type: Byte
for byte, Integer for int, Long for long, and so on. Using the class type
allows the variable to be null (meaning no value). However, using the
primitive type can have better performance when handling a lot of values.
Java can automatically wrap and unwrap primitives in their corresponding
classes (this is called boxing and unboxing).

Strings/Declarations
A String is a list of characters (text). It is a very useful built-in class in Java
(and most languages). To define a string, you simply surround some text in
quotes. For example:

1   String hello = "Hello World!";

Here the variable hello is assigned the string "Hello World!".

9
Chapter 3 The Basics

In Java, you must put the type of the variable in the declaration. That’s
why the first word here is String.
In Groovy and JavaScript, strings can also be surrounded by single
quotes ('hello'). Also, declaring variables is different in each language.
Groovy allows you to use the keyword def, while JavaScript and Scala use
var. Java 10 also introduced using var to define local variables. For example:

1   def hello = "Hello Groovy!" //groovy


2   var hello = "Hello Scala/JS!" //Scala or JS

Statements
Almost every statement in Java must end in a semicolon (;). In many
other languages, such as Scala, Groovy, and JavaScript, the semicolon is
optional, but in Java, it is necessary. Much as how periods at the end of
each sentence help you to understand the written word, the semicolon
helps the compiler understand the code.
By convention, we usually put each statement on its own line, but this
is not required, as long as semicolons are used to separate each statement.

Assignment
Assignment is an extremely important concept to understand, but it can
be difficult for beginners. However, once you understand it, you will forget
how hard it was to learn.
Let’s start with a metaphor. Imagine you want to hide something
valuable, such as a gold coin. You put it in a safe place and write the
address on a piece of paper. This paper is like a reference to the gold. You
can pass it around and even make copies of it, but the gold remains in the
same place and does not get copied. On the other hand, anyone with the
reference to the gold can get to it. This is how a reference variable works.

10
Chapter 3 The Basics

Let’s look at an example:

1   String gold = "Au";


2   String a = gold;
3   String b = a;
4   b = "Br";

After running the preceding code, gold and a refer to the string "Au",
while b refers to "Br".

Class and Object


A class is the basic building block of code in object-oriented languages.
A class typically defines state and behavior. The following class is named
SmallClass:

1   package com.example.mpme;
2   public class  SmallClass  {
3   }

Class names always begin with an uppercase letter in Java. It’s


common practice to use CamelCase to construct the names. This means
that instead of using spaces (or anything else) to separate words, we
uppercase the first letter of each word.
The first line is the package of the class. A package is like a directory on
the file system. In fact, in Java, the package must actually match the path
to the Java source file. So, the preceding class would be located in the path
com/example/mpme/ in the source file system. Packages help to organize
code and allow multiple classes to have the same name as long as they are
in different packages.
An object is an instance of a class in memory. Because a class can have
multiple values within it, an instance of a class will store those values.

11
Chapter 3 The Basics

Create a Class

• Open your IDE (NetBeans).


• Note the common organizational structure of a typical
Java project in the file system:
• src/main/java: Java classes
• src/main/resources: Non-Java resources
• src/test/java: Java test classes
• src/test/resources: Non-Java test resources
• Right-click your Java project and choose New ➤
Java Class. Under “Class-Name” put “SmallClass”.
Put “com.example.mpme” for the package name.

Fields, Properties, and Methods


Next you might want to add some properties and methods to your class.
A field is a value associated with a particular value or object. A property is
essentially a field which has a “getter” or “setter” or both (a getter gets the
value and a setter sets the value of a property). A method is a block of code
on a class which can be called later on (it doesn’t do anything until called).

1   package  com.example.mpme;
2   public  class  SmallClass  {
3       String name; //field
4       String getName() {return  name;} //getter
5       void print() {System.out.println(name);} //method
6   }

12
Random documents with unrelated
content Scribd suggests to you:
The Project Gutenberg eBook of Notre Coeur;
or, A Woman's Pastime: A Novel
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

Title: Notre Coeur; or, A Woman's Pastime: A Novel

Author: Guy de Maupassant

Release date: November 18, 2015 [eBook #50477]


Most recently updated: October 22, 2024

Language: English

Credits: Produced by Dagny and Marc D'Hooghe (Images


generously made available by the Hathi Trust.)

*** START OF THE PROJECT GUTENBERG EBOOK NOTRE COEUR;


OR, A WOMAN'S PASTIME: A NOVEL ***
NOTRE CŒUR
OR
A WOMAN'S PASTIME
A NOVEL

By
GUY DE MAUPASSANT
SAINT DUNSTAN SOCIETY

AKRON, OHIO

1903

CONTENTS

GUY DE MAUPASSANT - Critical Preface: Paul Bourget


INTRODUCTION - Robert Arnot, M. A.
NOTRE CŒUR

CHAPTER I.
THE INTRODUCTION

CHAPTER II.
"WILL YOU WALK INTO MY PARLOR?"

CHAPTER III.
THE THORNS OF THE ROSE

CHAPTER IV.
THE BENEFIT OF CHANGE OF SCENE

CHAPTER V.
CONSPIRACY

CHAPTER VI.
QUESTIONINGS

CHAPTER VII.
DEPRESSION

CHAPTER VIII.
NEW HOPES

CHAPTER IX.
DISILLUSION

CHAPTER X.
FLIGHT

CHAPTER XI.
LONELINESS

CHAPTER XII.
CONSOLATION

CHAPTER XIII.
MARIOLLE COPIES MME. DE BURNE
ADDENDA

THE OLIVE GROVE


REVENGE
AN OLD MAID
COMPLICATION
FORGIVENESS
THE WHITE WOLF

ILLUSTRATIONS

HENRI RENE GUY DE MAUPASSANT


"THEY WERE ALONE ... SHE WAS WEEPING"
GUY DE MAUPASSANT

Of the French writers of romance of the latter part of the nineteenth


century no one made a reputation as quickly as did Guy de
Maupassant. Not one has preserved that reputation with more ease,
not only during life, but in death. None so completely hides his
personality in his glory. In an epoch of the utmost publicity, in which
the most insignificant deeds of a celebrated man are spied, recorded,
and commented on, the author of "Boule de Suif," of "Pierre et Jean,"
of "Notre Cœur," found a way of effacing his personality in his work.
Of De Maupassant we know that he was born in Normandy about
1850; that he was the favorite pupil, if one may so express it, the
literary protégé, of Gustave Flaubert; that he made his début late in
1880, with a novel inserted in a small collection, published by Emile
Zola and his young friends, under the title: "The Soirées of Medan";
that subsequently he did not fail to publish stories and romances
every year up to 1891, when a disease of the brain struck him down
in the fullness of production; and that he died, finally, in 1893,
without having recovered his reason.
We know, too, that he passionately loved a strenuous physical life
and long journeys, particularly long journeys upon the sea. He owned
a little sailing yacht, named after one of his books, "Bel-Ami," in
which he used to sojourn for weeks and months. These meager
details are almost the only ones that have been gathered as food for
the curiosity of the public.
I leave the legendary side, which is always in evidence in the case of
a celebrated man,—that gossip, for example, which avers that
Maupassant was a high liver and a worldling. The very number of his
volumes is a protest to the contrary. One could not write so large a
number of pages in so small a number of years without the virtue of
industry, a virtue incompatible with habits of dissipation. This does
not mean that the writer of these great romances had no love for
pleasure and had not tasted the world, but that for him these were
secondary things. The psychology of his work ought, then, to find an
interpretation other than that afforded by wholly false or exaggerated
anecdotes. I wish to indicate here how this work, illumined by the
three or four positive data which I have given, appears to me to
demand it.
And first, what does that anxiety to conceal his personality prove,
carried as it was to such an extreme degree? The answer rises
spontaneously in the minds of those who have studied closely the
history of literature. The absolute silence about himself, preserved by
one whose position among us was that of a Tourgenief, or of a
Mérimée, and of a Molière or a Shakespeare among the classic great,
reveals, to a person of instinct, a nervous sensibility of extreme
depth. There are many chances for an artist of his kind, however
timid, or for one who has some grief, to show the depth of his
emotion. To take up again only two of the names just cited, this was
the case with the author of "Terres Vierges," and with the writer of
"Colomba."
A somewhat minute analysis of the novels and romances of
Maupassant would suffice to demonstrate, even if we did not know
the nature of the incidents which prompted them, that he also
suffered from an excess of nervous emotionalism. Nine times out of
ten, what is the subject of these stories to which freedom of style
gives the appearance of health? A tragic episode. I cite, at random,
"Mademoiselle Fifi," "La Petite Roque," "Inutile Beauté," "Le Masque,"
"Le Horla," "L'Épreuve," "Le Champ d'Oliviers," among the novels,
and among the romances, "Une Vie," "Pierre et Jean," "Fort comme la
Mort," "Notre Cœur." His imagination aims to represent the human
being as imprisoned in a situation at once insupportable and
inevitable. The spell of this grief and trouble exerts such a power
upon the writer that he ends stories commenced in pleasantry with
some sinister drama. Let me instance "Saint-Antonin," "A Midnight
Revel," "The Little Cask," and "Old Amable." You close the book at
the end of these vigorous sketches, and feel how surely they point to
constant suffering on the part of him who executed them.
This is the leading trait in the literary physiognomy of Maupassant, as
it is the leading and most profound trait in the psychology of his
work, viz., that human life is a snare laid by nature, where joy is
always changed to misery, where noble words and the highest
professions of faith serve the lowest plans and the most cruel egoism,
where chagrin, crime, and folly are forever on hand to pursue
implacably our hopes, nullify our virtues, and annihilate our wisdom.
But this is not the whole.
Maupassant has been called a literary nihilist—but (and this is the
second trait of his singular genius) in him nihilism finds itself
coexistent with an animal energy so fresh and so intense that for a
long time it deceives the closest observer. In an eloquent discourse,
pronounced over his premature grave, Emile Zola well defined this
illusion: "We congratulated him," said he, "upon that health which
seemed unbreakable, and justly credited him with the soundest
constitution of our band, as well as with the clearest mind and the
sanest reason. It was then that this frightful thunderbolt destroyed
him."
It is not exact to say that the lofty genius of De Maupassant was that
of an absolutely sane man. We comprehend it to-day, and, on re-
reading him, we find traces everywhere of his final malady. But it is
exact to say that this wounded genius was, by a singular
circumstance, the genius of a robust man. A physiologist would
without doubt explain this anomaly by the coexistence of a nervous
lesion, light at first, with a muscular, athletic temperament. Whatever
the cause, the effect is undeniable. The skilled and dainty pessimism
of De Maupassant was accompanied by a vigor and physique very
unusual. His sensations are in turn those of a hunter and of a sailor,
who have, as the old French saying expressively puts it, "swift foot,
eagle eye," and who are attuned to all the whisperings of nature.
The only confidences that he has ever permitted his pen to tell of the
intoxication of a free, animal existence are in the opening pages of
the story entitled "Mouche," where he recalls, among the sweetest
memories of his youth, his rollicking canoe parties upon the Seine,
and in the description in "La Vie Errante" of a night spent on the sea,
—"to be alone upon the water under the sky, through a warm
night,"—in which he speaks of the happiness of those "who receive
sensations through the whole surface of their flesh, as they do
through their eyes, their mouth, their ears, and sense of smell."
His unique and too scanty collection of verses, written in early youth,
contains the two most fearless, I was going to say the most
ingenuous, paeans, perhaps, that have been written since the
Renaissance: "At the Water's Edge" (Au Bord de l'Eau) and the
"Rustic Venus" (La Venus Rustique). But here is a paganism whose
ardor, by a contrast which brings up the ever present duality of his
nature, ends in an inexpressible shiver of scorn:
"We look at each other, astonished, immovable,
And both are so pale that it makes us fear."
* * * * * * * *
"Alas! through all our senses slips life itself away."
This ending of the "Water's Edge" is less sinister than the murder and
the vision of horror which terminate the pantheistic hymn of the
"Rustic Venus." Considered as documents revealing the cast of mind
of him who composed them, these two lyrical essays are especially
significant, since they were spontaneous. They explain why De
Maupassant, in the early years of production, voluntarily chose, as
the heroes of his stories, creatures very near to primitive existence,
peasants, sailors, poachers, girls of the farm, and the source of the
vigor with which he describes these rude figures. The robustness of
his animalism permits him fully to imagine all the simple sensations of
these beings, while his pessimism, which tinges these sketches of
brutal customs with an element of delicate scorn, preserves him from
coarseness. It is this constant and involuntary antithesis which gives
unique value to those Norman scenes which have contributed so
much to his glory. It corresponds to those two contradictory
tendencies in literary art, which seek always to render life in motion
with the most intense coloring, and still to make more and more
subtle the impression of this life. How is one ambition to be satisfied
at the same time as the other, since all gain in color and movement
brings about a diminution of sensibility, and conversely? The paradox
of his constitution permitted to Maupassant this seemingly impossible
accord, aided as he was by an intellect whose influence was all
powerful upon his development—the writer I mention above, Gustave
Flaubert.
These meetings of a pupil and a master, both great, are indeed rare.
They present, in fact, some troublesome conditions, the first of which
is a profound analogy between two types of thought. There must
have been, besides, a reciprocity of affection, which does not often
obtain between a renowned senior who is growing old and an
obscure junior, whose renown is increasing. From generation to
generation, envy reascends no less than she redescends. For the
honor of French men of letters, let us add that this exceptional
phenomenon has manifested itself twice in the nineteenth century.
Mérimée, whom I have also named, received from Stendhal, at
twenty, the same benefits that Maupassant received from Flaubert.
The author of "Une Vie" and the writer of "Clara Jozul" resemble each
other, besides, in a singular and analogous circumstance. Both
achieved renown at the first blow, and by a masterpiece which they
were able to equal but never surpass. Both were misanthropes early
in life, and practised to the end the ancient advice that the disciple of
Beyle carried upon his seal: μεμνήσο απιστἔιν—"Remember to
distrust." And, at the same time, both had delicate, tender hearts
under this affectation of cynicism, both were excellent sons,
irreproachable friends, indulgent masters, and both were idolized by
their inferiors. Both were worldly, yet still loved a wanderer's life;
both joined to a constant taste for luxury an irresistible desire for
solitude. Both belonged to the extreme left of the literature of their
epoch, but kept themselves from excess and used with a judgment
marvelously sure the sounder principles of their school. They knew
how to remain lucid and classic, in taste as much as in form—
Mérimée through all the audacity of a fancy most exotic, and
Maupassant in the realism of the most varied and exact observation.
At a little distance they appear to be two patterns, identical in certain
traits, of the same family of minds, and Tourgenief, who knew and
loved the one and the other, never failed to class them as brethren.
They are separated, however, by profound differences, which perhaps
belong less to their nature than to that of the masters from whom
they received their impulses: Stendhal, so alert, so mobile, after a
youth passed in war and a ripe age spent in vagabond journeys, rich
in experiences, immediate and personal; Flaubert so poor in direct
impressions, so paralyzed by his health, by his family, by his theories
even, and so rich in reflections, for the most part solitary.
Among the theories of the anatomist of "Madame Bovary," there are
two which appear without ceasing in his Correspondence, under one
form or another, and these are the ones which are most strongly
evident in the art of De Maupassant. We now see the consequences
which were inevitable by reason of them, endowed as Maupassant
was with a double power of feeling life bitterly, and at the same time
with so much of animal force. The first theory bears upon the choice
of personages and the story of the romance, the second upon the
character of the style. The son of a physician, and brought up in the
rigors of scientific method, Flaubert believed this method to be
efficacious in art as in science. For instance, in the writing of a
romance, he seemed to be as scientific as in the development of a
history of customs, in which the essential is absolute exactness and
local color. He therefore naturally wished to make the most
scrupulous and detailed observation of the environment.
Thus is explained the immense labor in preparation which his stories
cost him—the story of "Madame Bovary," of "The Sentimental
Education," and "Bouvard and Pécuchet," documents containing as
much minutiæ as his historical stories. Beyond everything he tried to
select details that were eminently significant. Consequently he was of
the opinion that the romance writer should discard all that lessened
this significance, that is, extraordinary events and singular heroes.
The exceptional personage, it seemed to him, should be suppressed,
as should also high dramatic incident, since, produced by causes less
general, these have a range more restricted. The truly scientific
romance writer, proposing to paint a certain class, will attain his end
more effectively if he incarnate personages of the middle order, and,
consequently, paint traits common to that class. And not only middle-
class traits, but middle-class adventures.
From this point of view, examine the three great romances of the
Master from Rouen, and you will see that he has not lost sight of this
first and greatest principle of his art, any more than he has of the
second, which was that these documents should be drawn up in
prose of absolutely perfect technique. We know with what passionate
care he worked at his phrases, and how indefatigably he changed
them over and over again. Thus he satisfied that instinct of beauty
which was born of his romantic soul, while he gratified the demand of
truth which inhered from his scientific training by his minute and
scrupulous exactness.
The theory of the mean of truth on one side, as the foundation of the
subject,—"the humble truth," as he termed it at the beginning of
"Une Vie,"—and of the agonizing of beauty on the other side, in
composition, determines the whole use that Maupassant made of his
literary gifts. It helped to make more intense and more systematic
that dainty yet dangerous pessimism which in him was innate. The
middle-class personage, in wearisome society like ours, is always a
caricature, and the happenings are nearly always vulgar. When one
studies a great number of them, one finishes by looking at humanity
from the angle of disgust and despair. The philosophy of the
romances and novels of De Maupassant is so continuously and
profoundly surprising that one becomes overwhelmed by it. It
reaches limitation; it seems to deny that man is susceptible to
grandeur, or that motives of a superior order can uplift and ennoble
the soul, but it does so with a sorrow that is profound. All that
portion of the sentimental and moral world which in itself is the
highest remains closed to it.
In revenge, this philosophy finds itself in a relation cruelly exact with
the half-civilization of our day. By that I mean the poorly educated
individual who has rubbed against knowledge enough to justify a
certain egoism, but who is too poor in faculty to conceive an ideal,
and whose native grossness is corrupted beyond redemption. Under
his blouse, or under his coat—whether he calls himself Renardet, as
does the foul assassin in "Petite Roque," or Duroy, as does the sly
hero of "Bel-Ami," or Bretigny, as does the vile seducer of "Mont
Oriol," or Césaire, the son of Old Amable in the novel of that name,—
this degraded type abounds in Maupassant's stories, evoked with a
ferocity almost jovial where it meets the robustness of temperament
which I have pointed out, a ferocity which gives them a reality more
exact still because the half-civilized person is often impulsive and, in
consequence, the physical easily predominates. There, as elsewhere,
the degenerate is everywhere a degenerate who gives the impression
of being an ordinary man.
There are quantities of men of this stamp in large cities. No writer
has felt and expressed this complex temperament with more justice
than De Maupassant, and, as he was an infinitely careful observer of
milieu and landscape and all that constitutes a precise middle
distance, his novels can be considered an irrefutable record of the
social classes which he studied at a certain time and along certain
lines. The Norman peasant and the Provençal peasant, for example;
also the small officeholder, the gentleman of the provinces, the
country squire, the clubman of Paris, the journalist of the boulevard,
the doctor at the spa, the commercial artist, and, on the feminine
side, the servant girl, the working girl, the demi-grisette, the street
girl, rich or poor, the gallant lady of the city and of the provinces, and
the society woman—these are some of the figures that he has
painted at many sittings, and whom he used to such effect that the
novels and romances in which they are painted have come to be
history. Just as it is impossible to comprehend the Rome of the
Cæsars without the work of Petronius, so is it impossible to fully
comprehend the France of 1850-90 without these stories of
Maupassant. They are no more the whole image of the country than
the "Satyricon" was the whole image of Rome, but what their author
has wished to paint, he has painted to the life and with a brush that
is graphic in the extreme.
If Maupassant had only painted, in general fashion, the characters
and the phase of literature mentioned, he would not be distinguished
from other writers of the group called "naturalists." His true glory is in
the extraordinary superiority of his art. He did not invent it, and his
method is not alien to that of "Madame Bovary," but he knew how to
give it a suppleness, a variety, and a freedom which were always
wanting in Flaubert. The latter, in his best pages, is always strained.
To use the expressive metaphor of the Greek athletes, he "smells of
the oil." When one recalls that when attacked by hysteric epilepsy,
Flaubert postponed the crisis of the terrible malady by means of
sedatives, this strained atmosphere of labor—I was going to say of
stupor—which pervades his work is explained. He is an athlete, a
runner, but one who drags at his feet a terrible weight. He is in the
race only for the prize of effort, an effort of which every motion
reveals the intensity.
Maupassant, on the other hand, if he suffered from a nervous lesion,
gave no sign of it, except in his heart. His intelligence was bright and
lively, and above all, his imagination, served by senses always on the
alert, preserved for some years an astonishing freshness of direct
vision. If his art was due to Flaubert, it is no more belittling to him
than if one call Raphael an imitator of Perugini.
Like Flaubert, he excelled in composing a story, in distributing the
facts with subtle gradation, in bringing in at the end of a familiar
dialogue something startlingly dramatic; but such composition, with
him, seems easy, and while the descriptions are marvelously well
established in his stories, the reverse is true of Flaubert's, which
always appear a little veneered. Maupassant's phrasing, however
dramatic it may be, remains easy and flowing.
Maupassant always sought for large and harmonious rhythm in his
deliberate choice of terms, always chose sound, wholesome
language, with a constant care for technical beauty. Inheriting from
his master an instrument already forged, he wielded it with a surer
skill. In the quality of his style, at once so firm and clear, so gorgeous
yet so sober, so supple and so firm, he equals the writers of the
seventeenth century. His method, so deeply and simply French,
succeeds in giving an indescribable "tang" to his descriptions. If
observation from nature imprints upon his tales the strong accent of
reality, the prose in which they are shrined so conforms to the genius
of the race as to smack of the soil.
It is enough that the critics of to-day place Guy de Maupassant
among our classic writers. He has his place in the ranks of pure
French genius, with the Regniers, the La Fontaines, the Molières. And
those signs of secret ill divined everywhere under this wholesome
prose surround it for those who knew and loved him with a pathos
that is inexpressible.
Paul Bourget

INTRODUCTION

Born in the middle year of the nineteenth century, and fated


unfortunately never to see its close, Guy de Maupassant was probably
the most versatile and brilliant among the galaxy of novelists who
enriched French literature between the years 1800 and 1900. Poetry,
drama, prose of short and sustained effort, and volumes of travel and
description, each sparkling with the same minuteness of detail and
brilliancy of style, flowed from his pen during the twelve years of his
literary life.
Although his genius asserted itself in youth, he had the patience of
the true artist, spending his early manhood in cutting and polishing
the facets of his genius under the stern though paternal mentorship
of Gustave Flaubert. Not until he had attained the age of thirty did he
venture on publication, challenging criticism for the first time with a
volume of poems.
Many and various have been the judgments passed upon
Maupassant's work. But now that the perspective of time is
lengthening, enabling us to form a more deliberate and therefore a
juster, view of his complete achievement, we are driven irresistibly to
the conclusion that the force that shaped and swayed Maupassant's
prose writings was the conviction that in life there could be no phase
so noble or so mean, so honorable or so contemptible, so lofty or so
low as to be unworthy of chronicling,—no groove of human virtue or
fault, success or failure, wisdom or folly that did not possess its own
peculiar psychological aspect and therefore demanded analysis.
To this analysis Maupassant brought a facile and dramatic pen, a
penetration as searching as a probe, and a power of psychological
vision that in its minute detail, now pathetic, now ironical, in its
merciless revelation of the hidden springs of the human heart,
whether of aristocrat, bourgeois, peasant, or priest, allow one to call
him a Meissonier in words.
The school of romantic realism which was founded by Mérimée and
Balzac found its culmination in De Maupassant. He surpassed his
mentor, Flaubert, in the breadth and vividness of his work, and one of
the greatest of modern French critics has recorded the deliberate
opinion, that of all Taine's pupils Maupassant had the greatest
command of language and the most finished and incisive style.
Robust in imagination and fired with natural passion, his
psychological curiosity kept him true to human nature, while at the
same time his mental eye, when fixed upon the most ordinary phases
of human conduct, could see some new motive or aspect of things
hitherto unnoticed by the careless crowd.
It has been said by casual critics that Maupassant lacked one quality
indispensable to the production of truly artistic work, viz.: an
absolutely normal, that is, moral, point of view. The answer to this
criticism is obvious. No dissector of the gamut of human passion and
folly in all its tones could present aught that could be called new, if
ungifted with a view-point totally out of the ordinary plane. Cold and
merciless in the use of this point de vue De Maupassant undoubtedly
is, especially in such vivid depictions of love, both physical and
maternal, as we find in "L'histoire d'une fille de ferme" and "La
femme de Paul." But then the surgeon's scalpel never hesitates at
giving pain, and pain is often the road to health and ease. Some of
Maupassant's short stories are sermons more forcible than any moral
dissertation could ever be.
Of De Maupassant's sustained efforts "Une Vie" may bear the palm.
This romance has the distinction of having changed Tolstoi from an
adverse critic into a warm admirer of the author. To quote the
Russian moralist upon the book:

"'Une Vie' is a romance of the best type, and in my judgment the


greatest that has been produced by any French writer since
Victor Hugo penned 'Les Misérables.' Passing over the force and
directness of the narrative, I am struck by the intensity, the
grace, and the insight with which the writer treats the new
aspects of human nature which he finds in the life he describes."

And as if gracefully to recall a former adverse criticism, Tolstoi adds:

"I find in the book, in almost equal strength, the three cardinal
qualities essential to great work, viz: moral purpose, perfect
style, and absolute sincerity.... Maupassant is a man whose vision
has penetrated the silent depths of human life, and from that
vantage-ground interprets the struggle of humanity."

"Bel-Ami" appeared almost two years after "Une Vie," that is to say,
about 1885. Discussed and criticised as it has been, it is in reality a
satire, an indignant outburst against the corruption of society which
in the story enables an ex-soldier, devoid of conscience, honor, even
of the commonest regard for others, to gain wealth and rank. The
purport of the story is clear to those who recognize the ideas that
governed Maupassant's work, and even the hasty reader or critic, on
reading "Mont Oriol," which was published two years later and is
based on a combination of the motifs which inspired "Une Vie" and
"Bel-Ami," will reconsider former hasty judgments, and feel, too, that
beneath the triumph of evil which calls forth Maupassant's satiric
anger there lies the substratum on which all his work is founded, viz:
the persistent, ceaseless questioning of a soul unable to reconcile or
explain the contradiction between love in life and inevitable death.
Who can read in "Bel-Ami" the terribly graphic description of the
consumptive journalist's demise, his frantic clinging to life, and his
refusal to credit the slow and merciless approach of death, without
feeling that the question asked at Naishapur many centuries ago is
still waiting for the solution that is always promised but never comes?
In the romances which followed, dating from 1888 to 1890, a sort of
calm despair seems to have settled down upon De Maupassant's
attitude toward life. Psychologically acute as ever, and as perfect in
style and sincerity as before, we miss the note of anger. Fatality is the
keynote, and yet, sounding low, we detect a genuine subtone of
sorrow. Was it a prescience of 1893? So much work to be done, so
much work demanded of him, the world of Paris, in all its brilliant and
attractive phases, at his feet, and yet—inevitable, ever advancing
death, with the question of life still unanswered.
This may account for some of the strained situations we find in his
later romances. Vigorous in frame and hearty as he was, the
atmosphere of his mental processes must have been vitiated to
produce the dainty but dangerous pessimism that pervades some of
his later work. This was partly a consequence of his honesty and
partly of mental despair. He never accepted other people's views on
the questions of life. He looked into such problems for himself,
arriving at the truth, as it appeared to him, by the logic of events,
often finding evil where he wished to find good, but never
hoodwinking himself or his readers by adapting or distorting the
reality of things to suit a preconceived idea.
Maupassant was essentially a worshiper of the eternal feminine. He
was persuaded that without the continual presence of the gentler sex
man's existence would be an emotionally silent wilderness. No other
French writer has described and analyzed so minutely and
comprehensively the many and various motives and moods that
shape the conduct of a woman in life. Take for instance the
wonderfully subtle analysis of a woman's heart as wife and mother
that we find in "Une Vie." Could aught be more delicately incisive?
Sometimes in describing the apparently inexplicable conduct of a
certain woman he leads his readers to a point where a false step
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like