Posts mit dem Label Amber werden angezeigt. Alle Posts anzeigen
Posts mit dem Label Amber werden angezeigt. Alle Posts anzeigen

Mittwoch, 10. Oktober 2012

Using Processing.js with Amber


"The Processing language was originally created at MIT as part of the Media lab and Aesthetics and Computation group. They needed a way to bridge the gap between software developers, artists, data visualizers, etc., and to do so in a way that allowed new programmers (or non-programmers) to do complex visual work easily. Processing was built using Java, and can be thought of as a simplified Java, with a simplified Java API for drawing and graphics." (source)

Since it is possible to write Processing code with pure JavaScript, it should be possible to use Amber with Processing.
And so it is - with some little tricks.
First, Processing should get initialized in the html page like this

A Processing instance will be created, it can get accessed via Amber in this way:

processing := <Processing.instances[0]>.

After fetching this instance, it can be used like any other Smalltalk Object:

processing background: 224.

processing line: centerX y: centerY dX: myDX dY: myDY.

I converted the clock-example to Amber, you can find it in the Example-section of my Amber Git repo. And maybe soon in the "official" Amber-Examples.

You can try it out here.

Donnerstag, 5. Januar 2012

Ambrhino

Today i'd like to announce my newest Project "Ambrhino". Ambrhino integrates Amber Smalltalk with the Java Virtual Machine.
Ambrhino can act as a Server to serve Amber and persist changes to the filesystem (you could use it instead of node.js).
It can also act as a runtime to execute Amber-Programs.
Ambrhino is written in Java and uses JSR223 to execute Javascript with the Mozilla Rhino Engine
An interesting feature is, that you can directly call Java classes from a compiled Amber Smalltalk, e.g.:


buttonPrintit := .
buttonPanel add: buttonPrintit.


A really cool feature is that it seems to be possible to add Smalltalk BlockClosures as ActionListeners to (Swing-) Buttons like this:



buttonDoit addActionListener: [ 
self eval: (textArea javaObject getSelectedText).
].

The main goal of this project is not to use Amber to write Swing-Applications - it feels somehow weird to use a Webbased-IDE to create a native Swing Application ...
Someday i want to use it to create Android-Applications with Amber - i could start an Ambrhino-Server on the Android-Emulator to create/ compile/ package programs. The Android-API will be called with the Android Scripting Framework (ASF)
But to get familiar with the (sometimes strange looking) Smalltalk-Java-Javascript-Mixture, i made a little Swing-Application - a simple Workspace to execute Smalltalk-Code.

To try it out you may fork the project on Github or just download the ambrhino.zip unpack it and start the workspace.bat file.

Like in other Smalltalk-Workspaces you can select text and execute it by pressing  "do it" or "print it".

To get an idea of what is possible you can copy this gist to the workspace and execute it. It fetches via HTTP-GET content from a Webserver and displays it on a JTextPane. Not really useful - but somehow cool.

Ideas, Hints, Help and rants are very welcome!

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.