<?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>Monomorphic &#187; java</title>
	<atom:link href="http://www.monomorphic.org/wordpress/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.monomorphic.org/wordpress</link>
	<description>Conceptual meandering</description>
	<lastBuildDate>Wed, 11 Jan 2012 02:07:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>What makes a good programming language?</title>
		<link>http://www.monomorphic.org/wordpress/what-makes-a-good-programming-language/</link>
		<comments>http://www.monomorphic.org/wordpress/what-makes-a-good-programming-language/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 09:00:09 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[academic]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=1012</guid>
		<description><![CDATA[New programming languages are released all the time. History is littered with dead ones. There are also many long time survivors in good shape, as well as geriatric languages on life support. What makes a programming language attractive and competitive? How can we evaluate its quality? There are many different aspects of this problem. Ease [...]]]></description>
			<content:encoded><![CDATA[<p>New programming languages are released all the time. History is littered with dead ones. There are also many long time survivors in good shape, as well as geriatric languages on life support.</p>
<p>What makes a programming language attractive and competitive? How can we evaluate its quality? There are many different aspects of this problem.</p>
<p><strong>Ease of reading and writing</strong>, or: directness of the mapping between the problem in your head and the model you are creating on the computer. This can be highly domain dependent, for instance languages such as LaTeX, Matlab and R are designed with specific problems in mind and cater to users from that domain. Their limits show quickly when you try to stretch them beyond their envisioned purpose. Speaking of general programming languages, I think Python deserves to be mentioned as a language that is extremely readable and writable. It has other shortcomings though &#8211; see below. Prolog is also highly read- and writable if it suits your problem.</p>
<p><strong>Runtime performance. </strong>Arguably this is one of the few reasons to bother with using C++. For the majority of programming projects though, performance is much less of a problem than one might think, especially if one considers how close the performance of many JVM languages get to C++. When programmers think about their overall productivity and effectiveness in developing and maintaining a system, C++ is often not the best choice, obviously.</p>
<p><strong>Scalability to large teams. </strong>The key property here is: does the language do anything to help me, as a developer, work with code that other people wrote? Ease of maintenance may be strongly correlated with usability in large teams. An anti-pattern here is languages that allow for solving the same problem in a huge amount of ways with very variable syntax. For instance, Perl and C++ can lead to notoriously unmaintainable code if used carelessly. Some say that Scala also suffers from this problem. Basically, the language helps here if it prevents me from doing things that other developers might not expect, and that I might forget to document or communicate. This is why Gosling famously called Java a blue collar language; it restricts you enough to make teamwork quite practical. It even restricts the layout of your source file hierarchy. (Now we begin to see that some goals are in conflict with each other).</p>
<p><strong>Scalability to large systems. </strong>This is related to the preceding property, but whereas team scalability seems to be mainly about avoiding the creation of code fragments that surprise people other than their creators, system size scalability seems to be about avoiding the creation of code fragments that surprise other code fragments. Here one needs invariants, good type checking, static constraints of all kinds. Scripting languages like Perl and Python, lacking static typing completely, are some of the worst in this regard, since we cannot even be sure at startup time that methods we try to invoke on objects exist at all (Python).</p>
<p><strong>Scalability over time (maintainability).</strong> If there is both system size scalability and team scalability, then the system is also likely to be able to live for a long time without great troubles.</p>
<p><strong>Developer efficiency and rapid prototyping. </strong>Depending on the nature of the system being developed, this may depend on several different properties listed above.</p>
<p><strong>Availability of quality tools.</strong> Mature runtime environments, such as the JVM, have many more high quality tools and IDEs available than a language than Ruby. Mature languages also have more compilers for more different architectures available.</p>
<p>These points begin to give us an idea of how we can evaluate programming languages. However, I also believe that making a good language and making people use it is largely about luck and factors outside the design itself. Just like there&#8217;s a big step between imagining and specifying an utopian society and making that social order an actuality, there&#8217;s a big step between designing an ideal programming language and achieving widespread adoption for it. We have seen a way forward though: with generalised runtime environments such as the JVM and the CLR, we may develop and deploy languages that take advantage of a lot of existing infrastructure much more easily than before. And what I hope for is in fact that it becomes even easier to deploy new languages, and that new languages are as interoperable as possible (insofar as it doesn&#8217;t constrain their design), so that we could see more competition, more evolution and more risk taking in the PL space.</p>
 <p><a href="http://www.monomorphic.org/wordpress/?flattrss_redirect&amp;id=1012&amp;md5=fff6eeac12b2b852112ea787fe9ec90f" title="Flattr" target="_blank"><img src="http://www.monomorphic.org/wordpress/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/what-makes-a-good-programming-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pointers in programming languages</title>
		<link>http://www.monomorphic.org/wordpress/pointers-in-programming-languages/</link>
		<comments>http://www.monomorphic.org/wordpress/pointers-in-programming-languages/#comments</comments>
		<pubDate>Thu, 25 Aug 2011 15:21:03 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[academic]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[research]]></category>
		<category><![CDATA[reuse]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[state]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=1006</guid>
		<description><![CDATA[It is likely that few features cause as much problems as pointers and references in statement-oriented languages, such as C, C++ and Java. They are powerful, yes, and they allow us to control quite precisely how a program is to represent something. We can use them to conveniently compose objects and data without the redundancy [...]]]></description>
			<content:encoded><![CDATA[<p>It is likely that few features cause as much problems as pointers and references in statement-oriented languages, such as C, C++ and Java. They are powerful, yes, and they allow us to control quite precisely how a program is to represent something. We can use them to conveniently compose objects and data without the redundancy of replicating information massively. In languages like C they are even more powerful than in Java, since just about any part of memory can be viewed as if it were just about anything through the use of pointer arithmetic, which is indeed frightening.</p>
<p>But they also complicate reasoning about programs enormously. Both human reasoning and automated reasoning. Pointers allow any part of the program to have side effects in any other part of the program (if we have a reference to an object that originated there), and they make it very hard to reason about the properties that an object might have at a given point in time (since we generally have no idea who might hold a reference to it &#8211; it is amazing that programmers are forced to track this in their heads, more or less). In my effort to design my own language, multiple pointers to the same objects &#8211; aliases &#8211; have come back from time to time to bite me and block elegant, attractive designs. I believe that this is a<em> very </em>hard problem to design around. Aliased pointers set up communication channels between arbitrary parts of a program.</p>
<p>Nevertheless attempts have been made, in academia and in research labs, to solve this problem. Fraction-based permissions track how many aliases exist and endow each alias with specific permissions to access the object that is referred to. Ownership analysis forces access to certain objects to go through special, &#8220;owning&#8221; objects. Unique or &#8220;unshared&#8221; pointers in some language extensions restrict whether aliases may be created or not. But so far no solution has been extremely attractive and convenient, and none has made it into mainstream languages. (<del>I know that someone</del> Philipp Haller made a <a href="http://lamp.epfl.ch/~phaller/readme_uniqueness.html">uniqueness plugin for the Scala compiler</a>, but it is not in wide use, I believe.)</p>
<p>If we are to attempt further incremental evolution of the C-family languages, aliased pointers are one of the most important issues we can attack in my opinion.</p>
 <p><a href="http://www.monomorphic.org/wordpress/?flattrss_redirect&amp;id=1006&amp;md5=45794a6be4c8cfc42a0be706de7eb18b" title="Flattr" target="_blank"><img src="http://www.monomorphic.org/wordpress/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/pointers-in-programming-languages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JTronic, a programming game</title>
		<link>http://www.monomorphic.org/wordpress/jtronic-a-programming-game/</link>
		<comments>http://www.monomorphic.org/wordpress/jtronic-a-programming-game/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 06:51:28 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=894</guid>
		<description><![CDATA[Now for something quite different from the philosophical entries I&#8217;ve been writing recently. We finally got the time to release the game &#8220;JTron&#8221; on Sourceforge. It is there under its new name Jtronic. This game is designed for programming competitions; participants program an agent that plays the game by obtaining information about its environment and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.monomorphic.org/wordpress/wp-content/uploads/2011/03/screenshot.png"><img class="alignleft size-medium wp-image-895" style="margin: 1em;" title="screenshot" src="http://www.monomorphic.org/wordpress/wp-content/uploads/2011/03/screenshot-300x226.png" alt="" width="300" height="226" /></a></p>
<p>Now for something quite different from the philosophical entries I&#8217;ve been writing recently. We finally got the time to release the game &#8220;JTron&#8221; on Sourceforge. It is there under its new name <a href="http://sourceforge.net/projects/jtronic/">Jtronic</a>.</p>
<p>This game is designed for programming competitions; participants program an agent that plays the game by obtaining information about its environment and making decisions. The programming language is Java. The game itself combines features of Pac-man and Tron in what we think is an interesting synthesis.</p>
<p>This game was used for the <a href="http://icpc2010.honiden.nii.ac.jp/">ACM-ICPC regional contest in Tokyo 2010</a>, for the &#8220;Java Challenge&#8221; part. I&#8217;ve had the honour to work with some great people in the Honiden lab in developing this game, and we spent time on it on and off for almost a year. A very educational process, and the final result was not bad at all.</p>
<p>If you can program in Java, you can have fun with this framework by programming your own agent and competing against others (including some pre-made ones that are included in the release), or you can contribute to the game framework itself, should you feel so inclined. It&#8217;s GPL licensed. The documentation is still slightly sparse, but we will release more &#8220;shortly&#8221;.</p>
<p>A similar framework is the <a href="http://queue.acm.org/icpc/">&#8220;Icy Challenge&#8221;</a> that was used in the world final ICPC Java Challenge. It has much nicer graphics than our game. Maybe someone would take the time to make 3D graphics for JTronic?</p>
 <p><a href="http://www.monomorphic.org/wordpress/?flattrss_redirect&amp;id=894&amp;md5=690ca61c1a90c9da41f87f7f088873e3" title="Flattr" target="_blank"><img src="http://www.monomorphic.org/wordpress/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/jtronic-a-programming-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Type theory</title>
		<link>http://www.monomorphic.org/wordpress/type-theory/</link>
		<comments>http://www.monomorphic.org/wordpress/type-theory/#comments</comments>
		<pubDate>Sun, 26 Dec 2010 21:23:32 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Philosophy]]></category>
		<category><![CDATA[academic]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming languages]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=774</guid>
		<description><![CDATA[One of the most interesting things I&#8217;ve been studying in the past year has been type theory. I feel that type theory is an area where a lot of separate fields can come together in a good design. In strongly typed languages, language implementation efficiency, syntax and language semantics all leave essential marks in the [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most interesting things I&#8217;ve been studying in the past year has been type theory. I feel that type theory is an area where a lot of separate fields can come together in a good design. In strongly typed languages, language implementation efficiency, syntax and language semantics all leave essential marks in the type system, and conversely, flaws in the type system can impair all of them.</p>
<p>Type theory was invented by <a href="http://en.wikipedia.org/wiki/Bertrand_Russell">Bertrand Russell</a> as a solution to his own <a href="http://en.wikipedia.org/wiki/Russell%27s_paradox">well-known paradox</a>, which cast doubt on the foundations of mathematics upon its discovery.  The problem posed by the paradox is essentially: given a set of all sets that do not contain themselves, does that set contain itself? Another interesting problem arising from self-referentialism. Type theory resolves this issue by classifying the members of sets according to some type, and in such a system a set definition like this one is not permissible.</p>
<p>(The drama surrounding Russell&#8217;s paradox and <a href="http://en.wikipedia.org/wiki/Principia_Mathematica">Principia Mathematica</a> can now also be read in the form of a &#8220;logicomix&#8221; <a href="http://www.amazon.com/Logicomix-Search-Truth-Apostolos-Doxiadis/dp/1596914521">graphic novel</a> by Doxiadis et al!)</p>
<p>Type theory did not end its life as a metamathematical hack that solved a set theoretical problem. <a href="http://cacm.acm.org/magazines/2010/2/69367-type-theory-comes-of-age/fulltext">It has now come of age.</a> Type systems are, of course, at the heart of the development of many modern programming languages. Java, C#, Lisp, ML and Haskell are but a few of the ones that depend completely on a nontrivial type system. (Even though C and C++ have type systems, they are kept in a crippled state by the fact that the programmer is allowed to ignore their commandments at will.)</p>
<p>What is the benefit of a type system in a programming language? In the words of <a href="http://www.cis.upenn.edu/~bcpierce/">Benjamin Pierce</a>,</p>
<blockquote><p>A type system is a syntactic method for automatically checking the  absence of certain erroneous behaviors by classifying program phrases  according to the kinds of values they compute.</p></blockquote>
<p>So, generally speaking, a type system helps distinguish correct programs from incorrect programs. The parser also does part of this job, of course, since many programs that cannot compile will not parse. But there are programs that are syntactically correct but at the same time semantically unsound according to the evaluation rules of the language. Consider the following Java statement:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">T x <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> U<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This is clearly syntactically acceptable, but is it semantically valid? In order for it to be, either U needs to be the same type as T, or a subtype of T. But Java programmers are free to define new subtypes of existing types in source code. In order for the parser to check the correctness of the assignment, it seems that either the grammar would become enormously large, or it would place awkward restrictions on Java syntax. So we leave more refined aspects of correctness to the type checker, which is applied later, post-parsing.</p>
<p>What does a type system look like? As used in programming languages today, a type system consists of a set of <em>typing judgments</em>. The judgments can be stacked together to form the <em>typing derivation</em> of an expression in the language. Every expression normally has a unique typing derivation, and when a type can be derived, we call the expression well typed. As Benjamin Pierce&#8217;s formulation suggests, each typing rule makes some assumptions about the kinds of values that constitute the various parts of an expression, and then says something about the kind of value that will be computed by the expression as a whole.</p>
<p>Type systems can look prohibitive at first sight, since they use quite a few algebraic symbols. But in general, the structure and interrelationships between the symbols is the most important thing to discern from them, and focussing on this aspect makes reading them much easier.</p>
<p>In the following mini-type system, typing judgments will have the form <img src='http://www.monomorphic.org/wordpress/wp-content/latex/4e7/4e703057592a70077f2894e4f4643f16-ffffff-000000-0.png' alt='\Gamma \vdash t: T' title='\Gamma \vdash t: T' class='latex' />, where <img src='http://www.monomorphic.org/wordpress/wp-content/latex/077/07710b5c43702a8bb7b9104eacc6ba71-ffffff-000000-0.png' alt='\Gamma' title='\Gamma' class='latex' /> is a <em>typing context</em>, <img src='http://www.monomorphic.org/wordpress/wp-content/latex/e35/e358efa489f58062f10dd7316b65649e-ffffff-000000-0.png' alt='t' title='t' class='latex' /> is a <em>term</em>, and <img src='http://www.monomorphic.org/wordpress/wp-content/latex/b9e/b9ece18c950afbfa6b0fdbfa4ff731d3-ffffff-000000-0.png' alt='T' title='T' class='latex' /> is a type. Terms are essentially fragments of the source code, and from smaller terms we can construct larger terms using syntactic forms. So for example, if <strong>a</strong>, <strong>b</strong> and <strong>c</strong> are terms, then we might use the if-syntax to construct the larger term</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>b<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>c<span style="color: #009900;">&#125;</span></pre></div></div>

<p>in a java-like language. The typing context <img src='http://www.monomorphic.org/wordpress/wp-content/latex/077/07710b5c43702a8bb7b9104eacc6ba71-ffffff-000000-0.png' alt='\Gamma' title='\Gamma' class='latex' /> is essentially just a map, mapping already typed terms to the types assigned to them. As we type increasingly large terms, we gradually add more information to the typing context. The symbol <img src='http://www.monomorphic.org/wordpress/wp-content/latex/7f5/7f5788d56bd683ffba59eed8ad6ecbe6-ffffff-000000-0.png' alt='\vdash' title='\vdash' class='latex' /> is just notational convention and has no particular meaning. The judgment <img src='http://www.monomorphic.org/wordpress/wp-content/latex/4e7/4e703057592a70077f2894e4f4643f16-ffffff-000000-0.png' alt='\Gamma \vdash t: T' title='\Gamma \vdash t: T' class='latex' /> is read as &#8220;term t has type T in typing context <img src='http://www.monomorphic.org/wordpress/wp-content/latex/077/07710b5c43702a8bb7b9104eacc6ba71-ffffff-000000-0.png' alt='\Gamma' title='\Gamma' class='latex' />&#8220;.</p>
<p>A fragment of a minimal system might look like the following.</p>
<img src='http://www.monomorphic.org/wordpress/wp-content/latex/d7a/d7a8b6c7986eb44d76281142c2a69410-ffffff-000000-0.png' alt='  \inferrule  {  \Gamma \vdash t_1 : T  \and  \text{vartype}(v) = U  \and  T &lt;: U  }  {  \Gamma \vdash v = t_1 : U  }  {  \text{T-ASGN}  }  \\  \vspace{5mm}  \\   \inferrule  {  \Gamma \vdash t_1 : \text{Int}  \and  \Gamma \vdash t_2 : \text{Int}  }  {  \Gamma \vdash t_1~\textsf{intBinop}~t_2 : \text{Int}  }  {  \text{T-BINOP}  }   \\  \vspace{5mm}  \\   \inferrule  {  \Gamma \vdash t_1 : \text{Bool}  \and  \Gamma \vdash t_2 : T_0  \and  \Gamma \vdash t_3 : T_0  }  {  \Gamma \vdash \text{if}~t_1~\text{then}~t_2~\text{else}~t_3 : T_0  }  {  \text{T-IF}  }  ' title='  \inferrule  {  \Gamma \vdash t_1 : T  \and  \text{vartype}(v) = U  \and  T &lt;: U  }  {  \Gamma \vdash v = t_1 : U  }  {  \text{T-ASGN}  }  \\  \vspace{5mm}  \\   \inferrule  {  \Gamma \vdash t_1 : \text{Int}  \and  \Gamma \vdash t_2 : \text{Int}  }  {  \Gamma \vdash t_1~\textsf{intBinop}~t_2 : \text{Int}  }  {  \text{T-BINOP}  }   \\  \vspace{5mm}  \\   \inferrule  {  \Gamma \vdash t_1 : \text{Bool}  \and  \Gamma \vdash t_2 : T_0  \and  \Gamma \vdash t_3 : T_0  }  {  \Gamma \vdash \text{if}~t_1~\text{then}~t_2~\text{else}~t_3 : T_0  }  {  \text{T-IF}  }  ' class='latex' />
<p>Three typing rules have been introduced here, T-ASGN for assignments, T-IF for if-statements, and T-BINOP for binary operations on integers, like + and -.<br />
Every rule has the same structure: above the line, assumptions that must hold true for the rule to be applied; below the line, the conclusion we may draw if the assumptions are true.</p>
<p>Above, the following example was given.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">T x <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> U<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Using T-ASGN, we can type an assignment statement like this one. The assumption T &lt;: U says that T is a subtype of U. We have also assumed a lookup function <strong>vartype</strong> which gives the declared type of the variable we assign to. In English, we can read the rule T-ASGN as saying: &#8220;Assuming that the type of the right hand side is a subtype of, or the same type as, the declared type of the variable, the assignment will evaluate to a value that has the declared type of the variable&#8221;. Of course not all programming languages implement assignment in this way.</p>
<p>In the T-BINOP rule, we must of course substitute an actual operation on integers for the special word <strong>intBinop</strong> for it to be valid. For addition, the rule can be read as &#8220;Assuming that the left hand side and the right hand side are both integers, then the result is also an integer&#8221;.</p>
<p>Finally, the T-IF rule says &#8220;assuming that the truth condition is a boolean, and that the two alternative paths have the same type, then the if-statement evaluates to the same type as that of the two conditional paths&#8221;.</p>
<p>The shape of the type system follows the evaluation rules for the language quite closely, so that a well-typed term is also always possible to evaluate. We can thus avoid accepting programs that might get stuck without any valid evaluation rule at some point. (Consider what happens in Python if you try to invoke a method on an object, and the object doesn&#8217;t have a method with that name.) We are not limited to tracking just the kinds of values being computed in a type system. We can track various kinds of safety properties, such as memory regions being violated, as well, or we may track multiple properties at once. <a href="http://en.wikipedia.org/wiki/Effect_system">Type and effect systems </a>is one way of tracking both values being computed and resource violations.</p>
<p>A good source of more information on type systems applied to programming languages would be Benjamin Pierce&#8217;s <a href="http://www.amazon.com/Types-Programming-Languages-Benjamin-Pierce/dp/0262162091/ref=cm_cr_pr_product_top">Types and Programming Languages</a>.</p>
 <p><a href="http://www.monomorphic.org/wordpress/?flattrss_redirect&amp;id=774&amp;md5=d3d903e1d4d5f0b5f1bc76ddf9d7f12c" title="Flattr" target="_blank"><img src="http://www.monomorphic.org/wordpress/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/type-theory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tips for academics who develop software</title>
		<link>http://www.monomorphic.org/wordpress/advice-for-academics-who-develop-software/</link>
		<comments>http://www.monomorphic.org/wordpress/advice-for-academics-who-develop-software/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 17:44:14 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Software development]]></category>
		<category><![CDATA[academic]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=533</guid>
		<description><![CDATA[Academics and practitioners, having rather different goals in life, tend to approach software development in quite different ways. No doubt there are many things each side of the fence can learn from the other, but I think academics in particular could often benefit quite a lot by adopting some of the practices used in industrial [...]]]></description>
			<content:encoded><![CDATA[<p>Academics and practitioners, having rather different goals in life, tend to approach software development in quite different ways. No doubt there are many things each side of the fence can learn from the other, but I think academics in particular could often benefit quite a lot by adopting some of the practices used in industrial development. And not just computer science academics!</p>
<p>A common misconception is that these techniques only are useful with large projects and large teams. I find, though, that they can help reduce much of the growth pains even in small projects, helping them reach maturity much faster.</p>
<p><strong>Use version control.</strong> Classical, but invalid, counter arguments include &#8220;it&#8217;s a hassle and too much work to set up&#8221;, or &#8220;there&#8217;s only one person working on this project anyway&#8221;. Even if it&#8217;s only you, you will benefit massively from being able to undo your changes far back in time. It will let you experiment safely. Plus, setup is no longer an issue with free and easy-to-use services like <a href="http://www.gitbub.com">github</a> and <a href="http://www.bitbucket.org">bitbucket</a>. My tool of choice is now Mercurial, and I used to use SVN. And there are many other good choices.</p>
<p><strong>Use a debugger.</strong> If there is a debugger available for your language, and there most certainly is, then you should use it to find nontrivial errors, rather than extensive printf style testing.</p>
<p><strong>Don&#8217;t optimise prematurely, but when you need to, use a profiler.</strong> Profilers tell you where a program&#8217;s performance bottlenecks are. You can profile things like heap usage (what classes use most space in Java, for instance) and CPU usage (which functions use the most CPU time). For Java, I&#8217;ve discovered that the NetBeans IDE has a very good built in profiler. Eclipse also has one, but it didn&#8217;t work on Mac last time I checked. For C/C++, GProf used to be good and probably still is.</p>
<p><strong>Use unit testing wisely.</strong> All of the above apply even to very small projects, but I think some projects are too small to need unit tests, at least initially. You be the judge. I find that unit tests can have a lot of benefit when applied to the fragile, complicated parts of a system, where many different things interlock. If you are ambitious you can also write tests first and code later &#8212; test driven development.</p>
<p><strong>Use a good IDE if you can.</strong> For a language like Java, where you have to type a lot of code to get something done and spread out your code across lots of files, a good IDE that can generate boilerplate code and navigate quickly can really speed up your work. It&#8217;s beneficial for other languages too. But I have no problem with people who use pure vim or emacs, after all these are practically IDEs.</p>
<p>I believe that honing your software development skills as an academic can pay off. Also see: Daniel Lemire on <a href="http://feedproxy.google.com/~r/daniel-lemire/atom/~3/yCTh62CVGi0/">why you should open source your projects</a>. (I will get around to doing this eventually, I promise <img src='http://www.monomorphic.org/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> )</p>
 <p><a href="http://www.monomorphic.org/wordpress/?flattrss_redirect&amp;id=533&amp;md5=14bb341f8788878c419453008dcc01a6" title="Flattr" target="_blank"><img src="http://www.monomorphic.org/wordpress/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/advice-for-academics-who-develop-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Where is Java going?</title>
		<link>http://www.monomorphic.org/wordpress/where-is-java-going/</link>
		<comments>http://www.monomorphic.org/wordpress/where-is-java-going/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 05:51:16 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Software development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[platforms]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=391</guid>
		<description><![CDATA[Today, Java is one of the most popular programming languages. Introduced in 1995, it rests on a tripod of the language itself, its libraries, and the JVM. In the TIOBE programming language league charts, it has been at the top for as long as the measurements have been made (since 2002), overtaken by C only [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.monomorphic.org/wordpress/wp-content/uploads/2009/11/creative.jpg"><img class="aligncenter size-medium wp-image-401" title="creative" src="http://www.monomorphic.org/wordpress/wp-content/uploads/2009/11/creative-225x300.jpg" alt="creative" width="225" height="300" /></a></p>
<p>Today, Java is one of the most popular programming languages. Introduced in 1995, it rests on a tripod of the language itself, its libraries, and the JVM. In the <a href="http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html">TIOBE programming language league charts</a>, it has been at the top for as long as the measurements have been made (since 2002), overtaken by C only for a brief period due to measurement irregularities.</p>
<p>Yet not all is <a href="http://www.sun.com/">Sun</a>-shine in Java world. Sun Microsystems is about to be taken over by Oracle, pending EU approval. (EU is really dragging its feet in this matter but it seems unlikely they would really reject the merger). Larry Ellison has voiced strong support for Java and for Sun&#8217;s way of developing software, so maybe this is really not a threat by itself. But how far can the language itself go?</p>
<p>The Java language was carefully designed to be relatively easy to understand and work with. James Gosling, its creator, has <a href="http://www.computer.org/portal/web/csdl/doi/10.1109/2.587548">called it a blue collar language</a>, meaning it was designed for industrial, real world use. In a world where C++ was the de facto standard for OO programming, Java was a big step forward in terms of ease of development, with its lack of pointers and strong type system &#8211; to say nothing of its garbage collection. Many classes of common programming errors were removed altogether. However, in the interests of simplicity and clarity, some tradeoffs were made. The language&#8217;s detractors today point to problems such as excessive verbosity, the lack of closures, the limited generics, and the checked exceptions.</p>
<p>For some time there has been a lot of exciting alternative languages available on the JVM. Clojure is a Lisp dialect. Scala, the only non-Java JVM language I have used extensively, mixes the functional and object oriented paradigms. Languages like JPython and JRuby basically exist to allow scripting and interoperability with popular scripting languages on the JVM.</p>
<p>Today it seems as if the JVM and the standardized libraries will be Java&#8217;s most prominent legacy. The language itself will not go away for a long time either &#8211; considering that many companies still maintain or develop in languages like Cobol and Fortran, we will probably be maintaining Java code 30 years from now (what a sad thought!), but newer and more modern JVM languages will probably take turns being number one. The JVM and the libraries guarantee that we will be able to mix them relatively easily anyway, unless they stray too far from the standard with their custom features.</p>
<p>So in hindsight, developing this intermediate layer, this virtual machine &#8211; and disseminating it so widely &#8211;  was a stroke of genius. Will it be that in future programming models we have even more standardized middle layers, and not just one?</p>
<p>Meanwhile, there&#8217;s a lot of debate about the process being used to shape and define Java. For a long time, Sun employed something called the Java Community Process, JCP, which was supposed to ensure openness. Some people <a href="http://www.jroller.com/scolebourne/entry/no_more_java_7">proclaim</a> that the openness has ended. To take one example, very recently, Sun announced that there will be support for closures in Java 7, after first announcing that there would be no support for closures in Java 7. The process by which this decision has been managed has been <a href="http://blogs.tedneward.com/2009/11/19/Closures+Are+Back+Again.aspx">described as</a> not being a community effort. Some aspects of Java are definitely up in the air these days.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/where-is-java-going/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>An unusual Java construct</title>
		<link>http://www.monomorphic.org/wordpress/an-unusual-java-construct/</link>
		<comments>http://www.monomorphic.org/wordpress/an-unusual-java-construct/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 09:11:08 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Software development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming languages]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=215</guid>
		<description><![CDATA[I now break the longstanding tradition of not posting code on this blog. I just wanted to share what I believe to be a somewhat unusual pattern in Java: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 public IMethod findMethod&#40;String name, String&#91;&#93; types&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>I now break the longstanding tradition of not posting code on this blog. I just wanted to share what I believe to be a somewhat unusual pattern in Java:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> IMethod findMethod<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name, <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> types<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		outer<span style="color: #339933;">:</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>IMethod m<span style="color: #339933;">:</span> m_methods<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>m.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>IType t<span style="color: #339933;">:</span> m.<span style="color: #006633;">getArgList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getTypes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> t.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>types<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#123;</span>
						<span style="color: #000000; font-weight: bold;">continue</span> outer<span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					i<span style="color: #339933;">++;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #000000; font-weight: bold;">return</span> m<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>On line 2, there&#8217;s a label <tt>outer:</tt> which identifies a location in the code. Normally this feature is used with keywords like the <a href="http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html">hotly debated</a> <tt>goto</tt> in C. Java has <tt>goto</tt> as a keyword, but doesn&#8217;t support the feature. However, you can still use the labels with statements like <tt>continue</tt> above (line 12), which in this case starts a new iteration of the outer loop rather than the inner one.</p>
<p>I can&#8217;t remember ever having had to use this feature of any C-like language before (perhaps once) so it was intriguing when it popped up. It&#8217;s possible that a neater implementation of this would put the inner loop in a <tt>matchesSignature</tt> method in the <tt>IMethod</tt> interface instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/an-unusual-java-construct/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

