<?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>PC Pro blog &#187; Java</title>
	<atom:link href="http://www.pcpro.co.uk/blogs/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pcpro.co.uk/blogs</link>
	<description>Blogging in the real world</description>
	<lastBuildDate>Wed, 08 Feb 2012 16:54:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Google App Inventor: is drag and drop a flop?</title>
		<link>http://www.pcpro.co.uk/blogs/2010/09/07/googles-app-inventor/</link>
		<comments>http://www.pcpro.co.uk/blogs/2010/09/07/googles-app-inventor/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 16:09:17 +0000</pubDate>
		<dc:creator>Darien Graham-Smith</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[App Inventor]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.pcpro.co.uk/blogs/?p=23998</guid>
		<description><![CDATA[
Confession time: I have never learnt to program in Java. Swoon, gasp.
It&#8217;s not that I haven&#8217;t wanted to. In particular, I’ve always loved the idea of creating my own mobile phone apps; but I&#8217;ve never seemed to find the time. So I was excited to discover at the weekend that Google has finally given me [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.pcpro.co.uk/blogs/wp-content/uploads/2010/09/BlockEdFull.png"><img class="aligncenter size-full wp-image-24013" title="BlockEdThumb" src="http://www.pcpro.co.uk/blogs/wp-content/uploads/2010/09/BlockEdThumb.png" alt="BlockEdThumb" width="462" height="337" /></a></p>
<p>Confession time: I have never learnt to program in Java. Swoon, gasp.</p>
<p>It&#8217;s not that I haven&#8217;t wanted to. In particular, I’ve always loved the idea of creating my own mobile phone apps; but I&#8217;ve never seemed to find the time. So I was excited to discover at the weekend that Google has finally given me access to App Inventor — a visual development environment that lets you create Android applications via a drag-and-drop interface, with no Java skills required. <span id="more-23998"></span></p>
<p>It certainly does simplify the process. The first sample application – which puts up a picture of a cat that miaows when you prod it – is embarrassingly easy to assemble. In the design stage, you simply drag a button onto your workspace (representing the phone screen), import the cat picture, assign the picture to the button and import the sound. Create a click event that plays the sound, and the job’s done.</p>
<p>So yes, the workflow is similar to Microsoft Visual Studio — not that there’s anything wrong with that. But there’s one big difference: in VB.NET, setting up an event handler for the button involves getting to grips with some daunting syntax, along the lines of: <tt>Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click</tt></p>
<p><a href="http://www.pcpro.co.uk/blogs/wp-content/uploads/2010/09/Blocks1.png"><img class="alignright size-full wp-image-24001" title="Blocks1" src="http://www.pcpro.co.uk/blogs/wp-content/uploads/2010/09/Blocks1.png" alt="Blocks1" width="201" height="97" /></a>In App Inventor you assemble an event handler by simply snapping colour-coded, jigsaw-piece-shaped “blocks” together. In fact, all “code” is constructed by combining blocks within the Java-based Blocks Editor. As Google freely acknowledges, it’s a system that owes a heavy debt to MIT’s Scratch project, an educational programming system which we&#8217;ve already produced a tutorial for in our <a href="http://www.pcpro.co.uk/features/351556/free-computing-lessons-for-kids">Free Computing Lessons for Kids</a> feature.</p>
<p><strong>Childishly simple?</strong></p>
<p>Does this indicate that App Inventor is similarly intended for kids? Yes and no. Google has said that App Inventor was designed from &#8220;an educational  perspective&#8221;, and tested in &#8220;classrooms across the United States&#8221;, which sounds like a pretty clear hint. But then Google&#8217;s Mark Friedman has also described it as a broader tool, for &#8220;programmers and non-programmers, professionals and students&#8221; alike. Certainly it can support constructions as sophisticated as anything you&#8217;ll find in more grown-up languages:</p>
<p><a href="http://www.pcpro.co.uk/blogs/wp-content/uploads/2010/09/Blocks2.png"><img class="aligncenter size-full wp-image-24004" title="Blocks2" src="http://www.pcpro.co.uk/blogs/wp-content/uploads/2010/09/Blocks2.png" alt="Blocks2" width="462" height="232" /></a></p>
<p>So while App Inventor is aimed primarily at kids, it&#8217;s not just a classroom tool. In principle, it should be powerful enough to produce any application you can imagine.</p>
<p><strong>Writers&#8217; blocks</strong></p>
<p>Sadly, as soon as I started using App Inventor, I discovered the catch. Dragging blocks about may be a fine first introduction to computing, but if you want to create anything more complex than “Pet the Kitty” it&#8217;s a slow and fiddly way to work. It doesn&#8217;t help that the blocks you need are split across two tabs of seven or more drawers, and as you build up functions the workspace becomes messier and harder to navigate (see the screenshot at the top of this post). Perhaps in time the Blocks Editor will improve, but right now it&#8217;s such a faff I can see it driving people away from programming altogether.</p>
<p>That&#8217;s a shame, because some of the functions on offer seem designed to appeal to experienced coders, and support some neat mobile-specific capabilities:</p>
<p><a href="http://www.pcpro.co.uk/blogs/wp-content/uploads/2010/09/Blocks3.png"><img class="aligncenter size-full wp-image-24007" title="Blocks3" src="http://www.pcpro.co.uk/blogs/wp-content/uploads/2010/09/Blocks3.png" alt="Blocks3" width="462" height="280" /></a></p>
<p>But if you ask me, this representation is actually harder to understand than a function written in plain text — and it was certainly harder to construct.</p>
<p>All of which leaves App Inventor looking like a missed opportunity. Yes, for the kids at whom it&#8217;s chiefly aimed, it&#8217;s a decent introduction to programming concepts. But it has potential far beyond that, and I fear that will never be usefully harnessed, because anyone with the programming nous to make full use of App Inventor&#8217;s abilities will surely prefer a language that doesn&#8217;t force you to pedantically assemble every function, procedure and event out of multicoloured blocks.</p>
<p><strong>Rewriting the script</strong></p>
<p>In fairness, it&#8217;s optimistic to think that any development environment could ever be perfect for both beginner projects and more  complex designs. But, tantalisingly, I think App Inventor could get close with one single addition. What’s needed is a traditional script-based view that operates in parallel with the Blocks Editor. For beginners, this would show automatically-generated code (presumably using simple Java-type syntax) representing their block-based constructions, making App Inventor an even better introduction to programming.</p>
<p>Meanwhile, more advanced users could develop directly within the script editor, while still using App Inventor as a time-saving tool for designing interfaces and packaging completed projects. The blocks view, automatically generated from your code, would become a handy visual aid to debugging and program flow.</p>
<p>But in the absence of a script editor, I doubt I’ll be producing any mobile applications with App Inventor. Google certainly deserves credit for the   excellent work it&#8217;s done in simplifying Android development, and abstracting it away from   the nitty gritty of libraries and dependencies. But if the only way to take advantage of that is via drag-and-drop programming then personally I think I might be better off simply learning Java.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pcpro.co.uk/blogs/2010/09/07/googles-app-inventor/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Cheeky Sun throws in OpenOffice with Java</title>
		<link>http://www.pcpro.co.uk/blogs/2008/08/28/cheeky-sun-throws-in-openoffice-with-java/</link>
		<comments>http://www.pcpro.co.uk/blogs/2008/08/28/cheeky-sun-throws-in-openoffice-with-java/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 09:52:38 +0000</pubDate>
		<dc:creator>Barry Collins</dc:creator>
				<category><![CDATA[Newsdesk]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[OpenOffice]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[Sun]]></category>

		<guid isPermaLink="false">http://www.pcpro.co.uk/blogs/?p=3051</guid>
		<description><![CDATA[Sun, which has spent the past decade constantly moaning about the worst excesses of Microsoft&#8217;s behaviour, is clearly not averse to employing underhand tactics of its own.
Having spent the past couple of days wilfully ignoring the Java update nagging away in my System Tray, I finally relented and installed the latest version, only to be [...]]]></description>
			<content:encoded><![CDATA[<p>Sun, which has spent the past decade constantly moaning about the worst excesses of Microsoft&#8217;s behaviour, is clearly not averse to employing underhand tactics of its own.</p>
<p>Having spent the past couple of days wilfully ignoring the Java update nagging away in my System Tray, I finally relented and installed the latest version, only to be confronted with the following screen:</p>
<p><a href="http://www.pcpro.co.uk/blogs/wp-content/uploads/2008/08/java-oo-installer1.jpg"><img class="aligncenter size-full wp-image-3054" title="java-oo-installer1" src="http://www.pcpro.co.uk/blogs/wp-content/uploads/2008/08/java-oo-installer1.jpg" alt="Java OpenOffice installer" width="500" height="380" /></a></p>
<p>Admittedly, Sun was only trying to force the OpenOffice installer on me, rather than automatically downloading the hundreds of megabytes that comprise the full suite. But after the furore caused when <strong><a title="Apple alters updater following Safari protest" href="http://www.pcpro.co.uk/news/189939/" target="_self">Apple automatically ticked the Safari installation with iTunes updates</a> </strong>earlier this year, it&#8217;s amazing that companies are still resorting to such cheap tricks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pcpro.co.uk/blogs/2008/08/28/cheeky-sun-throws-in-openoffice-with-java/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The joy of interfacing</title>
		<link>http://www.pcpro.co.uk/blogs/2008/04/24/the-joy-of-interfacing/</link>
		<comments>http://www.pcpro.co.uk/blogs/2008/04/24/the-joy-of-interfacing/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 17:21:54 +0000</pubDate>
		<dc:creator>David Fearon</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[BBC Micro]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Interfacing]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.pcpro.co.uk/blogs/2008/04/24/the-joy-of-interfacing/</guid>
		<description><![CDATA[
So anyway, get yourself into your time machine and set it for sometime around 1986. Once you get there, pop on your invisibility cloak, find someone who looks spoddy and follow them into the dining room. See that BBC Micro in the corner? Pop over and give the top a quick tug. Chances are it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.pcpro.co.uk/blogs/wp-content/uploads/2008/04/_mg_3579.jpg" alt="Prototype interfacing. Not pretty, but it works." height="302" width="428" /></p>
<p>So anyway, get yourself into your time machine and set it for sometime around 1986. Once you get there, pop on your invisibility cloak, find someone who looks spoddy and follow them into the dining room. See that BBC Micro in the corner? Pop over and give the top a quick tug. Chances are it&#8217;s not screwed down.</p>
<p>That&#8217;s because, in the old days, computers were for hobbyists with soldering irons, and they were forever taking the tops off to install new circuit boards they&#8217;d made.</p>
<p>Doesn&#8217;t happen much anymore, of course &#8211; you might pop the side off once a year to install a new graphics card, but most people wouldn&#8217;t consider actually building new hardware to go inside their computer. And for very good reason: the insides of a modern PC are massively more complex and to build an add-on part yourself that would actually be any use is more or less impossible.</p>
<p>Thing is though, designing and connecting your own hardware to a PC, while unlikely to win you admiring glances from the opposite sex, is bloody good fun. Fact. I&#8217;ve been tinkering with the whole area again for the past year or so &#8211; for reasons I may document at some point &#8211; and it turns out that there&#8217;s a massive array of components that are relatively easy to interface to a PC and do interesting things with.<span id="more-130"></span></p>
<p>So here&#8217;s what I&#8217;ve done: I&#8217;ve interfaced a <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=1335&amp;dDocName=en010532">Microchip MCP3202-C</a> analogue-to-digital converter IC to the parallel port of a PC. And <em>voila</em>, I can use the computer to directly measure any analogue voltage between 0 and 5 volts. In fact I can measure two lots of voltages since the 3202 is a dual-channel device.</p>
<p>Now, the ability to measure some voltage or other doesn&#8217;t sound terrifically interesting <em>per se.</em> But it is! Because there&#8217;s a vast array of sensors and transducers out there, which measure all sorts of fascinating things about the real world like temperature and pressure and position and humidity and <em>everything</em>. And guess what their output is? Yes! Very often these devices produce an analogue voltage, and very often it&#8217;s between 0 and 5V (since 5V is kind of a universal logic voltage).</p>
<p>It&#8217;s certainly not as easy as it used to be to connect your computer to the real world. The BBC Micro, for instance, was specifically designed for interfacing and you didn&#8217;t even need any external circuitry to measure analogue voltages &#8211; you just used the analogue input ports on the back and read the voltage directly from BASIC with the ADVAL statement.</p>
<p>To get my 3202 ADC chip talking to a PC, I first had to add a little bit more buffer circuitry, to get the anaemic voltage levels coming out of its parallel ports to look a bit cleaner. But that&#8217;s only a single logic chip, costing about 20p (the 3202 itself <a href="http://uk.farnell.com/1196794/semiconductors/product.us0?sku=MICROCHIP-MCP3202-CI-P">currently costs £2.25</a> from <a href="http://www.farnell.co.uk/">Farnell</a> if you&#8217;re only buying one or two).</p>
<p>Next, I abandoned Windows and installed <a href="http://fedoraproject.org/">Fedora Linux</a>. Why? Because Linux has the joy of a predictable, stable tool-chain for programming, and it comes with a C compiler and everything you need for programming. It&#8217;s a geek&#8217;s OS and it&#8217;s set up for geeks to tinker with straight away. And if everything you need isn&#8217;t there in your particular installation, chances are all you&#8217;ll need to do is issue a command something like this:</p>
<p style="font-family: courier,sans-serif">sudo apt-get install gcc</p>
<p>And off Linux will go, ferreting out the gcc C compiler and all the necessary extra components. Also, of course, it&#8217;s free. And I wouldn&#8217;t dream of installing Windows on a PC when I didn&#8217;t have the correct license.</p>
<p>With that done, I had to decide on a programming environment. Java is my language of choice &#8211; it&#8217;s the best language on the planet and those people who talk about its nightmarishly complex class libraries are all wrong, honest &#8211; so Sun&#8217;s brilliant (and free) <a href="http://www.netbeans.org/">Netbeans IDE</a> was the only sensible choice.</p>
<p>You may be seeing the problem looming. Java is a high-level language deliberately abstracted from the hardware it runs on, meaning that getting the low-level access I needed to interface with my ADC chip wasn&#8217;t going to happen with Java alone. That meant one thing: JNI, the <a href="http://java.sun.com/j2se/1.5.0/docs/guide/jni/">Java Native Interface</a>, which allows you to write native C code and glue it to a Java method. That means fast, native access to the hardware combined with a lovely high-level language to write the graphical front-end for my app.</p>
<p>Only problem with JNI is that it&#8217;s hideous. I mean truly hideous. It&#8217;s badly implemented and appallingly documented and it took me a week of trial and error actually to mangle my C code for reading the ADC chip into a form that JNI could work with. But eventually I got there.</p>
<p>There&#8217;s nothing quite like getting really deeply into the binary operation of a chip. The 3202 IC uses a simple serial protocol called SPI to communicate with the outside world. So I had to sit down with <a href="http://ww1.microchip.com/downloads/en/DeviceDoc/21034D.pdf">the datasheet</a> in hand and write a routine in C that would directly communicate with the chip in binary, by waggling the voltage level of three of the PC&#8217;s parallel-port pins between 0 and 5V. Fairly amazingly, once I&#8217;d sorted out the JNI thing it worked first time. My Java graphical front-end can get the voltage levels and display them any way I like, and the hardware can manage a sample rate of about 2,000 readings per second, if I happen to want to measure something that fast.</p>
<p>Not as easy as with a BBC Micro then, but here&#8217;s the thing: BBC Micros used to cost about a month&#8217;s wages, so the chances of dedicating one to measuring the temperature in the greenhouse were always going to be pretty slim. A little Mini-ITX motherboard &#8211; which is what I&#8217;m using for my project &#8211; is only about £100. That means you can use one as a hardware appliance and dedicate it to the task of measuring, well, whatever it is you want to measure. And it&#8217;s the matter of an evening or two&#8217;s work to configure a web server and write some code so that you can communicate with it from anywhere and see what it&#8217;s been getting up to.</p>
<p>All a little bit pointless? Well, maybe. Fun? Depends on your proclivities I suppose. But it makes me happy.</p>
<p>So, who wants a feature in PC Pro about how to do it?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pcpro.co.uk/blogs/2008/04/24/the-joy-of-interfacing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

