<?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>Maxim Fridental</title>
	<atom:link href="http://maxim.fridental.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://maxim.fridental.de</link>
	<description>My personal blog</description>
	<lastBuildDate>Sun, 05 Feb 2012 00:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>This Week in Twitter</title>
		<link>http://maxim.fridental.de/2012/02/05/this-week-in-twitter-161/</link>
		<comments>http://maxim.fridental.de/2012/02/05/this-week-in-twitter-161/#comments</comments>
		<pubDate>Sun, 05 Feb 2012 00:00:00 +0000</pubDate>
		<dc:creator>MaximFridental</dc:creator>
				<category><![CDATA[random]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://maxim.fridental.de/2012/02/05/this-week-in-twitter-161/</guid>
		<description><![CDATA[I liked a @YouTube video http://t.co/SGw1gS7M 張惠妹－愛到不能收 # 研究, 解决, 讲究, 讲解. 汉语有时候傢LEGO一样. # … 继续, 连续剧, 京剧 … # Powered by Twitter Tools]]></description>
			<content:encoded><![CDATA[<ul class="aktt_tweet_digest">
<li>I liked a @<a href="http://twitter.com/YouTube" class="aktt_username">YouTube</a> video <a href="http://t.co/SGw1gS7M" rel="nofollow">http://t.co/SGw1gS7M</a> 張惠妹－愛到不能收 <a href="http://twitter.com/fridental/statuses/164839314503643136" class="aktt_tweet_time">#</a></li>
<li>研究, 解决, 讲究, 讲解. 汉语有时候傢LEGO一样. <a href="http://twitter.com/fridental/statuses/165795906740953088" class="aktt_tweet_time">#</a></li>
<li>… 继续, 连续剧, 京剧 … <a href="http://twitter.com/fridental/statuses/165798835006877696" class="aktt_tweet_time">#</a></li>
</ul>
<p class="aktt_credit">Powered by <a href="http://alexking.org/projects/wordpress">Twitter Tools</a></p>
]]></content:encoded>
			<wfw:commentRss>http://maxim.fridental.de/2012/02/05/this-week-in-twitter-161/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>This Week in Twitter</title>
		<link>http://maxim.fridental.de/2012/01/29/this-week-in-twitter-160/</link>
		<comments>http://maxim.fridental.de/2012/01/29/this-week-in-twitter-160/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 00:00:00 +0000</pubDate>
		<dc:creator>MaximFridental</dc:creator>
				<category><![CDATA[random]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://maxim.fridental.de/2012/01/29/this-week-in-twitter-160/</guid>
		<description><![CDATA[新年快乐！春节快乐！ # Powered by Twitter Tools]]></description>
			<content:encoded><![CDATA[<ul class="aktt_tweet_digest">
<li>新年快乐！春节快乐！ <a href="http://twitter.com/fridental/statuses/161116011800707072" class="aktt_tweet_time">#</a></li>
</ul>
<p class="aktt_credit">Powered by <a href="http://alexking.org/projects/wordpress">Twitter Tools</a></p>
]]></content:encoded>
			<wfw:commentRss>http://maxim.fridental.de/2012/01/29/this-week-in-twitter-160/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>This Week in Twitter</title>
		<link>http://maxim.fridental.de/2012/01/08/this-week-in-twitter-159/</link>
		<comments>http://maxim.fridental.de/2012/01/08/this-week-in-twitter-159/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 00:00:00 +0000</pubDate>
		<dc:creator>MaximFridental</dc:creator>
				<category><![CDATA[random]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://maxim.fridental.de/2012/01/08/this-week-in-twitter-159/</guid>
		<description><![CDATA[Looks like we’ve just passed the minimum, and hardware will be more expensive. 2000€ for entry-level PC soon normal. http://t.co/tfAQbNa3 # RT @asdtvg Onlinevideo– und TV-Markt: Eine Branche verändert sich http://t.co/CWPx6uBY # I favorited a @YouTube video http://t.co/NpGZ9SNS 蘇打綠sodagreen -【你在煩惱什麼 What’s The Trouble On Your Mind】MV 官方 # Powered by Twitter Tools]]></description>
			<content:encoded><![CDATA[<ul class="aktt_tweet_digest">
<li>Looks like we’ve just passed the minimum, and hardware will be more expensive. 2000€ for entry-level PC soon normal. <a href="http://t.co/tfAQbNa3" rel="nofollow">http://t.co/tfAQbNa3</a> <a href="http://twitter.com/fridental/statuses/154088715818512385" class="aktt_tweet_time">#</a></li>
<li>RT @<a href="http://twitter.com/asdtvg" class="aktt_username">asdtvg</a> Onlinevideo– und TV-Markt: Eine Branche verändert sich <a href="http://t.co/CWPx6uBY" rel="nofollow">http://t.co/CWPx6uBY</a> <a href="http://twitter.com/fridental/statuses/154533479240052736" class="aktt_tweet_time">#</a></li>
<li>I favorited a @<a href="http://twitter.com/YouTube" class="aktt_username">YouTube</a> video <a href="http://t.co/NpGZ9SNS" rel="nofollow">http://t.co/NpGZ9SNS</a> 蘇打綠sodagreen -【你在煩惱什麼 What’s The Trouble On Your Mind】MV 官方 <a href="http://twitter.com/fridental/statuses/155079173692596224" class="aktt_tweet_time">#</a></li>
</ul>
<p class="aktt_credit">Powered by <a href="http://alexking.org/projects/wordpress">Twitter Tools</a></p>
]]></content:encoded>
			<wfw:commentRss>http://maxim.fridental.de/2012/01/08/this-week-in-twitter-159/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>This Week in Twitter</title>
		<link>http://maxim.fridental.de/2012/01/01/this-week-in-twitter-158/</link>
		<comments>http://maxim.fridental.de/2012/01/01/this-week-in-twitter-158/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 00:00:00 +0000</pubDate>
		<dc:creator>MaximFridental</dc:creator>
				<category><![CDATA[random]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://maxim.fridental.de/2012/01/01/this-week-in-twitter-158/</guid>
		<description><![CDATA[Habt ihr schon gesehen, wie schön das Kerzenlicht ist? Aber wirklich gesehen? # Note how people communicate with self-created flawless infographics and typography. I wish I learned it at school. http://t.co/MZ24goGL # On December 18th another 230 tonnes of radioactive water leaked at Fukushima. Mass media not interested (?) # Eine sehr interessante Statistik: http://t.co/xRkvNrUE [...]]]></description>
			<content:encoded><![CDATA[<ul class="aktt_tweet_digest">
<li>Habt ihr schon gesehen, wie schön das Kerzenlicht ist? Aber wirklich gesehen? <a href="http://twitter.com/fridental/statuses/150894914895482880" class="aktt_tweet_time">#</a></li>
<li>Note how people communicate with self-created flawless infographics and typography. I wish I learned it at school. <a href="http://t.co/MZ24goGL" rel="nofollow">http://t.co/MZ24goGL</a> <a href="http://twitter.com/fridental/statuses/151021216826785793" class="aktt_tweet_time">#</a></li>
<li>On December 18th another 230 tonnes of radioactive water leaked at Fukushima. Mass media not interested (?) <a href="http://twitter.com/fridental/statuses/151281713467752449" class="aktt_tweet_time">#</a></li>
<li>Eine sehr interessante Statistik: <a href="http://t.co/xRkvNrUE" rel="nofollow">http://t.co/xRkvNrUE</a> <a href="http://twitter.com/fridental/statuses/152543661660446720" class="aktt_tweet_time">#</a></li>
<li>Checked out Firefox for Android: very quick and pretty, font size just right (small but not unreadable), and cool gestures. #<a href="http://search.twitter.com/search?q=%23like" class="aktt_hashtag">like</a> <a href="http://twitter.com/fridental/statuses/152872773105102848" class="aktt_tweet_time">#</a></li>
<li>I liked a @<a href="http://twitter.com/YouTube" class="aktt_username">YouTube</a> video <a href="http://t.co/0NRW8lgt" rel="nofollow">http://t.co/0NRW8lgt</a> Journey — Don’t Stop Believing Cover (Piano/Electric Guitar/Voc <a href="http://twitter.com/fridental/statuses/152910999207419904" class="aktt_tweet_time">#</a></li>
</ul>
<p class="aktt_credit">Powered by <a href="http://alexking.org/projects/wordpress">Twitter Tools</a></p>
]]></content:encoded>
			<wfw:commentRss>http://maxim.fridental.de/2012/01/01/this-week-in-twitter-158/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adventures in embedded C land</title>
		<link>http://maxim.fridental.de/2011/12/28/adventures-in-embedded-c-land/</link>
		<comments>http://maxim.fridental.de/2011/12/28/adventures-in-embedded-c-land/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 13:04:11 +0000</pubDate>
		<dc:creator>MaximFridental</dc:creator>
				<category><![CDATA[tech-and-biz]]></category>

		<guid isPermaLink="false">http://maxim.fridental.de/?p=1852</guid>
		<description><![CDATA[Preface I don’t think of myself as a software developer. My motivation to learn and work in software development was based on the idea of building things. But if you think about it, software alone is not a “thing”, it is just a component of software product. Even worse, it is an invisible component nobody [...]]]></description>
			<content:encoded><![CDATA[<h2>Preface</h2>
<p>I don’t think of myself as a software developer.</p>
<p>My motivation to learn and work in software development was based on the idea of building things. But if you think about it, software alone is not a “thing”, it is just a component of software product. Even worse, it is an invisible component nobody really cares about, as soon as it is not overly buggy.</p>
<p>Software products interact with users thru their UI. The UI together with use-cases supported by the product and its marketing platform create a user experience, which IS the software product from the user’s point of view. Note how the software itself is not part of this formula <img src='http://maxim.fridental.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If software is poorly written, it makes it hard to evolve it in the future versions. Unfortunately, more often than not the responsible managers either don’t care or can’t tell clean and good software from dirty and poor one. So even this internal aspect of a “thing” — its evolvability — is often neglected.</p>
<p>Having understood that software <em>per se</em> neither a “thing” for the users nor a “thing” for product owners, I’m moving to positions allowing me to define what really matters — UI, Usability and the Product as a whole. But because I have much more experience as a programmer, I both still have and want to work on some down-to-earth, in-the-trenches software development. At least part-time.</p>
<p>Currently I’m discovering embedded programming in C and want to share my impressions.</p>
<h2>Horror</h2>
<p>I have used various high-level programming languages in the last 19 years, and the last 12 years were exclusively in high-level area. Of course I’ve used assembler and C for some of my first programs back then 20 years ago; I also had some course works at my university to write in C, and I’ve created a commercial firmware for a telecom device in 1999 using ASM.</p>
<p>But returning back to C after having obtained all the experience and knowledge of other languages is something different. C was the third or fourth programming language I’ve learned in my life (after BASIC, ASM and Pascal). I was 15 at that time. In this age, when you learn a new language, you just accept it as it is and only care about how to bend you mind around it to produce a compilable program. This time,  learned designs of quite different programming languages (such as Smalltalk, C#, Javascript, etc), I had the possibility to actually evaluate the C language design and the paradigms behind it.</p>
<p>And my first impression was horror.</p>
<p><strong>C doesn’t have reasonable integer types</strong><br />
This one was perhaps the biggest negative surprise for me. I mean, C is currently used only to write some low-level platform and/or performance-critical stuff. Often, the exact bit size and alignment of your variables is very critical. And still, C’s built-in integer types are absolutely unusable. When you write <em>int</em> in C#, you have your 32 bits. Guaranteed, fixed, always the same for any platform from a tiny mobile phone to a powerful Azure server cluster, and this will never ever change. When you write <em>int</em> in C, you’ll get something, depending on your platform. The only thing you know for sure is that its bit size is greater or equal than <em>char</em>, and less or equal than <em>long int</em>. Well, thanks for nothing!</p>
<p>Because the integer types are so unusable, there are efforts to create appropriate pre-processor directives that will try to figure out the current platform’s native bit size and <em>#define</em> useful types. Unfortunately, there are several such efforts, and in the real-life down-to-earth C source code, you will see variables declared as <em>int</em>, <em>int32_t</em> and <em>gint32</em>, all meaning the same, and used in the very same function. This happens especially often when you have a software using several another components, which are open source.</p>
<p><strong>C doesn’t have <em>byte</em> and <em>bool</em></strong><br />
This is another WTF moment. C is often used in constrained memory conditions, so that you expect a very powerful bit and byte manipulation engine. But there is nothing.</p>
<p>Instead of <em>byte</em>, I saw <em>char</em> is being used (as well as<em> uint8_t</em>, <em>guint8</em> and <em>BYTE</em>). Such a byte of course does not support bit manipulations out of the box (which is even worse than some assemblers!), so that you have to spend hours trying to figure out what values you have to &amp; and | with some <em>int</em> to get its bits from 3rd to 18th.</p>
<p>As for <em>bool, </em>it is often <em>#defined</em> to be <em>char</em> or <em>int</em>. Sometimes, boolean types together with the <em>false</em> and <em>true</em> constants are <em>#defined</em> several times per module (one <em>#define</em> situated in some indirectly included header while another is directly in the file). But this definition of boolean is quite lousy one, because <em>if</em> and <em>while</em> are happy to accept any integer, so that compiler doesn’t have any static checking support. You can forget to dereference a pointer to your “bool” variable and the <em>if</em> would happily accept it as a <em>true</em> value; you will not get even a warning from the compiler!</p>
<p><strong>Generally, C compile-time checks are lousy</strong><br />
To demonstrate the point, let’s look at this code:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> main <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;This is a test!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Just put it into the file test.c and then execute</p>
<pre>
gcc -o test test.c
./test
</pre>
<p>Now, as a naïve ex-C# developer, I would expect the first command fail with the error telling me that the function printf is undefined. Right, <em>gcc </em>would link with <em>libc</em> by default, but I’ve forgot to <em>#include &lt;stdio.h&gt;</em>.</p>
<p>Instead! Instead, <em>gcc</em> would tell you the following:</p>
<pre>
test.c:3:3: warning: incompatible implicit declaration of built-in
function ‘printf’ [enabled by default]
</pre>
<p>How on the earth is can be a warning, you think. Then you check your working directory and see the executable <em>test</em> there. And then you execute it with the second command, and what does it do? Crashes? No, it prints out the given string! Are you amazed?</p>
<p>It turns out that, in case C detects something looking like a function call, and the function is undeclared, it just assumes this function takes an <em>int</em> as its argument, and returns an <em>int</em> back.</p>
<p>No, I’m <a href="http://stackoverflow.com/a/4654172">not kidding</a>!</p>
<p>And no, I don’t know why it is an <em>int-&gt;int</em> and not <em>float-&gt;void</em>, for example. And why the hell this automagic is required at all…</p>
<p>But wait, okay, okay, whoa! We’re passing a string to <em>printf</em>, so at least after assumption its signature is <em>int printf (int)</em>, the C should print an error and stop, for Lords sake? Well, you see, string is just <em>char*,</em> and this is a pointer, and a pointer… well, from where C is sitting, the pointer is just an <em>int</em>.</p>
<p>Sooo, let’s try it out:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> main <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">int</span> ret <span style="color: #339933;">=</span> foobar<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">int</span> foobar <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> a<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">return</span> a <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>then</p>
<pre>
gcc -Wall -o test test.c
test.c: In function ‘main’:
test.c:3:3: warning: implicit declaration of function ‘foobar’
[-Wimplicit-function-declaration]
test.c:3:7: warning: unused variable ‘ret’ [-Wunused-variable]
</pre>
<p>So, in C, an arbitrary assumption that undeclared functions are <em>int-&gt;int</em> has the same severity level than detection of an unused variable. If not the <em>–Wall</em> option (almost the highest warning level of gcc), it wouldn’t even print any warnings at all!</p>
<p>Let’s now go wild and explore the situation a little further. The following source code could easily occur after / during a slight refactoring of function signatures:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> num_records<span style="color: #339933;">;</span>
  <span style="color: #993333;">char</span><span style="color: #339933;">*</span> input<span style="color: #339933;">;</span>
&nbsp;
  init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  input <span style="color: #339933;">=</span> read_input_data<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>num_records<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> num_records<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    process_data<span style="color: #009900;">&#40;</span>input<span style="color: #339933;">,</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> init<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> security_token<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Initializing with token %d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> security_token<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">int</span> read_input_data<span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span> out_buf<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> security_token<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Reading with token %d to buffer %d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> security_token<span style="color: #339933;">,</span> out_buf<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  out_buf<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'a'</span><span style="color: #339933;">;</span>
  out_buf<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'b'</span><span style="color: #339933;">;</span>
  out_buf<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'c'</span><span style="color: #339933;">;</span>
  out_buf<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'<span style="color: #006699; font-weight: bold;">\0</span>'</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">3</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> process_data<span style="color: #009900;">&#40;</span><span style="color: #993333;">const</span> <span style="color: #993333;">char</span><span style="color: #339933;">*</span> buf<span style="color: #339933;">,</span> <span style="color: #993333;">char</span><span style="color: #339933;">*</span> out_ptr<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> num<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> security_token<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Processing from buffer %d to buffer %d %d items with token %d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
  buf<span style="color: #339933;">,</span> out_ptr<span style="color: #339933;">,</span> num<span style="color: #339933;">,</span> security_token<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> num<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #339933;">*</span>out_ptr<span style="color: #339933;">++</span> <span style="color: #339933;">=</span> <span style="color: #339933;">*</span>buf<span style="color: #339933;">++;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>When you compile it, gcc will print a lot of warnings but never an error, and produce the executable. When executed, it might print something like this before it crashes:</p>
<pre>
./test
Initializing with token 134513456
Reading with token 0 to buffer -1076015340
Processing from buffer 3 to buffer 0 11529179 items with token 12862244
Segmentation fault
</pre>
<p>So, apparently this implicit <em>int-&gt;int</em> function declaration is an overly simplistic description of how C handles unknown functions, which of course increases the number of wonderful cases where you have to fix a sudden <em>segfault</em>. I have no idea from where the values of missing parameters are coming, and what awesome security implications might happen when just commenting out some existing function and defining another one with additional parameter <em>void*</em>, which would allow you to write… where? On the stack?</p>
<p><strong>Generally, it is hard to write a future-proof code in C</strong><br />
I like the following example:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
&nbsp;
<span style="color: #993333;">typedef</span> <span style="color: #993333;">struct</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">int</span>  id<span style="color: #339933;">;</span>
  <span style="color: #993333;">char</span><span style="color: #339933;">*</span> name<span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> age<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> Employee<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">int</span> main <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  Employee ceo <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Bill Jobs&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">55</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s is %d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> ceo.<span style="color: #202020;">name</span><span style="color: #339933;">,</span> ceo.<span style="color: #202020;">age</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>It works as expected. Now, let’s say, we want to add department to the <em>Employee struct</em>. Piece of cake, right?</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
&nbsp;
<span style="color: #993333;">typedef</span> <span style="color: #993333;">struct</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">int</span>  id<span style="color: #339933;">;</span>
  <span style="color: #993333;">char</span><span style="color: #339933;">*</span> name<span style="color: #339933;">;</span>
  <span style="color: #993333;">char</span><span style="color: #339933;">*</span> department<span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> age<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> Employee<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">int</span> main <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  Employee ceo <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Bill Jobs&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">55</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s is %d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> ceo.<span style="color: #202020;">name</span><span style="color: #339933;">,</span> ceo.<span style="color: #202020;">age</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s works in %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> ceo.<span style="color: #202020;">name</span><span style="color: #339933;">,</span> ceo.<span style="color: #202020;">department</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The same example implemented in C# would print “Bill Jobs works in”, because the department is not initialized and is <em>null</em>. On C, the second <em>printf</em> will <em>segfault</em>, because the department string is being initialized with the CEOs age. There is one step between a perfectly working software and a sudden <em>segfault</em>. Either that, or you have to extend any existing <em>struct</em>s by adding new fields to the end.</p>
<p>These discoveries I’ve made in a mere several first weeks working with C. I’m looking forward to post even more similar war stories here. But horror was not the only feeling I had. Curiosity and a sudden recognition of how C is designed were a great fun for me.</p>
<h2>Fun</h2>
<p><strong>Modularity concept</strong></p>
<p>In the OOP world, we think in classes. It’s a habit. I was never concent with the silly tradition of C++ / C# / Java to store source code in files, because files add avoidable complexity. Best OOP languages like Smalltalk don’t need files and store the source code in a database. Therefore I was fascinated when I’ve first heard that Microsoft’s TFS was going to store source code in a database… Well, TFS turned out to be one of the most dissapointing Microsoft products to me, but that’s another story.</p>
<p>In C, they think in files, and they really use and need files. A file is a first-class concept in this language. Files are means of modularization. There are two kinds of them — the .c and the .h files.</p>
<p>In a .c file you normally put one or several functions. This is your module. Functions that belong together are stored in the same .c file. Some of them are exposed for usage from other modules (.c files), others are private (in C you use the keyword <em>static</em> to mark such functions).</p>
<p>Now, to call public functions of module A from another module B, you have <del>three</del> two options:</p>
<p>1) You can manually declare exported functions in the beginning of the module B.<br />
2) You can manually declare them in a .h file and then <em>#include</em> it in the module B.<br />
<del>3) You can use implicit declaration for your <em>int-&gt;int</em> functions as described above.</del></p>
<p>This makes the .h files to be roughly an analog of interfaces or public class members in OOP. The difference is that you are not constrained by any formal rules. For example, you can combine exposed functions of several modules in one .h file, or have different .h files for the same module, or even do all that for the code you don’t own (and it might be already compiled). This is more flexible.</p>
<p>So, generally, when I write a new module, first I write a .h file to define its public interface, then I <em>#include</em> only those .h files into my .h file that are needed for my function declarations (mostly typedefs of missing built-in types). Then I write the .c file, <em>#include</em> the corresponding .h file to forward-declare public functions, then forward-declare the private functions, and then <em>#include</em> the .h files of all the other modules I need when implementing my module.</p>
<p>This is radically different from how I did that in C++ ten years ago, where I used to <em>#include</em> all possible header files to any other file, because I was pissed of by this manual file management and wanted to think in terms of classes and interfaces only, considering files as one (and the worst) of many possible source code storage backends.</p>
<p><strong>Program for the compiler</strong><br />
When programming in modern languages, you have two very distinct modes: the run-time and the compile-time. My comeback to C has made me think about any program as being a double-program: the one for the compiler (executed at compile-time), and the other one for the run-time.</p>
<p>In the modern languages, the compile-time program is purely declarative without side effects. In C#, if you write</p>
<pre lang="C#" line="0">
public class Point
{
  public int X;
  public int Y;
}
</pre>
<p>this is in essence a declarative instruction to the C# compiler to create a new class with the given members. It is declarative, because it doesn’t matter if this class appears in the source code before or after some other class; and the order of its members also doesn’t matter. The declarative compile-time style of modern languages makes it easy to think about it, so that you can distribute more of your focus to the run-time.</p>
<p>Not in C. There, the best way to think about a program is a double-helix DNA where procedural compile-time instructions are intertwined with procedural run-time instructions:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> open <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> write_data <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> fd<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">int</span> main <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">int</span> fd<span style="color: #339933;">;</span>
&nbsp;
  fd <span style="color: #339933;">=</span> open<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  write_data<span style="color: #009900;">&#40;</span>fd<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Reading this source code as compile-time program, first there is a command to put “open” and “write_data” with the corresponding signatures into the name table, then a command to put “main” into the name table, then a command to start writing compiled code of “main”, then the command to put “fd” to the local scoped name table, then a command to compile a function call to “open” and add it to the “main” function object code, and so on.</p>
<p>Thinking about it this way makes it easier to grasp the behavior of the language. Especially when you start using macros (and in C, you have to). And it explains quite naturally the need of forward function declarations and the importance of the struct member order.</p>
<p>In a sense it reminds me how Smalltalk (also an ancient language) works; there, new classes or methods are also defined by calling a procedural method. The difference is that in Smalltalk the syntax for the compile-time is almost the same as the run-time syntax so that you don’t have to learn two languages instead of one.</p>
<p><strong>C with classes: GLib</strong><br />
C++ is often called “C with classes”, but this is not the only truth; the pure C has its own OOP implementation; in GLib they’ve managed to do it without modifying the programming language itself. And boy it is a funny hack, I must say.</p>
<p>Consider the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">typedef</span> <span style="color: #993333;">struct</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">int</span>  id<span style="color: #339933;">;</span>
  <span style="color: #993333;">char</span><span style="color: #339933;">*</span> name<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> BaseObject<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">typedef</span> <span style="color: #993333;">struct</span>
<span style="color: #009900;">&#123;</span>
  BaseObject parent<span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> age<span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> department_id<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> Employee<span style="color: #339933;">;</span>
&nbsp;
Employee<span style="color: #339933;">*</span>  ceo<span style="color: #339933;">;</span></pre></div></div>

<p>They use the fact that according to the C standard, fields of the parent field are stored in the declaration order at the beginning of the Employee structure, so the memory representation of it looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">struct</span> Employee_in_memory
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">int</span>  id<span style="color: #339933;">;</span>
  <span style="color: #993333;">char</span><span style="color: #339933;">*</span> name<span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> age<span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> department_id<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This allows you to cast pointer to <em>Employee</em> to pointer to <em>BaseObject</em>, because, hey, its fields are at the beginning of the memory. This enables polymorhism like this:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">typedef</span> <span style="color: #993333;">struct</span>
<span style="color: #009900;">&#123;</span>
  BaseObject parent<span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> num_employees<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> Department<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #339933;">#define MAX_REPOSITORY_OBJECT_COUNT 1000;</span>
BaseObject<span style="color: #339933;">*</span> repository<span style="color: #009900;">&#91;</span>MAX_REPOSITORY_OBJECT_COUNT<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">int</span> read_repository<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">int</span> stream<span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
  stream <span style="color: #339933;">=</span> open<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>is_eof<span style="color: #009900;">&#40;</span>stream<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span>get_next_type<span style="color: #009900;">&#40;</span>stream<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">case</span> EMPLOYEE<span style="color: #339933;">:</span>
        Employee<span style="color: #339933;">*</span> emp <span style="color: #339933;">=</span> deserialize_employee<span style="color: #009900;">&#40;</span>stream<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        repository<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> emp<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">case</span> DEPARTMENT<span style="color: #339933;">:</span>
        Department<span style="color: #339933;">*</span> dept <span style="color: #339933;">=</span> deserialize_department<span style="color: #009900;">&#40;</span>stream<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        repository<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> dept<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    i<span style="color: #339933;">++</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> i<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> dump_repository<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> top<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> top<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d,%s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> repository<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span>id<span style="color: #339933;">,</span> repository<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span>name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>As for methods, you could just add function pointers to the structs, but this would mean you copy them with each object instance, which is a big waste of memory (at least according to the C ideology), besides, it would allow you to have different methods per instance of the same class, which is normal for languages such as JavaScript, but just too weird for the conservative C. Therefore, in GLib, in their very base object <em>GObject</em> they put a pointer to another structure, the class structure, which has the function pointers of the class methods. This has the added benefit of run-time reflection, because this class structure has a couple of fields allowing you to read the class name, query for properties and so on.</p>
<p>But, because of this, as soon as you have any non-trivial hierarchy with virtual methods and so, it would be too complex to use it directly in plain C (because of constant casting and using <em>obj-&gt;parent</em> and <em>obj-&gt;class</em>), so that GLib has added a lot of <em>#defines</em> hiding this complexity (but also preventing an easy understanding of what exactly is happening). <a href="https://github.com/zorgnax/gobject-examples/tree/master/05-bank-account">Here is a good example of how a simple OOP code with GLib looks like.</a> All in all it feels like programming in C++ with all its black box covers removed. But this is yet another story.</p>
]]></content:encoded>
			<wfw:commentRss>http://maxim.fridental.de/2011/12/28/adventures-in-embedded-c-land/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>This Week in Twitter</title>
		<link>http://maxim.fridental.de/2011/12/25/this-week-in-twitter-157/</link>
		<comments>http://maxim.fridental.de/2011/12/25/this-week-in-twitter-157/#comments</comments>
		<pubDate>Sun, 25 Dec 2011 00:00:00 +0000</pubDate>
		<dc:creator>MaximFridental</dc:creator>
				<category><![CDATA[random]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://maxim.fridental.de/2011/12/25/this-week-in-twitter-157/</guid>
		<description><![CDATA[Cool looking mix of Apple and HTC phones for just 200 euro http://t.co/XkunpXFz # Acer, Lenovo, HTC and Samsung — all but ASUS — plan 4core tablets early next year. 春节 is more important for them than Christmas? A shift? # Apple, Facebook, Twitter, Google and co. are the new Hollywood, bring American lifestyle to [...]]]></description>
			<content:encoded><![CDATA[<ul class="aktt_tweet_digest">
<li>Cool looking mix of Apple and HTC phones for just 200 euro <a href="http://t.co/XkunpXFz" rel="nofollow">http://t.co/XkunpXFz</a> <a href="http://twitter.com/fridental/statuses/148313501952262145" class="aktt_tweet_time">#</a></li>
<li>Acer, Lenovo, HTC and Samsung — all but ASUS — plan 4core tablets early next year. 春节 is more important for them than Christmas? A shift? <a href="http://twitter.com/fridental/statuses/149165237281632259" class="aktt_tweet_time">#</a></li>
<li>Apple, Facebook, Twitter, Google and co. are the new Hollywood, bring American lifestyle to the world. <a href="http://twitter.com/fridental/statuses/149805832551399424" class="aktt_tweet_time">#</a></li>
<li>Against commercialization of christmas? Your presents are too good! Mine are completely useless and therefore are only of spiritual value. <a href="http://twitter.com/fridental/statuses/150275262624444416" class="aktt_tweet_time">#</a></li>
</ul>
<p class="aktt_credit">Powered by <a href="http://alexking.org/projects/wordpress">Twitter Tools</a></p>
]]></content:encoded>
			<wfw:commentRss>http://maxim.fridental.de/2011/12/25/this-week-in-twitter-157/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>This Week in Twitter</title>
		<link>http://maxim.fridental.de/2011/12/11/this-week-in-twitter-156/</link>
		<comments>http://maxim.fridental.de/2011/12/11/this-week-in-twitter-156/#comments</comments>
		<pubDate>Sun, 11 Dec 2011 00:00:00 +0000</pubDate>
		<dc:creator>MaximFridental</dc:creator>
				<category><![CDATA[random]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://maxim.fridental.de/2011/12/11/this-week-in-twitter-156/</guid>
		<description><![CDATA[unglaublich! http://t.co/yxvuIOZR Danke, GfK Retail : Na dann, mein Ziel ist es, aus 1 Prozent 48 zu machen Auf dem Metz Fernseher # Nikolaus hat mir keine Schokolade, sondern Entscheidung gebracht, wieder einen Abnehmen-Versuch zu starten. Mit 130 Kilo die höchste Zeit! # 45m3 water with 260GBq leaked from a Fukushima cleaning apparatus. 150 l. [...]]]></description>
			<content:encoded><![CDATA[<ul class="aktt_tweet_digest">
<li>unglaublich! <a href="http://t.co/yxvuIOZR" rel="nofollow">http://t.co/yxvuIOZR</a> Danke, GfK Retail : Na dann, mein Ziel ist es, aus 1 Prozent 48 zu machen <img src='http://maxim.fridental.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Auf dem Metz Fernseher <a href="http://twitter.com/fridental/statuses/143428230228082690" class="aktt_tweet_time">#</a></li>
<li>Nikolaus hat mir keine Schokolade, sondern Entscheidung gebracht, wieder einen Abnehmen-Versuch zu starten. Mit 130 Kilo die höchste Zeit! <a href="http://twitter.com/fridental/statuses/144081083753955329" class="aktt_tweet_time">#</a></li>
<li>45m3 water with 260GBq leaked from a Fukushima cleaning apparatus. 150 l. are already in the ocean, rest in puddles <a href="http://t.co/zHC1JyCC" rel="nofollow">http://t.co/zHC1JyCC</a> <a href="http://twitter.com/fridental/statuses/144488776255799296" class="aktt_tweet_time">#</a></li>
<li>YESS!!! B-) <a href="http://t.co/NAHW3vGU" rel="nofollow">http://t.co/NAHW3vGU</a> <a href="http://twitter.com/fridental/statuses/144838392713199617" class="aktt_tweet_time">#</a></li>
<li>Now this is what I call absolutely amazing web design, the very essence of how the modern web (should) look like: <a href="http://t.co/CPyBSNbd" rel="nofollow">http://t.co/CPyBSNbd</a> <a href="http://twitter.com/fridental/statuses/145472019755044864" class="aktt_tweet_time">#</a></li>
</ul>
<p class="aktt_credit">Powered by <a href="http://alexking.org/projects/wordpress">Twitter Tools</a></p>
]]></content:encoded>
			<wfw:commentRss>http://maxim.fridental.de/2011/12/11/this-week-in-twitter-156/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iScreen</title>
		<link>http://maxim.fridental.de/2011/12/10/iscreen/</link>
		<comments>http://maxim.fridental.de/2011/12/10/iscreen/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 15:55:15 +0000</pubDate>
		<dc:creator>MaximFridental</dc:creator>
				<category><![CDATA[tech-and-biz]]></category>

		<guid isPermaLink="false">http://maxim.fridental.de/?p=1832</guid>
		<description><![CDATA[Before we start, I’d like to remind that this post, like all other posts on this site, reflect only my personal opinion, not of my employer. There are more and more rumors that Apple will announce a new TV set around March next year, and the press speculates about its features and look. Well, I think, [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #999999;">Before we start, I’d like to <a href="http://maxim.fridental.de/impressum/"><span style="color: #999999;">remind</span></a> that this post, like all other posts on this site, reflect only my personal opinion, not of my employer.</span></p>
<p>There are more and more rumors that Apple will announce a new TV set around March next year, and the <a href="http://www.chip.de/news/Apple-TV-Neue-Geruechte-Verkauf-ab-Sommer-2012_53000589.html">press speculates</a> about its features and look.</p>
<p>Well, I think, TV sets have no future, and Apple will announce a TV set killer, not a better TV set.</p>
<p>Because, what is a TV set? It is a TV tuner plus a big screen. Modern devices have many additional features, including various inputs, network and Internet access, time shift, etc. But these features are all not defining. Remove time shift, and it is still a TV set. But remove the tuner, and it is just a monitor. But in broader sense, TV set is not only a device. It also defines how the television industry is structured. And it is also the way how viewers perceive role and place of television in their entertainment and informational workflows.</p>
<p>The life of a modern television user is hard. To operate the TV, he has (or expected to) understand</p>
<ul>
<li>the differences between analog and digital TV</li>
<li>the differences between DVB-T, DVB-S and DVB-C</li>
<li>the difference between free TV and pay TV, and understand the need of set-top boxes and CI slots and cards, and has to be a guru to understand what kind of set-top boxes is compatible with what kind of pay TV stations</li>
<li>what do SCART, HDMI, VGA, DVI, S-Video, etc. mean and what adapters are needed or possible</li>
<li>the difference between PAL, SECAM and NTSC</li>
<li>How teletext, EPG and Hbb-TV are different from each other, and how to use all of them (differently for each TV station)</li>
<li>CD, DVD, DVD+-RW, Blu-Ray, USB sticks, SD and CF cards: when to use them, and how to play their contents on TV</li>
<li>Files: Xvid, DivX, WMV, AVI, MP4, MPG, MOV, MKS, RT, TS, VOD, M2TS… and how to play them on TV</li>
<li>What is a media center, and why there are different media center concepts: a set-top box implementing media center functions? A Blu-Ray player with integrated media center? Media center in a hard drive? Or in the Internet router? Or in a NAS storage? Or inside a low-noise PC besides the TV set? And if using PC, what software to use: Windows Media Center, xbmc, … Or better an XBOX besides the TV extending the media center on PC?</li>
<li>What is a game console, and what is the difference between XBOX, PS3, Wii…</li>
</ul>
<p>I guess, there are a lot of paid jobs out there, requiring to know and to understand less than the TV industry currently demands from their customers to know and understand, just to be able to entertain themselves.</p>
<p>People are not like this. They don’t like knowing and understanding things. They just want to be informed and entertained, and the device in their living room should “just work”. No matter if they want to play a networked first-person shooter game, to check the current Dow-Jones index, to enjoy some movie, or to observe a football match — the device must work consistently and straightforwardly.</p>
<p>Apple’s success in other industries suggests that contemporary people are ready and willing not only to pay a huge premium to somebody who would allow them not knowing technical details, but also give up a bit of their privacy and freedom for that. This gives the possibility for Apple to enter to this market — the market’s consumers are ready for the change (they just yet don’t know it).</p>
<p>And they are ready for the change, because the current situation is so unsatisfying (from the usability perspective). The reason for that is the TV industry structure, consisting of stations, networks, and CE manufacturers. Heritage of governmental control times, this structure is the primary reason of the current deadlock and absence of innovations (3D video leading to headache and requiring to put on glasses, like children playing in doctors? come on! This is exactly what the most viewers were missing so far!)</p>
<p>Just think about it. CE manufacturers create screens attracting eyeballs of huge population for unbelievable several hours a day, every day. Social network startups capable to attract a tiny fraction of this love are being sold for billions of dollars. Yet the manufacturers neither able nor know how to monetize it. As a result they have to live on near zero margins. No wonder they cannot innovate; money is just not there.</p>
<p>And even those who have money, wouldn’t design their devices to be perfectly usable by the end user; instead, they design it to be conforming to various industry standards, and to be appealing to the sellers. Typically, earnings of TV set manufacturers depend not on viewer satisfaction, but rather on sellers satisfaction. It doesn’t matter how well the device can be used, it is only matter how well it can be sold. So, the usability of devices is just “nice to have”, and this is the reason of the famous “blinking 00:00 VCR display” issue: you have to bend your mind around to understand how to set the clock.</p>
<p>Network companies have had a terrible, huge, unbelievable high investment in the infrastructure and cannot allow any innovations not compatible with it, until the investment pays off. Their earnings do depend on user satisfaction, but they have educated the viewers that television HAS to consist from three components (the device, the cable and the stations), so that they are and feel themselves only responsible for their part and would therefore happily sleep another 100 years monetizing their DVB infrastructure.</p>
<p>Stations have potential, knowledge, understanding and talents to improve television and make it more immersive and more user friendly. Alas, they get all the advertisement money, so that their motivation is rather altruistic and artistic rather then dictated by the hard rule of the market. Besides, they don’t have the possibility to change technology used in the infrastructure and in devices. And developing their own devices and using another infrastructure (for example, Internet) doesn’t seem to be their core competency. The best they have produced (in Europe) in this area was the Hbb-TV.</p>
<p>Apple has the possibility to unlock it. The secret of success for their mobile devices was that they simultaneously:</p>
<ul>
<li>Own the usability and user experience of the device, both in hard– and in software</li>
<li>Own the entertainment content distribution</li>
<li>Partially control the network by partnering with mobile operators and providing their server backend for iTunes</li>
<li>Partially control the marketing, by selling their hardware directly to the customers, on-line and in Apple stores, and selling the software via tightly controlled App Store.</li>
</ul>
<p>These factors were responsible for providing entertainment intensity of levels of magnitude higher than those of Apple’s competition.</p>
<p>Apple also has experience unlocking such convoluted markets. The mobile market in the pre-Apple era has had similar issues: mobile operators invested in the infrastructure and wanted to sleep forever monetizing it, and device manufacturers didn’t sell directly to the customers, but had to satisfy the sellers (mobile operators and electronics chains) and couldn’t monetize the usage of their devices. As the history teaches us, people have readily paid up to 10x times more for something more usable, more immersive and more entertaining.</p>
<p>So, how this TV set killer device could look like? I don’t know. It depends heavily on talents Apple has, on result of negotiations with other industry players they might have conducted, on commercial feasibility of some specific technologies, etc, I have no idea about all that. If I was in charge and didn’t have any limitations, I would do the following:</p>
<p>1) Create a technology for games similar to XNA allowing to write games for iPhone, iPad, Mac and the new device, all using the same toolchain. And convince some key players in the game industry to port their successful franchises to this platform.</p>
<p>2) Ensure a live streaming cloud capable of taking broadcast signals and streaming them via the Internet in near real-time with high quality, no interruptions and integrated time shift and VoD. And convince some key TV stations to license their programmes (this is where Google TV has failed).</p>
<p>3) Partner with somebody helping me to convince others, for example with a best ISV in the country.</p>
<p>4) Create a device, which would have a big bright screen with the best video processing (400 Hz, motion compensation, scaling, etc), terrific multi-core processor with several TFLOPS, but still without any noisy rotating parts (I’m looking at you, XBOX), a modified iOS, huge and quiet HDD or SSD, best available Wi-Fi, perhaps some web cameras, but nothing else: no other connectors (except of power), and may be one power button.</p>
<p>5) Ensure all kinds of content can be streamed to the device via WiFi using the Internet protocol: VoD movies, music, and apps from the Apple store servers, live broadcast from the new cloud service, and user-own content from his Apple devices in his local network, or from his iCloud. As well as converting locally available signal sources (cable, satellite, VCR, PC) for those who still need them, using an optionally available adapter box.</p>
<p>6) Create a content-centered UX concept. Viewers wouldn’t switch between signal inputs (channels, connectors, sources) as they do now; they would choose between contents. Do I want to rent this movie, or watch that live sport event, or look at my own photos shot by iPhone and uploaded to the iCloud, or would I rather play this game? This is the kind of choice viewers will take. And for lean-back scenarios, a partner TV station network will provide some live channel that will be “tuned on” by default.</p>
<p>As for the actual interaction technology, I do believe Apple will invest much in it, be it just a remote control, Kinect-like NUI, Siri-like voice control, or something else. But in my opinion, this wouldn’t be a big variable in the equation. The mere absence of all this stuff users have to know to operate TV would be already a huge difference. The Apple’s device will “just work”, i.e. just inform and entertain.</p>
<p>If Apple will really do that, and this will really work, all the traditional industry players will have hard times competing. One realistic option would be to jump into the Google TV bandwagon, a similar strategy many mobile players went with the Android. Another one is to go with Microsoft, who have recently announced some interesting and revolutionary changes in the XBOX (which I to my confusion didn’t yet have had time to check out) and clearly aiming at the same market. And the last option: to give up the TV set market, and try to earn money on something else.</p>
<p>So, before I close this very long post and having predicted the close future, I’d also like to predict the distant future. After unlocking the TV market, where Apple will going to look next? My bet is that it will be cars and homes. Both industries are stagnating, both have a pretty awful usability (operating 3 pedals and several levers just to drive from A to B with high risks for the life? Ridiculous! Having to endure bad neighbours, just because it is so hard to move a house? Stone age!). So get ready for your iCars and iHomes.</p>
<p>And after solving that, we can then slowly approach what really matters: the human beings, with their bodies and their psyche…</p>
<p><span style="color: #999999;">NB. I’m sorry for typography of this post. “3D” and “PS3” look really awful. Unfortunately, I’m limited here by the standard WordPress editor and don’t know how to improve it.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://maxim.fridental.de/2011/12/10/iscreen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>This Week in Twitter</title>
		<link>http://maxim.fridental.de/2011/12/04/this-week-in-twitter-155/</link>
		<comments>http://maxim.fridental.de/2011/12/04/this-week-in-twitter-155/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 00:00:00 +0000</pubDate>
		<dc:creator>MaximFridental</dc:creator>
				<category><![CDATA[random]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://maxim.fridental.de/2011/12/04/this-week-in-twitter-155/</guid>
		<description><![CDATA[http://t.co/BJpGNURY # Powered by Twitter Tools]]></description>
			<content:encoded><![CDATA[<ul class="aktt_tweet_digest">
<li><a href="http://t.co/BJpGNURY" rel="nofollow">http://t.co/BJpGNURY</a> <a href="http://twitter.com/fridental/statuses/140874553600655360" class="aktt_tweet_time">#</a></li>
</ul>
<p class="aktt_credit">Powered by <a href="http://alexking.org/projects/wordpress">Twitter Tools</a></p>
]]></content:encoded>
			<wfw:commentRss>http://maxim.fridental.de/2011/12/04/this-week-in-twitter-155/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>This Week in Twitter</title>
		<link>http://maxim.fridental.de/2011/11/27/this-week-in-twitter-154/</link>
		<comments>http://maxim.fridental.de/2011/11/27/this-week-in-twitter-154/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 00:00:00 +0000</pubDate>
		<dc:creator>MaximFridental</dc:creator>
				<category><![CDATA[random]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://maxim.fridental.de/2011/11/27/this-week-in-twitter-154/</guid>
		<description><![CDATA[I liked a @YouTube video http://t.co/pM4ccfp2 dont try and rob an asian # Important things like love and death happen not so often, so nobody is a pro. We are puppies, hitting all the walls trying to find a door. # Do you also have to think about OLPC when looking at this? http://t.co/BDcPnNg9 # [...]]]></description>
			<content:encoded><![CDATA[<ul class="aktt_tweet_digest">
<li>I liked a @<a href="http://twitter.com/YouTube" class="aktt_username">YouTube</a> video <a href="http://t.co/pM4ccfp2" rel="nofollow">http://t.co/pM4ccfp2</a> dont try and rob an asian <a href="http://twitter.com/fridental/statuses/138684667363737600" class="aktt_tweet_time">#</a></li>
<li>Important things like love and death happen not so often, so nobody is a pro. We are puppies, hitting all the walls trying to find a door. <a href="http://twitter.com/fridental/statuses/139247049257402369" class="aktt_tweet_time">#</a></li>
<li>Do you also have to think about OLPC when looking at this? <a href="http://t.co/BDcPnNg9" rel="nofollow">http://t.co/BDcPnNg9</a> <a href="http://twitter.com/fridental/statuses/139862915590275072" class="aktt_tweet_time">#</a></li>
<li>is wondering if it is possible to make a Skype client using WebRTC: <a href="http://t.co/ThXPQd3o" rel="nofollow">http://t.co/ThXPQd3o</a> <a href="http://twitter.com/fridental/statuses/140552523034533888" class="aktt_tweet_time">#</a></li>
<li>Fireworks show around the largest Christmas tree in South America, LIVE streaming now in 360º video: <a href="http://t.co/kg0D9hsY" rel="nofollow">http://t.co/kg0D9hsY</a> <a href="http://twitter.com/fridental/statuses/140554176211066880" class="aktt_tweet_time">#</a></li>
</ul>
<p class="aktt_credit">Powered by <a href="http://alexking.org/projects/wordpress">Twitter Tools</a></p>
]]></content:encoded>
			<wfw:commentRss>http://maxim.fridental.de/2011/11/27/this-week-in-twitter-154/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

