Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tcl support for Android Scripting Environment

470 views
Skip to first unread message

Cyan

unread,
Sep 5, 2011, 1:07:45 PM9/5/11
to
Why this is marked as abuse? It has been marked as abuse.
Report not abuse
Does anyone know what happened to the Tcl support in ASE?

It's still mentioned on the main ASE page: http://code.google.com/p/android-scripting/
but it isn't listed as an available interpreter, and this page
http://groups.google.com/group/android-scripting/browse_thread/thread/a07a7536b2af6f76
seems to indicate that support has been removed in the current
version.

I'd really like to build stuff for android devices (even just my own)
in Tcl. I started down the native Java route, but hundreds of MB
later and a splitting headache convinced me that it wasn't a life
enhancing option. If there is work that needs to be done to make Tcl
work on ASE again, I'm happy to help.

Cyan

zdia

unread,
Sep 8, 2011, 3:48:36 AM9/8/11
to

I am trying to port a Tcl/Tk application to Android and carried out some tests with Pat Thoyt's tclkit 8.6 for Android on the Android emulator (no Tk):

http://www.patthoyts.tk/tclkit/android-arm/.

There you will find also a working ASE:

http://www.patthoyts.tk/tclkit/android-arm/AndroidScriptingEnvironment.apk

If you install the ASE apk you have the choice to start a shell and in this shell you can start Pat Thoyt's tclkit in the emulator after having installed it with "adb install".

It was working well on the emulator. Probably it will be more complicated to get the things running on a real Android machine.

But perhaps you would be interested in Hecl (http://www.hecl.org/docs/android.html#android_quick_start) which is written in Java and has a Tcl-like syntax.

It is very easy to add new commands to Hecl writing some lines in Java code or to get access to the Java API by a Hecl "java" command.

java android.widget.button button
set myButton [button <method> <parameter>]

This makes it possible to access the Android GUI widgets, e.g. taken from Hecl's script example lightly modified:

set myButton [button -new $context -text "Ok" -layoutparams
$layoutparams]

set callback [callback -new [list [list MyButtonCallback $arg1
$arg2]]]

$myButton setonclicklistener $callback

All Hecl scripts can be packaged to a native executable .apk bundle which can be launched directly on the Android machine.

Gerald W. Lester

unread,
Sep 8, 2011, 8:27:00 AM9/8/11
to
On 9/8/11 2:48 AM, zdia wrote:
> Am 05.09.2011 19:07, schrieb Cyan:
>>...
> But perhaps you would be interested in Hecl (http://www.hecl.org/docs/android.html#android_quick_start) which is written in Java and has a Tcl-like syntax.

Have you tried running Jtcl, which is a Tcl interp written in Java) on the
Android?


--
+------------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+------------------------------------------------------------------------+

Zbigniew Diaczyszyn

unread,
Sep 8, 2011, 6:03:19 PM9/8/11
to
Am 08.09.2011 14:27, schrieb Gerald W. Lester:
> On 9/8/11 2:48 AM, zdia wrote:
>> Am 05.09.2011 19:07, schrieb Cyan:
>>> ...
>> But perhaps you would be interested in Hecl
>> (http://www.hecl.org/docs/android.html#android_quick_start) which is
>> written in Java and has a Tcl-like syntax.
>
> Have you tried running Jtcl, which is a Tcl interp written in Java) on
> the Android?
>

I have made some tests with jtcl.jar on my Linux system and it looked
very well but in order to test it on an Android system you have to
install at first a Java app on Android and then feed the Java app with
the jtcl.jar.

The proper way would be to compile JTcl's Java sources to get the dex (I
think D-alvik Ex-ecutable) byte-code from them which will be executed by
Android's Dalvik interpreter. In addition you have to make a package
bundle with the resource files Android requires (like the MacOS app
bundle) in order to create an .apk executable.

Access to Anroid's GUI seems given like in Hecl by JTcl's java::*
commands which allow to create Java objects, call Java methods and
access fields and properties.

So it seems worth while to me to make some feasibility studies with JTcl
but at first I would like to finish the Android port with Hecl.



Gerald W. Lester

unread,
Sep 8, 2011, 8:10:47 PM9/8/11
to

Fair enough.

Tcl Bliss

unread,
Sep 8, 2011, 11:30:09 PM9/8/11
to
On Sep 5, 10:07 am, Cyan <cyan.ogil...@gmail.com> wrote:
> Does anyone know what happened to the Tcl support in ASE?
>
> It's still mentioned on the main ASE page:http://code.google.com/p/android-scripting/
> but it isn't listed as an available interpreter, and this pagehttp://groups.google.com/group/android-scripting/browse_thread/thread...

> seems to indicate that support has been removed in the current
> version.
>
> I'd really like to build stuff for android devices (even just my own)
> in Tcl.  I started down the native Java route, but hundreds of MB
> later and a splitting headache convinced me that it wasn't a life
> enhancing option.  If there is work that needs to be done to make Tcl
> work on ASE again, I'm happy to help.
>
> Cyan

There is one available here: http://ww1.pragana.net/Android/
I have been able to install it and it was pretty easy. The TCL shell
works but I wasn't able to make the Android GUI interface to work.
Perhaps someone can pick it up and make it work. The current
maintainer does not work on it anymore.
There are some instructions on how to do it on the main page:
http://ww1.pragana.net/

Gerald W. Lester

unread,
Sep 9, 2011, 7:42:04 AM9/9/11
to
I think it would need to add in JavaBlend to be able to call the various
Java classes on an Android.

There seems to be interest in Tcl on the Android, just not a lot of people
with time to get over the (high) hurdle of getting it there with the ability
to call the native APIs.

Tcl Bliss

unread,
Sep 9, 2011, 12:11:45 PM9/9/11
to
On Sep 9, 4:42 am, "Gerald W. Lester" <Gerald.Les...@KnG-
> | Email: Gerald.Les...@kng-consulting.net                                |
> +------------------------------------------------------------------------+

Note that the Android API support is there, it just doesn't work
anymore (or on my device). I think it would not be too difficult for
someone who knows what he is doing to make it work. Rildo Pragana, the
site owner, hints that he would do more work on it if someone helps
him.

cattaghia

unread,
Sep 14, 2011, 10:44:03 PM9/14/11
to
If Steve Jobs is quoted as saying "iPad would benefit from having
something like Hypercard", I can only dream about what Tcl/Tk would
mean for Android. Even though I am a programming enthusiast for years,
I feel really sorry about having a too little C/C++ knowledge for any
help on it.

But if Tcl (and Tk as well, I presume?) is written in pure ANSI C,
would anyone here be able to try the Android NDK? Link is here:
http://developer.android.com/sdk/ndk/overview.html .

I have already seen some explanations about the Tcl interpreter in C,
but I can't remember to have read anything about the Tk
implementation: which widgets are C, which widgets are pure Tcl, which
parts of Tk are platform dependent, etc.

Regards!

Fabricio Rocha
Brasilia, Brasil

oc_forums

unread,
Sep 15, 2011, 4:58:51 AM9/15/11
to
"Tk was also born of frustation. The basic idea for Tk arose in response to Apple's announcement of HyperCard in the fall of 1987." John Ousterhout , Tcl and the Tk Toolkit / preface, 1994 .

Zbigniew Diaczyszyn

unread,
Oct 8, 2011, 1:58:32 PM10/8/11
to
Am 05.09.2011 19:07, schrieb Cyan:

> I'd really like to build stuff for android devices (even just my own)
> in Tcl. I started down the native Java route, but hundreds of MB
> later and a splitting headache convinced me that it wasn't a life
> enhancing option. If there is work that needs to be done to make Tcl
> work on ASE again, I'm happy to help.
>
> Cyan

It is possible to run Tcl on Android (or any other Linux executable
compiled for the ARM processor) without the ASE scripting environment.
You just take a Terminal app like the "Android Terminal Emulator"
written by Jack Palevich:

https://github.com/downloads/jackpal/Android-Terminal-Emulator/Term.apk

"Android Terminal Emulator is a terminal emulator for communicating with
the built-in Android shell. Emulates a reasonably large subset of
Digital Equipment Corporation VT-100 terminal codes, so that programs
like "vi", "Emacs" and "NetHack" will display properly."

Because no application is allowed to start from sdcard it is necessary
to create at first a system folder into which the tclkit (see precedent
posts) has to be pushed. "Terminal Emulator" proposes /data/local/bin.

$ adb shell
# mkdir /data/local/bin
# exit
$ adb push ~/Projekte/android/tclkit-cli-8.6b1.2-android-arm
/data/local/bin/tclkit

$ adb shell
# ls -l /data/local/bin
-rw-rw-rw- root root 1581165 2011-10-08 14:05 tclkit

Because we are not root we have to manage the permissions issue.

The command "id" in the "Terminal Emulator" will give us the necessary
information: We find we are a member of group "sdcard_rw" because this
application has the rights to read and write to the sdcard.

So we change the membership in the adb shell:

# chown root.sdcard_rw tclkit
# ls -l
-rwxr-xr-x root sdcard_rw 1581165 2011-10-08 14:05 tclkit

Now the command "tclkit" will be found and executed.

A screenshot can be seen at:

http://zdia.de/images/screenshots/Android/tclkit.png

If there were a "package java" like JTcl is providing one then there
would be given easy access to Android's GUI.


Gerald W. Lester

unread,
Oct 8, 2011, 5:40:39 PM10/8/11
to
So if TclBlend was in the tclkit, then you could access the Andrioid's APIs
(including the GUIs)?

Also, for a StarPack -- would you still need the terminal emulator -- or
could it then be launched like any other application?


--
+------------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+------------------------------------------------------------------------+

Zbigniew Diaczyszyn

unread,
Oct 9, 2011, 2:03:19 PM10/9/11
to
Am 08.10.2011 23:40, schrieb Gerald W. Lester:

>
> So if TclBlend was in the tclkit, then you could access the Andrioid's
> APIs (including the GUIs)?

As to now, I have no experiences or lucid ideas about TclBlend. The
links in http://wiki.tcl.tk/862 are no longer valid.

But if it works like the description in the wiki tells:

"TclBlend is used to either embed C version Tcl into a running Java
process, or embed a JVM into a running C version Tcl process."

then, yes, it would be the right tool: The "Terminal Emulator" way would
embed the DalvikVM into the running C Tcl.

>
> Also, for a StarPack -- would you still need the terminal emulator -- or
> could it then be launched like any other application?
>

As I know you can launch applications on the Android only by going the
Java way.

There seems to exist some hackish way to launch applications on Android
from the shell commandline (by calling "am" or "dalvikvm") but this will
serve just for development.

A normal Android package is a zipped folder like a starpack with all the
necessary subfolders for external libraries, drawing, resources, scripts
etc.

res
|-- drawable
| |-- aicon.png
| |-- buttonhecl.png
| `-- heclicon.png
|-- layout
| |-- list_item.xml
| `-- main.xml
|-- raw
| |-- lib.hcl
| `-- script.hcl
`-- values
`-- strings.xml

David Welton implemented Hecl in a tclkit way: after having been
launched by a click Hecl will look for a file "script.hcl" and execute
it just like tclkit is doing for "main.tcl". So a starpack will not be
needed on Android.

I tried to launch JTcl from the command-line by calling the dalvikvm
with JTcl's entrypoint tcl.lang.Shell (after having "dex-ed" it) but got
a path-not-found issue.

# /system/bin/dalvikvm -Xbootclasspath:/system/framework/core.jar
-classpath /data/local/bin/jtcl.jar tcl.lang.Shell

cannot read resource "/tcl/lang/library/init.tcl"

Well, we will see.

Last not least:

After having finished my feasibility study on Hecl the good message for
the Tcl community is:

Hecl is an excellent tool for writing Tcl programs on Android!


Zbigniew Diaczyszyn

unread,
Oct 20, 2011, 4:51:24 AM10/20/11
to
Am 08.09.2011 14:27, schrieb Gerald W. Lester:
> Have you tried running Jtcl, which is a Tcl interp written in Java) on
> the Android?

I've finally got a working (simplified version without tcllib) JTcl on
Android.

For the moment it is just byte-code for the dalvikvm but it can be
called with "adb shell" or in the app "Terminal emulator" following the
hints in this thread.

It is interesting to note that the binary has just 500MB.

Attached is a screenshot:

http://zdia.de/images/screenshots/Android/jtcl1.png

I will cleanup my working directories and then put an article about
porting JTcl to Android into the Tcl Wiki which will contain the new
build.xml for ant and the little patch in interpr.java.

Uwe Klein

unread,
Oct 20, 2011, 1:56:45 PM10/20/11
to
Zbigniew Diaczyszyn wrote:
> Am 08.09.2011 14:27, schrieb Gerald W. Lester:
>
>> Have you tried running Jtcl, which is a Tcl interp written in Java) on
>> the Android?
>
>
> I've finally got a working (simplified version without tcllib) JTcl on
> Android.
>
> For the moment it is just byte-code for the dalvikvm but it can be
> called with "adb shell" or in the app "Terminal emulator" following the
> hints in this thread.
>
> It is interesting to note that the binary has just 500MB.
577320 bytes is just a bit over 500k ?
>
> Attached is a screenshot:
>
> http://zdia.de/images/screenshots/Android/jtcl1.png
>
> I will cleanup my working directories and then put an article about
> porting JTcl to Android into the Tcl Wiki which will contain the new
> build.xml for ant and the little patch in interpr.java.

waiting, pretty please!

uwe

>

Zbigniew Diaczyszyn

unread,
Oct 21, 2011, 5:43:17 PM10/21/11
to
Am 20.10.2011 19:56, schrieb Uwe Klein:

>> It is interesting to note that the binary has just 500MB.
> 577320 bytes is just a bit over 500k ?

oops, @^-^@

>>
>> Attached is a screenshot:
>>
>> http://zdia.de/images/screenshots/Android/jtcl1.png
>>
>> I will cleanup my working directories and then put an article about
>> porting JTcl to Android into the Tcl Wiki which will contain the new
>> build.xml for ant and the little patch in interpr.java.
>
> waiting, pretty please!

Just added some lines to http://wiki.tcl.tk/4060

cattaghia

unread,
Oct 22, 2011, 10:54:56 AM10/22/11
to
That's great news, Zbigniew, congratulations! I am quite limited in
time and technical skills in Java, but I'll keep following this and I
hope I can help soon. With all this movement towards mobile computing,
I have been worried about my "time investment" in Tcl/Tk and, on the
other hand, I can't imagine anything else which would go so nicely
with Android.

So it seems that JTcl, Jacl and Hecl are the smaller bridges betweeen
Tcl and Android. Which one of these would be closer to the official
8.5 or 0.6 versions?

Also, Tk seems to be the most difficult part to implement. As far as I
read, Android uses XML files which describe the interface widgets,
more or less like libglade. I have been doing some experiments on
building Tk interfaces from pure data: nested dicts, directly saved to
or read from ASCII files, containing properties, layout information,
etc about each widget and its children. This has been a somewhat
simple thing (certainly much easier for most Tclers of this list), and
I presume that it would be not too hard to convert an interface
described in a pure-data dict into an XML file similar to those used
by Android.

I don't believe it would be possible to port existing Tk interfaces to
Android like this, simply because there are immense, conceptual
differences between desktop- and mobile-design for interfaces. I
definitely think that this "libglade approach" would work better (and
more easy to implement, both in Android itself and in a desktop-based
interface designer) than porting the Tk commands to Android.

It will be interesting to study the Android widgets for finding
similarities and equivalences among them and Tk widgets, or how these
could be created in Android using "View", which seems to be somewhat
similiar to our canvas. For this, it would be good to know which Tk
widgets are implemented in C / native APIs, and which ones are
implement in pure Tcl. Anyway, it might be easier to have the native
Android widgets and interface-building API available from a "package
require android" which would be simply different from Tk.

Regards,

Fabricio Rocha
Brasilia, Brasil

Gerald W. Lester

unread,
Oct 22, 2011, 11:13:59 AM10/22/11
to
On 10/22/11 9:54 AM, cattaghia wrote:
> ...
> Also, Tk seems to be the most difficult part to implement. As far as I
> read, Android uses XML files which describe the interface widgets,
> more or less like libglade. ...

Correct

> I don't believe it would be possible to port existing Tk interfaces to
> Android like this, simply because there are immense, conceptual
> differences between desktop- and mobile-design for interfaces. ...

In the general case, I think the answer is a "practical" yes.

> It will be interesting to study the Android widgets for finding
> similarities and equivalences among them and Tk widgets, or how these
> could be created in Android using "View", which seems to be somewhat
> similiar to our canvas. For this, it would be good to know which Tk
> widgets are implemented in C / native APIs, and which ones are
> implement in pure Tcl.

Take a look at the Tk source, although some things will be in pure Tcl on
one platform and use the native APIs on another platform (e.g. the open file
dialog).

> Anyway, it might be easier to have the native
> Android widgets and interface-building API available from a "package
> require android" which would be simply different from Tk.

The first step would be exposing the Android APIs, including the GUI APIs,
to Tcl.

The next step would be creating a wrapper that would implement some, or all,
of the Tk widgets using the Android GUI APIs (maybe the very low level ones
for some of the widgets).

Zbigniew Diaczyszyn

unread,
Oct 22, 2011, 3:51:33 PM10/22/11
to
Am 22.10.2011 16:54, schrieb cattaghia:
> That's great news, Zbigniew, congratulations!
Ah, thank you. But I did just some little hacking. Looking at the JTcl
code I am full of respect for the work Tom Poindexter and his JTcl team did.

> So it seems that JTcl, Jacl and Hecl are the smaller bridges betweeen
> Tcl and Android. Which one of these would be closer to the official
> 8.5 or 0.6 versions?

Well, Hecl is not a pure Tcl implementation:

strlen $string vs. string length $string
+ 1 2 vs. expr {1 + 2}
or expr1 expr2 (expr3 ...) vs { expr1 || expr2}
$fileObjectPointer read vs. read $channel

So you would have to modify your code.

JTcl has Tcl version 8.4

>
> Also, Tk seems to be the most difficult part to implement. As far as I
> read, Android uses XML files which describe the interface widgets,
> more or less like libglade.

Google encourages the XML based construction of widgets but you can
create them also by code.

> Anyway, it might be easier to have the native
> Android widgets and interface-building API available from a "package
> require android" which would be simply different from Tk.

Am 22.10.2011 17:13, schrieb Gerald W. Lester:

> The first step would be exposing the Android APIs, including the GUI APIs, to Tcl.

Yes, this would be a great step.

0 new messages