<?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>Observations from Uppsala &#187; Windows phone</title>
	<atom:link href="http://jakob.engbloms.se/archives/tag/windows-phone/feed" rel="self" type="application/rss+xml" />
	<link>http://jakob.engbloms.se</link>
	<description>Computer Technology: Simulation, Virtualization, Virtual Platforms, Embedded, Multicore and Multiprocessing (by Jakob Engblom)</description>
	<lastBuildDate>Sun, 29 Jan 2012 19:45:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<image>
    <title>Observations from Uppsala</title>
    <url>http://jakob.engbloms.se/favicon.png</url>
    <link>http://jakob.engbloms.se</link>
    <width>32</width>
    <height>32</height>
    <description>Observations from Uppsala - http://jakob.engbloms.se</description>
    </image>		<item>
		<title>C in Danger &#8211; and thus Higher-Level Languages (?)</title>
		<link>http://jakob.engbloms.se/archives/1131?&#038;owa_medium=feed&#038;owa_sid=</link>
		<comments>http://jakob.engbloms.se/archives/1131#comments</comments>
		<pubDate>Sun, 09 May 2010 20:00:20 +0000</pubDate>
		<dc:creator>Jakob</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[DSL]]></category>
		<category><![CDATA[Erlang]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Nokia]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Windows phone]]></category>

		<guid isPermaLink="false">http://jakob.engbloms.se/?p=1131</guid>
		<description><![CDATA[Some recent developments among development environments for mobile phones have made me consider the hereto unthinkable: that C might be on a decline as the universal programming language. Indeed, maybe there is even a chance that we will not have a universal low-level language in the future at all. What is happening is that the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jakob.engbloms.se/wp-content/uploads/2010/05/C-dino.png"><img class="alignleft size-full wp-image-1132" title="C dino" src="http://jakob.engbloms.se/wp-content/uploads/2010/05/C-dino.png" alt="" width="105" height="94" /></a>Some recent developments among development environments for mobile phones have made me consider the hereto unthinkable: that C might be on a decline as the universal programming language. Indeed, maybe there is even a chance that we will not have a universal low-level language in the future at all. What is happening is that the hitherto &#8220;given&#8221; role of C as the base language for a platform is being questioned. The reason appears to be security, which cannot be said to be a bad thing. However, a large-scale move away from C might hurt many of today&#8217;s higher-level languages and even model-based engineering.<br />
<span id="more-1131"></span><br />
So what is going on? For the past decade or two, and even longer back than that on Unix platforms, it has been a truth that a (well-written) C program can be made to run on any platform. All platforms have had C compilers available (even Windows), and C programs with a dash of platform-dependent code in file operations could be easily made portable.  This has been used by common cross-platform application programs like Firefox, the Gimp, MySQL, and Wireshark, as well as by technical products like MatLab, the Diab and IAR C compilers (which I once worked on), and Simics (which I currently work on). It is a way of creating software that in my experience works very well. Especially since pretty much anything higher-level can be made to link with a basic C code base.</p>
<p>Ever since Unix became the role model for operating systems, C has been the &#8220;base&#8221; language. In desktop operating systems like Windows and Linux the platform API is expressed as C function calls, and the ABI (the binary calling conventions) for linking code from different compilation units and binary distribution units is also expressed in terms of the code that a C compiler would generate. A C compiler is the first thing you need to get the platform going, and C is a language that allows arbitrary applications to be developed and run on the platform. The semantics of dynamically loadable and shared objects are expressed in C, not C++, as the C++ ABI is too variable.</p>
<p>This ubiquitousness of C has also proven to  be a key enabler for higher-level languages. C is the language of choice to implement the basic virtual machines used by languages and programming systems like Perl, Python, Erlang, and Java. C (or C++) is also used as the target language of many modeling tools with code generation, such as MatLab/Simulink, Rational Rose, Rhapsody, and Labview. A single generator of C code can be reused to target many platforms. Sometimes C++ is the generated language (in particular for UML-based object-oriented tools), but C++ essentially falls back on the ubiquitousness of C to be able to call platform APIs and connect to other tools.</p>
<p>That is the state of things as we know them today. What seems to be happening is that this is slowly being deprecated&#8230; platforms are coming out where user code might not be possible to write in C at all, or where C programs cannot access the real platform API. For these platforms, it is quite difficult  port in an existing C/C++ portable program.</p>
<p>The first example is Google&#8217;s mobile phone operating system Android,where  Java was the only supported language at launch. Google have since made it possible to use C and C++ for some parts of an application, <a href="http://arstechnica.com/open-source/news/2009/06/android-goes-beyond-java-gains-native-cc-dev-kit.ars ">but it does not seem to be a full platform API allowing a whole program to be written only in C or C++: </a></p>
<blockquote><p>&#8220;The NDK will not benefit most applications. As a developer, you will need to balance its benefits against its drawbacks; notably, using native code does not result in an automatic performance increase, but does always increase application complexity,&#8221; the documentation says. &#8220;Typical good candidates for the NDK are self-contained, CPU-intensive operations that don&#8217;t allocate much memory, such as signal processing, physics simulation, and so on.&#8221;</p></blockquote>
<p>To port an application written in C/C++ such as Firefox to the Android platform, the app has to be modified to work as a backend to the Java interface.  <a href="http://arstechnica.com/open-source/reviews/2010/02/hands-on-and-under-the-hood-ars-tests-firefox-on-android.ars  ">ArsTechnica has a write-up on how Firefox was brought to Android through just such a modification</a>. Note that this does mean that ports are not as straight-forward as they would be to other platforms with a directly accesible C API. Interestingly, the Android approach essentially inverts the traditional relationship between C and other languages, where it was common to have a C adapter layer around other languages (like Java) in order to access the platform.</p>
<p>Note that the NDK quote does not mention language run-times. One of my favorite languages, Python, has had to be completely reimplented to run on Android. <a href="http://stackoverflow.com/questions/101754/is-there-any-way-to-run-python-on-android">Either using a &#8220;Jython&#8221; approach of compiling Python to Java byte codes, or using the Android Scripting Environment</a>.</p>
<p>Other languages that you would ordinarily just port using a simple recompile of the its C code base are not helped by this at all. One interesting example is the <a href="http://erlang.2086793.n4.nabble.com/Running-Erlang-on-Android-td2107544.html#a2107544">Erlang runtime</a>, which is basis for CouchDB. According to an interview on <a href="http://twit.tv/floss99">FLOSS weekly show 99, about Ubuntu One</a>, this fact prevents Ubuntu One from synching data from your desktop to your phone.  This demonstrates that the assumption that you can run a C program on &#8220;any Unix-like system&#8221; is no longer true for a large numbers of smartphones&#8230; and that is already affecting how you have to develop products.</p>
<p>Microsoft is also moving in the &#8220;no C for you&#8221; direction with Windows Mobile 7, where C# is the default language. This also prevents easy reuse of existing C programs on smartphones. <a href="http://arstechnica.com/microsoft/news/2010/03/winphones-first-big-native-code-casualty-firefox-on-winmob.ars">Ars Technica notes how this killed Firefox on Microsoft-based mobiles</a>.</p>
<p>Finally, we have Apples downright weird approach to languages and programming. Their recent banning of <a href="http://arstechnica.com/apple/news/2010/04/apple-takes-aim-at-adobe-or-android.ars">anything except Objective C and their own compilers </a>for iPhones (and iPods and iPads) is downright bizarre. They explicitly forbid code-generating tools to be used with their platform, as well as kicking out any alternative language runtimes (which is a move aimed at Adobe Flash that also hits Erlang, Python, et al.). This might make some sense from a security perspective, as it prevents programs from loading executable code at run-time on the phone&#8230; but it also makes for a much more restricted set of programming tools.</p>
<p>The only mobile platform that seems honest to old traditions is really Nokia&#8217;s Maemo. And Symbian. Suddenly, what used to be considered &#8220;closed&#8221; platforms have become the most open and most desktop-like of all the mobile operating systems. Really, that is a very important reason to get a Nokia N900 rather than an Android or Apple device.</p>
<p>I think this points to a somewhat more complicated future, where mobile applications will cannot be cross-platform, as you have to use Android-Java, Windows-C#, iPhone-ObjC, and Maemo-C/C++/anything to code. It could also point to a move even in the desktop and server space away from C and to more sandboxed, controlled, and not-as-common programming platforms. That would be really bad from a programmer productivity and language innovation perspective, as so much of the innovations today are actually based on the ubiquitousness of C and the use of C as a good implementation language and code-generation target language.</p>
<h3>Updates and clarifications</h3>
<p>Given the comments below, it seems that I need to make some things clearer&#8230;</p>
<p>First, the iPhone. It is really a special case, in that you do have C/objective-C access to the API. So in principle, you could port any C program including language virtual machines to the iPhone. Firefox, for example, would work. However, Apple for commercial (and maybe security) reasons does not allow programs that implement virtual machines to be distributed across their controlled application store. That you can implement a VM there does not really help you, as it is the first openly programmable platform that I have seen where a control body actually forbids certain classes of programs. The Apple approach is apparently even more idiotic than I first believed.  According to some more reports I read and heard, they do not enforce a technical limitation on the final program (such as running in a JVM or .net VM), but rather require all software to be originally and directly written in C, C#, or C++.  All just a swipe at Adobe and flash&#8230; so even Flash compiled to native code is disallowed.  And with it goes all other higher-level languages.</p>
<p>Second, on security. I do think that running programs on top of a VM like done with Java and .net does have security benefits. It gives you a level of indirection which can be used to check what applications does. Obviously not perfect since there will always be bugs and mistakes, but still it is a better architecture than raw access to the underlying machine. The  iPhone controlled mode of distribution could also be beneficial here. The <a href="http://www.twit.tv/sn245">SecurityNow podcast episode 245 </a>discusses this topic.</p>
<p>Third, on appropriate programming languages for different tasks. I totally agree with some comments that C is not a very nice language for GUI programming. No doubt about that. However, that was not really the point I was trying to make. I want to use higher level languages! But not having C available might make that harder and with limited choice&#8230; leading up to point four.</p>
<p>Fourth, my core point. <strong>Having platform-level access in C is a basic technology used today to implement the higher-level environments</strong>. Languages like Python, Perl, Erlang, Lua, and even the basic Java and .net virtual machines, all depend on having C available to bootstrap the process of getting the core virtual machine going. If we take this away, we limit choice in language and might stifle innovation, as well as the attractiveness of cross-platform environments.</p>
<p>Fifth, I agree with the comments C is definitely not going anywhere in terms of being used to develop operating systems and embedded systems (that&#8217;s where I spend most of my time, by the way). My observation is about what is happening to user-level programming for certain systems, not the systems programming which is intentionally made separate from user-level programming.</p>
<p><strong>Another Update:</strong></p>
<p>The Inquirer just pointed out that <a href="http://www.theregister.co.uk/2010/06/11/steve_jobs_lifts_interpreted_code_ban_for_chosen_few/">Apple is explicitly forbidding interpreters </a>to run on their phones, unless it is an interpreter they created or one explicitly allowed. That&#8217;s making the above very clear, Apple is consciously denying iPhone users all modern programming languages. And that&#8217;s just to make sure Adobe can&#8217;t weasel Flash in there. Politics sometimes make no sense at all. The Inq quote is worth quoting:</p>
<blockquote><p><em>Famously, when Apple released its iPhone SDK in spring of 2008, the  end user licensing agreement barred applications from downloading and  running any interpreted code. &#8220;No interpreted code may be downloaded or  used in an Application except for code that is interpreted and run by  Apple’s Documented APIs and built-in interpreter(s),&#8221; it said.</em></p></blockquote>
<div class="simple_likebuttons_container_small">
      <div class="simple_likebuttons_googleplus">
        <g:plusone size="medium" count="false" href="http://jakob.engbloms.se/archives/1131"></g:plusone>
      </div>
    
      <div class="simple_likebuttons_twitter simple_likebuttons_twitter_s">
        <a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-url="http://jakob.engbloms.se/archives/1131" data-lang="en">Tweet</a>
      </div>
    
      <div class="simple_likebuttons_facebook">
        <div id="fb-root"></div>
        <script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) {return;}
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, "script", "facebook-jssdk"));</script>
        <div class="fb-like" data-href="http://jakob.engbloms.se/archives/1131" data-send="false" data-layout="button_count" data-show-faces="false" data-width="90"></div>
      </div>
    </div>]]></content:encoded>
			<wfw:commentRss>http://jakob.engbloms.se/archives/1131/feed</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>

