javaclass

Change of docs/index.html

140:1afe376ec3fd
docs/index.html
     1.1 --- a/docs/index.html	Fri Jan 21 18:22:28 2005 +0100
     1.2 +++ b/docs/index.html	Sat Jan 22 23:34:27 2005 +0100
     1.3 @@ -15,7 +15,10 @@
     1.4  into Python, without the need for a Java virtual machine, so that the classes
     1.5  may be instantiated, accessed, run and manipulated just like Python classes,
     1.6  and that the resulting objects and methods can be accessed and manipulated
     1.7 -just like Python objects and methods.</p>
     1.8 +just like Python objects and methods. It should be possible to run compiled
     1.9 +Java programs with the Python interpreter and not notice that it isn't the
    1.10 +Java virtual machine being used - given sufficient library support for the
    1.11 +program concerned, of course.</p>
    1.12  
    1.13  <h2>Quick Examples</h2>
    1.14  
    1.15 @@ -97,20 +100,26 @@
    1.16  
    1.17  <p class="python-result">20050401</p>
    1.18  
    1.19 +<h2>Getting Started</h2>
    1.20 +
    1.21 +<p>See the <code>README.txt</code> file in the distribution directory.</p>
    1.22 +
    1.23  <h2>Motivation</h2>
    1.24  
    1.25  <p>Pick one of the following:</p>
    1.26  <ul>
    1.27    <li>The need/desire to access Java libraries from Python without firing up
    1.28 -    Java virtual machines or switching to Jython (and thereby losing access
    1.29 -    to various CPython libraries).</li>
    1.30 +    Java virtual machines or switching to Jython (and thereby losing
    1.31 +    convenient access to various CPython libraries).</li>
    1.32 +  <li>Mixing languages available for the Java runtime with Python.</li>
    1.33    <li>Static typing for the Python environment, albeit achieved by writing
    1.34      Java or other appropriate languages.</li>
    1.35    <li>Having an open source environment from top to bottom to run Java
    1.36      bytecode on.</li>
    1.37    <li>Experimentation around import hooks, bytecode generation; observation
    1.38      of different runtime and type systems interacting.</li>
    1.39 -  <li>Using Python libraries from Java.</li>
    1.40 +  <li>Making Python libraries available to Java programs - Tkinter for Java,
    1.41 +    anyone?!</li>
    1.42  </ul>
    1.43  
    1.44  <h2>Limitations</h2>
    1.45 @@ -129,7 +138,69 @@
    1.46      files (and .jar archives). Generally, anyone who is anyone in the Python
    1.47      pantheon has largely recommended against doing anything with the
    1.48      bytecode, despite noble efforts to make exciting things happen by
    1.49 -    transforming it, optimising it, and so on - </li>
    1.50 +    transforming it, optimising it, and so on. (Instead, there's been more
    1.51 +    emphasis on lots of runtime baggage for things which could be done by
    1.52 +    analysis of the code with modified bytecode being produced as a result,
    1.53 +    and let's not get started on some of the syntactical enhancements.)
    1.54 +    Consequently, stability might be an issue for some configurations,
    1.55 +    especially since CPython doesn't fail particularly graciously with badly
    1.56 +    behaved bytecode.</li>
    1.57 +  <li>Some of the translation from Java to Python bytecode takes a few
    1.58 +    liberties. For example, Java exceptions are handled in ways reminiscent
    1.59 +    of a 1980s microcomputer assembly language, whereas Python bytecode has
    1.60 +    higher level constructs for exceptions; this translation can probably be
    1.61 +    done incorrectly, triggering some kind of bytecode misbehaviour, and we
    1.62 +    all know what happens then.</li>
    1.63 +  <li>At the Python level, not all things seem totally right. For example,
    1.64 +    Java bytecode instructions are used to instantiate and then initialise
    1.65 +    exceptions just like other objects, and while Python can support this
    1.66 +    with new-style objects, Python won't let you use new-style objects as
    1.67 +    exceptions. Consequently, when Java exceptions appear in Python programs,
    1.68 +    they will be wrapped in old-style exceptions and have to be handled
    1.69 +    specially.</li>
    1.70 +  <li>In order to support method dispatch properly, special names are used
    1.71 +    for the translated methods which include the type information found in
    1.72 +    the bytecode; things like <code>main___java__lang__String_array_</code>
    1.73 +    and <code>setValue____I_</code> appear when you look inside classes and
    1.74 +    objects. When implementing libraries in Python for Java programs, such
    1.75 +    method naming conventions have to be used because the original code is
    1.76 +    very specific about which method is being invoked, and for specialised
    1.77 +    versions of <code>__init__</code> it becomes necessary to do a
    1.78 +    <code>setattr</code> to add such methods into classes because of various
    1.79 +    "name mangling" measures in the Python compilation process. Now, many
    1.80 +    people might start advocating decorators at this point, but not everyone
    1.81 +    is running the very latest stuff from python.org, and decorators won't
    1.82 +    help you target a specific specialised method anyway.</li>
    1.83 +  <li>Imported and translated bytecode is not written out or cached. This
    1.84 +    means that a fair amount of work happens every time you need to import
    1.85 +    Java classes, although the generation of .pyc files could be introduced
    1.86 +    provided that it captured the slightly different import semantics of
    1.87 +    Java; for example, you can import classes belonging to a package from
    1.88 +    several places on the PYTHONPATH, and this is something that generally
    1.89 +    isn't allowed/supported with the classic Python module import
    1.90 +  mechanisms.</li>
    1.91 +</ul>
    1.92 +
    1.93 +<h2>Suggestions for Python Improvements</h2>
    1.94 +<ul>
    1.95 +  <li>Make the bytecode interpreter more robust when encountering badly
    1.96 +    behaved bytecode, consider bytecode verification and other exciting
    1.97 +    features.</li>
    1.98 +  <li>Allow new-style objects as exceptions. Actually, just do something
    1.99 +    about the whole old-style vs. new-style class thing!</li>
   1.100 +  <li>Allow possible optimisation for things like statically predetermined
   1.101 +    method calls. The debate about static typing intersects slightly with the
   1.102 +    need to define methods with parameters of particular types, but
   1.103 +    supporting Java-style method "coexistence" (or multimethods, or whatever
   1.104 +    the proper name is) would presumably involve doing lots of things to the
   1.105 +    language that were once thought to be highly un-Pythonic. Besides, the
   1.106 +    need to interoperate with statically typed languages shouldn't dictate
   1.107 +    the design of Python, especially if better type systems could be adopted
   1.108 +    instead, leaving the static typing glue for strictly special
   1.109 +  occasions.</li>
   1.110 +  <li>Not that threaded Java programs have been run on Python yet, but with
   1.111 +    Python's current threading architecture I'd expect some
   1.112 +  disappointment.</li>
   1.113  </ul>
   1.114  </body>
   1.115  </html>