Thinking in Patterns with Java V0.9: chapter 17: Multiple languages: TIPatterns.htm#_Toc41169757
1, Sections:
Multiple languages 120
Interpreter motivation. 121
Python overview.. 122
Built-in containers. 123
Functions. 124
Strings. 125
Classes. 127
Creating a language. 130
Controlling the interpreter. 134
Putting data in. 134
Getting data out. 140
Multiple interpreters. 143
Controlling Java from Jython 144
Inner Classes. 148
Using Java libraries. 148
Inheriting from Java library classes 150
Creating Java classes with Jython 151
Building the Java classes from the Python code 156
The Java-Python Extension (JPE) 157
Summary. 157
Exercises
2, The main content and feeling:
First at all, let me remember a fact, this book is written at 3 years ago,
too many changes has been taken, so I think the language Python introduced
by Bruce in this book has many changes. And, there are many kinds of other languages maybe has present.
Then, let us see what has been told in this chapter.
At last, two days' reading without installing Python or Jython, I get a
conclusion: Python, maybe is the best lovely program language of Bruce's. The
most part of this chapter is introducing Python. On the other hand, the Interpreter Pattern in this Design patterns book is a little part of this chapter.
What is Interpreter Pattern?
It says:
|
Note, although in almost all applications there are some factors that end
user can change it by some ways, for example, input something or press some
buttons, etc.. But, in a interpreter pattern, it provides end users the most probability for custom there many factors by simple programming.
And, a ready for use this kind of Interpreter system introduced by Bruce is
Jython, a pure Java implementation of Python language. Of course, you can
write your own Interpreter sytem. But it seems too unecessary.
Along with Bruce's lines, I got some about Python and Jython, and this is
almost real the first touch of this language for me. I can understand little
bit of examples in this book without to run it under *ython.
Use some sentences in this book to summary the understanding for *ython of
mine.
|
|
...
If you program with *ython, no redundant charactor typing. And it can be
worked together with java very well. All the Jython class and Java class can
almost interact without any problem. And, if you need native Python program
interact with Java, a resolution called The Java-Python Extension (JPE) can be
used.
In this book, Bruce says maybe a new Design Pattern called Multiple Language
can be invented. In this way, mixing languages to resolve a question can be
better than using only one language. All the languages has its advantage and
shortage, mix them is a good idea.
Bruce says:
|
But, I doubt that "5-10 times faster than C++ or Java", although I am not a
professional programmer(I don't work in IT), I think it is impossible that a
language has 5-10 times development speed than others. Because, building an
application need not only coding, but also many other works. I suppose, Python is good at coding, at building a good classes system, but, what classes are we need? How do they interact with each other? etc.. These kind of things is can't be reduced many only by a language.
But, maybe, "Python?s extremely rapid development" is only refer to coding,
and mix this coding process with "Java's architecture" which is good at
building system architecture.
3, Questions about programming:
1), if you create fields using the C++/Java style, they implicitly become static fields.
2),
In addition, Jython’s JavaBean awareness means that a call to any method with a name that begins with “set” can be replaced with an assignment, as you can see above.
You are not required to inherit from Object; any other Java class will do.
Note that it?s important that the directory where the target lives be specified, so that the makefile will create the Java program with the minimum necessary amount of rebuilding.
4, Questions about english language:
1), Strange words:
advantageous, arbitrarily, stuck, tedious, Interpreter, distraction, for-profit, royalties, basically, incorporating, scales up, purity, referred to, marvelous, affirmative, subsequent, add-on, acknowledged, associative, formalize, takes on, imitate, verbiage, signature, other than, tuple, control over, decimal place, spare, set off, turns out to be, aggressively, albeit, penchant, comma, from within, deceptively, thorough, further down, ambiguous, back and forth, it is worth noting that, disposal, endearing, intuitively, awareness, automated, shorthand, presumably,
come over, lambda, succinct, hood, frustrating, stem from, arguably, lurking,
potent, flesh out, terrific, leverage
2), Strange sentences:
Indenting can nest to any level, just like curly braces in C++ or Java, but unlike those languages there is no option (and no argument) about where the braces are placed the compiler forces everyone’s code to be formatted the same way, which is one of the main reasons for Python’s consistent readability.
Note that Python was not named after the snake, but rather the Monty Python comedy troupe, and so examples are virtually required to include Python-esque references.
incomplete