<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Nerd wannabe</title>
	<atom:link href="http://blad.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blad.wordpress.com</link>
	<description>lazy weblog</description>
	<lastBuildDate>Tue, 01 Sep 2009 14:22:25 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='blad.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/98c7c77494811908014342973aa13e4e?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Nerd wannabe</title>
		<link>http://blad.wordpress.com</link>
	</image>
			<item>
		<title>Static analysis screenshot</title>
		<link>http://blad.wordpress.com/2009/09/01/static-analysis-screenshot/</link>
		<comments>http://blad.wordpress.com/2009/09/01/static-analysis-screenshot/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 14:21:46 +0000</pubDate>
		<dc:creator>vlad</dc:creator>
				<category><![CDATA[ideas]]></category>

		<guid isPermaLink="false">http://blad.wordpress.com/?p=171</guid>
		<description><![CDATA[Apple seems to make good GUIs and recently it makes compilers too, and IDEs of course.
Actually I don&#8217;t have a mac, never saw XCode, and never used CLang (yet).
But this makes me want them all:

Remember, this is primary a C compiler! I saw few static analysis on C.
And then&#8230; just look, it draws a diagram. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=171&subd=blad&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Apple seems to make good <strong>GUI</strong>s and recently it makes <strong>compilers</strong> too, and <strong>IDE</strong>s of course.</p>
<p>Actually I don&#8217;t have a mac, never saw XCode, and never used CLang (yet).</p>
<p>But this makes me want them all:</p>
<p><a href="http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/9"><img class="size-full wp-image-172 alignnone" title="via Ars Technica" src="http://blad.files.wordpress.com/2009/09/static-analyzer.png?w=608&#038;h=287" alt="static-analyzer" width="608" height="287" /></a></p>
<p>Remember, this is primary a C compiler! I saw few static analysis on C.</p>
<p>And then&#8230; just look, it draws a diagram. Mmm&#8230; arrows!</p>
<p>Good work!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blad.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blad.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blad.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blad.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blad.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blad.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blad.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blad.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blad.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blad.wordpress.com/171/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=171&subd=blad&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blad.wordpress.com/2009/09/01/static-analysis-screenshot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/63c88ae33d4ff81df685930742b96317?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vlad</media:title>
		</media:content>

		<media:content url="http://blad.files.wordpress.com/2009/09/static-analyzer.png" medium="image">
			<media:title type="html">via Ars Technica</media:title>
		</media:content>
	</item>
		<item>
		<title>Old: RAII Obliterator Pattern</title>
		<link>http://blad.wordpress.com/2009/08/22/old-raii-obliterator-pattern/</link>
		<comments>http://blad.wordpress.com/2009/08/22/old-raii-obliterator-pattern/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 14:13:59 +0000</pubDate>
		<dc:creator>vlad</dc:creator>
				<category><![CDATA[laugh]]></category>

		<guid isPermaLink="false">http://blad.wordpress.com/?p=154</guid>
		<description><![CDATA[I implemnted an obliterator for C#. It works around this problem:


foreach (var item in list)
 if (item == &#34;two&#34;)
   list.Remove(item);

System.InvalidOperationException: Collection was modified;enumeration operation may not execute.
The new version of the code is one line longer:


using (var obliterator = Obliterator.From(list))
  foreach (var item in list)
    if (item == &#34;two&#34;)
 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=154&subd=blad&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I implemnted an <a href="http://weblogs.java.net/blog/chet/archive/2007/10/male_pattern_bo.html">obliterator</a> for C#. It works around this problem:</p>
<pre class="brush: csharp;">

foreach (var item in list)
 if (item == &quot;two&quot;)
   list.Remove(item);
</pre>
<p><strong>System.InvalidOperationException: Collection was modified;enumeration operation may not execute.</strong></p>
<p>The new version of the code is one line longer:</p>
<pre class="brush: csharp;">

using (var obliterator = Obliterator.From(list))
  foreach (var item in list)
    if (item == &quot;two&quot;)
      obliterator.Remove(item);
</pre>
<p>The Obliterator class :</p>
<pre class="brush: csharp;">

/* This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The Fuck You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://sam.zoy.org/wtfpl/COPYING for more details. */ 

using System;
using System.Collections.Generic;

namespace Obliterator
{
 public class Obliterator&lt;T&gt; : IDisposable
 {
   ICollection&lt;T&gt; collection;
   List&lt;T&gt; toRemove;

   public Obliterator(ICollection&lt;T&gt; collection)
   {
     this.collection = collection;
     toRemove = new List&lt;T&gt;();
   }

   public void Remove (T item)
   {
     toRemove.Add(item);
   }

   public void Dispose()
   {
     foreach (var item in toRemove) collection.Remove(item);
   }

 }

 public static class Obliterator
 {
   public static Obliterator&lt;T&gt; From &lt;T&gt; (ICollection&lt;T&gt; collection)
   {
     return new Obliterator&lt;T&gt; (collection);
   }
 }
}
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blad.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blad.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blad.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blad.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blad.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blad.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blad.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blad.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blad.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blad.wordpress.com/154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=154&subd=blad&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blad.wordpress.com/2009/08/22/old-raii-obliterator-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/63c88ae33d4ff81df685930742b96317?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vlad</media:title>
		</media:content>
	</item>
		<item>
		<title>Gnome/Ubuntu NIH syndrome?</title>
		<link>http://blad.wordpress.com/2009/03/16/gnomeubuntu-nih-syndrome/</link>
		<comments>http://blad.wordpress.com/2009/03/16/gnomeubuntu-nih-syndrome/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 20:33:18 +0000</pubDate>
		<dc:creator>vlad</dc:creator>
				<category><![CDATA[morons]]></category>

		<guid isPermaLink="false">http://blad.wordpress.com/?p=128</guid>
		<description><![CDATA[There are at least 3 times when Ubuntu/Gnome teams* bit my user experience by:
- pushing alpha-quality technology
- taking a year to deliver a stable one
- just so that it can match a previous offer.
First: Totem
When I first tried it, it didn&#8217;t manage to play anything. When it did, it didn&#8217;t had subtitles. Or sound. Or [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=128&subd=blad&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>There are at least 3 times when Ubuntu/Gnome teams* bit my user experience by:</p>
<p>- pushing alpha-quality technology</p>
<p>- taking a year to deliver a stable one</p>
<p>- just so that it can match a previous offer.</p>
<p>First: <strong>Totem</strong></p>
<p>When I first tried it, it didn&#8217;t manage to play anything. When it did, it didn&#8217;t had subtitles. Or sound. Or it crashed. Or it crashed Nautilus. Or the browser.<br />
However the Gnome Desktop kept on shipping it, even if 90% of people were using <strong>mplayer</strong> or <strong>xine</strong> or <strong>vlc</strong>. It doesn&#8217;t even matches these today, but I can call it stable. Why did they spent that much resources when they could have taken an existing, proven, technology?</p>
<p>Second: <strong>Network Manager</strong></p>
<p>Ok, this is sad. Network manager started as an wifi deamon with a usermode icon panel. It didn&#8217;t even &#8220;speak&#8221; wpa_supplicant. Because of the deamon you cannot use wifi-radar an other decent solution. Even hamachi choked with it, because every new connection it sees, it tries to manage.</p>
<p>After one year of NM 0.6, the next version seems a little bit better. It even knows ppp and stuff. But the year with the network-manager 0.6 deamon, with prays for connections, I will never forget..:(</p>
<p>Third: <strong>Pulseaudio</strong></p>
<p>First, I don&#8217;t even understand what&#8217;s that. From my point of view, it&#8217;s the thing that stops Audacity from working. And you cannot disable it (I mean, it was hard to find out it existed..)</p>
<p>Basically it locks your soundcard so that anybody should play through pulseaudio. Why the hell would something like that be pushed, along with programs known not to work with it??</p>
<p>I am beginning the wait for <em>another year</em> for a mature pulseaudio or a Gnome/Ubuntu Audacity replacement. &#8220;Not invented here&#8221; its the oposite of collaboration and hurts other OSs projects.</p>
<p>All these (3) technologies exist because of the Gnome desktop and the way it pushed them. With that &#8220;one-year-to-get-decent&#8221; policy, they would have failed in infancy.</p>
<p>Is this a bad thing?</p>
<p><strong>update 05/07/2009: </strong>i reinstalled PulseAudio while trying to get my bluetooth headset to work (it didn&#8217;t). And now I am exposed to a &#8216;new&#8217; <a href="https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/275392">bug</a>, from 2008: I only hear static.</p>
<address>*Ubuntu/Gnome teams: what&#8217;s the relation between them?<br />
</address>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blad.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blad.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blad.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blad.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blad.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blad.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blad.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blad.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blad.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blad.wordpress.com/128/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=128&subd=blad&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blad.wordpress.com/2009/03/16/gnomeubuntu-nih-syndrome/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/63c88ae33d4ff81df685930742b96317?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vlad</media:title>
		</media:content>
	</item>
		<item>
		<title>XAML vs MXML (part 1)</title>
		<link>http://blad.wordpress.com/2008/12/06/xaml-vs-mxml-part-1/</link>
		<comments>http://blad.wordpress.com/2008/12/06/xaml-vs-mxml-part-1/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 23:21:22 +0000</pubDate>
		<dc:creator>vlad</dc:creator>
				<category><![CDATA[gtkaml]]></category>

		<guid isPermaLink="false">http://blad.wordpress.com/?p=86</guid>
		<description><![CDATA[Lately I have accepted a job involving WPF (Windows Presentation Foundation) and all the .net 3.5 nastiness.
I have a little previous exposure on Flex (MXML) and that only kick-started me to write a(nother) markup language for Gtk+.
It is only now that I came to reckon what XAML is about. And thought you might want to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=86&subd=blad&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Lately I have accepted a job involving WPF (Windows Presentation Foundation) and all the .net 3.5 nastiness.</p>
<p>I have a little previous exposure on Flex (MXML) and that only kick-started me to write a(nother) markup language for Gtk+.</p>
<p>It is only now that I came to reckon what XAML is about. And thought you might want to know how it stacks agains Flex, too.</p>
<p>Before going to code and charts, let me tell you that Microsoft&#8217;s offer is far more spreaded that Adobe&#8217;s:</p>
<p><strong>Abobe</strong> Flex was just the flash plugin for &#8220;stage&#8221;-oriented advertising and online games, which later got widgets (the Flex SDK) then strong-typeness (ActionScript 3), and now <em>tries to conquer the desktop</em> world with Adobe AIR, which is a standalone runtime that gives access to local files.<br />
The flash player is now a full-blown virtual machine, with a garbage collected, strong-typed language, with access to all the graphic features flash already has and since version 10, access to 3D features. <strong></strong></p>
<p><strong>Microsoft</strong> has a very long history of <em>dominating the desktop</em> (Win32 hacks were common-knowledge for 15+ years), then switched to a &#8220;bytecode&#8221;-like technology which was running against the same Win32 platform widgets (.NET Windows.Forms).<br />
Much more later they introduced this XAML markup (plus a widget toolkit refactoring &#8211; WPF) <em>and</em> implemented something for Firefox, something less for MacOS, helped some more the Novell Linux guys implementing even less on Linux (Moonlight)&#8230; <em>and are generally heading towards RIA</em>.<br />
So now Microsoft offers full-blown desktop applications only for Windows, XBAP (WPF browser applications) for Firefox and IE but only on Windows, Silverlight applications on Windows and MacOS, and Moonlight on Linux (see above).<br />
What is interesting is that if you compare the Silverlight 2 browser plugin vs a WPF application shows that the former cannot do networking using binary protocols, and cannot do accelerated 3D, both of which Flash/Flex do. So there should be no &#8216;browser plugin is limited&#8217; mindset, but there is.</p>
<p>That is, the history of desktop-to-web transition is reversed for the two players (MS and Adobe).</p>
<p>(The good part from this race is that the old <strong>.res</strong>/<strong>.rc</strong> are ditched now, the macros from MFC are less and less used, and spaghetti code generated by Visual Studio.NET xxxx interface designers is now history (I am looking at you, Java!). Long live <strong>Application Markup</strong>!</p>
<h2><strong>Markup Comparison</strong></h2>
<p>So basically this is a comparison of the &#8216;<strong>markups</strong>&#8216; named used in Silverlight and WPF (XAML) and the one used in Flex and AIR (MXML), but also of a couple of other features of the platforms.</p>
<p>But how is this markup made? is it something like HTML DOM + JS? something like Mozilla&#8217;s XUL? Something like OpenLaszlo?</p>
<p><strong>No</strong>. This is where MXML and XAML are alike: they are unlike any of the above.</p>
<p>What they do have in common is:</p>
<ul>
<li>tags are (usually) classes</li>
<li>attributes are properties (fields with automatic getter and setter method call)</li>
<li>the root tag of the XML is the base class you&#8217;re inheriting</li>
<li>all other tags are instances that are added up to the parent container</li>
<li>both use xml namespaces in a similar way (although the URL schemes are different), to specify that the name of a class belongs to another AS3 package or C# namespace(s)</li>
</ul>
<p>For example, this is the minimum source code for an application in Flex:<br />
App.mxml</p>
<pre class="brush: xml;">
&lt;mx:Application
  xmlns:mx=&quot;http://www.macromedia.com/2003/mxml&quot;
  name=&quot;App&quot;/&gt;</pre>
<p>And in WPF:<br />
App.xaml</p>
<pre class="brush: xml;">
&lt;Application
  x:Class=&quot;MyNamespace.App&quot;
  xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
  xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot; /&gt;
</pre>
<p>One of the first differences is that XAML seems to need 2 xml prefixes: one for the Application and other tags, and a special one for meta-attributes specific to xaml. That, is &#8216;<strong>x:Class</strong>&#8216;, is not an attribute of the Application class, but a meta-attribute valid only on the first tag.<br />
The class name includes the namespace definition.</p>
<p>Flex, apparently, simply uses <strong>name</strong>, an existing attribute which is present on all UI components, to give the class name. But if you&#8217;re not stopping at generating classes with Flex Builder but code your own by hand, you&#8217;ll notice that in fact the <em><strong>file name</strong> </em>is the name of the class, and the &#8216;name&#8217; attribute is just run-time information (i.e. exactly the value of the &#8216;name&#8217; property). Even more, the whole subdirectories path represents the package in which the class resides.</p>
<h2><strong>Including actual code</strong></h2>
<p>So far so good, you can define your application or another object like this. But how does one include ActionScript code (for MXML) or .NET code (for XAML) to.. actually accomplish something?</p>
<p>In MXML&#8217;s case, there is a &#8217;special&#8217; tag in the <strong>mx</strong> namespace: <strong>&lt;mx:Script</strong>&gt; which accepts either direct text content (usually written as a CDATA section) or you can use <strong>&lt;mx:Script source=&#8230;</strong> to specify a file from where the code should be included at compile time. Notice that Script is not actually an object that is added to the UI of the application, but a specially-handled tag.</p>
<pre class="brush: xml;">
&lt;mx:Application
  xmlns:mx=&quot;http://www.macromedia.com/2003/mxml&quot;
  name=&quot;App&quot;&gt;
  &lt;mx:Script&gt;
    &lt;![CDATA[
      //code here
    ]]&gt;
  &lt;/mx:Script&gt;
&lt;/mx:Application&gt;
</pre>
<p>In XAML, the preffered way is <strong>code behind</strong>. You have your App.xaml file automatically associated with <strong>App.xaml.cs</strong> <em>if</em> the following apply: the .cs file (or .vb) defines the same class in the same namespace, the class in the .cs file is &#8216;partial&#8217;, and both are included in the files to be compiled list of Visual Studio. That is, automagically:)</p>
<pre class="brush: java;">
public partial class App : Application
{
//code here
}
</pre>
<p>XAML&#8217;s x: prefix also includes an <strong>&lt;x:Code&gt;</strong> tag (notice that it&#8217;s in the XAML-specific namespace) but its use is highly discouraged by Microsoft.</p>
<pre>--</pre>
<p>This post was only a warm-up (for you, for me) to give the general impression of how the two technologies are similar a bit of their differences.</p>
<p>The part 2 will continue to explore all the features of these two Application Markups.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blad.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blad.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blad.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blad.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blad.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blad.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blad.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blad.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blad.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blad.wordpress.com/86/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=86&subd=blad&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blad.wordpress.com/2008/12/06/xaml-vs-mxml-part-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/63c88ae33d4ff81df685930742b96317?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vlad</media:title>
		</media:content>
	</item>
		<item>
		<title>JavaFX: it&#8217;s JAVA!</title>
		<link>http://blad.wordpress.com/2008/12/05/javafx-its-java/</link>
		<comments>http://blad.wordpress.com/2008/12/05/javafx-its-java/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 00:13:30 +0000</pubDate>
		<dc:creator>vlad</dc:creator>
				<category><![CDATA[morons]]></category>

		<guid isPermaLink="false">http://blad.wordpress.com/?p=93</guid>
		<description><![CDATA[Edit (relevant quote):
When asked why developers and authors would want to choose JavaFX over other tools, such as Flex or Silverlight, Octavian summed it up in one word: Java
Before jumping there, remember: just because you can tell entire corporates that this is the &#8216;next best thing&#8217;, it doesn&#8217;t mean people will use it!
Just think ActiveX [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=93&subd=blad&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Edit (relevant quote):</p>
<blockquote><p>When asked why developers and authors would want to choose JavaFX over other tools, such as Flex or Silverlight, Octavian<a href="http://dobbscodetalk.com/index.php?option=com_myblog&amp;show=JavaFX-1.0-Released.html&amp;Itemid=29"> summed it up in one word: Java</a></p></blockquote>
<p>Before jumping there, remember: just because you can tell entire corporates that this is the &#8216;next best thing&#8217;, it doesn&#8217;t mean people will use it!</p>
<p>Just think ActiveX and their banishment from the Internet..,or, wait, you can think of the <a href="http://software.free.vovoid.com/data/java%20applets%20-%20visual%20fx/water/example6.html">water applet</a>!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blad.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blad.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blad.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blad.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blad.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blad.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blad.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blad.wordpress.com/93/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blad.wordpress.com/93/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blad.wordpress.com/93/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=93&subd=blad&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blad.wordpress.com/2008/12/05/javafx-its-java/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/63c88ae33d4ff81df685930742b96317?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vlad</media:title>
		</media:content>
	</item>
		<item>
		<title>Pointless update</title>
		<link>http://blad.wordpress.com/2008/08/21/pointless-update/</link>
		<comments>http://blad.wordpress.com/2008/08/21/pointless-update/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 20:00:29 +0000</pubDate>
		<dc:creator>vlad</dc:creator>
				<category><![CDATA[gtkaml]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[morons]]></category>

		<guid isPermaLink="false">http://blad.wordpress.com/?p=82</guid>
		<description><![CDATA[So.. I needed to re-cap a never-learned science, the computer one.
You see, when I joined a computer science university, I had no &#8220;official&#8221; CS background (math high-school, yadda-yadda).
I did had a computer at home in highschool &#8211; which allowed me to poke around with some &#8216;exotic&#8217; VGA poking.. but never got into backtracking or other [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=82&subd=blad&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>So.. I needed to re-cap a never-learned science, the computer one.</p>
<p>You see, when I joined a computer science university, I had no &#8220;official&#8221; CS background (math high-school, yadda-yadda).<br />
I did had a computer at home in highschool &#8211; which allowed me to poke around with some &#8216;exotic&#8217; VGA poking.. but never got into backtracking or other stuff my friends from CS highschool got.</p>
<p>Then, just when the 3rd year in university got to those subjects, I was _so_ employed I haven&#8217;t had the time to.. you know.. think before the exams.</p>
<p>So I bought some books now, that I am old enough to afford myself shopping from amazon (heh):<br />
- the algorithm design manual &#8211; which I favoured over &#8216;CLR&#8217; because everybody said CLR was &#8217;sooo basic&#8217;. Now I have to struggle with my english skills because the ADM is explained in plain english rather than scientific way<br />
- the dragon book &#8211; yeah..<br />
- learn to tango with D &#8211; the only D book available today (I love reading paper, you know..)<br />
- erlang &#8211; the only book to &#8211; influenced by my reddit fellows</p>
<p>Soo.. I am planning re-writing gtkaml, the markup for UI that I ripped from my XAML/MXML/XUL experience.</p>
<p>But is it worth it?</p>
<p>I want to:<br />
- stop using libxml2, switch to GMarkup, to minimize dependencies. But GMarkup doesn&#8217;t even discern CDATA from regular text (I need that for code in a gtkaml class)<br />
- cleanly separate parsing from semantic analisys (lexing is XML).<br />
- generate native Vala AST instead of text (I currently feed a generated source to the Vala parser)</p>
<p>Again.. why would I do it? It&#8217;s my first open-source attempt, I tried to announce it on vala list, I had as little as.. one user, then a couple of _month_ later tried to announce it on gnome-announce.</p>
<p>It seems like nobody&#8217;s getting where I&#8217;m going or doesn&#8217;t want to. Since I have this (mainly MXML) background, I concieved gtkaml as a shortcut for _me_ to learn the _Gtk_ UI widgets and their properties. I used it a couple of times to prototype UI for something that would have been to boring to write in C or in Vala.</p>
<p>I got at maximum 100 downloads per release, starring on gnomefiles and freshmeat. It lowers &#8211; the latest version, posted on gnome-announce, had less downloads.<br />
Is it because, not having a well organized parser/code generator, every hacker scares away (from the error messages for example)??</p>
<p>I also get compared with glade/GtkBuilder that often that I explained in a previous post the differences. But still nobody cared.</p>
<p>Can somebody point me their open-source experience? is this normal? (i.e. to have an unique itch and scratch it?)</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/blad.wordpress.com/82/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/blad.wordpress.com/82/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blad.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blad.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blad.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blad.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blad.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blad.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blad.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blad.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blad.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blad.wordpress.com/82/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=82&subd=blad&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blad.wordpress.com/2008/08/21/pointless-update/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/63c88ae33d4ff81df685930742b96317?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vlad</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Dependency Injection</title>
		<link>http://blad.wordpress.com/2008/04/24/sql-dependency-injection/</link>
		<comments>http://blad.wordpress.com/2008/04/24/sql-dependency-injection/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 20:28:20 +0000</pubDate>
		<dc:creator>vlad</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ideas]]></category>

		<guid isPermaLink="false">http://blad.wordpress.com/?p=71</guid>
		<description><![CDATA[&#8220;All problems in computer science can be solved by another level of indirection, but that usually will create another problem.&#8221; &#8212; David Wheeler, inventor of the subroutine
This is the story of a &#8220;framework&#8221; that doesn&#8217;t exist: SqlDi
Most database frameworks&#8217; authors consider that it is wrong to write SQL in your source code and provide many [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=71&subd=blad&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><em>&#8220;All problems in computer science can be solved by another level of indirection, but that usually will create another problem.&#8221;</em> &#8212; David Wheeler, inventor of the subroutine</p>
<p>This is the story of a &#8220;framework&#8221; that doesn&#8217;t exist: <strong>SqlDi</strong></p>
<p>Most database frameworks&#8217; authors consider that <strong>it is wrong to write SQL in your source code</strong> and provide many kinds of wrappers you need to deal with, instead of pure query strings.</p>
<p>Their reasons are along the lines of:</p>
<h2>Portability: SQL is not database independent</h2>
<p>Sadly, this is true. Although there are ANSI standards &#8211; ANSI SQL 99, 2003 etc. &#8211; no RDBMS supports <em>all</em> the features from ANSI and <em>most </em>vendors force you to use some of their custom extensions to accomplish things from the standard.</p>
<p>(For example, SQL 2003 introduces  <a href="http://en.wikipedia.org/wiki/Window_function_(SQL)">&#8216;window functions&#8217;</a> that could be used instead of the vendor specific ROWNUM, LIMIT or TOP keywords &#8211; and the window functions allow you to do even more. Few database systems support SQL 2003 though..)</p>
<h2>Abstraction: SQL queries contain details about the storage mechanism</h2>
<p>The relational model is a good way of assuring the integrity and non-redundancy of data. JOINs allow you to reverse the normalization process, while keeping the &#8220;Single Point of Truth&#8221; &#8211; storage model. INDEXes allow you to lookup faster.</p>
<p>Having SQL (in your source) that displays all these storage details is bad in practice. Even if your attributes (columns) are not subject to change, <em>the way of retrieving them</em> may be.</p>
<p>For example, if you want to display a (paginated) list of books on a web page, with their authors, a minimal query would be:</p>
<pre class="brush: sql;">

SELECT books.title as title, books.date_published as date_published, authors.name as author
FROM
  books
INNER JOIN
  authors
ON
  books.author_id = autors.id
WHERE
  ROW_NUMBER() OVER (ORDER BY books.title) BETWEEN 1 AND 10
</pre>
<p>This is both an example of SQL that reveals the storage internals <em>and</em> that is not portable (because ROW_NUMBER() is supported by very few &#8216;chosen&#8217; ones)</p>
<h2>Correctness: Query strings are validated only when run against the database</h2>
<p>Even if you&#8217;re using an editor that knows how to highlight syntax from the SQL strings, you are still prone to mistakes, syntactical or not (e.g. wrong column name).</p>
<p>The usual solution is to write objects that construct your query &#8211; here&#8217;s an example for Hibernate&#8217;s Criteria API</p>
<pre class="brush: java;">

Criteria crit = session.createCriteria(Cat.class);
crit.add( Expression.eq( &quot;color&quot;, eg.Color.BLACK ) );
crit.setMaxResults(10);
List cats = crit.list();
</pre>
<p>This still fails if the &#8220;color&#8221; string is mistyped, for example.</p>
<h2>SqlDi</h2>
<p>The proposed SqlDi solution emphasizes some of the <strong>positive things</strong> about SQL, while working around the above-mentioned issues.</p>
<p>First let&#8217;s talk about the &#8220;Domain Specific Language&#8221; well known <a href="http://en.wikipedia.org/wiki/Meme">meme</a> &#8211; SQL is one of the <em>best examples of DSL around</em>, but suddenly everybody wants to write in <a href="http://lolcode.com">lolcode</a> like this:</p>
<pre class="brush: ruby;">
include StarbucksDSL

order = latte venti, half_caf, non_fat, no_foam, no_whip
print order.prepare
</pre>
<p>As opposed to this ruby Starbucks language I found on the web, SQL has proper syntax rules, and everybody knows at least its basics.</p>
<p>So SqlDI will allow you to write a subset of SQL called SqlDi.</p>
<h3>But how about the aforementioned <strong><em>Abstraction</em> ?</strong></h3>
<p>In order to decouple the storage model from the application query, SqlDi uses a kind of remote-process <a href="http://en.wikipedia.org/wiki/Inversion_of_Control">inversion of control</a> (RP/IoC) pattern where the actual storage-specific part of the query gets <em>injected</em> in your code by the RDBMS process (instead of your code depending on the storage layout).</p>
<p>Here&#8217;s an example of the previous query, re-written in SqlDi:</p>
<pre class="brush: sql;">
SELECT title, date_published, author
FROM books_with_authors
LIMIT 1,10
</pre>
<p>You can already guess the syntax of SqlDi, but I will paste it here anyway:</p>
<pre class="brush: sql;">SELECT attribute_expr [, attribute_expr]* FROM thing [WHERE boolean_expr] [LIMIT n [,m]]</pre>
<p>Now how does the &#8216;thing&#8217; called &#8216;books_with_authors&#8217; got injected?</p>
<p>Simple, it&#8217;s part of the database &#8220;configuration file&#8221; (the script that creates the schema):</p>
<pre class="brush: sql;">
CREATE TABLE authors
( id INTEGER PRIMARY KEY, name VARCHAR(80), birthday DATE);

CREATE TABLE books
( id INTEGER PRIMARY KEY, date_published DATE, author_id INTEGER FOREIGN KEY
  REFERENCES authors(id) );

CREATE VIEW books_with_authors AS
SELECT books.title as title, books.date_published as date_published, authors.name as author
FROM books INNER JOIN authors ON books.author_id = autors.id;
</pre>
<p>Now, if some other time you discover that one book can have multiple authors, all you have to do is to re-write the storage-dependent part of the query.</p>
<h3>But how does SqlDi provide <em><strong>Portability</strong></em> ?</h3>
<p>SqlDi is a parser for a subset of SQL &#8211; you have already seen the SELECT statement syntax. The various functions dealing with numbers, dates and strings, even the operators (such as string concatenation) are defined one way or another in SqlDi and <em>translated into the native</em> <em>dialect</em>.</p>
<p>For example, the LIMIT keyword is translated into ROWNUM, LIMIT, TOP or ROW_NUMBER() depending on the used database.</p>
<p>This translation is accomplished in two steps:</p>
<ul>
<li>First, the query is tokenized and parsed, and an object which represents the root of the Abstract Syntax Tree is constructed.</li>
<li>Second, the AST spills out the native dialect &#8211; based on some form of run-time pluggable dialect writers (plus &#8216;drivers&#8217;)</li>
</ul>
<p>In this way you&#8217;ll never need to change the &#8220;SELECT x FROM y WHERE &#8230;&#8221; from your source, even if you change the used database. (You do, however, need another schema creation script).</p>
<h3>Yeah, but how about the compile-time <em><strong>Correctness</strong></em> ?</h3>
<p>This is the most interesting part.</p>
<p>SqlDi is implemented in <a href="http://www.digitalmars.com/d/">D</a> (because I don&#8217;t know LISP), and the first step (parsing) is accomplished at compile-time, through the use of <a href="http://www.digitalmars.com/d/2.0/statement.html#MixinStatement">mixin</a>() statement. The output of parsing is <em>code</em>, like this:</p>
<pre class="brush: java;">SqlDi.Select ( &quot;books_with_authors&quot;, null /*the where clause*/, 1, 10 );</pre>
<p>For example, if you have WHERE name LIKE &#8216;Richard %&#8217;, instead of a null you will have SqlDi.Like ( SqlDi.Column(&#8220;name&#8221;), &#8220;Richard %&#8221; ) &#8211; where &#8220;SqlDi&#8221; is the package name.</p>
<p>Of course you could write this yourself if you are a hardcore SqlDi user;)</p>
<h3><em>Conclusion</em></h3>
<p>To summarize what we achieved:</p>
<ul>
<li>you <strong><em>can</em> write SQL</strong> in your source code,</li>
<li>it will be <strong>database independent</strong> and</li>
<li>you will get compile-time <strong>syntax checking</strong></li>
<li>bonus points: the <strong>DBA </strong>will become your best <strong>friend</strong></li>
</ul>
<p>What we <em>didn&#8217;t</em> do:</p>
<ul>
<li>no object mapping was even considered</li>
<li>we didn&#8217;t enter into details of INSERTs and UPDATEs</li>
<li>SqlDi does not exist</li>
</ul>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/blad.wordpress.com/71/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/blad.wordpress.com/71/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blad.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blad.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blad.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blad.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blad.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blad.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blad.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blad.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blad.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blad.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=71&subd=blad&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blad.wordpress.com/2008/04/24/sql-dependency-injection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/63c88ae33d4ff81df685930742b96317?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vlad</media:title>
		</media:content>
	</item>
		<item>
		<title>what gtkaml is not</title>
		<link>http://blad.wordpress.com/2008/03/25/what-gtkaml-is-not/</link>
		<comments>http://blad.wordpress.com/2008/03/25/what-gtkaml-is-not/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 13:29:58 +0000</pubDate>
		<dc:creator>vlad</dc:creator>
				<category><![CDATA[gtkaml]]></category>

		<guid isPermaLink="false">http://blad.wordpress.com/?p=75</guid>
		<description><![CDATA[I noticed that the first reaction when people hear about gtkaml is &#8220;But GtkBuilder/glade already does this!&#8221; or &#8220;How is gtkaml better than glade?&#8221; or something along these lines.
Let me put this straight: there is no resemblance between gtkaml and glade (other than using markup). None. They are not mutually exclusive, and do not do [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=75&subd=blad&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I noticed that the first reaction when people hear about <a href="http://gtkaml.googlecode.com">gtkaml</a> is <em>&#8220;But GtkBuilder/glade already does this!&#8221;</em> or <em>&#8220;How is gtkaml better than glade?&#8221;</em> or something along these lines.</p>
<p>Let me put this straight: <strong>there is no resemblance between gtkaml and glade</strong> (other than using markup). <strong>None</strong>. They are not mutually exclusive, and do not do the same thing.</p>
<p>You can tell this by looking at them!</p>
<table border="0">
<tbody>
<tr>
<td><img class="alignnone size-medium wp-image-77" src="http://blad.files.wordpress.com/2008/04/glade-screenshot.png?w=276&#038;h=250" alt="" width="276" height="250" /></td>
<td><img class="alignnone size-medium wp-image-78" src="http://blad.files.wordpress.com/2008/04/gtkaml-screenshot.png?w=276&#038;h=250" alt="" width="276" height="250" /></td>
</tr>
</tbody>
</table>
<h2>what they are</h2>
<p>First, glade is a <em>library</em> (and GtkBuilder comes bundled with Gtk+). You link against it and <em>it parses your UI markup at runtime.</em>.</p>
<p>On the other side, gtkaml is a <em>preprocessor</em>. Your <em>markup becomes code</em>, Vala code, which and eventually becomes static C code.</p>
<h2>language bindings</h2>
<p>glade and GtkBuilder can be used from many different programming languages.</p>
<p>gtkaml is only available for Vala. However, widget libraries created with Vala can be used from any language.</p>
<h2>run-time vs compile-time</h2>
<p>GtkBuilder and glade make it possible to change the UI markup without compiling. This is because they call Gtk+ functions from libgtk, functions determined at runtime.</p>
<p>gtkaml only knows what you meant when compiling &#8211; it uses Vala&#8217;s <acronym title="Abstract Syntax Tree">AST</acronym> to do this. You have to recompile to change the UI, therefore.</p>
<h2>syntax</h2>
<p>GtkBuilder and glade have their own markup which usually must be written by means of an interactive tool (glade).</p>
<p>gtkaml simply maps tags to classes and attributes to properties/fields/signals.</p>
<h2>signals</h2>
<p>Because of the run-time capabilities, GtkBuilder and glade require you to export your signal handlers from your own executable, like an .so/.dll does, or to write GtkBuilderConnectFunc&#8217;s for them.</p>
<p>gtkaml simply uses Vala&#8217;s += signal capability which translates into g_signal_connect () function calls.</p>
<h2>widget referencing</h2>
<p>GtkBuilder requires calling gtk_builder_get_object (&#8220;by name&#8221;) to get a reference to a widget. Similarly, glade has lookup_widget (&#8220;by name&#8221;).</p>
<p>gtkaml optionally lets you declare widgets as public or private fields, so you can use them directly.</p>
<h2>using custom widgets</h2>
<p>glade requires specific code to instantiate custom widgets (set_custom_handler ()). GtkBuilder requires the widgets to implement GtkBuildable (which is a Good Thing).</p>
<p>gtkaml only needs them to inherit from GtkWidget (or a class more specialized).</p>
<h2>creating custom widgets</h2>
<p>GtkBuilder or glade do not have support for creating custom widgets.</p>
<p>gtkaml <em>does only this.</em> It creates custom widgets.</p>
<p><strong>Conclusion</strong>: use GtkBuilder an glade to separate UI from behavior. Use gtkaml to write custom widgets (with code within) &#8211; in Vala.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/blad.wordpress.com/75/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/blad.wordpress.com/75/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blad.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blad.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blad.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blad.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blad.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blad.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blad.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blad.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blad.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blad.wordpress.com/75/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=75&subd=blad&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blad.wordpress.com/2008/03/25/what-gtkaml-is-not/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/63c88ae33d4ff81df685930742b96317?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vlad</media:title>
		</media:content>

		<media:content url="http://blad.files.wordpress.com/2008/04/glade-screenshot.png" medium="image" />

		<media:content url="http://blad.files.wordpress.com/2008/04/gtkaml-screenshot.png" medium="image" />
	</item>
		<item>
		<title>C++ and C++ TR1 (Technical Report 1)</title>
		<link>http://blad.wordpress.com/2008/03/12/cpp-and-cpp-tr1-technical-report-1/</link>
		<comments>http://blad.wordpress.com/2008/03/12/cpp-and-cpp-tr1-technical-report-1/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 15:32:25 +0000</pubDate>
		<dc:creator>vlad</dc:creator>
				<category><![CDATA[trivia]]></category>

		<guid isPermaLink="false">http://blad.wordpress.com/?p=72</guid>
		<description><![CDATA[In this post I will assume you&#8217;re familiar with other languages like Java and C#, which are OO languages, and you start to learn the &#8216;multi-paradigm&#8217; C++. Yeah, you couldn&#8217;t be that guy, could you.
So you already know the syntax.. so quick, let&#8217;s write classes!
We&#8217;ll start with a &#8216;bitmap&#8217; that supposedly encapsulates a bitmap image, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=72&subd=blad&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In this post I will assume you&#8217;re familiar with other languages like Java and C#, which are OO languages, and you start to learn the &#8216;multi-paradigm&#8217; C++. Yeah, you couldn&#8217;t be that guy, could you.</p>
<p>So you already know the syntax.. so quick, let&#8217;s write classes!</p>
<p>We&#8217;ll start with a &#8216;bitmap&#8217; that supposedly encapsulates a bitmap image, allocating memory at construction and freeing it at destruction:</p>
<pre class="brush: cpp;">
/* bitmap.h */
#include &lt;string&gt;
class bitmap
{
    unsigned char *data;
public:
    bitmap(std::string path);
    ~bitmap(void);
};</pre>
<pre class="brush: cpp;">
/* bitmap.cpp */
#include &quot;bitmap.h&quot;
bitmap::bitmap(std::string path)
{
    //allocate memory
    data = new unsigned char [1024];
    //read data from path
    //parse it as an image
}
bitmap::~bitmap(void)
{
    //free the memory
    delete [] data;
}</pre>
<p>Now that&#8217;s pretty simple and obvious, given that details about reading/parsing the bitmap are left out.Let&#8217;s see how we can use this class; we can allocate a bitmap object on <b>heap</b> like this:</p>
<pre class="brush: cpp;">
/* main.cpp */
#include &quot;bitmap.h&quot;
int main (int argc, char * argv[])
{
    bitmap *icon = new bitmap (&quot;./icon&quot;);
}</pre>
<p>Oops.. not good, our destructor doesn&#8217;t get called. We have to manualy call <b>delete icon</b> so that it calls its <b>delete [] data</b>.</p>
<p>Hmm.. ugly.</p>
<p>But we do know that desctructors are automatically called when an <b>auto</b> variable gets out of scope and so we do this:</p>
<pre class="brush: cpp;"> bitmap icon = bitmap (&quot;./icon&quot;);</pre>
<p>Bummer! this time the destructor is called <i>twice!</i> Obviously, it fails the second time:(</p>
<p>The reason is that we weren&#8217;t aware that the default assignment operator is called in what we thought was an initializer (that <b>&#8216;=&#8217;</b> that stands between the object and the constructor call).</p>
<p>This is actually one of the reasons most C++ code reads like:</p>
<pre class="brush: cpp;">bitmap icon(&quot;./icon&quot;);</pre>
<p>The other is performance.<br />
(yeah, event a simple <i>int f = 0;</i> gets obfuscated to <i>int f(0);</i> which looks like a goddamn function call)</p>
<h3>Introducing auto_ptr&lt;T&gt;</h3>
<p>We can further get rid of: the stars &#8216;*&#8217; and the destructor by declaring the <i>data</i> to be an auto_ptr:</p>
<pre class="brush: cpp;">
#include &lt;string&gt;
#include &lt;memory&gt;
using namespace std;
class bitmap
{
    auto_ptr&lt;unsigned char&gt; data;
public:
    bitmap(string path);
};</pre>
<pre class="brush: cpp;">
#include &quot;bitmap.h&quot;
bitmap::bitmap(string path)
{
    data = auto_ptr&lt;unsigned char&gt; (new unsigned char [1024]);
}</pre>
<p><b>auto_ptr</b> is a class that wraps a pointer. Its instance being used <i>without</i> dynamic allocation, the instances are freed (after being destructed) when they are out of scope.</p>
<p>This simply allows the ~auto_ptr () destructor to <i>call &#8216;delete&#8217; on the wrapped <b>heap</b> <b>object</b> just like with an <b>auto object</i></b>: when it gets out of scope.</p>
<p>It allows us to write code like this &#8211; once again:</p>
<pre class="brush: cpp;"> bitmap icon = bitmap (&quot;./icon&quot;);</pre>
<p>and like this:</p>
<pre class="brush: cpp;"> data = auto_ptr&lt;unsigned char&gt; (new unsigned char [1024]);</pre>
<p>That is because the assignment operator of the auto_ptr transfers ownership of the wrapped object, NULL-ing the old reference, and because the right-hand expressions in the above two examples are <i>not</i> used further in the code.</p>
<p>You&#8217;re still fucked up if you write:</p>
<pre class="brush: cpp;">bitmap largeicon = icon;</pre>
<p>since the right-hand object is left with a NULL reference!</p>
<h3>Introducing shared_ptr&lt;T&gt;</h3>
<p>shared_ptr is a class that <a href="http://www.boost.org/libs/smart_ptr/shared_ptr.htm">boost</a> provided long time ago, and now will be part of the upcoming C++ standard (C++09 probably, but currently named C++0x).</p>
<p>This is, one way or another, already supported in the upcoming Visual C++ 9 SP1 (today as a <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=D466226B-8DAB-445F-A7B4-448B326C48E7&amp;displaylang=en">beta feature pack</a>) and also in GNU g++ 4.x</p>
<p>The simple fact that this feature, now in the standard, can be provided by a library tells something about the power of C++. Unfortunately, the fact that the boost implementation is unreadable tells another thing &#8211; about C++ compilers. (to think about it, <i>what other languages have as many compilers &#8211; and compilers&#8217; problems &#8211; as C and C++</i>?)</p>
<p>Basically, shared_ptr is counting the references to a pointer, and, when copied, increments the references, and when destructed, decrements their number. Finally, when no more references exists, it calls &#8216;delete&#8217;.</p>
<p>So our pointer-free source (sic!) becomes:</p>
<pre class="brush: cpp;">
#include &lt;string&gt;
#include &lt;memory&gt;
using namespace std;
using namespace tr1;
class bitmap
{
    shared_ptr&lt;unsigned char&gt; data;
public:
    bitmap(string path);
};</pre>
<pre class="brush: cpp;">
#include &quot;bitmap.h&quot;
bitmap::bitmap(string path)
{
    data = shared_ptr&lt;unsigned char&gt; (new unsigned char [1024]);
}</pre>
<pre class="brush: cpp;">
#include &quot;bitmap.h&quot;
int main (int argc, char * argv[])
{
    bitmap icon = bitmap (&quot;./icon&quot;);
    bitmap largeicon = icon;
}</pre>
<p>If read up until here, you have just seen the way to<a href="http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization"> aquire the memory resource on instantiation</a>, so that you don&#8217;t need to manage it&#8217;s release.</p>
<p><b>TR1</b> has other new things too.. next time we&#8217;ll check on the &lt;functional&gt; classes <b>function</b>, <b>bind</b> and <b>result_of</b>.</p>
<p><i>(to compile the above in g++ 4.x, use </i>#include &lt;tr1/memory&gt;<i> and </i>using namespace std::tr1;<i>).</i></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/blad.wordpress.com/72/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/blad.wordpress.com/72/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blad.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blad.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blad.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blad.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blad.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blad.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blad.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blad.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blad.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blad.wordpress.com/72/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=72&subd=blad&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blad.wordpress.com/2008/03/12/cpp-and-cpp-tr1-technical-report-1/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/63c88ae33d4ff81df685930742b96317?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vlad</media:title>
		</media:content>
	</item>
		<item>
		<title>attribute values in gtkaml</title>
		<link>http://blad.wordpress.com/2008/02/26/attribute-values-in-gtkaml/</link>
		<comments>http://blad.wordpress.com/2008/02/26/attribute-values-in-gtkaml/#comments</comments>
		<pubDate>Tue, 26 Feb 2008 00:42:27 +0000</pubDate>
		<dc:creator>vlad</dc:creator>
				<category><![CDATA[gtkaml]]></category>

		<guid isPermaLink="false">http://blad.wordpress.com/?p=58</guid>
		<description><![CDATA[Rule of the thumb: when you don&#8217;t enclose your attribute values in {}&#8217;s, something magic is going to happen.
That is because gtkaml tries to make your life easier. Let&#8217;s take the first example, 
Properties

&#60;Window title=&#34;my window&#34; type=&#34;{WindowType.TOPLEVEL}&#34; ...
The difference between using and not using curly braces is obvious: if you use {}, you get to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=58&subd=blad&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><i>Rule of the thumb: when you don&#8217;t enclose your attribute values in {}&#8217;s, something magic is going to happen.</i></p>
<p>That is because gtkaml tries to make your life easier. Let&#8217;s take the first example, <b></b></p>
<h2>Properties</h2>
<pre class="brush: xml;">
&lt;Window title=&quot;my window&quot; type=&quot;{WindowType.TOPLEVEL}&quot; ...</pre>
<p>The difference between using and not using curly braces is obvious: if you use {}, you get to write a valid <b>code</b> expression. Otherwise, gtkaml tries to guess a literal for you: in this case, title being a <b>string </b>property, the value &lt;&lt;my window&gt;&gt; gets translated to &lt;&lt;&#8221;my window&#8221;"&gt;&gt; in Vala.</p>
<p>This would be the equivalent of <b>title=&#8217;{&#8220;my window&#8221;}&#8217;</b> (you have to use the alternate single-quotes of xml for this).If the  property is <b>bool</b>, you get exactly the &#8220;false&#8221; or &#8220;true&#8221; literal, and if the property is an <b>integer</b>, the same.</p>
<p>Actually, whatever the property is that is not a string, you get what you typed &#8211; the &#8220;magic&#8221; happens only for string properties.</p>
<p>Alternate &#8217;spellings&#8217; for the code above are possible, along the lines of:</p>
<pre class="brush: xml;">
&lt;Window&gt;
   &lt;title&gt;my window&lt;/title&gt;
   &lt;type&gt;{WindowType.TOPLEVEL}&lt;/type&gt;
&lt;/Window&gt;
</pre>
<p>or if your value contains invalid xml characters:</p>
<pre class="brush: xml;">
   &lt;title&gt;&lt;![CDATA[my window &gt;= your window]]&gt;&lt;/title&gt;
</pre>
<h2>Signals</h2>
<pre class="brush: xml;">
&lt;Window destroy=&quot;{Gtk.main_quit}&quot; /&gt;
&lt;Window delete_event=&quot;Gtk.main_quit()&quot; /&gt;
&lt;Window delete_event=&quot;{ widget =&gt; { Gtk.main_quit (); }&quot; /&gt;</pre>
<p>The difference is that the first is an <b>expression of type &#8220;function</b>&#8221; (an expression that returns a function), while the second is <b>executable code</b>. The generated Vala source is like this:</p>
<pre class="brush: csharp;">
//with curly braces:
this.destroy += Gtk.main_quit;

//without curly braces
this.delete_event += (target, event) =&gt; { Gtk.main_quit(); };

//third way - just like the first
this.delete_event += widget =&gt; { Gtk.main_quit (); };</pre>
<p>Second, the value without curly braces does the &#8220;magic&#8221; of creating an anonymous function and to automatically fill the signal parameters for you. This can be helpful if you want to write short executable code in a simple attribute; otherwise you can write a &#8216;full-blow&#8217; function body in a CDATA section:</p>
<pre class="brush: xml;">
&lt;Window&gt;
   &lt;delete_event&gt;&lt;![CDATA[{
widget =&gt; {
     Gtk.main_quit ();
}
}]]&gt; &lt;/delete_event&gt;
&lt;/Window&gt;
</pre>
<p>Notice, however, that you have to use curly braces <i>two </i>times: one for the method body, the other for gtkaml to know not to do any &#8216;magic&#8217;.As you can see, no matter how you specify the signal, gtkaml adds the last &#8220;;&#8221;. </p>
<h2>Construct</h2>
<p>gtkaml 0.2 (svn version as we speak) features two new properties, named <b>gtkaml:construct</b> and <b>preconstruct</b>. This is because gtkaml creates the class construct for you (where it sets up the attributes, adds children to containers etc), but you might need to <i>add yourself code </i>there. You can use gtkaml:preconstruct and gtkaml:preconstruct on all tags:</p>
<ul>
<li>preconstruct is executed just after the object is instantiated, before setting the other properties</li>
<li>construct is executed just before the object is added to it&#8217;s parent container</li>
</ul>
<p>As a side effect, the root tag has &#8216;preconstruct&#8217; executed before all others preconstructs and the &#8216;construct&#8217; after all other constructs.</p>
<p>These attributes are to be used exactly like a signal: you write code, and you have the &#8220;target&#8221; parameter (the widget)</p>
<p>In the case of using <b>{}</b>, you can directly assign an existing function that receives a widget or void as parameter, or write a lambda expression in-place.</p>
<p>Example:</p>
<pre class="brush: xml;">
&lt;Window
   class:preconstruct=&quot;{view_init}&quot;
   class:construct=&quot;post_init(target)&quot; /&gt;
</pre>
<p>As with the signals above, the first attribute simply sets &#8220;view_init&#8221; as the method to be called, and the second method actually wraps the call into a lambda function defined like <b>target =&gt; { post_init (target); };</b></p>
<p>There isn&#8217;t much to do with the target parameter in this example: you can always use <b>this.</b> instead. But it may be very useful if you want to modify an unnamed widget.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/blad.wordpress.com/58/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/blad.wordpress.com/58/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blad.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blad.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blad.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blad.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blad.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blad.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blad.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blad.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blad.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blad.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blad.wordpress.com&blog=1830221&post=58&subd=blad&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blad.wordpress.com/2008/02/26/attribute-values-in-gtkaml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/63c88ae33d4ff81df685930742b96317?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vlad</media:title>
		</media:content>
	</item>
	</channel>
</rss>