Freitag, 23. September 2011

Using Amber with a free WebDAV-Service

I really love Amber - but there's one thing i could not get used to. To persist the code you produce you need to setup a local WebDAV-Server or you need to run the Amber server-tool based on node.js.
The Problem i had is that i wanted to work only with a browser. Do some work on my PC, then switch to my wifes notebook, work in an internet-café, have a quick look at some code when i'm at my mothers house and so on.
My first attempt was a project on the google-app-engine, where jtalk (now "Amber") code was saved to a database. That approach was a quick hack and somehow proprietary. I also ran JTalk on the JVM on the serverside using google-backend-technology. Everything was much too complicated.
My current idea is to keep everything simple, use free services and have a real cloud-approach. I needed a free WebDAV-Service, accessible by a Webbrowser and the possibility to sync my files with a local folder on my harddisc.
I had the idea to use Dropbox, because Dropbox has an easy to use syncing tool and a nice web-view. I used Dropbox to server my Twitterwall demo for Amber. It would be quite easy to put a git-repository in my public Dropbox-folder and server Ambers index.html to the Cloud. But since Dropbox has no WebDAV-support it would not be possible to work from somewhere and save code and then push the changes to github when i'm back to a PC with git installed. To solve this problem, i would need to use the Dropbox-API. But that approach has other difficulties ...
On my quest i was experimenting with a lot of Cloud, WebTop and Filehosting Services and the only one that was easy and free to use and was working with Amber was the gmx MediaCenter.
There are just a few steps:
  1. Register a gmx account
  2. Navigate to the MediaCenter
  3. Upload the git-repository with Amber sources (drag & drop)
  4. Navigate to https://webdav.mc.gmx.net/ and login with your gmx-passwort
  5. Go to the index.hmtl in your amber-folder, do some coding and press "commit package"
The commited Category js will be updated in the gmx MediaCenter!
When you want to push your code to github, you just need to go to a PC where you can sync your gmx MediaCenter to a local disc and where a git-client is available.
It's possible to share WebDAV-folders with other gmx users so you easily could collaborate outside of github.
There's only one drawback - you can't grant access to everybody, it's restricted to gmx-users. So if you want to show something to a wider audience you would need to copy the files e.g. to your Dropbox folder.

Mittwoch, 21. September 2011

A Twitterwall with Amber

Amber, formerly known as JTalk, is evolving. It is so much fun playing with Smalltalk just only with a browser - it's addictive! So i wanted to contribute a little Example of how Amber can be used to mesh-up Web2.0 stuff.
The result was a very simple Twitterwall using the restful Twitter-Search API. I pushed it to my amber-fork on github and made a pull-request. Nicolas already pulled it and now it's in the amber examples-section.
You can have a look at it in my public Dropbox folder. You can examine the two responsible classes Tweet and TwitterSearch in the Examples category from there too.

Dienstag, 20. September 2011

An Eclipse-Plugin for Redline Smalltalk

I just started the development of an eclipse-plugin for redline smalltalk. It is the very first preview but i wanted to release this early to be prepared for any wishes/ commets etc. The project ist hosted on github.
I'm using Xtext for parsing/ syntax coloring/ code completition etc. So i have to reimplement parts of the parser, but Xtext is very powerful and we can use all of the nifty features of the eclipse plugin development environment.
Currently it's only an Editor but it could be enhanced to an own "Perspective" with more Smalltalk-Development Tools, e.g. 
  • Class Hierarchy Browser (by switching to that perspective all .st-files would get parsed to an ecore-model)
  • Debugger (it's already there)
  • Transcript (a console, it's already there too)
  • a Workspace (we could use something like the eclipse-scrapbook-pages for that)
This Perspective could be packaged as an own RCP-Application so we would have a standalone Smalltalk-IDE ... 


The plugin registers a viewer for files with the extension ".st"
The viewer has two tabs. You can switch between the source view with syntax coloring and code completition and the class view, where you can select from a list of methods and see the associated method-source.
Any Ideas and wishes are welcome!

Mittwoch, 6. Juli 2011

Java Hirsch

Bei der Recherche nach der Frage, ob ein öffentlicher default-constructor bei einer EJB3-Entity Bean jetzt ok ist oder doch eher ein anti-pattern, werde ich per Google-Anzeige gefragt, ob ich ein Java Hirsch bin:
Mir stellt sich natürlich die Frage: Was ist ein Java Hirsch?
Hier ein Auszug aus einem Reisebericht: "Heute lebt der Java-Hirsch im Hochland von Mauritius, wo Zuckerrohr angebaut wird und wo der Primärwald beginnt, eine Mischung aus Lichtungen, Gras und Bäumen. Um die Hirsche zu sehen, geht man am besten zu Fuß auf den Wegen eines ökotouristischen Anwesens. Die Jagd ist auch im Chasseur möglich, mit einer Gebühr für die Schlachtung."
Mal abgesehen von der Schlachtung klingt das doch eigentlich ganz idyllisch.
Da es sich aber wohl eher um eine Art Stellenanzeige handelt, recherchiere ich weiter und stelle fest: "Unter einem Hirsch verstand man um die Wende des 19. zum 20. Jahrhundert einen ausgelernten Schneidergesellen, der bei einem Meister in Lohn und Brot (Kost und Logis) stand, aber aus Platzgründen nicht in dessen Werkstatt arbeitete." (Quelle: Wikipedia) - also übertragen, so 'ne Art Java-Entwickler im HomeOffice?
Andererseits kann ein Hirsch auch "ein 200 Liter fassendes Bierfass" sein (Quelle: Wikipedia) ... das lasse ich mal kommentarlos stehen.
Abschließend entdecke ich in einem Lexikon für umgangssprachlich Redewendungen noch Folgendes:

Und kann nun eindeutig feststellen: Nein, ich bin keiner, kenne aber einige Java Hirsche, an die ich die Stellenanzeige gerne weiterleiten werde.

Mittwoch, 29. Juni 2011

"An internal error occurred while showing an internal error"





What a great error-message showed up while doing some trivial work with eclipse helios! It made me think about recursions (remember: before you can understand recursions you first need to understand recursions).
My first reaction on the question "Do you want to exit the workbench?" was (after making a screenshot) pressing "No". I hoped to see an error-message like that: "An internal error occurred while showing an internal error while showing an internal error".
But i did not see that message - eclipse presented the "white bar of death" and silently stopped working ...

Mittwoch, 15. Juni 2011

JTalk Server now using Backends on Google App Engine

My JTalk-Server project has some interesting new features. First of all: i'm using Google Backends to handle the Javascript scope on the server-side. Backends are a new feature of the Google App Engine 1.5. and allow the usage of long-running processes in the background.
Now i have two servlets - the original JTalk-Servlet for saving the jtalk.js or resetting etc. and second one, the backend servlet for executing smalltalk code on the server and for maintaining a user session.
The main cause for using backends was that the ScriptEngine for executing Javascript was not serializable, so it was necessary to setup the JTalk environment for every server roundtrip.
The call to the backend looks like that:
        BackendService backendsApi = BackendServiceFactory.getBackendService();
        String rhinoscopeURL = "http://" + backendsApi.getBackendAddress("rhinoscope", 0) + "/jtalk_backend";
        System.out.println(("rhinoscopeURL: " + rhinoscopeURL));

        URLFetchService fetchService = URLFetchServiceFactory.getURLFetchService();
        HTTPRequest requestToBackend = new HTTPRequest(new URL(rhinoscopeURL), HTTPMethod.POST);
        requestToBackend.setPayload(("contentString=" + contentString + "&owner=" + owner + "&commandString="+commandString).getBytes());

        HTTPResponse responseFromBackend = fetchService.fetch(requestToBackend);
        byte[] respContent = responseFromBackend.getContent();

        String resultString = new String(respContent);

The full code is available here.

As mentioned in this thread, backends on GAE only work in production-mode by using the appcfg.cmd:
C:\Users\krecher\Documents\eclipse\plugins\com.google.appengine.eclipse.sdkbundl
e_1.5.0.r35v201105092302\appengine-java-sdk-1.5.0\bin>appcfg.cmd backends update
 "C:\Documents and Settings\krecher\My Documents\workspace\jtalk-server\war"
Otherwise the backends won't appear in the admin-console of the GAE.
In development mode the existence of a backends.xml is enough for using backends.

Another new feature is the possibility to pass arguments to the RemoteRunner. Without passing arguments from the client to the server that whole thing would be completly useless ...

A call with arguments would look like that:

RemoteRunner new runClass: RemoteTest3 with: #('hack' 'the' 'planet')

The arguments should be an array of strings.

The last new feature ist the usage of a logger in the Javascript-Scope on the server-side.
Here an excerpt from the example class: params do: [ :each | {'logger.fine(each);'} ].
logger is the logger-instance of the servlet.

If you want to use these new features, and you've used the JTalk Server on GAE before, remember to first press the Reset-button and then press "Export & Save JTalk to DB".

I guess the next step will be to implement a binding for the google-datastore-api.

Mittwoch, 25. Mai 2011

RemoteRunner for JTalk Server

As announced in an earlier blog-post, i implemented a RemoteRunner for the jtalk-server (based on the jtalk-project). It's very simple: if you implement a Method runRemote in your class, e.g. RemoteTest, then by executing:
RemoteRunner new runClass: RemoteTest
will execute the Smalltalk-Code implemented in the runRemote-Method on the server. The example prints out the date and time of the server.
To see how the results can be transferred back to the client-caller, just look at the example-class.
The jtalk.js on the server-side is exactly the same as the one on the client-side. So if you make changes, don't forget to press the button "Export & Save JTalk to DB".
If you like to play around with this new feature and you played around with jtalk-server before (and pressed the save-button), you need to reset the jtalk.js by pressing the button. This is because, the jtalk.js will be saved to the database for every user (identified by his/ her google-id). So changes made to the jtalk.js, which is located in the server-filesystem won't get executed, because on startup (page-load) a jtalk.js in the DB, associated with the current google-user, has priority.
The JVM of the JDK/ JRE 6 is packaged with a ScriptEngine for executing Javascript. This feature is currently not supported on the Google App Engine, so i needed to use the "external" Rhino-jar, and a slightly different mechanism. Here is some work needed on optimizing the server-execution. So, the jtalk.js on the server should get reduced to the classes that are needed on the server (no canvas etc.) and most imported, the precompiled jtalk.js should get persisted somehow. Currently the complete javascript-source of the Smalltalk-System is executed/ interpreted for every call on the server.
But the next step will be to use the GAE persistence-layer via java-calls from Smalltalk/ Javascript to the google-api. Calling java is already possible and i think this is where the fun begins ...

Dienstag, 10. Mai 2011

Smalltalk & Java: JTalk Server

Recently I was playing around with the amazing Jtalk Project. It's a Smalltalk-System running on top of Javascript - completly in your browser!
I have some far away goals for software development in mind:
1. develop Software from within a Browser
2. use Smalltalk as primary Language, because it's the best programming language ever :-)
3. have interfaces to the JVM, so i can use sophisticated and reliable frameworks
There are a few Projects i know of, that address the goal of integrating Smalltalk with the Java (redline, Athena) but none of them seems to be very stable.
Now i found out, that Jtalk could do the job! So i spend a little time to set up a project hosted on the google app engine that serves as a development home for Jtalk Projects, where you have the possibility to save the current "state" (the complete source) to a database and resume developing anywhere anytime. You need a google-account to use it.
In this thread on the jtalk-discussion-group, i showed that it is possible to run Jtalk on top of the JVM and execute Smalltalk-Code. The way back - calling Java-Classes from Smalltalk is shown also.
At the moment my project only uses Jtalk on the client-side, the next step will be, make it run on the server-side.
Here's the link to where you can test JTalk Server: http://jtalk-server.appspot.com/ and the code is here: http://code.google.com/p/jtalk-server/
Any help, tipps or comments are welcome!