<?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>blog.joa-ebert.com - Blog of Joa Ebert &#187; misc</title>
	<atom:link href="http://blog.joa-ebert.com/category/misc/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.joa-ebert.com</link>
	<description>Actionscript3, Flash, Scala, Java, C#, C++, Algorithms &#38; Imageprocessing</description>
	<lastBuildDate>Fri, 11 Nov 2011 11:13:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>First look at Dart</title>
		<link>http://blog.joa-ebert.com/2011/10/11/first-look-at-dart/</link>
		<comments>http://blog.joa-ebert.com/2011/10/11/first-look-at-dart/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 09:35:23 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[dart]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=849</guid>
		<description><![CDATA[In this post I want to give you a short introduction to Google&#8217;s new language called Dart. Personally I am quite disappointed that Dart looks a lot like Java 8 with some tweaks here and there. Although the language is in its early stages I wonder why pattern matching was not a top-priority to the [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I want to give you a short introduction to Google&#8217;s new language called <a href="http://www.dartlang.org/" target="_blank">Dart</a>.<br />
<span id="more-849"></span><br />
Personally I am quite disappointed that Dart looks a lot like Java 8 with some tweaks here and there. Although the language is in its early stages I wonder why pattern matching was not a top-priority to the language team since Dart relies heavily on message passing. More on that in a second.</p>
<p>Since Dart should scale from small scripts to full applications it is nice to see support for generics from the start, optional typing and functions as first-class citizens.<br />
However that makes Dart look more like a better Java than JavaScript.</p>
<p>What makes Dart more of a web language is how you perform concurrent computations. This is done by shared-nothing message passing. The same way you do it with workers in JavaScript, actors in Erlang or Scala and hopefully quite soon in the Flash Player. We should not forget Go in this equation since it was also an effort to try out concurrency via channels that can send and receive messages. If we look a little bit more into Dart we can see some of the same ideas.</p>
<p>A worker in Dart are called <code>Isolate</code> <a href="http://www.dartlang.org/docs/api/Isolate.html#Isolate::Isolate" title="Isolate" target="_blank">[1]</a>. This makes sense since it runs completely isolate from the rest of your program. What is nice about the Dart approach is that you do not have to deal with files anymore when using an <code>Isolate</code>. JavaScript requires you to perform the task of having some special file lying around somewhere that adheres to the Worker protocol. When I write my application, I do not want to think about files that have some special top-level logic in them. Especially, I do not want to write a custom file at runtime using a blob-builder.</p>
<p>Dart embeds this from the start just like Go does. You will have a lot of <code>Isolate</code> objects communicating via a <code>SendPort</code> <a href="http://www.dartlang.org/docs/api/SendPort.html#SendPort::SendPort" title="SendPort" target="_blank">[2]</a> and a <code>ReceivePort</code> <a href="http://www.dartlang.org/docs/api/ReceivePort.html#ReceivePort::ReceivePort" title="ReceivePort" target="_blank">[3]</a>. The <code>Promise&lt;T&gt;</code> <a href="http://www.dartlang.org/docs/api/Promise.html#Promise::Promise" title="Promise" target="_blank">[4]</a> is just like Java&#8217;s <code>Future&lt;T&gt;</code> a holder for a value that can be computed later. I just wonder why they did not implement a read-only and write-only view on them. It would be nice if <code>Promise&lt;T&gt;</code> would be extended with methods like <code>map</code>, <code>flatMap</code> etc. because your code would be less spaghetti.</p>
<p>With no further ado I would like to explain some code now that you know how Dart works. Basically we calculate the n-th Fibonacci number with a very expensive approach. You would never do this in reality. Let us define <code>fib(x) = fib(x - 1) + fib(x - 2)</code> with <code>fib(1) = 1</code> and <code>fib(2) = 1</code>. So <code>fib(3)</code> is <code>fib(2) + fib(1)</code> which is <code>1 + 1</code>. Sorry for to bore you to death.</p>
<p>If we implement this in pseudo-code we get something like this:</p>
<p><code>
<pre>int fib(int x) {
  return x < 3 ? 1 : fib(x - 1) + fib(x - 2);
}</pre>
<p></code></p>
<p>If you would like to make this multi-threaded with Scala you could wrap the calls to <code>fib</code> into a <code>Future[Int]</code> like this:</p>
<p><code>
<pre>def fib(x: Int) =
  x match {
    case 1 | 2 => 1
    case _ =>
      val n1 = future { fib(x - 1) }
      val n2 = future { fib(x - 2) }
      n1() + n2()
  }</pre>
<p></code></p>
<p>We want to do the same with Dart. Since it is a language targeted for the web we get no access to blocking calls. The Scala code blocks when <code>n1()</code> or <code>n2()</code> is called. In layman's terms: we wait until the value has been computed.</p>
<p>Since there is no support for continuation passing style like C#'s <code>async</code> we have to write a lot of callbacks now.</p>
<p>This is the entry-point for the Dart version of this:</p>
<p><code>
<pre>main() {
  int n = 7;

  print("Computing fib($n) ... ");

  new FibIsolate().spawn().then(
    (port) =>
      port.call(n).receive(
        (value, port) => print("fib($n) = $value")
      )
  );
}</pre>
<p></code></p>
<p>First of all we see string-interpolation which is nice. Then we create a <code>FibIsolate</code> which I will show you in a second. When you create an <code>Isolate</code> it does not do anything so we have to call <code>spawn()</code> to perform the actual computation. However <code>spawn</code> returns us only a <code>Promise&lt;SendPort&gt;</code> which we can only use when available. This is done with the <code>then</code> method. <code>then</code> takes a function as an argument.<br />
There are multiple ways we could do this. <code>then((x) => ...)</code> is the same as <code>then((x) { ... })</code>. You are only allowed to use the first form for a single expression but you do not need to write all that boilerplate. In fact you are even allowed to omit a semicolon. Hell Yeah!</p>
<p>So when we get a <code>SendPort</code> which happens to be the case when our function is called we can send some value via the <code>call</code> method. Why use <code>call</code> and not <code>send</code>? <code>call</code> returns a <code>ReceivePort</code> which allows us to wait for the result. We do this by calling <code>receive</code> on the <code>ReceivePort</code> with a closure to print the value we get back.</p>
<p>Now let's have a look at the implementation of <code>FibIsolate</code>.</p>
<p><code>
<pre>class FibIsolate extends Isolate {
  main() {
    port.receive((n, replyTo) {
      switch(n) {
        case 0:
          replyTo.send(0); break;

        case 1:
        case 2:
          replyTo.send(1); break;

        default:
          Promise&lt;int&gt; n1 = new Promise&lt;int&gt;();
          Promise&lt;int&gt; n2 = new Promise&lt;int&gt;();

          new FibIsolate().spawn().then(
            (port) =&gt;
              port.call(n - 1).receive(
                (n, port) =&gt; n1.complete(n)
              )
          );

          new FibIsolate().spawn().then(
            (port) =&gt;
              port.call(n - 2).receive(
                (n, port) =&gt; n2.complete(n)
              )
          );

          n1.then(
            (x) =&gt; n2.then(
              (y) =&gt; x + y
            )
          ).flatten().then(
            (x) =&gt; replyTo.send(x)
          );
      }
    });
  }
}</pre>
<p></code></p>
<p>First of all we have to extend from <code>Isolate</code>. The <code>main()</code> function of an <code>Isolate</code> is its entry-point. Now something that really bugs me is the amount of indentation. Nearly every second <code>Isolate</code> which you are going to write has this form. Your actual logic starts at the fifth indentation level.</p>
<p>In the <code>main</code> method we immediately start listening for messages via the <code>Isolate</code>'s <code>ReceivePort</code>. Then we need to react on the message via a switch case. Now although it might look simple in this case it is very sad that Dart does not come with proper pattern matching since you will need to write a lot of switch-case in Dart code. If you have ever seen <a href="http://www.codecommit.com/blog/scala/scala-for-java-refugees-part-4" title="Scala for Java refugees (Part 4)" target="_blank">pattern matching in action</a> using Scala you never want to go back to a dumb switch statement.</p>
<p>In the <code>default</code> case it gets a little bit more interesting. We need to spawn two new instances of <code>FibIsolate</code> since we want to do this recursive. We need to receive their result and when we have both results we want to perform the addition and send our value back to the caller.</p>
<p>Since there are no blocking calls we create a <code>Promise&lt;int&gt;</code> for each <code>FibIsolate</code>. When can complete the <code>Promise&lt;int&gt;</code> once we receive a value from an isolate. This allows us to combine both <code>Promise&lt;int&gt;</code> objects and wait on their results. Why do we not nest the <code>FibIsolate</code> you might ask. Because we want to spawn both at the same time so the computation can happen in parallel.</p>
<p>The actual nesting happens in the <code>n1.then((x) =&gt; n2.then((y) =&gt; x + y))</code> construct. However the return type of <code>n1.then((x) =&gt; n2.then((y) =&gt; ...)</code> is no longer <code>Promise&lt;int&gt;</code> but <code>Promise&lt;Promise&lt;int&gt;&gt;</code>. Fortunately someone thought about this case and there is a <code>flatten()</code> method which turns the <code>Promise&lt;Promise&lt;int&gt;&gt;</code> into a <code>Promise&lt;int&gt;</code> we just have to await and the finally reply with the computed value.</p>
<p>However remember the definition of <code>fib(x)</code>? The case for 1, 2 and 0 is quite simple because we can reply with the value immediately. And we do this by calling <code>send</code> on the <code>SendPort</code> which I named <code>replyTo</code>.</p>
<p>You can take a look at the full example running in the browser <a href="http://try.dartlang.org/s/YwsV" target="_blank">here</a>.</p>
<p>What I like about Dart is that someone thought about workers and made them first-class citizens. Pattern-matching is on the road map and they will hopefully copy Scala. There are however a lot of things that I dislike.</p>
<ol>
<li>Semicolons are required but optional for shorthand <code>(x) =&gt; x</code></li>
<li>The <code>return</code> keyword is required but optional when used with <code>(x) =&gt; x</code></li>
<li>No control about concurrency. Are my isolates CPU or I/O bound?!</li>
<li>No syntactic sugar for writing an Isolate</li>
<li>Not DSL friendly like Scala or maybe even Kotlin</li>
<li><code>int</code> disguises itself as a primitive but is an object instead</li>
<li>Missed the opportunity to embed continuation passing style into the language from the start</li>
<li>Function is the only function-type</li>
</ol>
<p>The type-system can be argued as well. I did not find anything about type erasure yet. Personally Dart feels much more like Java and Go than JavaScript. But in the end I would be quite happy if Dart could replace JavaScript since it is a step in the right direction from my personal point of view.</p>
<p>[1] <a href="http://www.dartlang.org/docs/api/Isolate.html#Isolate::Isolate" target="_blank">http://www.dartlang.org/docs/api/Isolate.html#Isolate::Isolate</a><br />
[2] <a href="http://www.dartlang.org/docs/api/SendPort.html#SendPort::SendPort" target="_blank">http://www.dartlang.org/docs/api/SendPort.html#SendPort::SendPort</a><br />
[3] <a href="http://www.dartlang.org/docs/api/ReceivePort.html#ReceivePort::ReceivePort" target="_blank">http://www.dartlang.org/docs/api/ReceivePort.html#ReceivePort::ReceivePort</a><br />
[4] <a href="http://www.dartlang.org/docs/api/Promise.html#Promise::Promise" target="_blank">http://www.dartlang.org/docs/api/Promise.html#Promise::Promise</a></p>
<div class="none"><div class="g-plusone" data-href="http://blog.joa-ebert.com/2011/10/11/first-look-at-dart/" size="standard" count="true"></div></div> <p><a href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=849&amp;md5=e10e1c8fcd870004b1b39b84065bd672" title="Flattr" target="_blank"><img src="http://blog.joa-ebert.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2011/10/11/first-look-at-dart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=849&amp;md5=e10e1c8fcd870004b1b39b84065bd672" type="text/html" />
	</item>
		<item>
		<title>Real-world functional Scala</title>
		<link>http://blog.joa-ebert.com/2011/07/11/real-world-functional-scala/</link>
		<comments>http://blog.joa-ebert.com/2011/07/11/real-world-functional-scala/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 15:33:36 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[functional]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=797</guid>
		<description><![CDATA[If Java is a get shit done™​ language then Scala is a get shit done fast™​ language. The reason is that the signal to noise ratio is very high and that concise code is easier to reason about which makes it less error prone. When understanding Scala it is sometimes important to have a look [...]]]></description>
			<content:encoded><![CDATA[<p>If Java is a <em>get shit done</em>™​ language then Scala is a <em>get shit done fast</em>™​ language. The reason is that the signal to noise ratio is very high and that concise code is easier to reason about which makes it less error prone.</p>
<p>When understanding Scala it is sometimes important to have a look at some real-world examples &#8212; especially when it comes to functional programming. When I first started using Scala I had a hard time understanding some of the constructs used by other people. In this blog post I want do explain some of them. The first example is a classic one. You want to debug some structure and output all elements which have a condition set.</p>
<h3>Printing Elements of a Collection</h3>
<p>You will find this in every first-steps guide for Scala. What I like about it is the fact that you have only little amount of code to write if you want to inspect a certain structure.</p>
<pre class="brush: scala; title: ; notranslate">list filter { _.condition } foreach println</pre>
<h3>Flattening a Collection</h3>
<p>Convert a collection of collections to a flat collection. For instance you have a <code>List&lt;List&lt;String&gt;&gt;</code> in Java and want to get a <code>List&lt;String&gt;</code> instead.</p>
<pre class="brush: java; title: ; notranslate">
final List&lt;String&gt; newList = new LinkedList&lt;String&gt;();
for(final List&lt;String&gt; innerList : oldList) {
  newList.addAll(innerList);
}
</pre>
<p>A lot of code for a common operation. Probably the reason why the Google Guava library supports <code>Iterables.concat(oldList)</code> to get the same result. So how is this done in Scala?</p>
<pre class="brush: scala; title: ; notranslate">val newList = oldList.flatten</pre>
<p>A simple operation which is very powerful. Let me give you another example. Suppose you have a <code>List[Option[T]]</code> for some <code>T</code>. Before understanding Scala very well and before reading this <a href="http://www.codecommit.com/blog/ruby/monads-are-not-metaphors" target="_blank" title="Monads are not metaphors.">excellent article</a> about monads I once wrote shameful code like this.</p>
<pre class="brush: scala; title: ; notranslate">
val listOfOptions: List[Option[Int]] =
  List(Some(1), None, Some(3), None, Some(5))

// don't do this!
val listOfDefinedValues: List[Int] =
  listOfOptions filter { _.isDefined } map { _.get }

println(listOfDefinedValues) //List(1, 3, 5)
</pre>
<p>When encountering such a construct an alarm should raise in your head, telling you there must be a better way to do this. <code>flatten</code> to the rescue. <code>println(listOfOptions.flatten)</code> would do the job.</p>
<pre class="brush: scala; title: ; notranslate">
val listOfOptions: List[Option[Int]] =
  List(Some(1), None, None, Some(2))

println(listOfOptions.flatten) //List(1, 2)
</pre>
<h3>Using <code>flatMap</code> for good</h3>
<p>Although <code>flatMap</code> might sound esoteric at first it is a very helpful operation. So first of all you know there is the <code>map</code> operation which is extremely useful in a sense like this.</p>
<pre class="brush: scala; title: ; notranslate">&quot;hello world&quot; map { _.toUpper }</pre>
<p>So what is the deal with <code>flatMap</code>? It would not work in this case and the compiler would raise a type error. That is because a collection is expected as the result.</p>
<p><code>flatMap</code> makes a lot of sense when you have a collection and need to pass every element into a function that would then again return a collection.</p>
<pre class="brush: scala; title: ; notranslate">
val list = List(1,2,3,4)

def intToListOfChars(i: Int) =
  i.toString.toList

val listOfListOfChar: List[List[Char]] =
  list map intToListOfChars
</pre>
<p>As you can see calling <code>map</code> with <code>intToListOfChars</code> creates a list of lists and we could later <code>flatten</code> that list agin. Or we simply use <code>flatMap</code> which does all of this in one step.</p>
<pre class="brush: scala; title: ; notranslate">val listOfChars = list flatMap intToListOfChars</pre>
<p>Still this example is pretty awkward. But imagine you have a method like <code>trimToOption(value: String): Option[String]</code> which trims a string and returns <code>None</code> if the string is empty or null (for whatever reason).</p>
<p>If you write a webapplication which expects user input you are probably working with a lot of <code>Option[T]</code> values (or Box[T] in case of Lift). For example like this:</p>
<pre class="brush: scala; title: ; notranslate">val description: Option[String] = extractDescription(request)</pre>
<p>Now you also want to trim that description. Here are a couple of ways on how to do it using <code>trimToOption</code>.</p>
<pre class="brush: scala; title: ; notranslate">
// not so nice
val trimmed1 = trimToOption(description getOrElse &quot;&quot;)

// ugly as hell
val trimmed2 = description match {
  case Some(desc) =&gt; trimToOption(desc)
  case None =&gt; None
}

// kind of ugly
val trimmed3 = (description map trimToOption).flatten

// yey! :)
val trimmed4 = description flatMap trimToOption
</pre>
<p>So you see that <code>flatMap</code> is actually a pretty usable function.</p>
<h3>Passing a Tuple to a Function</h3>
<p>Sometimes you have to pass a tuple to a function and instead of the tuple you would like to pass each value of the tuple as a parameter.</p>
<pre class="brush: scala; title: ; notranslate">
val listOfStrings =
  List(&quot;Hello&quot;, &quot;World&quot;)

val withIndex = listOfStrings.zipWithIndex

println(withIndex) //List((Hello,0), (World,1)))
</pre>
<p>So now imagine you have a method like this:</p>
<pre class="brush: scala; title: ; notranslate">
def printStringWithIndex(value: String, index: Int) =
  println(index+&quot;: &quot;+value)
</pre>
<p>In this case <code>withIndex foreach printStringWithIndex</code> would not work because we pass a tuple to that method. Scala has a nice built-in method called <code>tupled</code> which takes a function and converts it to one accepting a tuple.</p>
<pre class="brush: scala; title: ; notranslate">withIndex foreach (printStringWithIndex _).tupled</pre>
<h3>Using the Compiler</h3>
<p>Imagine you have a class with a type parameter like <code>CustomList[T]</code> and now you want to have a method which is implemented only for some kind of <code>T</code>. Obviously one way would be to use traits and mix them in on demand. But it gets more and more complex.</p>
<p>Fortunately we can let the compiler proof the evidence of a type at a position in our code.</p>
<pre class="brush: scala; title: ; notranslate">
class Foo[T](bar: T) {
  // only allow this method if T is a String
  def length()(implicit proof: T =:= String) =
    bar.length
}

val foo1 = new Foo(123) //works just fine
foo1.length //does not compile.

val foo2 = new Foo(&quot;hello&quot;)
foo2.length //5
</pre>
<p>This is great because it allows us to introduce phantom types and to write less code for certain structures. For instance we have a <code>Connector[A]</code> in <a href="http://www.audiotool.com" target="_blank"/>Audiotool</a>. This connector accepts connections to other connectors. It is either an input or an output and it transmits an abstract signal. You can only connect an output with an input. A Connector accepts only connections of its own type and <i>virtual</i> connections. This means the following example would be uber-cool code. Unfortunately we did not write Audiotool in Scala ;)</p>
<pre class="brush: scala; title: ; notranslate">
class Connector[A] {
  add[B](conn: Conn[A, B])(implicit proof: A =:= B)
    { ... }

  add(connection: VirtualConn[_, _])
    { ... }
}
</pre>
<p>Note: This is in fact not a real example since it would not work. You could only connect an output with another output but I think you might get the idea and it is easier to follow.</p>
<h3>Conclusion</h3>
<p>Functional programming might seem weird. Constructs like <code>=:=</code> or <code>flatMap</code> are awkward at first but make complete sense. Using Scala and picking some of the functional idioms which you think are right and well understood in your team can increase productivity and lead to less bugs.</p>
<div class="none"><div class="g-plusone" data-href="http://blog.joa-ebert.com/2011/07/11/real-world-functional-scala/" size="standard" count="true"></div></div> <p><a href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=797&amp;md5=6fc55d24d694a29d49bb1568c7d8675c" title="Flattr" target="_blank"><img src="http://blog.joa-ebert.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2011/07/11/real-world-functional-scala/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<atom:link rel="payment" href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=797&amp;md5=6fc55d24d694a29d49bb1568c7d8675c" type="text/html" />
	</item>
		<item>
		<title>Endless scrolling with Lift</title>
		<link>http://blog.joa-ebert.com/2011/03/07/endless-scrolling-with-lift/</link>
		<comments>http://blog.joa-ebert.com/2011/03/07/endless-scrolling-with-lift/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 12:12:31 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=770</guid>
		<description><![CDATA[For the upcoming Audiotool 2.0 launch in collaboration with Burn I am developing our new website. The framework choice was quite obvious for me since I love Scala and really like Lift. Lift is very nice because of its excellent Ajax and Comet support. My main problem getting started with Lift was the lack of [...]]]></description>
			<content:encoded><![CDATA[<p>For the upcoming Audiotool 2.0 launch in collaboration with <a href="http://www.burn.com" target="_blank">Burn</a> I am developing our new website. The framework choice was quite obvious for me since <a href="http://blog.joa-ebert.com/2010/12/26/a-year-of-scala/">I love Scala</a> and really like <a href="http://www.liftweb.net/" target="_blank">Lift</a>. </p>
<p>Lift  is very nice because of its excellent Ajax and Comet support. My main problem getting started with Lift was the lack of documentation and real world examples. E.g. if you want a custom 404 page without a redirect your only source of information is a thread in the mailing list. Lift also comes with its own terminology and a lot of custom DSLs.</p>
<p>Cricitcs aside: I am absolutely happy that Lift exists. You simply have to start using it. The documentation has also improved a lot. <a href="http://simply.liftweb.net/" target="_blank">Simply Lift</a> and <a href="http://exploring.liftweb.net/" target="_blank">Exploring Lift</a> are available for free and the <a href="http://www.assembla.com/wiki/show/liftweb" target="_blank">Wiki</a> contains a lot of useful information too.</p>
<p>I want to give you a simple example of why I think that Lift is simply awesome and what sold me to the framework.  You probably know those endless scrolling pages.</p>
<p>Let&#8217;s see how to develop something similar with Lift and Scala. First of all we have to prepare a little template.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div class=&quot;lift:surround?with=default;at=content&quot;&gt;
  &lt;div class=&quot;lift:endless&quot;&gt;
    &lt;ul&gt;
      &lt;li&gt;item0&lt;/li&gt;
      &lt;li&gt;item1&lt;/li&gt;
      &lt;li&gt;item2&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
&lt;/div&gt;
</pre>
<p>That is all the HTML we need. In fact we need even less but if you are going for <a href="http://www.assembla.com/wiki/show/liftweb/Designer_Friendly_Templates" target="_blank">designer friendly templates</a> you could extend it with your usual page chrome.</p>
<p>There are two calls to Scala code in this template. <em>lift:surround</em> will trigger the <code>SurroundSnippet</code> and insert the current template into the <em>default</em> template at the <em>content</em> position.</p>
<p>Our duty is now the implementation of <em>lift:endless</em>. Lift comes with a dynamic convention-over-configuration lookup for the so-called snippets. I am not a fan of COC so I will stick to the manual mechanism of binding <em>endless</em> to a snippet. Lift offers the DispatchSnippet in this case.</p>
<p>You will have to add this line to <code>Boot.scala</code>:</p>
<pre class="brush: scala; title: ; notranslate">LiftRules.snippetDispatch append Map(&quot;endless&quot; -&gt; EndlessSnippet)</pre>
<p>It tells Lift to invoke the <code>dispatch</code> method of the EndlessSnippet object whenever a snippet named <em>endless</em> is encountered.</p>
<p>So the only missing piece is the implementationof the EndlessSnippet and this is where Lift really shines.</p>
<pre class="brush: scala; title: ; notranslate">
import net.liftweb.common._
import net.liftweb.util._
import net.liftweb.http._
import net.liftweb.util.Helpers._
import net.liftweb.http.js.jquery.JqJsCmds
import net.liftweb.http.js.JsCmds
import net.liftweb.http.js.JE
import scala.xml.{NodeSeq, Unparsed}

object EndlessSnippet extends DispatchSnippet with Loggable {
  def dispatch = {
    // If you want to execute render only when &quot;embed.xyz&quot; is called
    // you would match on &quot;xyz&quot; here.
    case _ =&gt; render
  }

  def render =  {
    // Generate a random identifier
    val containerId = nextFuncName

    // The page which we are currently looking at.
    var page = 0

    // Method to be called by JavaScript.
    def process(in: Any) = in match {
      case id: String if id == containerId =&gt;
        page += 1
        logger.debug(&quot;Generating page &quot;+page+&quot;.&quot;)

        // Generate new markup and append it to the list.
        JqJsCmds.AppendHtml(id, getItems(page))
      case _ =&gt;
        logger.error(&quot;Illegal data has been sent.&quot;)
        JsCmds.Noop
    }

    // Here we marry the template with our code.
    // &quot;*&quot; is a CSS selector that matches anything and #&gt; binds it to the content
    // we specify.
    // The most interesting part here is the JavaScript  which we bind to the process
    // closure. Lift does all the magic for us and calls the server-side method once the
    // user scrolls to the bottom of the page.
    &quot;*&quot; #&gt; (&lt;ul id={containerId}&gt;{getItems(page)}&lt;/ul&gt; ++ JsCmds.Script(JE.JsRaw(
&quot;&quot;&quot;$(window).scroll(function(){
  if($(window).scrollTop() == $(document).height() - $(window).height()) {&quot;&quot;&quot;+
    SHtml.jsonCall(containerId, process)._2.toJsCmd+&quot;&quot;&quot;
  }
})&quot;&quot;&quot;).cmd))
  }

  def getItems(offset: Int): NodeSeq = {
    val count = 100
    val start = offset * count
    val end = from + count

    // We generate a couple of &lt;li&gt; elements here.
    for(i &lt;- start until end) yield {
      &lt;li&gt;{&quot;item&quot;+i}&lt;/li&gt;
    }
  }
}
</pre>
<p>This little amount of code really shows the power of Lift. Simply write a closure and bind it to your JavaScript. Lift does all the plumbing for you. Then you only have to implement some logic on the server. In most cases you do not even have to write any JavaScript since Lift offers Ajax links, forms etc. already. <code>SHtml.a(...)</code> generates a link which will trigger a function on the server for instance.</p>
<p>But please beware: I am not sure if <code>SHtml.jsonCall</code> is actually the way how you should do this. There might be a better way of calling a server-side method via JavaScript.</p>
<p>There is of course more to Lift. Comet is where things get really cool and the record framework seems interesting as well. Hopefully this little excursion into Scala and Lift could quicken your appetite. Since I am usually not a frontend fan this made it interesting and fun again.</p>
<p>I will try to post a complete project in the next days as well. Before starting with the Audiotool website I wrote some test cases that might help other people getting started.</p>
<div class="none"><div class="g-plusone" data-href="http://blog.joa-ebert.com/2011/03/07/endless-scrolling-with-lift/" size="standard" count="true"></div></div> <p><a href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=770&amp;md5=1b7b40fbd7b1ee8d084618ca7f52d85a" title="Flattr" target="_blank"><img src="http://blog.joa-ebert.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2011/03/07/endless-scrolling-with-lift/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<atom:link rel="payment" href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=770&amp;md5=1b7b40fbd7b1ee8d084618ca7f52d85a" type="text/html" />
	</item>
		<item>
		<title>Understanding Scala Implicits</title>
		<link>http://blog.joa-ebert.com/2010/12/26/understanding-scala-implicits/</link>
		<comments>http://blog.joa-ebert.com/2010/12/26/understanding-scala-implicits/#comments</comments>
		<pubDate>Sun, 26 Dec 2010 21:30:54 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[implicit]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=741</guid>
		<description><![CDATA[Many languages make use of implicit conversions. Scala is the only language I know of which makes implicit definitions a feature. It is very easy to understand an implicit conversion since most programming languages do this already for you. Here are two examples (AS3/Java): trace("Implicitly converted: "+1) System.out.println("Implicitly converted: "+1); We only have to care [...]]]></description>
			<content:encoded><![CDATA[<p>Many languages make use of implicit conversions. Scala is the only language I know of which makes implicit definitions a feature.</p>
<p>It is very easy to understand an implicit conversion since most programming languages do this already for you. Here are two examples (AS3/Java):</p>
<p><code>trace("Implicitly  converted: "+1)</code><br />
<code>System.out.println("Implicitly converted: "+1);</code></p>
<p><span id="more-741"></span></p>
<p>We only have to care about the expression <code>"Implicitly  converted: "+1</code> which will result in &#8220;Implicitly  converted: 1&#8243;. Why does this happen? We have a string on the left hand side of the expression and an integer on the right hand side. When the compiler of your choice needs to emit code for this kind of expression it will widen the type of both operands. In this case the resulting type would be String since an implicit conversion from integer to String exists in both ActionScript and Java. If no such conversion exists you would probably get a compile time error.</p>
<p>The compiler inserts this conversion for you. In this example we can make use of an explicit conversion:</p>
<p><code>trace("Explicitly converted: "+1.toString())</code><br />
<code>System.out.println("Explicitly converted: "+Integer.toString(1));</code></p>
<p>Here we specify that we really want to concatenate two strings which is of course a tedious task. We are lucky to have implicit conversions. Whenever you want to go from type A to B a compiler either inserts an implicit conversion for you or tells you that it cannot do it with an error message.</p>
<p>In certain scenarios you might want to use implicit conversions for your own types. In ActionScript I might want to go from Sprite directly to BitmapData.</p>
<p>Here is an example. Please do not do this at home. There is a of course a much better way (and less memory intensive) to do a hit test on a Sprite.</p>
<p><code>
<pre>
function hitTest(bitmapData: BitmapData, x: int, y: int): Boolean {
  return bitmapData.getPixel32(x, y) != 0x00000000
}

const sprite: Sprite = new Sprite()
hitTest(sprite, 1, 2)
</pre>
<p></code></p>
<p>Now this code would not compile of course since <code>hitTest(sprite, 1, 2)</code> is incorrect. The compiler would tell you that it expects a BitmapData as the first parameter. Let us fix the example:</p>
<p><code>
<pre>
function hitTest(bitmapData: BitmapData, x: int, y: int): Boolean {
  return bitmapData.getPixel32(x, y) != 0x00000000
}

function toBitmapData(displayObject: DisplayObject): BitmapData {
  const result: BitmapData = new BitmapData(
      displayObject.transform.pixelBounds.width,
      displayObject.transform.pixelBounds.height)

  const matrix: Matrix = displayObject.transform.matrix

  matrix.tx = matrix.ty = 0.0
  result.draw(sprite, matrix)

  return result
}

const sprite: Sprite = new Sprite()
hitTest(toBitmapData(sprite), 1, 2)
</pre>
<p></code></p>
<p>Now it works but every time we would want to go from Sprite to BitmapData we have to insert our new <code>toBitmapData</code> function.</p>
<p>And here is what makes Scala so special. You can tell the compiler that toBitmapData may be used as an implicit conversion.</p>
<p>Here is the same example in Scala without making use of implicit conversions:</p>
<p><code>
<pre>
def hitTest(bitmapData: BitmapData, x: Int, y: Int) =
  bitmapData.getPixel32(x, y) != 0x00000000L

def toBitmapData(displayObject: DisplayObject) = {
  val result = new BitmapData(
      displayObject.transform.pixelBounds.width,
      displayObject.transform.pixelBounds.height)
  val matrix = displayObject.transform.matrix

  matrix.tx = 0.0
  matrix.ty = 0.0

  result.draw(sprite, matrix)
  result
}

val sprite = new Sprite()
hitTest(toBitmapData(sprite), 1, 2)
</pre>
<p></code></p>
<p>Not so different. However we can annotate the <code>toBitmapData</code> definition as implicit and the code would look like this:</p>
<p><code>
<pre>
def hitTest(bitmapData: BitmapData, x: Int, y: Int) = ...

implicit def toBitmapData(displayObject: DisplayObject) =
  ...

val sprite = new Sprite()
hitTest(sprite, 1, 2)
</pre>
<p></code></p>
<p>So I think now it is time to take a deep breath. If you think that this is dangerous you should keep two more things in mind. First of all the compiler will only use implicit conversions that are in the current scope of your method. This means if you define an implcit conversion in class A and want to use it in B you have to import it. Also it could happen that you have two implicit conversions in the same scope. Since the compiler does not know which one it should pick it will give you an error message. This makes a lot of sense.</p>
<p>So in the end it is a great way to enable a specific implicit conversion for parts of your code. You are also able to use an import statement only in a method body like this:</p>
<p><code>
<pre>
def myComplexMethod(a: A) = {
  import ImplicitConversions.fromAtoB
  ...
}
</pre>
<p></code></p>
<p>But this is just the one part about implicit conversions. In my <a href="http://blog.joa-ebert.com/2010/12/26/a-year-of-scala/" target="_self" title="A Year Of Scala">A Year Of Scala</a> post I did mention that implicit conversions can be used to build domain specific languages.</p>
<p>Right now we get rid of our explicit casts which is nice but a true DSL needs obviously much more. For instance I might want to say <code>0xff00ff.toHexString</code> instead of <code>toHexString(0xff00ff)</code>. This can also be achieved with implicit conversions. And this is not what you might already know from Java or ActionScript.</p>
<p>Whenever we invoke a method on an object, and the object&#8217;s type does not support that method, but an implicit conversion to a different type containing the method exists, it is applied. So remember the Sprite and BitmapData example?</p>
<p>This would be illegal in ActionScript:<br />
<code>sprite.getPixel(x, y)</code></p>
<p>This would be legal:<br />
<code>toBitmapData(sprite).getPixel(x, y)</code></p>
<p>And with an implicit toBitmapData method in Scala we get:<br />
<code>sprite.getPixel(x, y)</code></p>
<p>In fact this is quite simple. So in case you did not notice: this is also statically typed <a href="http://en.wikipedia.org/wiki/Monkey_patch" target="_blank" title="Monkey Patch">monkey patching</a>. And because you can omit dots and parenthesis we get code like <code>G("vertex1" --&gt; "vertex2")</code>. Where is the implicit conversion? A string has no <code>--&gt;</code> method defined but we could define an implicit conversion to a class <code>VertexPair</code> that has the <code>--&gt;</code> method defined.</p>
<p>Last but not least there are also implicit parameters and values in Scala. In fact only an implicit value may be used as an implicit parameter.</p>
<p>If you are always carrying the same parameter around you, why not define it as implicit? An OpenGL context for instance. <code>render(float t, GL11 gl)</code> is some kind of code that might occur very often. Let us make the <code>gl</code> parameter implicit.</p>
<p><code>def render(t: Float)(implicit gl: GL11) = ...</code></p>
<p>Now if you do not have an implicit value available, you can still call this method via <code>render(1.0f)(gl)</code>. But if you declare a GL11 object once as implicit it can be passed down the chain very easy.</p>
<p><code><br />
implicit val gl = framework.getOpenGLContext()<br />
render(1.0f)<br />
render(1.5f)<br />
</code></p>
<p>Now if you call a method inside render that needs an implicit GL11 parameter as well you would not have to declare it as implicit again. But the same rules apply here. If there are two implicit GL11 typed objects available the compiler will complain.</p>
<p>I hope this makes working with implicit conversions and values a little  bit easier.</p>
<div class="none"><div class="g-plusone" data-href="http://blog.joa-ebert.com/2010/12/26/understanding-scala-implicits/" size="standard" count="true"></div></div> <p><a href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=741&amp;md5=e68723f9b16fb59d657df5d8abe9526c" title="Flattr" target="_blank"><img src="http://blog.joa-ebert.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2010/12/26/understanding-scala-implicits/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<atom:link rel="payment" href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=741&amp;md5=e68723f9b16fb59d657df5d8abe9526c" type="text/html" />
	</item>
		<item>
		<title>Apparat RC6: Say Hello To An Old Friend</title>
		<link>http://blog.joa-ebert.com/2010/07/28/apparat-rc6-say-hello-to-an-old-friend/</link>
		<comments>http://blog.joa-ebert.com/2010/07/28/apparat-rc6-say-hello-to-an-old-friend/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 16:43:53 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[apparat]]></category>
		<category><![CDATA[as3c]]></category>
		<category><![CDATA[inline asm]]></category>
		<category><![CDATA[patrick le clec'h]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=628</guid>
		<description><![CDATA[Patrick Le Clec&#8217;h is an active committer to the Apparat project and recently we just merged his work into the main branch. With a couple of other changes this is now a good time for another release candidate. Patrick added a good old friend to Apparat: The __asm function. You might remember __asm from my [...]]]></description>
			<content:encoded><![CDATA[<p>Patrick Le Clec&#8217;h is an <a href="https://www.ohloh.net/p/apparat/contributors" target="_blank" title="Apparat Contributors">active committer</a> to the <a href="http://apparat.googlecode.com/" target="_blank" title="Apparat on Googlecode">Apparat</a> project and recently we just merged his work into the main branch. With a couple of other changes this is now a good time for another release candidate. Patrick added a good old friend to Apparat: The <code>__asm</code> function. You might remember <code>__asm</code> from my work on the now deprecated <a href="http://as3c.googlecode.com/" target="_blank" title="AS3C on Googlecode">AS3C</a> project.</p>
<p>However the Apparat version is much better. First of all we have put a lot of work into Apparat to make such transformations rock-solid. AS3C had its issues and was never a reliable tool. But there are a lot of new great features Patrick implemented. You can mix AS3 in your bytecode as well. <code>__as3</code> is the best friend of <code>__asm</code>. Because sometimes writing pure bytecode is very verbose and not necessary.</p>
<p>A simple <code>trace('Hello World!')</code> with pure bytecode would look like this. Please note the <code>FindPropStrict</code> and <code>CallPropVoid</code> operations which reference <code>trace</code>.</p>
<p><code>
<pre>__asm(
  FindPropStrict(AbcQName('trace', AbcNamespace(NamespaceKind.PACKAGE, ''))),
  PushString('Hello World!'),
  CallPropVoid(AbcQName('trace', AbcNamespace(NamespaceKind.PACKAGE, '')), 1)
);</pre>
<p></code></p>
<p>Finding the object in the correct namespace is often a very cumbersome task. Thanks to <code>__as3</code> we can also write this in a much more conciese way.</p>
<p><code>
<pre>__asm(
  FindPropStrict(__as3(trace)),
  PushString('Hello World!'),
  CallPropVoid(__as3(trace), 1)
);</pre>
<p></code></p>
<p>Note that the ASM compiler will try to guess the required name once it is requested by an operation. You can use <code>__as3</code> also for other tasks.</p>
<p><code>
<pre>
var x: int = 1;
__asm(
  FindPropStrict(__as3(trace)),
  __as3(x < 10),
  CallPropVoid(__as3(trace), 1)
);
</pre>
<p></code></p>
<p>This would trace "true" for instance. If you are curious about the ASM syntax I can recommend you using the dump tool. It produces code which is nearly <code>__asm</code>-ready. We will probably write another output so you can directly transform existing code to <code>__asm</code> calls.</p>
<p>If you are interested in some more examples the Apparat Math replacements make use of <code>__asm</code> now as well. <a href="http://code.google.com/p/apparat/source/browse/apparat-ersatz/src/main/as3/apparat/math/IntMath.as" target="_blank" title="Apparat IntMath">IntMath</a> is a good example for an inlined class where you are using maybe a simple method like <code>IntMath.abs</code> and the heavy lifting is done behind the scenes using inline assembler. To use the ASM expansion you have to process your SWF file with TDSI. It is by default turned on.</p>
<div class="none"><div class="g-plusone" data-href="http://blog.joa-ebert.com/2010/07/28/apparat-rc6-say-hello-to-an-old-friend/" size="standard" count="true"></div></div> <p><a href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=628&amp;md5=355cdbce300b6499b16a1cdc1d022223" title="Flattr" target="_blank"><img src="http://blog.joa-ebert.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2010/07/28/apparat-rc6-say-hello-to-an-old-friend/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		<atom:link rel="payment" href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=628&amp;md5=355cdbce300b6499b16a1cdc1d022223" type="text/html" />
	</item>
		<item>
		<title>LZMA compression in Apparat RC5</title>
		<link>http://blog.joa-ebert.com/2010/07/15/lzma-matryoshka/</link>
		<comments>http://blog.joa-ebert.com/2010/07/15/lzma-matryoshka/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 21:23:12 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[apparat]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[deflate]]></category>
		<category><![CDATA[lzma]]></category>
		<category><![CDATA[matryoshka]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=614</guid>
		<description><![CDATA[I have released Apparat RC5 at GoogleCode. It contains a really cool feature which is called LZMA compression. Reducer has advanced a lot during the last couple of weeks. It is now also a strong SWF compression tool even if you do not have any PNG files it can compress. You may ask: &#8220;What is [...]]]></description>
			<content:encoded><![CDATA[<div align="center"><img src="/wp-content/images/matryoshka.png" width="480" height="371" alt="Matryoshka avec moustache"/></div>
<p>I have released <a href="http://apparat.googlecode.com/" target="_blank" title="Apparat">Apparat</a> RC5 at GoogleCode. It contains a really cool feature which is called <a href="http://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Markov_chain_algorithm" target="_blank" title="Lempel-Ziv-Markov chain algorithm">LZMA</a> compression.</p>
<p>Reducer has advanced a lot during the last couple of weeks. It is now also a strong SWF compression tool even if you do not have any PNG files it can compress. You may ask: &#8220;What is that Matryoshka doing there? And why the hell the top hat?&#8221; The top hat: <a href="http://www.youtube.com/watch?v=SL-BTMEDEs4" target="_blank" title="42">I do not know</a>. The Matryoshka: I can explain.</p>
<p>The Flash Player does not understand LZMA. SWF files are compressed using good old <a href="http://en.wikipedia.org/wiki/Deflate" target="_blank" title="DEFLATE">DEFLATE</a>. So what happens? Apparat extracts your original SWF. It compresses it again using the LZMA algorithm. The compressed SWF is injected into another SWF that contains an LZMA decoder. Size, background color, frame rate, etc. get adjusted. Finally you get a new SWF that contains your old SWF and a decoder to extract it at runtime. The overhead of the decoder is currently at around 5kb and I hope I can get it even smaller.</p>
<p>When you open that SWF with the Flash Player it will extract your original file and load it. Another nice feature is that I created different versions of the runtime decoder. One is using a classic preloader which is great if your SWF is a little bit bigger. And hey: it is a preloader for free so you do not have to deal with the [Frame] hassle. But here is the catch. We at <a href="http://www.audiotool.com/" target="_blank">audiotool.com</a> always write our SWF files in the same style and I can just hope you do the same or use the great <a href="http://va.lent.in/blog/2010/07/08/initinjector-0-2b/" target="_blank" title="InitInjector 0.2b">InitInjector</a> by Valentin Simonov.</p>
<p>Your main SWF class or the so called DocumentClass must make sure that a <code>stage</code> is available before accessing it. This is really easy:</p>
<p><code>
<pre>public function Main() {
  addEventListener(Event.ADDED_TO_STAGE, init)
  if(null != stage) init()
}

private function init(event: Event = null): void {
  removeEventListener(Event.ADDED_TO_STAGE, init)
  // your original constructor code goes here ...
}</pre>
<p></code></p>
<p>Stick to that rule or InitInjector can automate it for you. Otherwise you will get a runtime exception that the <code>stage</code> is <code>null</code>. So this is one new feature. The other one is actually pretty standard. If you compile and link against a SWC file all classes will come in their own ABC file. Each ABC file has a constant pool. So if you link against 1000 classes you get 1000 constant pools. Reducer can merge all those files into a single one with some minor exceptions. It can also sort the constant pool so that constants which are used frequently consume less bytes when accessed. The <a href="http://funk-as3.googlecode.com" target="_blank" title="funk-as3">funk-as3</a> test runner which links against FlexUnit and the Flex framework is only loosing 3.01% of its weight with the old Reducer. The new version reduces it by 17.81% already thanks to the ABC merging. Combine that with some LZMA love and we get <b>35.34%</b>.</p>
<p>Besides you can call the LZMA compression as often as you want for some basic obfuscation. The LZMA compression alone is already a (weak) obfuscation of your bytecode.</p>
<p>Last but not least: <a href="http://www.youtube.com/watch?v=1D1cap6yETA" target="_blank" title="Good News">Good news everyone</a>! <a href="http://www.scala-lang.org/downloads" title="Scala Downloads" target="_blank">Scala 2.8</a> arrived so this is the last time you will have to update it for a while.</p>
<p>You can <a href="http://code.google.com/p/apparat/downloads/list" title="Apparat Downloads" target="_blank">download</a> the latest Apparat version at <a href="http://apparat.googlecode.com/" title="Apparat" target="_blank">GoogleCode</a>. Scala 2.8.0 is required.</p>
<div class="none"><div class="g-plusone" data-href="http://blog.joa-ebert.com/2010/07/15/lzma-matryoshka/" size="standard" count="true"></div></div> <p><a href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=614&amp;md5=15e555b84f4830c483be70613efce66f" title="Flattr" target="_blank"><img src="http://blog.joa-ebert.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2010/07/15/lzma-matryoshka/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		<atom:link rel="payment" href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=614&amp;md5=15e555b84f4830c483be70613efce66f" type="text/html" />
	</item>
		<item>
		<title>FITC San Francisco 2010</title>
		<link>http://blog.joa-ebert.com/2010/07/01/fitc-san-francisco-2010/</link>
		<comments>http://blog.joa-ebert.com/2010/07/01/fitc-san-francisco-2010/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 13:27:24 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[apparat]]></category>
		<category><![CDATA[fitc 2010]]></category>
		<category><![CDATA[san francisco]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=608</guid>
		<description><![CDATA[When you have people like Scott Dadich, Ben Fry, Kevin Lynch and Yugo Nakamura gathered at one conference you can be sure to expect nothing less than a stunning event. Shawn Pucknell is obviously raising the bar. This will be a tough time for an ordinary speaker like me. However I have no other intentions [...]]]></description>
			<content:encoded><![CDATA[<p>When you have people like <a href="http://www.wired.com/" target="_blank">Scott Dadich</a>, <a href="http://www.processing.org/" target="_blank">Ben Fry</a>, <a href="http://www.adobe.com" target="_blank">Kevin Lynch</a> and <a href="http://www.yugop.com/" target="_blank">Yugo Nakamura</a> gathered at one conference you can be sure to expect nothing less than a stunning event.</p>
<p><a href="http://www.fitc.ca/" target="_blank">Shawn Pucknell</a> is obviously raising the bar. This will be a tough time for an ordinary speaker like me. However I have no other intentions than giving a <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=110&#038;presentation_id=1213" target="_blank">lecture</a> that proves itself worthy of this event.</p>
<div class="none"><div class="g-plusone" data-href="http://blog.joa-ebert.com/2010/07/01/fitc-san-francisco-2010/" size="standard" count="true"></div></div> <p><a href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=608&amp;md5=5e9764d065b4531ea07f941c34e16ec7" title="Flattr" target="_blank"><img src="http://blog.joa-ebert.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2010/07/01/fitc-san-francisco-2010/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<atom:link rel="payment" href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=608&amp;md5=5e9764d065b4531ea07f941c34e16ec7" type="text/html" />
	</item>
		<item>
		<title>AudioTool Update With ToneMatrix</title>
		<link>http://blog.joa-ebert.com/2009/04/17/audiotool-update-with-tonematrix/</link>
		<comments>http://blog.joa-ebert.com/2009/04/17/audiotool-update-with-tonematrix/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 18:38:33 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[misc]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[audiotool]]></category>
		<category><![CDATA[hobnox]]></category>
		<category><![CDATA[tonematrix]]></category>

		<guid isPermaLink="false">http://blog.joa-ebert.com/?p=305</guid>
		<description><![CDATA[We have release a small update of the AudioTool and included André&#8217;s ToneMatrix. Some features that have been implemented in the last weeks are online as well. Removing an effect for instance will not destroy the cables. The desktop scales now without interrupting the audio output and various other performance tweaks have been made.]]></description>
			<content:encoded><![CDATA[<div align="center"><a href="http://www.hobnox.com/audiotool"><img src="http://blog.joa-ebert.com/wp-content/2009/04/at_tonematrix.png" alt="AudioTool with Tonematrix" title="tonematrix" width="438" height="302" class="size-full wp-image-306" /></a></div>
<p>We have release a small update of the AudioTool and included <a href="http://lab.andre-michelle.com/" target="_blank">André&#8217;s ToneMatrix</a>. Some features that have been implemented in the last weeks are online as well. Removing an effect for instance will not destroy the cables. The desktop scales now without interrupting the audio output and various other performance tweaks have been made.</p>
<div class="none"><div class="g-plusone" data-href="http://blog.joa-ebert.com/2009/04/17/audiotool-update-with-tonematrix/" size="standard" count="true"></div></div> <p><a href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=305&amp;md5=12189ada9373ec6f43f1695ae92ddf91" title="Flattr" target="_blank"><img src="http://blog.joa-ebert.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2009/04/17/audiotool-update-with-tonematrix/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<atom:link rel="payment" href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=305&amp;md5=12189ada9373ec6f43f1695ae92ddf91" type="text/html" />
	</item>
		<item>
		<title>AudioTool Update</title>
		<link>http://blog.joa-ebert.com/2008/05/09/audiotool-update/</link>
		<comments>http://blog.joa-ebert.com/2008/05/09/audiotool-update/#comments</comments>
		<pubDate>Fri, 09 May 2008 10:38:51 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[misc]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[hobnox audiotool]]></category>

		<guid isPermaLink="false">http://blog.je2050.de/?p=182</guid>
		<description><![CDATA[Hooray! The Hobnox AudioTool has been updated. You will find the TR-808 now and also some of our new stompboxes like the Compressor and Crusher. The mixer has also been expanded to cover 16 channels. There is a lot more stuff in the pipe and I am really excited about it. Developing the timeline and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.hobnox.com/" target="_blank"><img src="http://blog.je2050.de/wp-content/images/audiotool_808_update.png" alt="Hobnox AudioTool" border="0"/></a></p>
<p>Hooray! The <a href="http://www.hobnox.com/" target="_blank">Hobnox AudioTool</a> has been updated. You will find the TR-808 now and also some of our new stompboxes like the Compressor and Crusher. The mixer has also been expanded to cover 16 channels.</p>
<p>There is a lot more stuff in the pipe and I am really excited about it. Developing the timeline and saving arrangements are the next big steps. Until then: have fun playing around and stay tuned!</p>
<div class="none"><div class="g-plusone" data-href="http://blog.joa-ebert.com/2008/05/09/audiotool-update/" size="standard" count="true"></div></div> <p><a href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=182&amp;md5=de1f5b439016e5373ff03533495a646f" title="Flattr" target="_blank"><img src="http://blog.joa-ebert.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2008/05/09/audiotool-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=182&amp;md5=de1f5b439016e5373ff03533495a646f" type="text/html" />
	</item>
		<item>
		<title>First contribution to the ImageProcessing library</title>
		<link>http://blog.joa-ebert.com/2007/01/23/first-contribution-to-the-imageprocessing-library/</link>
		<comments>http://blog.joa-ebert.com/2007/01/23/first-contribution-to-the-imageprocessing-library/#comments</comments>
		<pubDate>Tue, 23 Jan 2007 16:25:32 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[imageprocessing]]></category>

		<guid isPermaLink="false">http://blog.je2050.de/?p=98</guid>
		<description><![CDATA[I am glad that UnitZeroOne.com made a contribution to the imageprocessing library. Now there is a very fast bump mapping and normal map filter (QuickBumpMap and QuickNormalMap). Theese filters work with a native filter like the QuickSepia and there would be a way to implement them on a pixel-level. So this is why they have [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://je2050.de/blog/wp-content/images/quickbumpmap.jpg" width="360" height="114" alt="QuickNormalMap and QuickBumpMap" style="float:right; padding-left: 3px"/>I am glad that <a href="http://www.unitzeroone.com/" target="_blank">UnitZeroOne.com</a> made a contribution to the imageprocessing library. Now there is a very fast bump mapping and normal map filter (QuickBumpMap and QuickNormalMap).<br />
Theese filters work with a native filter like the QuickSepia and there would be a way to implement them on a pixel-level. So this is why they have the Quick prefix.</p>
<p>Right now I am working (besides of my work) on very nice filters to synthesize textures. As always: Stay tuned!</p>
<div class="none"><div class="g-plusone" data-href="http://blog.joa-ebert.com/2007/01/23/first-contribution-to-the-imageprocessing-library/" size="standard" count="true"></div></div> <p><a href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=98&amp;md5=9135fdf7965adaa8de01637d23c9ee4d" title="Flattr" target="_blank"><img src="http://blog.joa-ebert.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2007/01/23/first-contribution-to-the-imageprocessing-library/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<atom:link rel="payment" href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=98&amp;md5=9135fdf7965adaa8de01637d23c9ee4d" type="text/html" />
	</item>
		<item>
		<title>Imageprocessing results</title>
		<link>http://blog.joa-ebert.com/2006/06/18/imageprocessing-results/</link>
		<comments>http://blog.joa-ebert.com/2006/06/18/imageprocessing-results/#comments</comments>
		<pubDate>Sun, 18 Jun 2006 09:32:46 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[imageprocessing]]></category>

		<guid isPermaLink="false">http://blog.je2050.de/?p=77</guid>
		<description><![CDATA[Maybe you remember me some days ago talking about research and object recognition. I finished it and had to present the theoretical background and practical working example. What can I say? I worked the night before my examination until seven o&#8217;clock in the morning to get it working. Without a written speech, sleep or something [...]]]></description>
			<content:encoded><![CDATA[<p>Maybe you remember me some days ago talking about <a href="http://blog.je2050.de/?p=51">research</a> and <a href="http://blog.je2050.de/?p=52">object recognition</a>. I finished it and had to present the theoretical background and practical working example. What can I say? I worked the night before my examination until seven o&#8217;clock in the morning to get it working. Without a written speech, sleep or something else helpful I talked about my program. The result was 14 of 15 possible points which is quiet good.</p>
<p>Now about the Imageprocessing part. I wrote a program that gets structural information from an obstacle you hold into the camera. The title is &#8220;Objectrecognition of presented obstacles&#8221; and this is done using a motion-detection for the movement. A scene background-substraction is done to get only the moved obstacle. Then there is a median-colour lookup after a lof of filters have been applied. Closing, Retinex and Blobcounter to mention only some of them.<br />
The last final part which I like most is the artificial neuronal network that recognizes the shape of the obstacle. I used a simple feed forward net and the results were also quiet good.</p>
<p>You can read the full  article <a href="http://blog.je2050.de/main.pdf">here</a>. I am sorry but it is not written in English so you can only read if you understand German.</p>
<div class="none"><div class="g-plusone" data-href="http://blog.joa-ebert.com/2006/06/18/imageprocessing-results/" size="standard" count="true"></div></div> <p><a href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=77&amp;md5=3b7df4acde50b393d48fc25d12bc9c43" title="Flattr" target="_blank"><img src="http://blog.joa-ebert.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2006/06/18/imageprocessing-results/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=77&amp;md5=3b7df4acde50b393d48fc25d12bc9c43" type="text/html" />
	</item>
		<item>
		<title>Free Visual C# 2005</title>
		<link>http://blog.joa-ebert.com/2006/06/14/free-visual-c-2005/</link>
		<comments>http://blog.joa-ebert.com/2006/06/14/free-visual-c-2005/#comments</comments>
		<pubDate>Wed, 14 Jun 2006 08:59:15 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://blog.je2050.de/?p=74</guid>
		<description><![CDATA[This is kind of old news but maybe you are as outdated as I am and you are happy about the news that there is a free version of Visual C# available at MSDN. Get it here!.]]></description>
			<content:encoded><![CDATA[<p>This is kind of old news but maybe you are as outdated as I am and you are happy about the news that there is a free version of Visual C# available at MSDN. Get it <a href="http://msdn.microsoft.com/vstudio/express/visualcsharp/" target="_blank">here!</a>.</p>
<div class="none"><div class="g-plusone" data-href="http://blog.joa-ebert.com/2006/06/14/free-visual-c-2005/" size="standard" count="true"></div></div> <p><a href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=74&amp;md5=e3afb53807394c921431b427b409f51d" title="Flattr" target="_blank"><img src="http://blog.joa-ebert.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2006/06/14/free-visual-c-2005/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=74&amp;md5=e3afb53807394c921431b427b409f51d" type="text/html" />
	</item>
		<item>
		<title>Steam Half-Life PHP util</title>
		<link>http://blog.joa-ebert.com/2006/04/24/steam-half-life-php-util/</link>
		<comments>http://blog.joa-ebert.com/2006/04/24/steam-half-life-php-util/#comments</comments>
		<pubDate>Mon, 24 Apr 2006 06:53:39 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://blog.je2050.de/?p=62</guid>
		<description><![CDATA[Here a free-to-use Half-Life server util that allows you to read players, rules and server-info from a server using the &#8220;new&#8221; Steam protocol. It was the request of a friend and I had my fun with PHP since I really hate it but this is the first time I used PHP5 (which seems to be [...]]]></description>
			<content:encoded><![CDATA[<p>Here a free-to-use Half-Life server util that allows you to read players, rules and server-info from a server using the &#8220;new&#8221; Steam protocol. It was the request of a friend and I had my fun with PHP since I really hate it but this is the first time I used PHP5 (which seems to be a little bit more interesting).</p>
<p>The protocol is based on UDP. So there can be packages in wrong order or even never reaching the target. As you can see the class should handle all possible problems with UDP. Features are for example merging of splitted packages and all that stuff.</p>
<ul>
<li><a href="http://je2050.de/highlight.php?file=/files/source/misc/hl.php" target="_blank">HLServer Class</a></li>
</ul>
<div class="none"><div class="g-plusone" data-href="http://blog.joa-ebert.com/2006/04/24/steam-half-life-php-util/" size="standard" count="true"></div></div> <p><a href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=62&amp;md5=1010dbc406f24cc5ca36f690414e244a" title="Flattr" target="_blank"><img src="http://blog.joa-ebert.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2006/04/24/steam-half-life-php-util/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=62&amp;md5=1010dbc406f24cc5ca36f690414e244a" type="text/html" />
	</item>
		<item>
		<title>Spark session of André</title>
		<link>http://blog.joa-ebert.com/2005/11/21/spark-session-of-andre/</link>
		<comments>http://blog.joa-ebert.com/2005/11/21/spark-session-of-andre/#comments</comments>
		<pubDate>Mon, 21 Nov 2005 17:17:08 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[misc]]></category>
		<category><![CDATA[news]]></category>

		<guid isPermaLink="false">http://blog.je2050.de/?p=47</guid>
		<description><![CDATA[If you were not able to visit the Spark Europe or MAX (like me) you might have a look at fabchannel.com where you can watch the whole &#8220;Natural Born Filters&#8221; lecture by André Michelle. I did not know about fabchannel before but this seems to be a great site. I am looking forward to the [...]]]></description>
			<content:encoded><![CDATA[<p>If you were not able to visit the Spark Europe or MAX (like me) you might have a look at <a href="http://www.fabchannel.com/" target="_blank">fabchannel.com</a> where you can watch the whole &#8220;Natural Born Filters&#8221; lecture by <a href="http://www.andre-michelle.com/" target="_blank">André Michelle</a>.</p>
<p>I did not know about fabchannel before but this seems to be a great site. I am looking forward to the <a href="http://www.blocparty.com/" target="_blank">Bloc Party</a> webcast :-)</p>
<div class="none"><div class="g-plusone" data-href="http://blog.joa-ebert.com/2005/11/21/spark-session-of-andre/" size="standard" count="true"></div></div> <p><a href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=47&amp;md5=b2b399b63e88865bcbb991dc0d701454" title="Flattr" target="_blank"><img src="http://blog.joa-ebert.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2005/11/21/spark-session-of-andre/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=47&amp;md5=b2b399b63e88865bcbb991dc0d701454" type="text/html" />
	</item>
		<item>
		<title>About this</title>
		<link>http://blog.joa-ebert.com/2005/10/02/about-this/</link>
		<comments>http://blog.joa-ebert.com/2005/10/02/about-this/#comments</comments>
		<pubDate>Sun, 02 Oct 2005 17:31:43 +0000</pubDate>
		<dc:creator>joa</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[personal]]></category>

		<guid isPermaLink="false">http://blog.je2050.de/?p=16</guid>
		<description><![CDATA[Welcome to my little treasure of knowledge and information. I will abuse this WordPress blog as a site where I can store all my projects which I have done in the past and I will complete in the future. Because of my personal interests in Flash, Graphics, Math and so many others I will share [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to my little treasure of knowledge and information. I will abuse this <a href="http://wordpress.org">WordPress</a> blog as a site where I can store all my projects which I have done in the past and I will complete in the future. Because of my personal interests in <a href="http://macromedia.com/">Flash</a>, <a href="http://www.google.com/imghp?hl=en&#038;tab=wi&#038;q=">Graphics</a>, <a href="http://en.wikipedia.org/wiki/Math">Math</a> and so many others I will share everything I discover on this blog. Expect especially interesting posts about Flash &#8211; but don&#8217;t expect too much ;-)</p>
<div class="none"><div class="g-plusone" data-href="http://blog.joa-ebert.com/2005/10/02/about-this/" size="standard" count="true"></div></div> <p><a href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=16&amp;md5=391683bbbbffe7e0a99ae51301f2071f" title="Flattr" target="_blank"><img src="http://blog.joa-ebert.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.joa-ebert.com/2005/10/02/about-this/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://blog.joa-ebert.com/?flattrss_redirect&amp;id=16&amp;md5=391683bbbbffe7e0a99ae51301f2071f" type="text/html" />
	</item>
	</channel>
</rss>

