<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: The Joy of Concatenative Languages Part 1</title>
	<atom:link href="http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1</link>
	<description>(permanently in beta)</description>
	<lastBuildDate>Sun, 29 Aug 2010 20:01:44 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Samuel A. Falvo II</title>
		<link>http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1/comment-page-1#comment-4407</link>
		<dc:creator>Samuel A. Falvo II</dc:creator>
		<pubDate>Fri, 19 Dec 2008 20:41:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1#comment-4407</guid>
		<description>If you find you need to be continually aware of the stack, then, plain and simple, &quot;You&#039;re Doing It Wrong.&quot;  With RPN-based languages, you should never have any words which accepts more than 3 items on the stack.  If you do, you almost certainly have to refactor.  This aids significantly in program comprehension as a side benefit, so it&#039;s actually GOOD that your awareness of the stack sticks out.

I&#039;ve had the &quot;luxury&quot; of maintaining Forth programs with poor factoring, and it&#039;s these kinds of programs that results in Forth&#039;s &quot;write-only&quot; conception.  This is absurdly false; Forth is no more write-only than Java, which I&#039;ve also had to maintain, particularly programs with six page-long methods.  You read that right -- SIX PAGES LONG.  I&#039;ll take write-only Forth over a six-page method definition in Java any day.

I&#039;ve also had the abject pleasure of maintaining (and even authoring) Forth code that follows the aforementioned guideline, along with the &quot;one definition, one line&quot; guideline, which resulted in a plethora of positive e-mails suggesting how readable the code was -- less than HALF of the respondents were proficient in Forth (many claimed it was their first exposure to the language).  So what does this tell us?

It tells me that people who b***h and moan over RPN syntax and how oh-so-hard it is to &quot;get it&quot;, blah blah blah, really needs to wake up and evaluate how they write their own code.  Nearly always, these are the kinds of programmers who don&#039;t give a hoot about the quality, readability, or stability of their code, because they feel that their proficiency in the language of their choice and training is such that they can do no wrong.  Therefore, RPN languages are useless toys, and can&#039;t possibly be used for grunt programming in real-world situations.

(Except that UPS and Fedex use digital signature tablets coded in Forth.  Power companies use electrical switches coded in Forth.  GE released a SONET switch whose OS **IS** Forth -- plug in a serial console, and you&#039;ll get the OK prompt!  Half of the orbiters around Mars run on Forth.  Our space shuttle&#039;s robotic arm and flight nav computers are programmed in Forth.  Etc.  Etc.  Etc.)

A program written well in a concatenative language will be shorter, easier to understand, and easier to reason about than a comparable program in an applicative language.  Because the stack replaces the use of local variables in most cases (of Factor&#039;s entire codebase, for example, locals were used in only 60 places, IIRC), issues concerning aliasing and update order disappear.  The explicit DUPs and SWAPs and so forth make register allocation somewhat easier, since the compiler now has unequivocal knowledge of the lifetime of a register&#039;s value.  It encourages a more lucid style of programming that isn&#039;t so math-centric (so-called &quot;fluent&quot; style of coding).  Ironically, concatenation is simply function composition, and as such can be reasoned about in a functional manner.

While I respect other&#039;s opinions on concatenative languages, to which they&#039;re free to express, I can&#039;t help but feel quite upset and even threatened when people make such absurd notions as the &quot;difficulty&quot; of learning such languages public.  Research shows people *naturally* follow a noun-verb order when communicating with others without a common language, and one need only remember just how difficult it was for you to learn algebra during highschool to understand the &quot;difficulty of learning&quot; infix notations!  Prior to your algebra lessons, learning about the semantics of variable substitution, the difficulties of memorizing the FOIL method and factoring, et. al., is something that concatenative notation would have TOTALLY eliminated from the get-go.  I&#039;ve seen five year olds do some mighty sophisticated arithmetic using concatenative notations, but few understand how to properly parse the quadratic formula.

So give me a break with this hard to learn stuff.  It&#039;s not hard to learn.  What *IS* hard is your inability to break out of your intellectual gutter.</description>
		<content:encoded><![CDATA[<p>If you find you need to be continually aware of the stack, then, plain and simple, &#8220;You&#8217;re Doing It Wrong.&#8221;  With RPN-based languages, you should never have any words which accepts more than 3 items on the stack.  If you do, you almost certainly have to refactor.  This aids significantly in program comprehension as a side benefit, so it&#8217;s actually GOOD that your awareness of the stack sticks out.</p>
<p>I&#8217;ve had the &#8220;luxury&#8221; of maintaining Forth programs with poor factoring, and it&#8217;s these kinds of programs that results in Forth&#8217;s &#8220;write-only&#8221; conception.  This is absurdly false; Forth is no more write-only than Java, which I&#8217;ve also had to maintain, particularly programs with six page-long methods.  You read that right &#8212; SIX PAGES LONG.  I&#8217;ll take write-only Forth over a six-page method definition in Java any day.</p>
<p>I&#8217;ve also had the abject pleasure of maintaining (and even authoring) Forth code that follows the aforementioned guideline, along with the &#8220;one definition, one line&#8221; guideline, which resulted in a plethora of positive e-mails suggesting how readable the code was &#8212; less than HALF of the respondents were proficient in Forth (many claimed it was their first exposure to the language).  So what does this tell us?</p>
<p>It tells me that people who b***h and moan over RPN syntax and how oh-so-hard it is to &#8220;get it&#8221;, blah blah blah, really needs to wake up and evaluate how they write their own code.  Nearly always, these are the kinds of programmers who don&#8217;t give a hoot about the quality, readability, or stability of their code, because they feel that their proficiency in the language of their choice and training is such that they can do no wrong.  Therefore, RPN languages are useless toys, and can&#8217;t possibly be used for grunt programming in real-world situations.</p>
<p>(Except that UPS and Fedex use digital signature tablets coded in Forth.  Power companies use electrical switches coded in Forth.  GE released a SONET switch whose OS **IS** Forth &#8212; plug in a serial console, and you&#8217;ll get the OK prompt!  Half of the orbiters around Mars run on Forth.  Our space shuttle&#8217;s robotic arm and flight nav computers are programmed in Forth.  Etc.  Etc.  Etc.)</p>
<p>A program written well in a concatenative language will be shorter, easier to understand, and easier to reason about than a comparable program in an applicative language.  Because the stack replaces the use of local variables in most cases (of Factor&#8217;s entire codebase, for example, locals were used in only 60 places, IIRC), issues concerning aliasing and update order disappear.  The explicit DUPs and SWAPs and so forth make register allocation somewhat easier, since the compiler now has unequivocal knowledge of the lifetime of a register&#8217;s value.  It encourages a more lucid style of programming that isn&#8217;t so math-centric (so-called &#8220;fluent&#8221; style of coding).  Ironically, concatenation is simply function composition, and as such can be reasoned about in a functional manner.</p>
<p>While I respect other&#8217;s opinions on concatenative languages, to which they&#8217;re free to express, I can&#8217;t help but feel quite upset and even threatened when people make such absurd notions as the &#8220;difficulty&#8221; of learning such languages public.  Research shows people *naturally* follow a noun-verb order when communicating with others without a common language, and one need only remember just how difficult it was for you to learn algebra during highschool to understand the &#8220;difficulty of learning&#8221; infix notations!  Prior to your algebra lessons, learning about the semantics of variable substitution, the difficulties of memorizing the FOIL method and factoring, et. al., is something that concatenative notation would have TOTALLY eliminated from the get-go.  I&#8217;ve seen five year olds do some mighty sophisticated arithmetic using concatenative notations, but few understand how to properly parse the quadratic formula.</p>
<p>So give me a break with this hard to learn stuff.  It&#8217;s not hard to learn.  What *IS* hard is your inability to break out of your intellectual gutter.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1/comment-page-1#comment-4404</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Wed, 17 Dec 2008 16:39:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1#comment-4404</guid>
		<description>@Daniel

Both forms work just fine.  In fact, the Scala parser turns them into the same thing under the surface.  I tend to prefer the curly-brace form for stylistic reasons (I think it&#039;s more clear that a closure is involved, rather than just a normal construct).  There are times that I use the ()=&gt; form, but not many.</description>
		<content:encoded><![CDATA[<p>@Daniel</p>
<p>Both forms work just fine.  In fact, the Scala parser turns them into the same thing under the surface.  I tend to prefer the curly-brace form for stylistic reasons (I think it&#8217;s more clear that a closure is involved, rather than just a normal construct).  There are times that I use the ()=&gt; form, but not many.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Yankowsky</title>
		<link>http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1/comment-page-1#comment-4403</link>
		<dc:creator>Daniel Yankowsky</dc:creator>
		<pubDate>Wed, 17 Dec 2008 08:02:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1#comment-4403</guid>
		<description>As a Scala newcomer, I was a little curious about your syntax. I would have left out the curly braces:

val plus = (x: Int, y: Int) =&gt; x + y
plus(2, 3)

Running that through the interpreter seems to work fine. I&#039;m wondering if there is any difference in meaning between the two forms. Was that just for grouping, or does it mean something very different?</description>
		<content:encoded><![CDATA[<p>As a Scala newcomer, I was a little curious about your syntax. I would have left out the curly braces:</p>
<p>val plus = (x: Int, y: Int) =&gt; x + y<br />
plus(2, 3)</p>
<p>Running that through the interpreter seems to work fine. I&#8217;m wondering if there is any difference in meaning between the two forms. Was that just for grouping, or does it mean something very different?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mwanji Ezana</title>
		<link>http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1/comment-page-1#comment-4387</link>
		<dc:creator>Mwanji Ezana</dc:creator>
		<pubDate>Tue, 09 Dec 2008 13:36:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1#comment-4387</guid>
		<description>Interesting, I&#039;d never heard of these kinds of languages. It took me a while to figure out why:

2 3 plus
10 </description>
		<content:encoded><![CDATA[<p>Interesting, I&#8217;d never heard of these kinds of languages. It took me a while to figure out why:</p>
<p>2 3 plus<br />
10</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1/comment-page-1#comment-4385</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Mon, 08 Dec 2008 18:02:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1#comment-4385</guid>
		<description>@Itay

I think Cat&#039;s main weak point is that some algorithms that require random-access variables can be extremely clumsy to express.  It&#039;s not terribly hard to think in terms of the stack, but that doesn&#039;t mean that it&#039;s the cleanest way to do things.

I&#039;m also unsure whether or not Cat has any meaningful integration with the common object system.  If not, then it is absolutely not worth looking at for any real work.</description>
		<content:encoded><![CDATA[<p>@Itay</p>
<p>I think Cat&#8217;s main weak point is that some algorithms that require random-access variables can be extremely clumsy to express.  It&#8217;s not terribly hard to think in terms of the stack, but that doesn&#8217;t mean that it&#8217;s the cleanest way to do things.</p>
<p>I&#8217;m also unsure whether or not Cat has any meaningful integration with the common object system.  If not, then it is absolutely not worth looking at for any real work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Itay Maman</title>
		<link>http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1/comment-page-1#comment-4384</link>
		<dc:creator>Itay Maman</dc:creator>
		<pubDate>Mon, 08 Dec 2008 17:42:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1#comment-4384</guid>
		<description>Daniel,

I believe that programming is about trade offs. I think that almost every principle, rule, guideline, model, paradigm, you name it, has its pros and cons. Focusing on PL paradigms then one can say (forgive me for the over simplification) that FP languages are good for writing computations/algorithms but not as natural for handling I/O. Given your experience with Cat, could you highlight its weak points? (its strong points are obvious).</description>
		<content:encoded><![CDATA[<p>Daniel,</p>
<p>I believe that programming is about trade offs. I think that almost every principle, rule, guideline, model, paradigm, you name it, has its pros and cons. Focusing on PL paradigms then one can say (forgive me for the over simplification) that FP languages are good for writing computations/algorithms but not as natural for handling I/O. Given your experience with Cat, could you highlight its weak points? (its strong points are obvious).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1/comment-page-1#comment-4383</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Mon, 08 Dec 2008 17:07:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1#comment-4383</guid>
		<description>@Jason

Nope, Cat isn&#039;t one of the supported languages.  I had to write a custom GeSHi mode for it based on the language specification.  I&#039;ve had to do that a few times now, including with Scala and SML.  Most of the time I just base the mode on jEdit&#039;s highlighting, but even that editor doesn&#039;t have a Cat mode that I know of.  :-)</description>
		<content:encoded><![CDATA[<p>@Jason</p>
<p>Nope, Cat isn&#8217;t one of the supported languages.  I had to write a custom GeSHi mode for it based on the language specification.  I&#8217;ve had to do that a few times now, including with Scala and SML.  Most of the time I just base the mode on jEdit&#8217;s highlighting, but even that editor doesn&#8217;t have a Cat mode that I know of.  <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Noakes</title>
		<link>http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1/comment-page-1#comment-4382</link>
		<dc:creator>Jason Noakes</dc:creator>
		<pubDate>Mon, 08 Dec 2008 16:56:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1#comment-4382</guid>
		<description>How did you highlight the Cat snippets? Does wp_syntax support Cat out of the box? I couldn&#039;t find Cat in the list of languages.</description>
		<content:encoded><![CDATA[<p>How did you highlight the Cat snippets? Does wp_syntax support Cat out of the box? I couldn&#8217;t find Cat in the list of languages.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1/comment-page-1#comment-4381</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Mon, 08 Dec 2008 16:50:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1#comment-4381</guid>
		<description>@Dmitriy

Of course the bytecode nonsense was sarcasm.  :-)  More importantly, I was trying to differentiate between commonly used high-level languages and rarely used low-levels.  Bytecode is an awesome stack oriented language, but it is rarely written by hand.  At least, hardly at all in proportion to the amount of auto-generation which takes place.  Also, it&#039;s filled with a number of low-level operations more reminiscent of assembly than ML.

@Itay

Actually, I&#039;ve been playing with stack-based languages for a few weeks now on-and-off, and I&#039;ve found very much to my surprise that the stack &quot;goes away&quot; over time.  It&#039;s like the parentheses in Lisp.  :-)  I can&#039;t say that it&#039;s as natural as writing code involving named variables with random access, but it&#039;s not too bad.  One thing Cat has going for it that the JVM lacks is higher-order functions (quotations).  These simplify things tremendously.  In fact, so much so that Cat doesn&#039;t have separate stacks and entirely lacks any variable mechanism (unlike Forth and Factor).

@Barry

Thanks for the clarification on RPN!  I threw in the reference half for coolness sake, I really know absolutely nothing about the language.

With regards to your comments on typing, just wait for Part 3.  :-)  It is true that conventional stack-based expressions are very easy to type: it just falls out without any effort whatsoever.  The first problem is in polymorphic arguments (e.g. pop, swap, dup).  That&#039;s easily overcome by adding universal types to the stack typing, but it doesn&#039;t solve every problem.  It turns out that higher-order functions are the real issue.  If you&#039;re impatient with regards to why and how it is resolved, I suggest you play around with Cat a little bit: it is a statically typed stack-based language with full inference.</description>
		<content:encoded><![CDATA[<p>@Dmitriy</p>
<p>Of course the bytecode nonsense was sarcasm.  <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />   More importantly, I was trying to differentiate between commonly used high-level languages and rarely used low-levels.  Bytecode is an awesome stack oriented language, but it is rarely written by hand.  At least, hardly at all in proportion to the amount of auto-generation which takes place.  Also, it&#8217;s filled with a number of low-level operations more reminiscent of assembly than ML.</p>
<p>@Itay</p>
<p>Actually, I&#8217;ve been playing with stack-based languages for a few weeks now on-and-off, and I&#8217;ve found very much to my surprise that the stack &#8220;goes away&#8221; over time.  It&#8217;s like the parentheses in Lisp.  <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />   I can&#8217;t say that it&#8217;s as natural as writing code involving named variables with random access, but it&#8217;s not too bad.  One thing Cat has going for it that the JVM lacks is higher-order functions (quotations).  These simplify things tremendously.  In fact, so much so that Cat doesn&#8217;t have separate stacks and entirely lacks any variable mechanism (unlike Forth and Factor).</p>
<p>@Barry</p>
<p>Thanks for the clarification on RPN!  I threw in the reference half for coolness sake, I really know absolutely nothing about the language.</p>
<p>With regards to your comments on typing, just wait for Part 3.  <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />   It is true that conventional stack-based expressions are very easy to type: it just falls out without any effort whatsoever.  The first problem is in polymorphic arguments (e.g. pop, swap, dup).  That&#8217;s easily overcome by adding universal types to the stack typing, but it doesn&#8217;t solve every problem.  It turns out that higher-order functions are the real issue.  If you&#8217;re impatient with regards to why and how it is resolved, I suggest you play around with Cat a little bit: it is a statically typed stack-based language with full inference.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fogus</title>
		<link>http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1/comment-page-1#comment-4380</link>
		<dc:creator>Fogus</dc:creator>
		<pubDate>Mon, 08 Dec 2008 14:54:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/cat/the-joy-of-concatenative-languages-part-1#comment-4380</guid>
		<description>An interesting book (although quite old) on Stack Machines and their languages can be found online at:

http://www.ece.cmu.edu/~koopman/stack_computers/index.html

-m</description>
		<content:encoded><![CDATA[<p>An interesting book (although quite old) on Stack Machines and their languages can be found online at:</p>
<p><a href="http://www.ece.cmu.edu/~koopman/stack_computers/index.html" rel="nofollow">http://www.ece.cmu.edu/~koopman/stack_computers/index.html</a></p>
<p>-m</p>
]]></content:encoded>
	</item>
</channel>
</rss>
