Archive for October, 2016

Java CLI in the Browser not as Stupid as it Sounds

October 27, 2016

Stay with me here, this may sound silly unless you are a teacher or student, but a standard part of many intro programming classes is learning the traditional Command Line Interface with simple tools like System.out.println() and java.util.Scanner. This lets you learn the basics of input, output and data processing with only a few lines of code:

System.out.println("Enter two numbers:");
Scanner scan = new Scanner(System.in);
int val1 = scan.nextInt();
int val2 = scan.nextInt();
System.out.println("Total value is: " + (val1 + val2));

With just these basics you can write many interesting programs:

  • Calculators, formula solvers, quizzes, surveys
  • String manipulation: word counting, palindromes, anagrams, etc.
  • Text based adventure games, digital psychologist, etc.

This was the only way to learn when I started on the TRS-80 and Apple II, and it’s still a great way to learn today, without introducing too many concepts that overwhelm new students. The downside is that these programs tend to be locked in the IDE or a terminal.

However, using a class called SnapPane, via one extra line of code, the same app that runs at the console pops up a window instead and runs on the desktop. And with SnapTea, and another line of code, you can then run in the browser and share with the world. Here’s a command line calculator running in the browser (notice, also, a tab to view the source code):

Simple Calculator using println and Scanner

SnapCode is a free IDE for education. Please like the blog, video, tweet (and retweet!) and join the discussion group if you’d like to hear more.

snapcode-cli

(video demo)

Java UI Builder for the Browser and Desktop

October 13, 2016

Last week I showed an example of writing just a few lines of UI code and running it on the desktop and in the browser, using SnapCode, SnapKit and TeaVM.

Well that was downright barbaric. There is a better way to design UI than code, compile and iterate: it’s a UI builder. This week I get rid of those extra lines of code by generating the UI in SnapCode’s UI builder. Much more civilized – and perhaps the most high-level “Hello World” ever seen.

This is the system I wish Flash had been: Visual designer, code editing, project file management, native browser (no plugin), native desktop and support for the most popular programming language on the planet.

SnapCode is a free IDE for education. I’d love to hear feedback. Please like the blog, video, tweet (and retweet!) if you’d like to see more.

snapcodequick

Quickest way to Java in the Browser

October 4, 2016

This week SnapCode was updated to automatically convert SnapKit Java apps to JavaScript and launch in the browser when it detects an app is linked against TeaVM (an incredible Java-to-JavaScript transpiler). This finally makes it trivial to write a Java UI app and immediately run in the browser.

I’m not a fan of demos with coding, but this is a UI version of “Hello World” (it’s only a few lines of code). The UI builder version of this demo will be available in a few weeks.

As a Java developer, I’m very excited. I have jumped through many hoops over the years with Applets, Web Start and native app packaging, and still I don’t have the ability to share and distribute even basic apps without a disproportionate amount of work. Until now.

SnapCode is a free IDE for education. I hope people check it out.

snapcodequick

If you want more – please like/retweet the blog, video, tweet. (tweet is here)!