redtamarin logo

Description

Everything you ever wanted to know about RedTamarin

What is RedTamarin?

RedTamarin can be qualified by four things

  1. an open source project

  2. based on the ActionScript Virtual Machine 2 (AVM2)

  3. with Cross Platform Native API

  4. which follow the Unix Philosophy
    (do one thing and do it well)

It allows you to write command line programs
using the ActionScript 3.0 language

those programs run using a runtime: redshell

redshell is available in 32-bit and 64-bit,
and can run under Windows, Macintosh and Linux.


Mission Statement

since day one of the project we have defined our mission

To support the use of the ActionScript 3.0 language
for cross-platform command-line executable,
as single exe either for the desktop or the server,
as scripts for automation,
as tools for the Flash Platform community.

Our mission have slightly evolved as we now try
to make RedTamarin an environment for ActionScript 3.0
to be able to be used as a server side language.


How does RedTamarin fit in with the Flash Platform?

we are like the lost brother or cousin :)

The Flash Platform provides 2 runtimes

  1. Flash Player, a browser plugin

  2. AIR, Adobe Integrated Runtime

RedTamarin provide a 3rd kind of runtime

  1. reshell, the RedTamarin shell

All those runtimes

  • share the same builtins class:
    String, Number, ByteArray, etc.

  • can run programs written in ActionScript 3.0

  • use an identical Virtual Machine: AVM2

  • allow you to run applications
    from a virtual machine in a cross-platform way

Flash Player
will run applications inside the Browsers
(Chrome, Firefox, IE, Safari, etc.)
(Windows, Macintosh, Linux, Solaris, etc.)

AIR
will run applications
on the Desktop (Windows, Macintosh)
on Mobile (iOS, Android)

redshell
will run applications
on the Desktop (Windows, Macintosh, Linux)
on the Server (Windows, Macintosh, Linux)

All those runtimes share the same core
the ActionScript Virtual Machine 2
which basically allow you to compile
a program in ActionScript 3.0
to bytecode, either ABC or SWF
and run it on different environments
without the need to recompile it.

The Flash Player and AIR share almost the same
functionalities with the Flash Platform API (FPAPI)
and are, in general, graphical applications.

redshell provide another set of functionalities
and focus only on non-graphical applications.

Here is an example with a chat application

you can have a flash graphical chat client
that run inside the browser

you can have an AIR graphical chat client
that run on the desktop and mobile

you can have a non-graphical chat server
that run on the backend

This little example only to illustrate
that RedTamarin is not here to replace
Flash Player or AIR, but to work with them
in places (command line, server side)
where they do run usually.

RedTamarin is just another piece of
technology for the Flash Platform.


What can you do with RedTamarin?

A lot of different things

the main idea is

I want to use ActionScript 3.0 to write applications

you can have small and big applications

on an operating system, you could have some “scripts”
to quickly automate some tasks

those scripts could use: bash, perl, python, etc.
and now they could use ActionScript 3.0

shell script example

If you are a developer already programming for
the Flash Player and/or AIR

you could find yourself wishing you could run
certain parts of your toolchain only on the command line

RedTamarin can help you with that

obfuscation/encryption example

You have the client side programming already
figured out with Flash Player and/or AIR
but you need to add some server side services ?

you could build them with RedTamarin

chat server example

You know quite well ActionScript 3.0
and want to write a full blown server app ?

again you could use RedTamarin

http server example

In fact, you should see RedTamarin as
extending your reach of platforms where you
can program applications

before, once you had to work on the server side
you may have no other choices to use PHP, Python, Ruby, etc.

after, amongs all those server side languages
you have now also the option to pick up ActionScript 3.0


What are those Cross Platform Native API?

Inside RedTamarin you have 3 main API

  • The POSIX API (CLIB)
  • The RedTamarin Native Libraries (RNL)
  • The Flash Platform API (AVMGlue)

The POSIX API (CLIB)

We took the different functions, structures,
constants, macros, etc. you can find
for ISO C / ANSI C and POSIX

we implemented them for ActionScript 3.0

it’s like writing C code but it is faster and easier

Inspired by our previous experience with RedTamarin v0.3
and by things like “Friendly Dialect of C” and other articles
about going from C++ to AS3 or vise versa

we took what we did with v0.3
and pushed the limit as far as we could

example how to copy a C program

The RedTamarin Native Libraries (RNL)

this is our very own Cross Platform Native API

Tamarin already layed out the work quite nicely for us
and we kept moving into that direction with more
and more features

the rule of thumb is pretty simple:
if we can not do it in AS3 or reusing the POSIX API
then we add that mising element in C++ code
so we can call it from AS3

example file downloaded from the Internet

The Flash Platform API (AVMGlue)

Here we simply try to replicate
the Flash Player and AIR API

we made some progress since last time
but this one will still take some time to implement

It’s not really esssential but it is a nice
feature to have, so if someone need to port
a program from Flash or AIR to the command line
he does not need to rwrite it from scratch

or for being able to reuse the numerous libraries
already made for Flash/AIR


What are the advantages to use RedTamarin?

if you already know ActionScript 3.0,
you can reuse your knowledge of the language

if you have other programs already using
ActionScript 3.0, you can reuse your existing
code, libraries, classes, etc.
and it can be easier to communicate
with them

if you have a project already using ActionScript 3.0
on the client-side, using it also on the server-side
allows you to use only one programming language
among all your programmers and teams
reuse of people know-how

but there are also some non-obvious advantages

  • prototyping / testing ideas in ActionScript 3.0
    you have no GUI to distract you from the code

  • learn C the easy way
    most of the POSIX API are identical to standard C and/or POSIX
    spending time learning and using them under RedTamarin
    could help you to use them with the C language later
    eg. fopen() ? socket()/bind()/listen() ? yeah I already know them

  • delegate part of your programming server-side
    the same way you can use services and other REST API
    you could delegate AS3 code server side

you could do that for different reasons,
maybe performance as things could run faster server side
or caching, as the server could resend a previously cached result
or for protecting your program against piracy
etc.

  • to distribute a program server side without providing
    the source code to either sell the program or protect it, etc.

ActionScript 3.0 code compile to ABC (ActionScript Byte Code)
which is a compact and non-readable format

  • to embed the program inside an executable

In this case the ABC is really merged with an EXE
no dependencies of any kind are required

you could need a tool for automation that need to
run on the different systems: Mac OS X and Windows

or maybe you need to distribute a server with
your game or app so users can host their own
LAN sessions

And many more scenarios.


Copyright 2017 zwetan

Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.