Programming Cocoa With Ruby Create Compelling Mac Apps Using Rubycocoa The Facets of Ruby Series 1st Edition Brian Marick Instant Download
Programming Cocoa With Ruby Create Compelling Mac Apps Using Rubycocoa The Facets of Ruby Series 1st Edition Brian Marick Instant Download
https://ebookbell.com/product/programming-cocoa-with-ruby-create-
compelling-mac-apps-using-rubycocoa-the-facets-of-ruby-
series-1st-edition-brian-marick-2091668
https://ebookbell.com/product/mastering-macos-programming-combine-
macos-programming-with-cocoa-and-swift-3-to-build-powerful-
applications-grimshaw-11409396
https://ebookbell.com/product/ios-12-programming-fundamentals-with-
swift-swift-xcode-and-cocoa-basics-5th-edition-matt-neuburg-22034678
https://ebookbell.com/product/ios-15-programming-fundamentals-with-
swift-swift-xcode-and-cocoa-basics-8th-edition-matt-neuburg-36104646
Ios 9 Programming Fundamentals With Swift Swift Xcode And Cocoa Basics
2nd Edition Matt Neuburg
https://ebookbell.com/product/ios-9-programming-fundamentals-with-
swift-swift-xcode-and-cocoa-basics-2nd-edition-matt-neuburg-5313850
Ios 8 Programming Fundamentals With Swift Swift Xcode And Cocoa Basics
1st Edition Matt Neuburg
https://ebookbell.com/product/ios-8-programming-fundamentals-with-
swift-swift-xcode-and-cocoa-basics-1st-edition-matt-neuburg-5471624
https://ebookbell.com/product/ios-10-programming-fundamentals-with-
swift-swift-xcode-and-cocoa-basics-3rd-edition-matt-neuburg-5563990
https://ebookbell.com/product/ios-11-programming-fundamentals-with-
swift-swift-xcode-and-cocoa-basics-4th-edition-matt-neuburg-10365296
https://ebookbell.com/product/ios-13-programming-fundamentals-with-
swift-swift-xcode-and-cocoa-basics-sixth-edition-matt-neuburg-11903566
https://ebookbell.com/product/ios-14-programming-fundamentals-with-
swift-swift-xcode-and-cocoa-basics-7th-edition-matt-neuburg-11950384
What Readers Are Saying About
Programming Cocoa with Ruby
This isn’t just a book on RubyCocoa; it is probably the best book I’ve
seen that explains Cocoa technology. It actually explains how some of
the core technologies, especially bindings, work instead of just show-
ing an example of how to use them.
Allison Newman
Cocoa application developer
Learning a new API is hard enough, but learning a new API and a new
programming language at the same time can be overwhelming. Pro-
gramming Cocoa with Ruby is written for those of us used to a lan-
guage like Ruby or Python who want to learn about all the great stuff
Cocoa has to offer.
Jeremy McAnally
Developer, entp
Brian Marick
Every precaution was taken in the preparation of this book. However, the publisher
assumes no responsibility for errors or omissions, or for damages that may result from
the use of information (including program listings) contained herein.
Our Pragmatic courses, workshops, and other products can help you and your team
create better software and have more fun. For more information, as well as the latest
Pragmatic titles, please visit us at
http://www.pragprog.com
ISBN-10: 1-934356-19-0
ISBN-13: 978-1-934356-19-7
Printed on acid-free paper.
P1.0 printing, July 2009
Version: 2009-8-6
Contents
1 Introduction 11
1.1 What Is Cocoa? . . . . . . . . . . . . . . . . . . . . . . . 12
1.2 What Is RubyCocoa? . . . . . . . . . . . . . . . . . . . . 12
1.3 What’s It Like to Learn Cocoa Using Ruby? . . . . . . . 12
1.4 RubyCocoa? That’s So Last Year! . . . . . . . . . . . . . 13
1.5 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.6 Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.7 Our Example App . . . . . . . . . . . . . . . . . . . . . . 16
1.8 Centuries of the Bookmaker’s Art: Scorned . . . . . . . 18
1.9 Some Terminology . . . . . . . . . . . . . . . . . . . . . 19
1.10 Service After the Sale . . . . . . . . . . . . . . . . . . . . 19
1.11 Solving Problems . . . . . . . . . . . . . . . . . . . . . . 19
1.12 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . 20
II Reshaping Fenestra 75
5 A Better GUI 76
5.1 Toggle Buttons . . . . . . . . . . . . . . . . . . . . . . . 77
5.2 The Default Button . . . . . . . . . . . . . . . . . . . . . 78
5.3 Combo Box Items . . . . . . . . . . . . . . . . . . . . . . 79
5.4 The Initial First Responder . . . . . . . . . . . . . . . . 80
5.5 Try This Yourself . . . . . . . . . . . . . . . . . . . . . . 80
5.6 What Now? . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6 Decoupled Controllers 82
6.1 Ignorant Objects . . . . . . . . . . . . . . . . . . . . . . 83
6.2 Extracting Subclasses . . . . . . . . . . . . . . . . . . . 85
6.3 Reacting to Button State . . . . . . . . . . . . . . . . . . 90
6.4 Using Nibs to Avoid Dependencies . . . . . . . . . . . . 90
6.5 Initializing Combo Boxes . . . . . . . . . . . . . . . . . . 92
6.6 What Now? . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Report erratum
this copy is (P1.0 printing, July 2009)
CONTENTS 7
Report erratum
this copy is (P1.0 printing, July 2009)
CONTENTS 8
Report erratum
this copy is (P1.0 printing, July 2009)
CONTENTS 9
VI Wrapping Up 286
Report erratum
this copy is (P1.0 printing, July 2009)
CONTENTS 10
25 MacRuby 334
25.1 Getting MacRuby . . . . . . . . . . . . . . . . . . . . . . 337
25.2 MacRuby Basics . . . . . . . . . . . . . . . . . . . . . . . 337
25.3 A MacRuby Checklist . . . . . . . . . . . . . . . . . . . . 339
25.4 What Now? . . . . . . . . . . . . . . . . . . . . . . . . . . 343
A Glossary 361
B Bibliography 372
Index 376
Report erratum
this copy is (P1.0 printing, July 2009)
Chapter 1
Introduction
It’s simple, really: if you like Ruby and you like Macs and you want
to put the two together, this book is for you. After you read through
it. . . wait, scratch that—after you work through it, you’ll be able to build
nice, Mac-like apps. You’ll have the memory of doing, at least once,
many of the tasks that make up building a Mac app. Your life will have
much less of the “What do I do now?” frustration that sinks so many
first attempts to use a big and complicated framework.
I endured that frustration for you. When I started writing the book, I
knew practically nothing about coding Mac GUI apps (in Ruby or any
other language). I learned how in my usual way: by diving into coding
something too ambitious. As always happens, I spent much of my time
blundering down blind alleys, staring at app crashes and weird behav-
iors, figuring out what pieces of the conceptual puzzle I was missing,
searching for them in vast masses of documentation, and revisiting old
code in the light of new understanding. The only difference was that
after I figured something out, I wrote a new chapter about what I’d
done and what I’d learned—except that I removed most of the frustra-
tion from the story line. When I had to backtrack because I didn’t know
something, I wrote that something into the story just when I would have
needed it. The result is what Imre Lakatos, the philosopher of science,
called a rational reconstruction of history: follow the book, and I think
you’ll get pretty much the experience I should have had.
That turns out to be a fantastically time-consuming way of writing a
book. The payoff is that, when I wrote, the experience of learning was
fresh in my mind. Experts often have a problem remembering what it
was like to learn and how much they used to not know. I solved that
problem by being barely not ignorant as I wrote.
W HAT I S C OCOA ? 12
Report erratum
this copy is (P1.0 printing, July 2009)
R UBY C OCOA ? T HAT ’ S So L AST Y EAR ! 13
guess whether the framework addresses it, roughly how it will address
it, and where to look to find the details. The aim of this book is to give
you that feel for Cocoa and RubyCocoa. It’s not a reference to the Cocoa
framework because that information is already on your hard drive or,
at most, an HTTP address away.
Still, because no single development history can naturally encounter
every topic and because exploring some topics in enough detail would
be too much of a digression from the story line, the last part of the book
consists of essays on important topics. They can be read in any order,
at any time.
1.5 Prerequisites
• You should have used a Mac enough that you’re familiar with the
conventions Mac apps follow. There’s no need to have ever built an
app with a graphical user interface, whether for the Mac or for any
other platform. You don’t need to understand Objective-C (or C).
• You should know Ruby reasonably well. A good measure of that is
whether you’re comfortable reading parts of someone else’s Ruby
code. If some gems’ behavior surprises you, do you follow a stack
trace into it to see what’s really going on?
I’ll use some tricky Ruby code behind the scenes, but the code
you’ll need to understand will be fairly straightforward. However, I
won’t stop to explain common idioms like this sort of initialization:
@var ||= 5
Report erratum
this copy is (P1.0 printing, July 2009)
P REREQUISITES 14
If you don’t think you know Ruby well enough, I recommend the
Pickaxe book, Programming Ruby [TFH08], possibly supplemented
with The Ruby Way [Ful06]. My own Everyday Scripting with Ruby
[Mar06] teaches Ruby in the same style as this book teaches Ruby-
Cocoa—by having you implement projects alongside the book—
but it may be too slow-paced for an experienced programmer, and
you’ll still want the Pickaxe book for reference.
• Make sure you’re running Apple’s version of Ruby. You can con-
firm that like this:
$ /usr/bin/which ruby
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
1. You had to choose to install the Developer Tools when you installed Leopard. If you
didn’t, you can fetch them off the install disc or from http://developer.apple.com.
Report erratum
this copy is (P1.0 printing, July 2009)
V ERSIONS 15
building your first app is a flood of tasks you vaguely know you
should perform but forget how. It’s better to build up your “muscle
memory” by building the book’s app before you build your own.
• You need to download bmrc-code.zip from http://pragprog.com/titles/
bmrc/source_code. It contains some files and tools you’ll need as
you work through the chapters. When you unzip bmrc-code.zip, it
will place all its contents in a code subdirectory. Since you’ll likely
want to rename that, I’ll leave off the code prefix when referring to
files. So, for example, when I direct you to the very first file you’ll
work on, I’ll refer to it as statusbar/most-basic-app.rb.
The download also contains snapshots of the app taken just before
and after each important step. As you work along, you can copy
snippets from the snapshots or use one of them as a starting point.
The download means that, at any given moment, there may be
thirty-four versions of the app on your disk: thirty-three interme-
diate versions that I supply and one that you’re working on. That
presents a problem. For example, on page 96, I write “look in Win-
dowController to see how it handles the AppChosen notification.”
The problem is that your version might not use the same names
as mine, so it might not handle anything called AppChosen. In that
case, you’ll need to look at my most recent version, not yours. But
which is most recent? You can find that out by looking backward
to the most recent code snippet that identifies its source file. The
following snippet, for example, would tell you we’re working on the
reshaped-with-dsl version of the app:
Download fenestra/reshaped-with-dsl/WindowController.rb
1.6 Versions
The book uses these tools:
• Ruby 1.8.6
• RubyCocoa 0.13.1
• Xcode 3.0
• Interface Builder 3.0
Report erratum
this copy is (P1.0 printing, July 2009)
O UR E XAMPLE A PP 16
These were the most recent versions delivered by Apple at the time of
writing.
When the book also uses libraries or gems, they’re included in the
book’s bmrc-code.zip file.
Report erratum
this copy is (P1.0 printing, July 2009)
O UR E XAMPLE A PP 17
It’s not right, and it’s our fault. We allow our apps to be childish. Every
parent knows how bad children are at answering the two vital ques-
tions: “All right, who did it?” and “What on Earth were you thinking to
make that seem like a good idea?” Trying to figure out a bug with noth-
ing more than a user’s report and the app’s regular GUI is like being
faced with the child who answers every question with “I dunno.” But
going after a bug with general-purpose tools like the language’s debug-
ger is like talking to the child who tries to get out of trouble by throwing
up a smoke screen of detail, irrelevancies, and finger-pointing. What we
need is to build every app with a special window into its inner workings
that programmers and testers can use (Figure 1.1, on the preceding
page).
The main example in this book will be a free-standing app that peeks
and pokes at another app through such a window. I’ll target a web app
in the book because that happens to be what I need right now, but
the same principle and much of the code would apply to any app. A
sketch of it in use is shown in Figure 1.2. It will contain a running log
of actions the web app has taken that is expandable to the desired level
of detail. A click of a button will tell the web app to undo or redo an
action. Our app, helped by the web app, will know when links refer to
domain objects (like user accounts), so the right gesture will pop up an
understandable, tweakable, and draggable representation of the object.
There’s much more that such an app could do, but since this is a book
Report erratum
this copy is (P1.0 printing, July 2009)
C ENTURIES OF THE B OOKMAKER ’ S A R T : S CORNED 18
Report erratum
this copy is (P1.0 printing, July 2009)
S OME T ERMINOLOGY 19
. . . big blank spaces at the bottom of some pages. Text and figures are
traditionally laid out to avoid that ugliness. I embrace it. You deserve
an unattractive book.
I’d normally say that Ruby “sends the message :upcase to the string
"foo".” Sometimes, though, the words sends and message won’t work
in a sentence, so I use “calling the method” instead. There’s nothing
but stylistic significance to the choice—I don’t mean a different thing.
Similarly, when writing of a variable, I might say that it “refers to,”
“names,” or “points at” an object. I might also say it “is” an object—
even though that’s strictly incorrect—because “i names 5” sounds silly.
Report erratum
this copy is (P1.0 printing, July 2009)
A CKNOWLEDGMENTS 20
When it comes to RubyCocoa itself, I’ve used both its source and tests
to answer my questions. I encourage you to download RubyCocoa from
http://rubycocoa.sourceforge.net.
1.12 Acknowledgments
Dawn, light of my life.
The creators of RubyCocoa: Eloy Duran, Fujimoto Hisa, Chris Mcgrath,
Satoshi Nakagawa, Jonathan Paisley, Laurent Sansonetti, Chris
Thomas, Kimura Wataru, and others.
Corey Haines, for spending two days of his Pair Programming Tour2 in
my living room, helping me figure out the mysteries of drag and drop.
My editor, Daniel Steinberg.
Technical reviewers Chris Adamson, Julio Barros, Craig Castelaz,
Michael Ivey, Jerry Kuch, Mathias Meyer, Allison Newman, and Scott
Schram.
Readers of the beta drafts: Steven Arnold, Jason M. Batchelor, Rune
Botten, Tom Bradford, Stephyn G. W. Butcher, Leroy Campbell, Gregory
Clarke, Eloy Duran, Frantz Gauthier, Joseph Grace, Aleksey Gureiev,
Christopher M. Hanson, Cornelius Jaeger, Masahide Kikkawa, Fred-
erick C. Lee, Jay Levitt, Tim Littlemore, Nick Ludlam, Stuart Malin,
Ule Mette, James Mitchum, Steve Ross, Peter Schröder, Jakub Suder,
Tommy Sundström, Matthew Todd, Daniel J. Wellman, Markus Werner,
“Dr. Nic” Williams, and perhaps others whose names I didn’t write
down. (Sorry.)
Although this is a book about RubyCocoa, I’ve snuck in bits and pieces
of a philosophy and pragmatics of application design. It’s a style I
have learned from people such as Kent Beck, Ward Cunningham, Carl
Erickson, Michael Feathers, Martin Fowler, Steve Freeman, Richard P.
2. http://programmingtour.blogspot.com
Report erratum
this copy is (P1.0 printing, July 2009)
A CKNOWLEDGMENTS 21
Report erratum
this copy is (P1.0 printing, July 2009)
Chapter 2
How Do We Get
This Thing Started?
We’re going to start fast, small, and with the fundamentals. To that end,
here’s the smallest RubyCocoa app:
Download statusbar/most-basic-app.rb
#!/usr/bin/env ruby
Ê require 'osx/cocoa'
Ë OSX::NSApplication.sharedApplication
Ì OSX::NSApp.run
If you run it, you’ll see that it does nothing but exist: no windows, no
output, no exit:
$ ruby most-basic-app.rb
The NS prefix is used by all the Cocoa classes you’re ever likely to see.
So, using the module prefix OSX:: isn’t really helping to avoid name
clashes. I’ll usually just include the OSX module and forget about it.
Notice that sharedApplication isn’t an idiomatic Ruby name. In Ruby,
you would be much more likely to see shared_application. It is idiomatic
Objective-C, though. You should expect to see such method names—
and even stranger ones—in RubyCocoa programs.
At Ì, NSApp is told to run. It does, waiting forever for someone to send
it work to do.
#!/usr/bin/env ruby
require 'osx/cocoa'
include OSX
Ì our_object = AppDelegate.alloc.init
NSApplication.sharedApplication # Creates global NSApp
Í NSApp.setDelegate(our_object)
NSApp.run
Report erratum
this copy is (P1.0 printing, July 2009)
A P ROGRAM T HAT P RINTS 24
NSApp
its
Weʼve finished launching delegate
1. Ruby actually works like Objective-C under the covers: new first uses the class
method allocate and then sends initialize to the resulting instance.
Report erratum
this copy is (P1.0 printing, July 2009)
A P ROGRAM T HAT P RINTS 25
NSApp is told of its delegate at Í. Then NSApp starts running. Once the
application setup work is finished, NSApp calls its delegate’s application-
DidFinishLaunching method.
2. What’s the point of knowing an application hasn’t finished launching yet? Certain
things happen between the two events you know about. For example, it’s between them
that an application is told it was started by double-clicking a file. If you want to do any
setup before then, applicationWillFinishLaunching is the time to do it.
Report erratum
this copy is (P1.0 printing, July 2009)
P UTTING AN I TEM IN THE S TATUS B AR 26
#!/usr/bin/env ruby
require 'osx/cocoa'
include OSX
Ì image = NSImage.alloc.initWithContentsOfFile("stretch.tiff" )
Í raise "Icon file 'stretch.tiff' is missing." unless image
Î status_item.setImage(image)
end
end
NSApplication.sharedApplication
NSApp.setDelegate(App.alloc.init)
NSApp.run
Line Ê fetches a reference to the global status bar. Then line Ë allocates
screen space (on the left of all the other items) for the item you are
about to create. The parameter NSVariableStatusItemLength says that the
amount of space needed is unknown yet.
Line Ì uses a handy class that represents an in-memory image. The
next line, Í, quits the program if there was no image file to load. Its
unless check works because NSImage’s init follows the Cocoa conven-
tion of returning nil—rather than the allocated object—when something
goes wrong during initialization. There’s a suitable image file in status-
bar/stretch.tiff.
Report erratum
this copy is (P1.0 printing, July 2009)
M ENUS 27
2.3 Menus
Our status bar item doesn’t do anything, so let’s give it a menu. For
fun, I’ll use it to make the app speak to us. That’s not hard: I’ll use a
Cocoa object, NSSpeechSynthesizer, to turn text into speech.
Before starting that, let’s separate concerns. App will concern itself only
with application-wide events such as being launched and being termi-
nated. A new class, SpeechController, will do everything else.
Here’s the new version of App:
Download statusbar/speaking-statusbar.rb
3. If you’re not working in the statusbar directory, get a copy of statusbar/stretch.tiff from
there before running the script.
Report erratum
this copy is (P1.0 printing, July 2009)
M ENUS 28
In this case, though, I know that NSObject’s init always returns self.
(In fact, it does nothing but return self, so I could omit the line
entirely.)
Ë In an ordinary Ruby class, initialize’s return value is irrelevant. In
contrast, an NSObject subclass must return self (or, in the case of
error, nil). If I’d forgotten line Ë, code like this:
s = SpeechController.alloc.init
s.add_menu_to(status_item)
Report erratum
this copy is (P1.0 printing, July 2009)
M ENUS 29
...
an NSMenu an NSMenuItem
...
a target object
Run that action method
(with an action method)
Download statusbar/speaking-statusbar.rb
def add_menu_to(container)
Ê menu = NSMenu.alloc.init
container.setMenu(menu)
Ë menu_item = menu.addItemWithTitle_action_keyEquivalent(
"Speak" , "speak:" , '' )
Ì menu_item.setTarget(self)
menu_item = menu.addItemWithTitle_action_keyEquivalent(
Í "Quit" , "terminate:" , 'q' )
Î menu_item.setKeyEquivalentModifierMask(NSCommandKeyMask)
Ï menu_item.setTarget(NSApp)
end
Ð def speak(sender)
@synthesizer.startSpeakingString("I have nothing to say." )
end
end
statusbar/speaking-statusbar.rb
Report erratum
this copy is (P1.0 printing, July 2009)
M ENUS 30
what it’s attached to, so long as that object responds to setMenu. Today,
it’s a status bar item. Tomorrow, it could be something else.
Next, an NSMenuItem is created and assigned to the menu by addItem-
WithTitle_action_keyEquivalent (line Ë). What’s up with that name? Objec-
tive-C has an interesting and nearly unique way of naming methods.
Here’s (almost) what Objective-C code that added a menu item would
look like:4
[menu addItemWithTitle: "Speak" action: "speak:" keyEquivalent: "" ]
4. I’ve removed a little type casting because it’s not important to this explanation. To be
pedantic, the title and key equivalent shouldn’t be strings. They should be NSString objects,
which are written as @"string". Similarly, the action argument should be a “selector,” not
a string. You’ll see more—and more correct—examples of Objective-C later in the book.
5. That’s not always safe: consider an Objective-C class that has two methods, action
and action:.
Report erratum
this copy is (P1.0 printing, July 2009)
A N A PPLICATION B UNDLE 31
The speak (Ð) action is simple. Notice that it takes a sender argument,
which will be the NSMenuItem that was clicked. Action methods can use
the sender to query or change the user interface.
If you run the app, you’ll probably notice that the synthesizer takes a
second or two to start talking after you click the menu item. Presumably
it’s doing some first-time initialization. It’s more prompt the second
time.
Use one or more of those methods to change the menu after some-
thing is said.
2. While terminating, NSApp will send its delegate two messages:
applicationShouldTerminate and applicationWillTerminate. The first lets
the delegate decide to cancel shutdown, and the second gives it a
chance to do any of its own cleanup.
Use applicationWillTerminate to print out “Goodbye, cruel world!”
3. Make applicationShouldTerminate return false unless the app has
spoken at least twice, true otherwise. See what happens when you
return values like nil, "fred", and the integer 0.
A small quirk: unlike the delegate messages you’ve seen so far,
applicationShouldTerminate takes an NSApplication as its argument,
so sender or app would be a better name than aNotification.
(If you need help, there’s a solution in statusbar/speaking-statusbar-
solution.rb.)
Report erratum
this copy is (P1.0 printing, July 2009)
A N A PPLICATION B UNDLE 32
Statusbar.app/
Contents/
6. If you’re browsing from the command line, Statusbar.app looks like what it is: a direc-
tory. If you’re browsing with the Finder, it appears to be a single file. That’s because it’s a
package, a special kind of directory that the Finder pretends is a file. All application bun-
dles are packages. You can tell Finder to let you look inside it by selecting Show Package
Contents from Statusbar.app’s context menu.
Report erratum
this copy is (P1.0 printing, July 2009)
A N A PPLICATION B UNDLE 33
Resources/
This directory contains unchanging information the application
might use. The good thing about resources is that their loca-
tion is relative to the bundle itself, so code doesn’t need to use
absolute pathnames or know where it has been installed. Apple’s
Resource Programming Guide [App08v] teaches how to load and
use resources.
Because this is a small program, it has few resources:
Statusbar.icns
.icns files contain the icons shown in the Finder, Dock, and so
on. I create icon files with a drawing program and Icon Com-
poser, which you can find in /Developer/Applications/Utilities.
rb_main.rb
All your Ruby source files are stored as resources.
stretch.tiff
Pictures, sound files, movies: all these are stored in Resources.
For more information about bundles, see Apple’s Bundle Programming
Guide [App08d].
image = NSImage.alloc.initWithContentsOfFile("stretch.tiff" )
That line assumes the script is running in the same directory as the
image file. That’s not true for an application, which should fetch the
image from Resources. That’s done like this:
Download statusbar/Statusbar.app/Contents/Resources/rb_main.rb
Simple enough.
Report erratum
this copy is (P1.0 printing, July 2009)
A N A PPLICATION B UNDLE 34
Log the directory both when double-clicking the app and when
opening it from the shell like this:
$ open Statusbar.app
2. What does the process environment look like when the app is
launched by double-clicking (NSLog(ENV.inspect))?
You should see that it’s pretty sparse, containing nothing you set
in your .bashrc file. Therefore, the common gem-loading trick of
setting the environment variable RUBYOPT to rubygems won’t work
for a RubyCocoa app. Here are three solutions:
a) Just use require ’rubygems’ in your Ruby code. This is probably
the best solution. In Leopard, RubyGems is guaranteed to be
installed.
b) Create a file named ~/.MacOSX/environment.plist. (Note that the
directory starts with a period so that the Finder ignores it.) In
it, place this XML:
Download statusbar/environment.plist
You will have to log out and log back in for the change to take
effect. Once you do, the environment variable will be set for
all applications.
c) Add the following lines to Info.plist:
<key>LSEnvironment</key>
<dict>
<key>RUBYOPT</key>
<string>rubygems</string>
</dict>
Report erratum
this copy is (P1.0 printing, July 2009)
W HAT N OW ? 35
Report erratum
this copy is (P1.0 printing, July 2009)
Part I
Working with
Interface Builder and Xcode
In this chapter, we’ll build a simple GUI that lets us fenestrate an app
(open a window, or fenestra, into its internals). It’s the acorn that will
grow into the mighty oak tree of Section 1.7, Our Example App, on
page 16. It looks like Figure 3.1. We’ll imagine we’ll type the name
of the application we want to fenestrate in the smaller text field, and
information from that app will ooze into the larger text view.
Pick an app:
Report erratum
this copy is (P1.0 printing, July 2009)
T HE B ASICS 39
After you hit Finish, you’ll see something like the following:
This view has nothing to do with the file system structure of the project.
It’s more like a collection of smart folders in the Finder or iTunes. I
won’t give a detailed description of what you see, but notice some files
we edited in Section 2.4, An Application Bundle, on page 31: Info.plist
and rb_main.rb. Those are the source versions of the files that are put in
the application bundle when it’s built.
Click Build and Go on the toolbar now. After a bit of a pause, you
should see this window:
Although you’ve written no code, your app already does some of what
a real app does. You can hide and show it, minimize and zoom it, and
quit it by either using the menu or pressing Command - Q . Quit it now.
Report erratum
this copy is (P1.0 printing, July 2009)
T HE B ASICS 40
Our next job is to make that window have the label, text field, and text
view shown in Figure 3.1, on page 37.
Interface Builder
In the project view, there’s an entry in the right panel called Main-
Menu.nib. You can also see it under the Resources or NIB Files groups
in the left panel. (If you see MainMenu.xib instead, don’t worry; it’s the
same data, just formatted differently.)
You can think of a nib file 1 as describing a user interface, but the
reality is more clever: it’s actually a “frozen” (“marshaled” or “serial-
ized” or “pickled”) user interface. For more about that cleverness, see
Section 11.2, Archiving, on page 134 and Section 14.4, bind_toObject_
withKeyPath_options, on page 192. For now, edit the nib file by double-
clicking its name.
You should see the following five windows, although sized and placed
differently. (If you don’t see all the windows, try selecting Window >
Bring All to Front.)
① ④ ⑤
②
• The main menu is what appears in the menu bar on top of the
screen. You’ll be tinkering with that in Chapter 22, Fit and Finish,
on page 287.
1. The name stands for “name’s irrelevant, basically,” although some claim it stands for
“NeXT Interface Builder.”
Report erratum
this copy is (P1.0 printing, July 2009)
T HE B ASICS 41
• The main window is what the window will look like in the running
app.
• The doc window (or document window) represents the contents of
the nib file in the same way that a window in Pages or Word repre-
sents the contents of a file. The doc window is a Finder-like view
of the objects most important to the user interface. We won’t be
using all of them, and I’ll describe only those we do. A good place
to look for descriptions is in Apple’s Human Interface Guidelines
[App08b].
The doc window starts out using icons, but hereafter I’ll show it
in list view because that lets me save some space in figures. I use
list view in my ordinary programming, too—as the UI gets more
complicated with objects within objects within objects, list view
makes working with them easier.
• The library contains a large set of predefined user interface ele-
ments. Shortly, you’ll be dragging three of them onto the main
window. Dragging is how you build a Cocoa user interface with
Interface Builder.
• The inspector is a tabbed editor for the bazillion-and-two things
you can change about each UI element.
To begin, use the search box at the bottom of the library’s window to
search for text. One of the results will be an element named Label, as
shown in the following images. Drag it into the top-left corner of the
main window. Note that as you get close, guide lines will appear to help
you put it an Apple-approved distance from the edges of the window.
Report erratum
this copy is (P1.0 printing, July 2009)
T HE B ASICS 42
After you drop the label, double-click it to edit its text. Change it to
“Pick an app:” or whatever you like.
The library will also contain text fields and text views. Drag them into
the window. Note that, when selected, they have drag handles that let
you resize them. Make a window that looks something like the following:
Report erratum
this copy is (P1.0 printing, July 2009)
T HE B ASICS 43
Once you’ve put IB’s doc window in list mode, you can see the view
structure of your window by expanding the NSWindow:
• The content view covers the entire space of the window. It contains
all the other views.
• The label and text field cover part of the content view. Notice
that they are both NSTextField objects—their different appearance
is entirely because of how they’re initialized. (See Section 3.5,
Attributes, on page 58, for more.)
• What seems like a simple text view is actually its own hierarchy of
objects. An NSScrollView contains the actual NSTextView and also two
scrollers. One of them (the vertical scroller) takes up some space
even when there’s no need for a scrollbar, but the other is invisible
until it’s needed.
• If there were other visible objects in the window, even ones as
insignificant as a vertical line used as a separator, they’d be NSView
objects too. (A line is an NSBox, just a very, very thin one.)
You’ll eventually need to know more about views to answer questions
like “What object handles a mouse click?” and “What object handles
keypresses?” This book will answer those questions only in the con-
text of Fenestra. For complete details, see Apple’s Cocoa Event-Handling
Guide [App08h].
Report erratum
this copy is (P1.0 printing, July 2009)
T HE B ASICS 44
Speak
class SpeechController < NSObject
Quit
...
def speak(sender)
@synthesizer.startSpeakingString(...)
end
...
end
. . . and this:
@synthesizer = NSSpeechSynthesizer.alloc.init
That kind of code is boring to write. Interface Builder can usually elim-
inate the need for it. All you need to do is create objects and draw lines
between them. The objects and wiring instructions are stored in the nib
file and decoded when the app starts up.
1. We already have almost all the objects that need to be wired to-
gether: you can see them in the main window and the doc window.
Those are all UI objects, though, and we need one more to serve
as the target of actions, the so-called controller.
Report erratum
this copy is (P1.0 printing, July 2009)
T HE B ASICS 45
2. Now we can add detail. With the new object selected, pick the
Identity (sixth) tab in the inspector. The result should look like the
following:
Report erratum
this copy is (P1.0 printing, July 2009)
T HE B ASICS 46
Interface Builder now knows that Controller exists (or will exist) and
needs two connections.
Report erratum
this copy is (P1.0 printing, July 2009)
T HE B ASICS 47
2. Our outlet and action show up there. Their lines have little circles
at the end. If you click the one for the log outlet, you can drag a
line to the text view in the main window, as shown in the follow-
ing figures. Make sure to drop the end of the line in the “Lorem
ipsum” text; if you drop it below there, you’ll actually be making
a connection to the scroll view that contains the text view. Check
the tooltip to make sure.
In IB 3.0, the inspector loses track of what it’s inspecting when you
drop the far end of the connection. Worse, clicking the Controller in
the doc window doesn’t get it back. What I do is click some other
object (like the text view) and then click the Controller again. (Later
versions of IB don’t have this problem.)
Report erratum
this copy is (P1.0 printing, July 2009)
C REATING AND E DITING C LASSES IN X CODE 48
Once you’ve made the connection correctly, the log entry in the
Connections tab will now describe the other end as “Text View,”
as shown here:
Report erratum
this copy is (P1.0 printing, July 2009)
C REATING AND E DITING C LASSES IN X CODE 49
Select the Ruby NSObject subclass. Name the new file Controller.rb. Al-
though that’s unidiomatic Ruby, it seems to make Xcode happier.
When that’s finished, you’ll see something like this:
(The comment at the head of the file will look different. If you want to
peek ahead and see how to make it include your name and company
name, see Section 22.6, The About Window, on page 297.)
Report erratum
this copy is (P1.0 printing, July 2009)
C REATING AND E DITING C LASSES IN X CODE 50
①
②
④
⑤
The arrows point out the parts of the browser I find most helpful:
1. I use the search field to find documentation for classes and meth-
ods whose name I know. To go from “I need to do X ” to ”I need
to use class Y,” I use Google. I find it does a better job of finding
relevant hits in Apple non-API documentation than does Xcode’s
search or the one at Apple’s Developer Connection website.3
2. If you have a similar experience (which you might not), you can
restrict search results to the API with the button on the far left
of this bar. Toward the middle, there’s an All Languages button,
which means in practice “include the Java API.” That’s not useful,
so I turn it off.
3. In the middle of this bar, there’s a drop-down list that contains
the class name. If you open it, you’ll get quick access to instance
and class methods.
At the right, marked with a “C,” you can get quick access to super-
class and subclass documentation.
3. http://developer.apple.com/
Report erratum
this copy is (P1.0 printing, July 2009)
Other documents randomly have
different content
pensée, il n'a pu cependant y échapper. Il est le fils du XVIIIe siècle.
Avec sa foi dans le progrès indéfini du genre humain, c'est une
bouture de Condorcet. Mais—disons-le à son éloge!—le XVIIIe siècle,
dont il procède, n'a pu lui donner ce mépris de brute pour les
problèmes surnaturels qui distingue ses plus beaux génies. Dieu,
l'âme, son essence et ses destinées, les hiérarchies spirituelles, etc.,
sont restés des questions pour Jean Reynaud, et des questions que
le panthéisme contemporain ne résoud pas. En vertu de son genre
d'intelligence, la notion théologique n'a donc pas été abolie en lui,
mais seulement obscurcie et faussée. Et voilà justement ce qui a
produit, sous la plume de ce philosophe singulier qui a le coup de
marteau de la théologie, un chaos également monstrueux pour les
théologiens et pour les philosophes! Voilà pourquoi il a mutilé, au
nom de la théologie, le triple monde que la théologie enseigne, et
qu'il le réduit à un seul dans son livre, malgré son double titre de
Terre et Ciel!
Mais rien de tout cela. Le livre de Jean Reynaud est et reste tout
simplement une hypothèse, qu'on propose, mais qu'on n'impose
pas... Ils savent très bien risquer le faux, les philosophes, mais ils ne
sont jamais assez sûrs que le faux qu'ils risquent est le vrai pour
avoir l'aplomb d'en faire un symbole. Ceci n'est réservé qu'aux
prêtres. Nous l'avons dit déjà, ce traité de Terre et Ciel, qui n'a de
grave que le ton, agrandit vainement et cache mal, sous le trompe-
l'œil des détails scientifiques, une théorie qui, réduite à ses plus
simples termes, n'est que ridicule et... immorale; car voilà son côté
sérieux! La métempsycose, ou la transformation successive de
l'humanité, emporte la morale humaine dans sa visible absurdité. Si
cette transformation qui recommence toujours est en effet la loi du
monde, tous les crimes et même l'assassinat ne sont plus que des
dérangements de molécules qui sauront toujours bien se
reconstituer, et l'affreux poète du suicide avait bien raison quand il
chantait:
De son sort l'homme seul dispose!
Il a toujours, quand il lui plaît,
Dans la balle d'un pistolet,
La clef de sa métamorphose!
I
Intellectuellement, c'est une frégate à la mer que la publication de
ces œuvres[7] de Donoso Cortès. Chargés de vérité et, pour ainsi
parler, pavoisés des couleurs d'un grand talent, dont le caractère est
l'éclat, ces trois volumes, comme le vaisseau que montait l'aïeul de
Cortès pour aller à la conquête d'un monde, s'en vont à la conquête
des âmes, qui sont aussi des mondes, et peut-être plus difficiles à
conquérir... Quelle que soit leur destinée, c'est un service rendu à
l'Église que d'avoir pensé à les traduire et à les publier dans cette
langue française qui n'est pas seulement, comme on l'a dit, la langue
de la diplomatie et de la philosophie, mais qui est plus qu'une autre
la langue de la propagation et de la foi.
Du reste, catholiques avant tout, ils n'ont point publié les œuvres
complètes du marquis de Valdegamas. Ils ont laissé la littérature de
l'homme exclusivement littéraire (Donoso Cortès l'avait été un
moment), et ils n'ont pris dans ses travaux que ce que le
catholicisme a animé de son inspiration toute-puissante. Ils se sont
donc strictement renfermés dans l'œuvre catholique de Donoso,
trouvant le reste de peu de signifiance, même pour sa gloire. En
cela, ils ont sainement jugé.
II
Et la preuve, elle est ici, dans ces œuvres qui ne sont pas complètes,
mais choisies. Trop facile à donner si nous examinions l'intégralité
des écrits de Donoso Cortès, cette preuve ne brille que mieux en ces
œuvres partielles, réunies par ces deux sœurs pieuses, l'admiration
et l'amitié. Les éditeurs de Donoso ont publié, avec son ouvrage
principal: l'Essai sur le catholicisme, le libéralisme et le socialisme,
qui a fixé sa gloire et qui la gardera, beaucoup de discours, d'articles
de journaux, de lettres datées de diverses époques, et il en est
plusieurs de celles-là où, comme tant de ses contemporains, Donoso
Cortès, trop fort d'esprit pour n'avoir pas le respect du catholicisme,
reculait encore devant la pratique, cet effroi des lâches, sans laquelle
il est impossible au penseur le plus fort de se justifier tout son
respect.
III
Donoso Cortès, qui a toujours raison quand il est entièrement
catholique, est donc un grand écrivain dont la Critique est appelée,
aujourd'hui qu'on publie ses œuvres, à dire les défauts et leur
étendue, les qualités et leur limite. Son mérite le plus net, à nos
yeux, le plus grand honneur de sa pensée, c'est d'avoir ajouté à une
preuve infinie; c'est, après tant de penseurs et d'apologistes qui,
depuis dix-huit cents ans, ont dévoilé tous les côtés de la vérité
chrétienne, d'avoir montré, à son tour, dans cette vérité, des côtés
que le monde ne voyait pas; c'est, enfin, d'avoir, sur la chute, sur le
mal, sur la guerre, sur la société domestique et politique, été
nouveau après le comte de Maistre et le vicomte de Bonald, ces
imposants derniers venus! La vérité a des fonds de sac étonnants et
inépuisables. On croit que c'est la fin, et voilà que tout recommence,
sans se répéter!
Le style d'un homme, lorsque cet homme n'est pas assez fort pour le
faire avec sa seule manière de sentir, a ses origines. Pascal, par
exemple, c'est Montaigne, plus la manière de sentir de Pascal, et
cette manière, c'était l'épouvante, l'effarement, le cabrement devant
l'abîme. L'origine du style de Donoso Cortès est saint Augustin dans
ses Confessions. Saint Augustin l'attire par sa tendresse, la grande
qualité de son esprit et de son âme. Il l'attire aussi par son défaut
peut-être, car saint Augustin, sous les magnificences de son génie,
comme Donoso Cortès sous le sien, cache son atome de rhéteur.
IV
Tel nous trouvons en ces trois volumes le talent du marquis de
Valdegamas. Plus oratoire que littéraire, Donoso Cortès a, même
lorsqu'il s'efforce d'être didactique, comme dans son Essai sur le
catholicisme, le libéralisme et le socialisme, les aspirations, les
apostrophes, le mouvement et le redoublement antithétique. Il a de
l'orateur: Il doit avoir lu immensément les sermonnaires. Il a les
grands mots oratoires qui une fois dits ne s'oublient plus: «Ou un
seul homme—dit-il un jour—suffirait pour sauver la société: cet
homme n'existe pas; ou, s'il existe, Dieu dissout pour lui un peu de
poison dans les airs!» Un autre jour: «Dieu a fait la chair pour la
pourriture, et le couteau pour la chair pourrie.» Et encore: «Où que
l'homme porte ses pas, il la rencontre (la douleur), statue muette et
en larmes, toujours devant lui!» Rappelez-vous ce qu'il dit une fois
de Sainte-Hélène: «Napoléon, le maître du monde, devait mourir
séparé du monde par un fossé dans lequel coulerait l'Océan.» Il
parle quelque part de je ne sais quelle doctrine indigne de la
majesté de l'absurde.
V
Nous avons dit que l'ouvrage principal de Donoso Cortès, le seul qui
lui gardera dans la postérité cette gloire à laquelle il ne tint point
durant sa vie, était son Essai sur le catholicisme, le libéralisme et le
socialisme, et c'est même le seul ouvrage régulièrement composé
qu'il ait laissé parmi ses œuvres. Turbulences dans un temps
turbulent, cris éloquents poussés sous la pression des circonstances,
les autres écrits de Donoso Cortès, discours, articles de journaux ou
lettres, ne sont pas des livres à proprement parler et dont la Critique
puisse donner l'anatomie.
On les lira encore quelque temps, puis ils tomberont des mains, ne
laissant dans les esprits d'autre impression que l'impression du bruit
qu'ils firent, et ce sera bientôt effacé. Les journalistes et les orateurs
sont plus mortels que les autres hommes. Ils se résolvent mieux et
plus vite en poussière. Voix de la bouche, voix de la plume, qui se
sont fiées à l'air, à cette petite bouffée de vent dans laquelle elles
ont parlé... Le vent ne les trahit pas, et il les emporte! Quoiqu'il ait
eu, comme orateur, ses deux à trois moments sublimes, Donoso
Cortès, ni dans le journal ni à la tribune, n'a été un de ces voyants à
distance, qu'on nous passe le mot! un de ces prophètes de longueur
qu'il faut forcément être si, comme orateur ou comme journaliste, on
a la prétention, que je trouve un peu forte, de ne pas mourir.
Dans ses Lettres sur la France en 1851, il parcourt, jour par jour, le
cercle que toutes les intelligences de ce temps, quand elles n'étaient
pas folles, ont pu parcourir; mais je ne vois rien là de prédominant
et de supérieur.
Les événements lui donnent dans les yeux de leur impalpable cendre
de chaque jour et font ciller ses mélancoliques paupières, qui n'ont
pas l'immobilité de celles de l'aigle. Lorsque ailleurs, je crois, sur
cette immense et noire tenture de mort dans laquelle il voit l'Europe
enveloppée (et qui l'est... peut-être), il se mêle de découper de
petites prophéties spéciales, il ne réussit pas. Il manque son coup:
«Si la Russie—dit-il—entre en Allemagne, il n'y a plus qu'à accepter,
en y ajoutant le mot de Napoléon: L'Europe sera républicaine ou
cosaque... si elle n'est catholique», et pourtant rien de tout cela
n'est arrivé. La peur, comme l'espoir, voit plus grand que nature.
Le vieux monde s'est rassis sur ses vieux fondements, et ç'a été
tout. Évidemment, la gloire vraie de Donoso Cortès n'est point dans
des perspicacités de cet ordre. Elle est ailleurs, et c'est dans son
Essai sur le catholicisme qu'il faut la chercher.
Elle est aussi dans cette philosophie de l'histoire qu'on trouve, dès
1849, dans la lettre, datée de Berlin, à Montalembert, et qui est
d'ailleurs la vue génératrice de toutes les vérités de l'Essai, lesquelles
sont nombreuses. Cette vue exprimée et développée déjà par
Donoso Cortès, et qu'il démontre, à savoir: le triomphe naturel du
mal sur le bien, et le triomphe surnaturel de Dieu sur le mal, par le
moyen d'une action directe personnelle et souveraine, n'avait jamais
été formulée avec cette plénitude et cette vigueur. C'est dans la
radieuse clarté de cette vue complète que Donoso écrivit l'Essai, qui
est tout ensemble la plus profonde apologie du dogme catholique et
une attaque contre les doctrines contemporaines dont le but est
d'abattre ce dogme et de le ruiner.
Dans cette réplique d'un siècle à un autre par ses plus grands
hommes, le comte de Maistre,—avec son esprit merveilleux, si
aristocratique, si français, et ce don de plaisanterie charmante qui
était comme la fleur de son profond génie,—le comte de Maistre
tient naturellement la place de Voltaire, et c'est bien le Voltaire du
catholicisme, en effet. Bonald, qui en est le Montesquieu, Bonald,
éloquent à force de dialectique, s'y oppose vivement à Rousseau, et,
chose singulière et piquante! Donoso Cortès, du pays du Cid et de
sainte Thérèse, Donoso Cortès, qui a mis toutes les sciences de la
terre aux pieds de la théologie, y fait vis-à-vis et contraste au
naturaliste Franklin!
VI
Les œuvres choisies de Donoso Cortès sont précédées d'une
introduction de Louis Veuillot, qui, comme il nous l'apprend, fut l'ami
du marquis de Valdegamas. Cette introduction est de la placidité
pleine de force qu'ont les chrétiens quand ils regardent deux choses
tristes:—le monde et un tombeau. Elle n'a point de chétive petite
mélancolie.
I
L'Essai de philosophie religieuse d'Émile Saisset veut à toute force
être modeste. C'est une composition très travaillée en modestie. On
s'attendait peu à ce ton, agréable du reste, et convenable surtout,
de la part de Saisset, un des diacres de Cousin, qui proclamait, il y a
peu d'années, que les philosophes «étaient désormais les seuls
prêtres de l'avenir,» et cela avec le contentement fastueux d'un
homme qui en tenait sous clef tout un petit séminaire. Saisset,
professeur, et, si je ne me trompe, suppléant de Cousin, lequel, lui, a
donné sa démission de philosophe entre les mains des dames et est
entré dans les pages de madame de Longueville, Saisset a baissé
infiniment de note depuis le temps où il se croyait un prêtre et, qui
sait? peut-être un évêque des temps futurs. Sa religion de l'avenir lui
paraît, en ce moment, fort menacée, et son livre est un cri d'alarme;
mais un cri d'alarme discrètement poussé, car tout est discret dans
Saisset: le ton, le talent, et même la peur.
II
Mais, si Saisset a vu très juste dans les circonstances
contemporaines, et si la question morale et intellectuelle du monde
doit s'agiter entre les conséquents du catholicisme et les
conséquents du panthéisme, a-t-il vu également juste en croyant
possible d'établir, ou, pour parler aussi modestement que lui, de
pressentir une troisième solution à introduire, en catimini, sous les
regards de l'opinion, avec des patelinages de plume qui montrent au
moins de la souplesse dans son talent? Si la question philosophique
du temps présent est, comme il l'a dit et comme je le crois, la
question de la personnalité divine; si, au terme où est arrivé l'esprit
humain, il faut, de rigueur, être pour l'homme-Dieu tel que la religion
de Jésus-Christ nous l'enseigne, ou pour le Dieu-homme tel que
l'établit Hegel, Saisset, qui veut bien du sentiment chrétien, mais qui
ne veut pas de la religion chrétienne, et qui, non plus, ne veut pas
du panthéisme, qu'il hait comme un voleur d'héritage parce qu'il le
priverait de la succession sur laquelle il a compté, Saisset, à qui je
ne demanderai pas plus qu'il ne peut me donner, a-t-il fait, du
moins, dans son Essai de philosophie religieuse, pour le compte de
la personnalité divine, quelque découverte qui fasse avancer cette
question?
Ce n'est pas même une théorie. Ce sont des affirmations peu carrées
et peu appuyées, mais rondes plutôt et glissantes, de ces inductions
données cent fois par l'école cartésienne tout entière, cette école du
moi qui n'a jamais su jeter de pont d'elle à Dieu et dont l'auteur de
l'Essai d'une philosophie religieuse a répété, sans les varier, les
termes connus. Ce n'est ni plus ni moins qu'un petit catéchisme
cartésien à l'usage des faibles qui ne veulent pas devenir forts, car la
force, c'est une témérité pour les prudents, et la force serait, sur
cette question de Dieu, de s'élever plus haut qu'une philosophie qui
la pose, l'agite, mais n'a jamais pu la résoudre.
III
Mais, si le livre de Saisset est d'une si profonde nullité dans sa partie
affirmative, nous serons assez juste pour revenir et pour insister sur
la valeur de la partie négative ou critique de son ouvrage. Cette
partie négative, d'ailleurs, est toujours la meilleure chez tous les
philosophes, ce qui, par parenthèse, est un cruel arrêt, implicitement
porté par les faits, contre la philosophie elle-même. Les philosophes
ne sont vraiment forts que les uns contre les autres. Sans leurs
erreurs mutuelles, que seraient-ils?...
Saisset, qui n'a jamais été une de ces supériorités qui ont, de génie,
le droit de haute et basse justice sur les systèmes couverts du porte-
respect des grands noms, Saisset, qui ne fut jamais rien de
beaucoup plus qu'un joli sujet en philosophie, n'en a pas moins
exercé la magistrature du bon sens et de la raison, en maint endroit
de ses critiques, contre des hommes de l'imposance d'un Leibnitz,
d'un Descartes, d'un Kant, d'un Spinoza. Je sais bien qu'en relevant
l'erreur il reste courbé devant celui qui l'a produite, et je reconnais là
le joli sujet dont je parlais tout à l'heure, respectueux pour ses
maîtres et obstiné au respect pour eux, malgré leurs plus honteuses
et leurs plus dangereuses folies.
Eh bien, cela est inférieur! Il est inférieur aussi, après avoir conclu
au particulier dans chacune de ces biographies intellectuelles, de
n'avoir pas su conclure au général et, après avoir fait passer
philosophes et systèmes par le creuset de l'analyse, de n'avoir pas
jaugé d'un dernier regard la puissance en soi de la philosophie. Otez,
en effet, les vérités indémontrables et nécessaires à la vie et à la
pensée humaines qu'on savait avant les philosophes et auxquelles ils
n'ont pas donné un degré de certitude de plus,—le nombre infini de
leurs sophismes laborieux,—les forces d'Hercule perdues par eux
pour saisir le faux ou le vide,—le mal social de leurs doctrines, qui
n'ont pas même besoin d'être grandes pour produire les plus grands
maux,—ôtez cela, après l'avoir pesé, et dites-moi ce qui reste de
tous ces philosophes et de toutes ces philosophies, même de ceux
ou de celles qui paraissent le plus des colosses!
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.
ebookbell.com