Posts Tagged ‘Scala’

20
May

Plasma pong

Finally I finished the video from FlashGAMM 2011 Moscow where we exhibited our multi-touch table with Fluid Pong game based on MSA Fluid library. The game was developed using Scala and Processing and was a major success at the conference.

Multi-touch Fluid Pong from InteractiveLab on Vimeo.

What’s more, it is open source and is availabale at GitHub.

Tags: , , , , , , ,

09
Apr

Processing in Clojure

Following my article about Processing and Scala I got a comment that it would be cool to do the same with Clojure, JRuby or Groovy. All of them run on JVM.

Today I found that someone actually did it: Processing in Closure (by Jacek Laskowski) and “Processing in Closure” made functional (by Konrad Garus). What’s more, in 2009 there was already a post about Processing and Closure. Too bad I can’t stand nested brackets q:

Tags: , , ,

04
Mar

Scala + Processing – an entartaining way to learn a new language

If you’ve read a book about some new technology it doesn’t necessarily mean that you learned or even understood it. Without practice your newly acquired knowledge will vanish soon. That’s why doing exercises from the book you are reading is important.

But all those examples are usually boring. Of course you can start your own pet project to master your skills. Several months ago to learn Scala I started my little command line tool which semi-worked at the end and I gave up on it. So, in a month or so I had to google syntax of “for loop”…

That’s where I decided that I should start writing simple examples for different Scala features that must be fun. Here’s where Processing comes into play. Using it, every novice like me can turn dull exercises into visual installations. And later you can try advanced stuff like fractals, particle systems or data visualisation.

You might be wondering what the hell is Scala. It’s a relatively new and extremely cool programming language. You can read more about it on Wikipedia or on official web site.

I rewrote in Scala and posted to GitHub several cool examples. One of them is on the left picture – famous MSA Fluid Processing sketch.

***

When I first met Scala I fell in love with the language immediately. I looked through a couple of books including Programming in Scala which I recommend to everyone. Even theory alone allowed me to change my perception of programming at the whole. Too bad that my day to day job doesn’t involve Scala in any way. Even the language I use mostly is in many ways different from Scala. No, this language is not Processing.

Processing

I guess now is a good time to introduce Processing because there’s a chance you haven’t heard of it at all. I’m not even talking about that you actually worked with Processing. Of course it’s great if you did.

Anyway, Processing is basically a DSL for Java with a little IDE and a mix of useful libraries. It’s mainly used by so-called Visual Artists to render generative art work. I recommend you to check out Processing channel on Vimeo. There’s really a lot of cool stuff!

Tags: , , , , ,

23
Aug

Scala functions vs. methods

Scala is hard. To use its syntax sugar you have to know what’s going on.

Tags:

17
Jul

initInjector 0.2.1b

Scala version 2.8.0 has been finally released, Joa updated apparat amazingly fast and v.0.2.1b is just a stable Scala 2.8.0 compiled application.

http://va.lent.in/projects/swf/initInjector/initInjector.0.2.1b.zip

InitInjector is a little Scala app which allows you to move code from SWF constructor to a private init method and subscribe it to ADDED_TO_STAGE. This fixes an error of stage being null in loaded SWFs constructor.

0.2.1b:

  • Recompiled for Scala 2.8.0

0.2b:

  • Fixed several bugs
  • Added -p option which also injects init method to parent class constructor
  • Thanks to Joa Ebert who modified apparat for my needs I got rid of half of my code

Thanks to everyone for reporting bugs.

Tags: , , ,

29
Jun

Tired of people using stage in constructor?

Recently someone in ruFlash user group asked if it’s possible to get rid of errors when loading a SWF which thinks it is the only SWF in the world and there totally must be stage available in its constructor. As you already understood such SWFs fail with Null Access errors.

TypeError: Error #1009: Cannot access a property or method of a null object reference.

This task looks like a great exercise for my epic Scala skills I got trying to understand famous Joa‘s code.

Thanks to apparat and Scala I managed to code a small app which rewrites SWF files and moves all constructor code to a private method which is later subscribed to ADDED_TO_STAGE event.

usage: java -jar initInjector.jar [-c] <from.swf> [to.swf]“)
-c — check for references to stage in constructor
If [to.swf] is not specified resulting SWF is saved to <from.swf>

The 0.1 version fails to move exceptions though. Trying to grasp that bytecode exceptions magic atm.

Here’s the application: initInjector.zip

Tags: , , , , ,

26
Nov

Scala vs. Erlang

I know a bit of Erlang but decided to learn Scala. So I researched a bit comparing these two languages. These links might be helpful if you are deciding Erlang or Scala.

Thinking in Scala vs Erlang
The Scala vs Erlang Debate
Concurrency in Erlang & Scala: The Actor Model
Are the Scala programs faster?

Tags: ,