<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jython Journeys &#187; java</title>
	<atom:link href="http://jython.xhaus.com/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://jython.xhaus.com</link>
	<description>Notes about my work with jython and python</description>
	<lastBuildDate>Sat, 05 Mar 2011 20:40:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Jython and Internationalized Domain Names.</title>
		<link>http://jython.xhaus.com/jython-and-internationalized-domain-names/</link>
		<comments>http://jython.xhaus.com/jython-and-internationalized-domain-names/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 22:59:57 +0000</pubDate>
		<dc:creator>alan.kennedy</dc:creator>
				<category><![CDATA[Information Security]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[sockets]]></category>
		<category><![CDATA[web technology]]></category>

		<guid isPermaLink="false">http://jython.xhaus.com/?p=208</guid>
		<description><![CDATA[I&#8217;m happy to announce that jython finally supports Internationalized Domain Names.

In May 2010, the Internet Committee for Assigned Names and Numbers (ICANN) permitted the first non-ASCII Internationalized Top-Level Domains to be made available.
An Internationalized Domain Name (IDN) is a domain name that includes characters from outside the ASCII character set. IDNs are specified in RFC [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m happy to announce that jython finally supports Internationalized Domain Names.</p>
<p><span id="more-208"></span></p>
<p>In May 2010, the <a href="http://www.icann.org/">Internet Committee for Assigned Names and Numbers</a> (ICANN) permitted the <a href="http://blog.icann.org/2010/05/idn-cctlds/">first non-ASCII Internationalized Top-Level Domains to be made available</a>.</p>
<p>An <a href="http://en.wikipedia.org/wiki/Internationalized_domain_name">Internationalized Domain Name</a> (IDN) is a domain name that includes characters from outside the <a href="http://en.wikipedia.org/wiki/ASCII">ASCII character set</a>. IDNs are specified in <a href="http://www.apps.ietf.org/rfc/rfc3490.html">RFC 3490</a>, and may contain any character from the <a href="http://en.wikipedia.org/wiki/Unicode">Unicode</a> character repertoire, meaning that domain names may now contain any writing symbol in use by human-beings anywhere on the planet.</p>
<p><b>Potential Issues</b></p>
<p>There are lots of interesting things and potential issues to note about IDNs.</p>
<p>They open up a whole new frontiers for cybersquatters and phishers, by opening up the possibility of <a href="http://en.wikipedia.org/wiki/IDN_homograph_attack">Homograph Attacks</a>, where the user is intentionally misguided by the visual similarity of character glyphs from different character sets. For example, is this character <b>&#946;</b> a greek lower case beta or a german eszett?</p>
<p>Will companies like <b>Société Générale</b> find themselves held hostage by cybersquatters who have registered the accented version of their brand name before they even realise that it was possible to register it? In the case of the SocGen, the answer is <a href="http://www.xn--socitgnrale-ebbbbb.com">no</a>.</p>
<p><b>Solutions</b></p>
<p>Doubtless, various solutions will be adopted to solve these problems, as national registrars from around the world deal with how these problems relate specifically to the characters in use in their country. For example, the Russian national registrar <a href="http://xn--j1ay.xn--p1ai/">Coordination Centre for RU TLD</a> only permits Cyrillic characters to be used in the new <a href="http://en.wikipedia.org/wiki/.%D1%80%D1%84">.&#1088;&#1092;</a> top-level domain.</p>
<p><b>Jython support</b></p>
<p>Unfortunately, <a href="http://bugs.jython.org/issue1153">jython idna encoding is currently broken</a>, due to shortcomings in the unicodedata module and lack of stringprep support.</p>
<p>But IDNs are now supported when you run jython on a Java 6 JVM, since that version of the JVM has built-in IDN support: I checked in the changes at <a href="https://fisheye3.atlassian.com/changelog/jython/?cs=7198">revision 7198</a>.</p>
<p>There is also a workaround for java 5, where you can use GNU LibIDN to convert domain and host names to punycode before passing them to domain names that expect to receive ASCII parameters. This workaround is documented on the <a href="http://wiki.python.org/jython/NewSocketModule#InternationalizedDomainNamesupport">jython socket wiki</a>.</p>
<p>If you&#8217;re interested in playing with IDNs, you can obviously <a href="http://www.jython.org/download.html">download the latest jython</a>. And there are plenty of <a href="http://www.google.com/#q=idn+converter">Online IDN converters</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jython.xhaus.com/jython-and-internationalized-domain-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jython supports IPV6.</title>
		<link>http://jython.xhaus.com/jython-supports-ipv6/</link>
		<comments>http://jython.xhaus.com/jython-supports-ipv6/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 14:33:49 +0000</pubDate>
		<dc:creator>alan.kennedy</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[sockets]]></category>
		<category><![CDATA[web technology]]></category>

		<guid isPermaLink="false">http://jython.xhaus.com/?p=199</guid>
		<description><![CDATA[I am delighted to announce that jython is IPV6 ready: the future of internet addressing is fully supported.

IPV4 exhaustion
As you are no doubt aware by now (since it&#8217;s been covered in all mainstream media), the reign of Internet Protocol Version 4 (IPV4) is coming to an end: the IPV4 address space will run out before [...]]]></description>
			<content:encoded><![CDATA[<p>I am delighted to announce that jython is IPV6 ready: the future of internet addressing is fully supported.</p>
<p><span id="more-199"></span></p>
<p><b>IPV4 exhaustion</b></p>
<p>As you are no doubt aware by now (since it&#8217;s been covered in all mainstream media), the reign of <a href="http://en.wikipedia.org/wiki/IPv4">Internet Protocol Version 4 (IPV4)</a> is coming to an end: the <a href="http://en.wikipedia.org/wiki/IPv4_address_exhaustion">IPV4 address space will run out before the end of 2011</a>. </p>
<p>The problem is a simple one: IPV4 addresses are made up of only 32 bits, meaning that they can only represent a maximum of 2<sup><small>32</small></sup> different addresses (nearly 4.3 billion). But the internet is so successful and growing so fast that this address space is now too small: there are over 6 billion people on this planet, over 4 billion mobile phones, and over 1 billion PCs. Multi-device ownership is commonplace and growing in the rich world, and networking device ownership in the developing world is growing rapidly.</p>
<p>The decision to use 32-bit addresses was the right decision to make back in the 1960s. At the birth of the Internet, there were only several dozen machines connected to it. Rather than go into this subject in detail, I recommend reading this article: <a href="http://dltj.org/article/vint-cerf-ip-addressing/">Vint Cerf on the Origins of 32-bit IP Addressing</a>.</p>
<p>But as the Internet expanded and more and more machines connected to it, it became clear in the 1990s that IPV4 addresses would eventually run out, and that something would be needed to replace it: <a href="http://en.wikipedia.org/wiki/IPv6">Internet Protocol Version 6 (IPV6)</a> was born.</p>
<p><b>IPV6</b></p>
<p>IPV6 solves the address space problem permanently, by introducing a mind-bogglingly large address space: 128 bits, or 2<sup><small>128</small></sup> possible addresses. That&#8217;s 340,282,366,920,938,463,463,374,607,431,768,211,456 possible addresses! (Although see below for some caveats).</p>
<p>My favourite way to describe the size of this address space is as follows. If we were to divide the theoretical IPV6 address space between every star in the known universe (estimated to be 10<sup><small>22</small></sup>, or 10,000,000,000,000,000,000,000 stars), every star would have nearly 2<sup><small>55</small></sup> addresses to itself, i.e. an address space that is 8.4 million (2<sup><small>23</small></sup>) times bigger than our existing IPV4 planetary internet (since 2<sup><small>23</small></sup> * 2<sup><small>32</small></sup> == 2<sup><small>55</small></sup>).</p>
<p>That&#8217;s a lot of addresses, and once IPV6 is fully in service across the internet, we won&#8217;t be running out of addresses for a very long time.</p>
<p>(Actually, the number of addresses available under IPV6 will be less than the theoretical maximum, because <a href="http://www.iana.org/assignments/ipv6-address-space/ipv6-address-space.xml">various sub-sets of the IPV6 address space have been reserved for special purposes</a>. But the set of addresses available will remain practically unlimited for the foreseeable future).</p>
<p><b>Java vs. python</b></p>
<p>As readers of this blog will be aware, <a href="http://www.jython.org/">jython</a> is an implementation of the <a href="http://www.python.org/">python language</a> that runs on the <a href="http://www.java.com/">java platform</a>.</p>
<p>Both python and java have been moving towards IPV6 for a number of years. Both are <a href="http://en.wikipedia.org/wiki/Cross-platform">multi-platform languages</a>, and attempt to provide APIs that work seamlessly across all operating systems. </p>
<p><a href="http://www.python.org/">Cpython</a>, the most well known version of the python language, that is written in <a href="http://en.wikipedia.org/wiki/C_%28programming_language%29">C</a>, <a href="http://docs.python.org/dev/whatsnew/2.2.html">first provided IPV6 facilities back in version 2.2</a>, released in December 2001. This support, although complete in design, did not initially work on all platforms on which cpython is used, because underlying operating system support was variable and patchy.</p>
<p>Simiarly, <a href="http://download.oracle.com/javase/1.4.2/docs/guide/net/ipv6_guide/">java introduced IPV6 support in version 1.4</a>, released in February 2002. But this support suffered the same problems as with cpython: underlying operating system support was variable, particularly on older OSes such as Windows 2000, XP and 2003.</p>
<p>Fortunately, most operating systems have caught up with the present, and provide excellent IPV6 support, including most open-source operating systems, MacOS and <a href="http://research.microsoft.com/en-us/projects/msripv6/">Windows since Windows Vista</a>.</p>
<p><b>Jython and IPV6</b></p>
<p>As is always true when using jython, there are two different approaches one can take to using IPV6 on jython: 1. Use the Java socket API or 2. Use the python socket API.</p>
<p><b>The java socket API</b></p>
<p>Users of jython have always had access to IPV6 though the java socket API, because of the <a href="http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html">seamless integration between java and jython</a>. However, jython users often avoid using java APIs, particularly the more over-complex ones. And the java socket API is probably one of the worst examples of over-complexity, since it comprises two entirely different APIs, with different designs, to provide the full range of socket functionality: the <a href="http://download.oracle.com/javase/1.4.2/docs/api/java/net/package-summary.html">java.net</a> APIs and the <a href="http://download.oracle.com/javase/1.4.2/docs/api/java/nio/package-summary.html">java.nio</a> APIs.</p>
<p><b>The python socket API</b></p>
<p>Long term users of jython networking libraries, which rely on the socket module, will be aware that the jython socket module has a particularly difficult task implementing the python socket API, since it must implement the cpython API, which has a C language philosophy, on top of the java API facilities, which have a different, more object-oriented philosophy. And as described above, the java socket API is really two completely different APIs, both of which must be used if you want the full range of functionality, e.g. <a href="http://www.nightmare.com/medusa/async_sockets.html">asynchronous networking</a>.</p>
<p>Implementing IPV6 has been problematic, for several reasons, including that operating system support has been patchy, thus making it difficult to reliably test on a cross-platform basis. Also, the <a href="http://mail.python.org/pipermail/python-3000/2007-March/006522.html">cpython socket API is not without problems when it comes to IPV6</a>.</p>
<p>Still, it has always been my stated intent that any python code written which uses the socket module should behave identically on jython and cpython, wherever possible. And now that intent extends to IPV6, final support for which I checked in recently (revisions <a href="https://fisheye3.atlassian.com/changelog/jython/?cs=7191">7191</a> and <a href="https://fisheye3.atlassian.com/changelog/jython/?cs=7193">7193</a>), and which should be included in the next release of jython, due any day now.</p>
<p>I am particularly satisfied with this step forward, since I believe that IPV6 opens up a whole new world of networking possibilities.</p>
<p><b>Reliability</b></p>
<p>I won&#8217;t yet make the claim that the new IPV6 support is 100% defect free, since there are so many different java-version and operating-system combinations on which jython is used. There will always be some combination of operations on some JVM on some operating systems where it just won&#8217;t work, for example <a href="http://bugs.sun.com/view_bug.do?bug_id=6230761">this java IPV6 defect on Windows</a>. But the jython socket module has a <a href="https://fisheye3.atlassian.com/browse/jython/trunk/jython/Lib/test/test_socket.py?hb=true">very large set of unit-tests</a>, currently 133 separate tests, and growing. As and when bugs are uncovered, I will <a href="http://wiki.python.org/jython/NewSocketModule">document them</a>, <a href="http://wiki.python.org/jython/NewSocketModule#IPV6addresssupport">provide work-arounds</a>, and unit-tests for the work-arounds.</p>
<p>Happy IPV6 networking!</p>
]]></content:encoded>
			<wfw:commentRss>http://jython.xhaus.com/jython-supports-ipv6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transforming with XSLT on Google AppEngine and jython.</title>
		<link>http://jython.xhaus.com/transforming-with-xslt-on-google-appengine-and-jython/</link>
		<comments>http://jython.xhaus.com/transforming-with-xslt-on-google-appengine-and-jython/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 18:42:26 +0000</pubDate>
		<dc:creator>alan.kennedy</dc:creator>
				<category><![CDATA[google appengine]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[java scripting]]></category>
		<category><![CDATA[web technology]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xslt]]></category>

		<guid isPermaLink="false">http://jython.xhaus.com/?p=171</guid>
		<description><![CDATA[I&#8217;m writing this post in response to a challenge. I wrote a post entitled Jython on Google AppEngine: Why bother?, which was a reply to a statement made by a Google engineer about not seeing the point of running jython on AppEngine. And a similar statement was repeated in a comment on that blog post [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing this post in response to a challenge. I wrote a post entitled <a href="http://jython.xhaus.com/jython-on-google-appengine-why-bother/">Jython on Google AppEngine: Why bother?</a>, which was a reply to a statement made by a Google engineer about not seeing the point of running jython on AppEngine. And a similar statement was repeated in a <a href="http://jython.xhaus.com/jython-on-google-appengine-why-bother/#comments">comment on that blog post</a> (i.e. &#8220;<i>the gist of what I intended to say was that while it was possible to run Jython on App Engine, I couldn’t think why you’d want to</i>.&#8221;)</p>
<p>So rather than get into a back-and-forth of yes-it-is-no-it-isnt-yes-it-is, I thought I&#8217;d reply with some simple code that demonstrates <b>something that cannot (currently) be done in cpython on AppEngine</b>, but is <b>easy with jython on AppEngine</b>: XSLT transforms. </p>
<p><span id="more-171"></span></p>
<p>So, without further ado, here is the jython source code for running an XSLT transform on Google AppEngine. It is implemented as a jython WSGI application, using xhaus.com&#8217;s <a href="http://modjy.xhaus.com">modjy WSGI gateway for java servlets</a> that was <a href="http://jython.xhaus.com/modjy-now-fully-integrated-into-jython/">contributed to the jython project a few months back</a>.</p>
<p>In order to get this code running, I suggest you download the <a href="http://downloads.xhaus.com/modjy_webapp_google_appengine/">modjy on google appengine demo</a> from our <a href="http://downloads.xhaus.com">downloads site</a>. In that download, there is a jython file called &#8220;demo_app.py&#8221;. Simply replace the entire contents of that file with the code below, and you&#8217;re good to go. If you need help with getting the modjy demo application working on Google AppEngine, see the documentation on the modjy wiki: <a href="http://opensource.xhaus.com/projects/modjy/wiki/ModjyGoogleAppEngine">Running jython WSGI applications on Google AppEngine, with modjy</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">__doc__ = <span style="color: #483d8b;">&quot;&quot;&quot;
A demonstration of how to run XSLT transforms on Google AppEngine with jython (not cpython).
Please feel free to use this code in whatever way you wish.
&quot;&quot;&quot;</span>
<span style="color: #ff7700;font-weight:bold;">from</span> java.<span style="color: black;">io</span> <span style="color: #ff7700;font-weight:bold;">import</span> StringReader, StringWriter
<span style="color: #ff7700;font-weight:bold;">from</span> javax.<span style="color: #dc143c;">xml</span>.<span style="color: black;">transform</span> <span style="color: #ff7700;font-weight:bold;">import</span> Transformer, TransformerFactory
<span style="color: #ff7700;font-weight:bold;">from</span> javax.<span style="color: #dc143c;">xml</span>.<span style="color: black;">transform</span>.<span style="color: black;">stream</span> <span style="color: #ff7700;font-weight:bold;">import</span> StreamResult, StreamSource
&nbsp;
xml_data = <span style="color: #483d8b;">&quot;&quot;&quot;
&lt;books&gt;
  &lt;book&gt;
    &lt;title&gt;2001 - A Space Odyssey&lt;/title&gt;
    &lt;author&gt;Arthur C Clarke&lt;/author&gt;
  &lt;/book&gt;
  &lt;book&gt;
    &lt;title&gt;I, Robot&lt;/title&gt;
    &lt;author&gt;Isaac Asimov&lt;/author&gt;
  &lt;/book&gt;
  &lt;book&gt;
    &lt;title&gt;Kil'n people&lt;/title&gt;
    &lt;author&gt;David Brin&lt;/author&gt;
  &lt;/book&gt;
&lt;/books&gt;
&quot;&quot;&quot;</span>
&nbsp;
xslt_source = <span style="color: #483d8b;">&quot;&quot;&quot;
&lt;xsl:stylesheet
  xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;
&gt;
&nbsp;
&lt;xsl:template match=&quot;books&quot;&gt;
&lt;html&gt;
  &lt;head&gt;&lt;title&gt;A list of books, transformed into html from xml using xslt and jython.&lt;/title&gt;&lt;/head&gt;
  &lt;body&gt;
    &lt;table border=&quot;1&quot; width=&quot;50%&quot; align=&quot;center&quot;&gt;
      &lt;caption&gt;A list of books, transformed into html from xml using xslt and jython.&lt;/caption&gt;
      &lt;tr&gt;&lt;th&gt;Title&lt;/th&gt;&lt;th&gt;Author&lt;/th&gt;&lt;/tr&gt;
    &lt;xsl:for-each select=&quot;book&quot;&gt;
      &lt;tr&gt;&lt;td&gt;&lt;xsl:value-of select=&quot;title/text()&quot;/&gt;&lt;/td&gt;&lt;td&gt;&lt;xsl:value-of select=&quot;author/text()&quot;/&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;/xsl:for-each&gt;
    &lt;/table&gt;
  &lt;/body&gt;
&lt;/html&gt;
&lt;/xsl:template&gt;
&nbsp;
&lt;/xsl:stylesheet&gt;
&quot;&quot;&quot;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> generate_html<span style="color: black;">&#40;</span>xml_data, xslt_source<span style="color: black;">&#41;</span>:
  transformer = TransformerFactory.<span style="color: black;">newInstance</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">newTransformer</span><span style="color: black;">&#40;</span>StreamSource<span style="color: black;">&#40;</span>StringReader<span style="color: black;">&#40;</span>xslt_source<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  output_buffer = StringWriter<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
  transformer.<span style="color: black;">transform</span><span style="color: black;">&#40;</span>StreamSource<span style="color: black;">&#40;</span>StringReader<span style="color: black;">&#40;</span>xml_data<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>, StreamResult<span style="color: black;">&#40;</span>output_buffer<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">return</span> output_buffer.<span style="color: black;">buffer</span>.<span style="color: black;">toString</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> handler<span style="color: black;">&#40;</span>environ, start_response<span style="color: black;">&#41;</span>:
  result = generate_html<span style="color: black;">&#40;</span>xml_data, xslt_source<span style="color: black;">&#41;</span>
  start_response<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;200 Hoopy&quot;</span>, <span style="color: black;">&#91;</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'content-type'</span>, <span style="color: #483d8b;">'text/html'</span><span style="color: black;">&#41;</span> <span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span>result<span style="color: black;">&#93;</span></pre></div></div>

<p>Happy Transforming!</p>
]]></content:encoded>
			<wfw:commentRss>http://jython.xhaus.com/transforming-with-xslt-on-google-appengine-and-jython/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Jython on Google AppEngine: Why bother?</title>
		<link>http://jython.xhaus.com/jython-on-google-appengine-why-bother/</link>
		<comments>http://jython.xhaus.com/jython-on-google-appengine-why-bother/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 14:40:09 +0000</pubDate>
		<dc:creator>alan.kennedy</dc:creator>
				<category><![CDATA[google appengine]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[java scripting]]></category>
		<category><![CDATA[web technology]]></category>

		<guid isPermaLink="false">http://jython.xhaus.com/?p=160</guid>
		<description><![CDATA[Why on earth would you want to run jython applications on Google Appengine?

First off, I must apologise for the flippant nature of the attention grabbing title. I&#8217;m a jython committer, and a jython user, so I believe that there are very good reasons for running jython on Google AppEngine. (You can read how to do [...]]]></description>
			<content:encoded><![CDATA[<p>Why on earth would you want to run <a href="http://www.jython.org">jython</a> applications on <a href="http://appengine.google.com">Google Appengine</a>?</p>
<p><span id="more-160"></span></p>
<p>First off, I must apologise for the flippant nature of the attention grabbing title. I&#8217;m a jython committer, and a jython user, so I believe that there are very good reasons for running jython on Google AppEngine. (You can read how to do so on the modjy wiki: <a href="http://opensource.xhaus.com/projects/modjy/wiki/ModjyGoogleAppEngine">how to run jython applications on Google AppEngine</a>).</p>
<p>The title is essentially a paraphrase of a statement made by a Google AppEngine Evangelist, at a talk about AppEngine that I attended here in Dublin. The speaker was of the opinion that there was no valid reason for running jython on AppEngine, a statement which I couldn&#8217;t let pass.</p>
<p>I think that the core of his reasoning for making that statement was a simple misunderstanding, but a misunderstanding that is common among users who are familiar with python, or users of cpython, but who are not familiar with jython&#8217;s use as a <a href="http://www.javaworld.com/javaworld/jw-11-2007/jw-11-jsr223.html">JVM scripting language</a>. The misunderstanding is that the only reason for running jython is so that one can run python applications on the JVM, using python&#8217;s wealth of &quot;batteries included&quot; APIs. If that is the case, then why bother running jython, when one can simply use the <a href="http://code.google.com/appengine/docs/python/gettingstarted/">cpython support on AppEngine</a> directly?</p>
<p>To explain, when writing a cpython application that processes email, for example, one can make use of the python&#8217;s <a href="http://docs.python.org/library/email.html">email module</a>, which provides a wealth of features for dealing with the many complexities of parsing, processing and generating email messages, MIME, etc. Users of jython can also use the python email modules, since those modules are written in pure python. But since jython runs on the Java Virtual Machine(JVM) and permits seamless integration of java and python code, jython users writing email processing also have the option of using the excellent <a href="http://java.sun.com/products/javamail/">JavaMail APIs</a>, which are just as robust as the pure python modules, and arguably more efficient. So jython users have the best of both worlds: they can use either python APIs or java APIs, with equal ease.</p>
<p>Processing email is perhaps too straightforward an example, in that both python and java have excellent email processing support. But due to the more widespread use of java in the development community in general, java generally has far more support for any given technology need, since there are often multiple options available. A good example of this is cryptography: there is a wealth of <a href="http://www.homeport.org/~adam/crypto/">java cryptography libraries</a> available, including the excellent <a href="bouncycastle.org">Bouncy Castle</a>, <a href="http://www.cryptix.org/">Cryptix</a>, <a href="http://www.flexiprovider.de/">Flexiprovider</a>, etc. The choice of crypto libraries in python is generally narrower, supports less functionality, and is sometimes abandon-ware.</p>
<p>So if one&#8217;s understanding of jython is simply that it is a way to run pure python modules on the JVM, then the above mentioned mis-understanding is forgivable. But it is simply not the case that the primary usage of jython is to run pure python modules: Jython excels as a dynamic/scripting language for the JVM, and permits the use of java APIs, without having to write java code.</p>
<p>In discussion with the Google engineer after the talk, he conceded that there was one possible use case for running jython on AppEngine, namely that of prototyping java applications. In this scenario, applications would</p>
<ol>
<li>Be developed in jython, taking advantage of the enormous productivity increases gained by developing in python</li>
<li>Be translated to java once the functionality of the application is complete</li>
</ol>
<p>My reply to this is: <b>&#8220;Why bother with step 2&#8243;</b>?</p>
<p>If you&#8217;ve got a running application that is fully functional and written in jython, then you don&#8217;t need to translate it to java. You should only consider translating it, or parts of it, into java <b>if you really have to</b>. For example, after profiling your jython application, you may find one or two core pieces that are performance bottlenecks: these are prime candidates for translation to java, to improve performance. But there&#8217;s no reason to translate the rest of the application: maintainability and productivity is best served by simply leaving the jython code exactly as is.</p>
<p>I suppose a part of the reason why this mis-perception of jython has come about is because python is such an excellent language that it is in the unique position of having two completely independent implementations of the language that run on Google AppEngine. But just because both cpython and jython run on AppEngine doesn&#8217;t mean that their usages should be identical. Jython&#8217;s place in the AppEngine ecosystem is primarily as a JVM dynamic language.</p>
<p>So, in summary, jython is more than just a mechanism for running pure python code on the JVM: it is an excellent JVM development platform in it&#8217;s own right.</p>
<p>I hope I&#8217;ve given you some good reasons to consider developing your next Google AppEngine project on jython.</p>
]]></content:encoded>
			<wfw:commentRss>http://jython.xhaus.com/jython-on-google-appengine-why-bother/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>A list of open source HTTP proxies written in Java.</title>
		<link>http://jython.xhaus.com/a-list-of-open-source-http-proxies-written-in-java/</link>
		<comments>http://jython.xhaus.com/a-list-of-open-source-http-proxies-written-in-java/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 15:48:51 +0000</pubDate>
		<dc:creator>alan.kennedy</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[web technology]]></category>

		<guid isPermaLink="false">http://jython.xhaus.com/?p=153</guid>
		<description><![CDATA[A few years ago, as an aide to python web programers, I compiled a database of open source HTTP proxies written in python, which became surprisingly popular.
So I&#8217;ve decided to expand the database to encompass the other language that I regularly use, java, and publish a database of open source HTTP proxies written in java.

While [...]]]></description>
			<content:encoded><![CDATA[<p>A few years ago, as an aide to python web programers, I compiled a <a href="http://proxies.xhaus.com/python/">database of open source HTTP proxies written in python</a>, which became surprisingly popular.</p>
<p>So I&#8217;ve decided to expand the database to encompass the other language that I regularly use, java, and publish a <a href="http://proxies.xhaus.com/java/">database of open source HTTP proxies written in java</a>.</p>
<p><span id="more-153"></span></p>
<p>While carrying out a web development project a few years ago, I needed a HTTP proxy to help with development and debugging. Rather than write my own, I decided to research what open source options were already available.</p>
<p>However, Python is such an easy language to write web servers and proxies in that a lot people had written and puiblished HTTP proxies, so making the decision wasn&#8217;t easy. It required a lot of research, which basically meant a code and architectural review of all of the open source python proxies available.</p>
<p>Since most web programmers use a HTTP proxy at some stage, I thought it would be a useful exercise to compile a complete list of the available options, with a comparison table to enable a feature by feature comparison.</p>
<p>The result of that was this <a href="http://proxies.xhaus.com/python/">comparison table of open source HTTP proxies written in python</a>, which became quite popular, because it saved python programmers going through the same complex comparison and review process I had undertaken.</p>
<p>Since I&#8217;m currently working on another proxy-related project, I needed to review available open source HTTP proxies written in java. And I thought I&#8217;d save someone some research time by publishing a similar <a href="http://proxies.xhaus.com/java/">comparison table of open source HTTP proxies in java</a>.</p>
<p>I hope you find it useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://jython.xhaus.com/a-list-of-open-source-http-proxies-written-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

