<?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>A Lexical Mistake &#187; Languages</title>
	<atom:link href="http://alexicalmistake.com/category/languages/feed/" rel="self" type="application/rss+xml" />
	<link>http://alexicalmistake.com</link>
	<description>Languages; Past, Present and Future</description>
	<lastBuildDate>Sun, 06 Sep 2009 22:00:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Prototype Pattern and Extensible Compilers</title>
		<link>http://alexicalmistake.com/2008/11/the-prototype-pattern-and-extensible-compilers/</link>
		<comments>http://alexicalmistake.com/2008/11/the-prototype-pattern-and-extensible-compilers/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 17:48:22 +0000</pubDate>
		<dc:creator>Lorenz Pretterhofer</dc:creator>
				<category><![CDATA[Languages]]></category>
		<category><![CDATA[AST]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[Mention]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[self]]></category>

		<guid isPermaLink="false">http://alexicalmistake.com/?p=75</guid>
		<description><![CDATA[During some of the early design work on the Mention programming language, I recognized that a fixed parser would be unable to deal with a great number of interesting language problems. Things like embedded SQL and other DSL language, or perhaps even a unit notation.
All of these things could be added into a syntax, I [...]]]></description>
			<content:encoded><![CDATA[<p>During some of the early design work on the Mention programming language, I recognized that a fixed parser would be unable to deal with a great number of interesting language problems. Things like embedded SQL and other DSL language, or perhaps even a unit notation.</p>
<p>All of these things could be added into a syntax, I believe, with a carefully constructed extensible parser. Each extension would become a libraries (modules) adding or replacing function points in the existing parser later reusing some of them as part of the extended syntax. (The actual parser would be based on Parsec and other similar combinator parsers. OMeta is also related to this parser architecture.)</p>
<p>The problem with adding new syntaxes to a language isn&#8217;t just the parser implementation however. Most of the really tricky problems actually come from the rest of the tool chain. Things like the compiler, debugger, profilers, editor, and a bunch of other potential tools. It had become clear to me that I wasn&#8217;t just working on an extensible parser, but rather an extensible language, and that meant an extensible compiler architecture.</p>
<p>Basically I thinking about a completely extensible intermediate language, which would power a set of semi-extensible libraries for implementing the bulk of the tool-chain. These libraries will take the leg-work out of processing the source code, and will allow the tools to manipulate or interact with the code in its intermediate form (this includes editors and analytical tools). The only problem I saw was that I had absolutely no idea how to construct such an intermediate language, little own how to write tools and libraries to interact with it.</p>
<p>Anyway, recently I run into the latest (at the time) Steve Yegge post, with a somewhat inspiring discussion about the Prototype Pattern (<a href="http://steve-yegge.blogspot.com/2008/10/universal-design-pattern.html">The Universal Design Pattern</a>). After musing about pattern (again) for a couple of days, it finally hit me, I had the architecture all wrong. This isn&#8217;t just some extensible compiler or parser&#8230;this was the Self programming language&#8230;redesigned, implemented and tailored for the task of compiler writing. The AST is simply a specialized variation of the Prototype pattern, or more succinctly, a compiler is just a constrained dialect of Self, designed for compiler tasks.</p>
<p>So this my proposal is this, use the prototype pattern for Mentions AST and build a framework of libraries and tools designed to aid in the maintenance and development of an AST and the compilers, parsers, debugger, <em>et cetera</em>, which depend on it.</p>
<p>There are already a few pitfalls that I can imagine coming out of this system. For one, a good namespace or typing system will probably be required to prevent name conflicts. That is, each extension or collection of extensions would add only private collections of attributes, while a smaller group of shared public attribute interfaces would be used to facilitate cooperation between extensions. And then there&#8217;s still the issue of expected behavior, which may be complicated by the potential for different combinations of compiler extensions to inadvertently interact in unexpected ways.</p>
<p>In any case, I believe that this will be one of the key features of the core Mention programming language and it may even make some of the more complicated features like type systems easier to implement and experiment with later on. At the very least, you can expect to see some follow up material on this when I start to get further into the implementation of the Mention.</p>
<p>&#8211; Lorenz</p>
]]></content:encoded>
			<wfw:commentRss>http://alexicalmistake.com/2008/11/the-prototype-pattern-and-extensible-compilers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Read Transparency</title>
		<link>http://alexicalmistake.com/2008/10/read-transparency/</link>
		<comments>http://alexicalmistake.com/2008/10/read-transparency/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 03:25:13 +0000</pubDate>
		<dc:creator>Lorenz Pretterhofer</dc:creator>
				<category><![CDATA[Languages]]></category>
		<category><![CDATA[functional]]></category>
		<category><![CDATA[Haskell]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[Mention]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://alexicalmistake.com/?p=59</guid>
		<description><![CDATA[Over the past few months I&#8217;ve been putting together a collection of requirements, of sorts, for a new class of dynamic functional programming languages, a language that could provide powerful dynamic features on par with Smalltalk or Self (and JavaScript etc.), without losing some important features like laziness or strong static typing.
One of the requirements [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past few months I&#8217;ve been putting together a collection of requirements, of sorts, for a new class of dynamic functional programming languages, a language that could provide powerful dynamic features on par with Smalltalk or Self (and JavaScript etc.), without losing some important features like laziness or strong static typing.</p>
<p>One of the requirements I keep stumbling across is the need for referentially transparent functions that are capable of interacting directly with mutable data structures. Yeah, the kind that, by definition, are not referentially transparent.</p>
<p>At first I considered using compiler attributes to mark a piece of code that interacts with side effects vs. code that doesn&#8217;t. Something like the IO/ST monads from Haskell but general enough any function can interact with mutable variables, not just ones returning a monadic value. Unfortunately any code that interacts with mutable variables may behave radically differently when not constrained by the full monadic infrastructure or some equivalent like strictness (Scheme and ML).</p>
<p>I believe the only useful solution is to define a new property of the code&#8211;<em>read transparency</em>&#8211;which allows us to recognize code that is referentially transparent on immutable data while also referentially transparent towards unchanging mutable variables.</p>
<div style="margin-left: 5%; margin-right: 5%">A function is <em>read transparent</em> if it does not cause new side effects (either by IO, mutable state or otherwise), and the function produces equivalent result between any two calls provided the state of all arguments is equivalent (or the arguments are both immutable and the same values).</div>
<p>The above definition depends on the equivalence property of values, which I define along the lines of &#8220;any two data structures are equivalent if they are functionally the same value, or they only contain mutable variables containing equivalent state.&#8221; Given a good equivalence for all primitives this allows us to easily check for all functions which could safely be called in our new <em>semi-functional</em> programs.</p>
<p>The original motivating example for this concept was to allow functions like <code>show</code> in Haskell to work with any arbitrary data structure, mutable or not. This would greatly simplify programs like interpreters, which could use many of the same functions as pure code, without having to use somewhat cumbersome combinators like the lifting functions and unboxing functions (<code>readIORef</code>, etc.).</p>
<p>An important thing to remember about this property is that, while many previously referentially transparent functions would now only be read transparent, when used only with pure functional data, they are in fact promoted automatically to fully referentially transparent functions. That is, they remain effectively referentially transparent if you don&#8217;t care about mutable state, or to put it another way&#8211;the functions become more flexible, not less so. Only when the implementation of a function relies on language features that prevent mutable data from being used would the more restrictive referential transparency be required (like lazily evaluated results, incorporating the read operation).</p>
<p>We don&#8217;t actually have to stop there either. Just because a piece of code isn&#8217;t read transparent, that doesn&#8217;t mean that it suffers from all variations of side-effects. There are still yet more shades of grey which we can use to limit the damage caused by bugs and side-effects in our software. A property like write transparency for code that reads and writes to mutable data structures but performs no IO could be equally useful, just as the ST monad in Haskell, which cannot perform IO is useful for working with mutable state.</p>
<p>Unfortunately while our little definition is a rather interesting take on the mutable state issue, there are some rather serious caveats we still have to consider. The biggest problem we face here is that, while a read transparent function can read from mutable variables without any reprimands, it cannot use the unread mutable variable in the result, unless it uses it, still boxed. That is, if we returned a result lazily, the result might be different depending on when the result was used, definitely not something we want, and the primary reason that mutable state in Haskell is limited to the ST monad <em>et cetera</em>.</p>
<p>More concretely, we can return new mutable variables (since the result would always be equivalent), use the results from reading a mutable variable so long as we read it strictly before the function returns, and finally we can return the mutable variable verbatim as part of the result (something Haskell can do also). If any language implemented mutable variables unboxed however, they would not be usable in last context however, and you would <em>always</em> have to read from them strictly, leading to somewhat less flexibility in the language.</p>
<p>One last thing I&#8217;d like to add. The above definition is strikingly similar to something that might be rigorously defined and explored, but for some reason I haven&#8217;t done so in this post. Well, for all intents and purposes, I wouldn&#8217;t know where to start, at least not yet anyway. If and when I apply this property in an actual language implementation however, you can be sure I&#8217;ll have a rigorous writeup of it and it will likely be part of the languages spec too.</p>
<p>&#8211; Lorenz</p>
]]></content:encoded>
			<wfw:commentRss>http://alexicalmistake.com/2008/10/read-transparency/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Obvious Truth</title>
		<link>http://alexicalmistake.com/2008/03/the-obvious-truth/</link>
		<comments>http://alexicalmistake.com/2008/03/the-obvious-truth/#comments</comments>
		<pubDate>Sat, 08 Mar 2008 03:30:07 +0000</pubDate>
		<dc:creator>Lorenz Pretterhofer</dc:creator>
				<category><![CDATA[Languages]]></category>
		<category><![CDATA[Abstraction]]></category>
		<category><![CDATA[Language Design]]></category>
		<category><![CDATA[Scheme]]></category>

		<guid isPermaLink="false">http://krysole.net/2008/03/07/the-obvious-truth/</guid>
		<description><![CDATA[One of the most important qualities of a good programming language is the first class function. This critical language feature makes possible a whole class of behavioural and data abstraction techniques. Without it we could not incorporate many modern language like continuations, generators, or callbacks.
There are of course many workarounds to any of these features. [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most important qualities of a good programming language is the first class function. This critical language feature makes possible a whole class of behavioural and data abstraction techniques. Without it we could not incorporate many modern language like continuations, generators, or callbacks.</p>
<p>There are of course many workarounds to any of these features. These workarounds range from articles on simulating continuations in Object-Oriented languages and callbacks can be replaced in most cases by the, somewhat more complicated, event or messaging passing mechanisms. Generators however, really are just un-useful without proper first class functions.</p>
<p>A generator is simply a function that sends a number, possibly infinite, of values to an independent language construct, which can then take advantage of these values, one at a time. The proverbial construct associated with generators is the for loop. The loop invokes the generator, a value function within the generator produces each value, and the value function itself calls a function parameter containing the code body of the loop itself. There are usually some extra mechanisms to handle premature termination of the loop (among other things).</p>
<p>I digress however, since what I really want to discuss here is the language elements left behind. Features such as environment management, the function dispatch mechanisms, exception handling, memory management, concrete syntax, and so on. What I really want to see is language designers moving towards a more unified system, providing programmers, or at least library implementers, with abstractions for these features, rather than fixed semantics that limit the expressivity of the language.</p>
<p>See despite so many languages taking great pride in providing first class functions, most actually just inherited these features due to the popularisation of functional programming techniques. The real hidden gem here, I feel, is reifying language semantics however. This can allow programmers to selectively enhance or extend their favourite language, without losing the built-in compiler or interpreter, possibly at the cost of optimisations complexity.</p>
<p>My favourite example here is the environment, an element of language design that has historically encountered limitless debate. Yet, for reasons that I cannot comprehend, even languages promoting expressivity over implementation consistently refuse to provide language level abstractions over these features.</p>
<p>I’m not saying that most programming requires such levels of expressivity, and quite the opposite, most programming tasks will never require it. But there are some tasks that would benefit greatly from the presence of such features. Rather than re-implementing these, it should be possible to just tap into the abstractions provided by the programming language.</p>
<p>One style of programming that would definitely benefit from these extensions is programming language research. It would be much simpler to test out new environment models, construct prototype virtual machines and interpreters, and even mess around with less common things like dispatch algorithms or meta object protocols, if instead of building entirely new environment abstractions, the existing ones could be utilized and re-engineered in a controlled way. This requires both abstractions limiting the direct manipulation of the host language implementation, otherwise you really just re-implementing the host language, and by providing a preferable more powerful interface than the one likely used in the host languages compilers or interpreter. </p>
<p>Using Scheme as an example, it would be trivial to add some intermediate abstractions for managing the environment. Scheme already implements something very close to first class environments, and in-fact many lisps do actually provide procedures for inspecting and controlling where evaluation takes place, but it’s really not quite there yet.</p>
<p>The reason I singled out Scheme in this case, even comparatively to other dialects of Lisp, is because the larger dialects typically include an impressive continuations facility. This combines with the hygienic macro feature, producing extremely impressive language extension capabilities. Unfortunately, you still need to generate raw code, when writing domain specific languages if you wish to allow fragments of host language code to be embedded into the DSL. In my case these fragments correspond to actions and predicates in a parsing language I’ve been implementing.</p>
<p>Perhaps I should attempt a Scheme dialect with such features, and just maybe I’ll even end up with something new?</p>
<p>&#8211; Lorenz</p>
]]></content:encoded>
			<wfw:commentRss>http://alexicalmistake.com/2008/03/the-obvious-truth/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bootstrapping Objects</title>
		<link>http://alexicalmistake.com/2008/01/bootstrapping-objects/</link>
		<comments>http://alexicalmistake.com/2008/01/bootstrapping-objects/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 09:21:59 +0000</pubDate>
		<dc:creator>Lorenz Pretterhofer</dc:creator>
				<category><![CDATA[Languages]]></category>
		<category><![CDATA[Bootstrapping]]></category>
		<category><![CDATA[Mention/SLP]]></category>
		<category><![CDATA[Object Oriented]]></category>
		<category><![CDATA[Smalltalk]]></category>

		<guid isPermaLink="false">http://krysole.net/2008/01/28/bootstrapping-objects/</guid>
		<description><![CDATA[Ok, my prototype is slowly moving along, but one thing still alludes me. What is the best set of objects to bootstrap the system with, and which objects should be written on top of the system after the system is running?
The final version of the language was meant to be based on a concept of [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, my prototype is slowly moving along, but one thing still alludes me. What is the best set of objects to bootstrap the system with, and which objects should be written on top of the system after the system is running?</p>
<p>The final version of the language was meant to be based on a concept of method inlining. Basically, since most memory accesses are <em>more or less</em> constant events within a message, and even when they&#8217;re not, most of the code could be inlined further down the message stack, we could rather than using conventions or making the language very memory neutral/high level, we can instead allow programmers to directly manipulate their objects.</p>
<p>Of course this doesn&#8217;t really help us now (the current prototype is based on Squeak, which lacks the effective memory model to warrant using raw memory layouts yet), but even if we did implement this approach, we would still require a more generalized object layer on top of it. For this reason I believe that implementing a more restricted object model is in order.</p>
<p>To start with, I believe the basic object structure will be needed (Objects must be defined by the external system), and from there I will attempt to describe the general structure of the language using the Multi-Method equivalent of delegation (traits). This will include all of the necessary interfaces required to make the language self sufficient post bootstrap (except the Virtual Machine itself which will be rewritten in C or Haskell until the language can compile itself).</p>
<p>There will also be several objects that need to be constructed right from the word go, which includes, roughly, Integers, Floats, Strings, Symbols, Lists/Arrays, Dictionaries, Classes, Traits, and the base level behavioral interfaces that apply to all objects. These objects will be provided from Squeak directly, or will be implemented on a Generic object Squeak class, which can provide all of the necessary behaviour to bootstrap language level objects.</p>
<p>One last point I&#8217;d like to make. The behavioral interfaces do not actually apply to Mention objects specifically, but rather describe how the programming environment reacts to objects in general. Any object may be added to the Mention system simply by defining the fundamental interfaces required (essentially just some relative typing information for the dispatch engine), and then it can be used anywhere in Mention that actual Mention objects can be! In-fact, this goes so far in the language that there will very likely be components that do not even encode type information into objects for the sake of performance (no object headers or garbage collection). This is possible if the interfaces do not require any dispatching at runtime (otherwise the lack of type information interfaces will cause compilation errors!).</p>
<p>Anyway, hopefully I&#8217;ll have the prototype more or less working soon and you&#8217;ll be able to check it out for yourself, though it won&#8217;t do very much at the moment;)</p>
<p>&#8211; Lorenz</p>
]]></content:encoded>
			<wfw:commentRss>http://alexicalmistake.com/2008/01/bootstrapping-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Growing Pains &#8211; Bootstrapping a new Language</title>
		<link>http://alexicalmistake.com/2008/01/growing-pains-bootstrapping-a-new-language/</link>
		<comments>http://alexicalmistake.com/2008/01/growing-pains-bootstrapping-a-new-language/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 19:32:05 +0000</pubDate>
		<dc:creator>Lorenz Pretterhofer</dc:creator>
				<category><![CDATA[Languages]]></category>
		<category><![CDATA[Language Design]]></category>
		<category><![CDATA[Lisp]]></category>
		<category><![CDATA[SLP]]></category>
		<category><![CDATA[Smalltalk]]></category>

		<guid isPermaLink="false">http://krysole.net/2008/01/25/growing-pains-bootstrapping-a-new-language/</guid>
		<description><![CDATA[Creating a programming language is hard. I&#8217;m not talking about the kind of hard that&#8217;s involved in math problems or even getting pwned with that rather expensive new internet connection (no, its not the mouse either&#8230; you&#8217;re really just not that good;). No, I&#8217;m talking about the sheer amount of effort required to first come [...]]]></description>
			<content:encoded><![CDATA[<p>Creating a programming language is hard. I&#8217;m not talking about the kind of hard that&#8217;s involved in math problems or even getting pwned with that rather expensive new internet connection (no, its not the mouse either&#8230; you&#8217;re really just not that good;). No, I&#8217;m talking about the sheer amount of effort required to first come up with your amazing, world changing programming language, and then realizing that you actually need to implement the whole thing a few times over, using variations of that language that are in-fact worse than what you started with (unless your using Java, in which case, jump right ahead).</p>
<p>As you might have guessed I&#8217;m mainly writing this out of mere frustration, that even the dumbed down, simplified variation of Mention that I&#8217;m attempting to bootstrap is going, well, slowly. Very slowly.</p>
<p>So far I&#8217;ve come to the conclusion that there may even be some general rules of thumb, which to the enlightened few, might not actually seem all that obvious. Firstly, the current attempt to bootstrap Mention is utilizing the Squeak programming language/tool-chain, in the hopes that it would help to speed up the development process. It didn&#8217;t. Actually, I&#8217;m even wondering if its actually slowing me down&#8230; Which brings me to the obvious question. Why?</p>
<p>The most useful languages that spring to mind after asking this question, probably actually come from the Lisp family, along the lines of some dialect of Scheme + a parsing language to complete the picture. But what would make a language like Lisp, outgun its successors like Smalltalk or perhaps even python. Well, actually, I think python might even work, but Smalltalk has issues&#8230; Namespace issues.</p>
<p>The issues with Smalltalk I&#8217;m referring to are the conventions surrounding the naming of global variables, or at least the lack-there-of. Many scripting languages and most Lisps, allow the programmer to assign to any old variable name, and its simply there, for the entire world to see. But of course, when you have to think in objects, you can&#8217;t expect to have globals. After all, good Object-Oriented software should be based on the interaction of object, and not glorified globals, singletons, or otherwise. Although you could be mistaken for thinking that the Application object is actually a global, but of course its not. Why, well I&#8217;m not sure really, its just not.</p>
<p>I&#8217;d rather not go on any further with this, but the point is simple. We know that software systems evolve, and don&#8217;t simply get designed and then implemented. And we know that software is not actually re-used until at least <em>some</em> refactoring has been performed (generally more than some). So why can&#8217;t we just use our globals while we understand the problem we&#8217;re working on, and if they do the job we can just keep them, and if they really are flakey code smells bend on silicon armageddon then we can simply refactor them once we understand how the problem breaks down into the individual problem level (application, subsystem, <em>et cetera</em>) objects.</p>
<p>&#8211; Lorenz <em>(feeling slightly better ;)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://alexicalmistake.com/2008/01/growing-pains-bootstrapping-a-new-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
