public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: "Adrián Medraño Calvo" <adrian@medranocalvo.com>
To: Per Bothner <per@bothner.com>
Cc: Panicz Maciej Godek <godek.maciek@gmail.com>, kawa@sourceware.org
Subject: Re: Porting SLAYER to Android
Date: Thu, 23 Jan 2020 22:47:00 -0000	[thread overview]
Message-ID: <5ADDBD63-E3E2-4A55-992A-FDD77FEA55D1@medranocalvo.com> (raw)
In-Reply-To: <f7064584-7078-8981-7e3a-88e48439ef55@bothner.com>

Dear Panicz Maciej Godek, Per Bothner,

> On 20. Jan 2020, at 16:12, Per Bothner <per@bothner.com> wrote:
> 
> On 1/19/20 1:43 AM, Panicz Maciej Godek wrote:
> 
>> Now, I've been thinking about porting this project to the Android platform.
>> But I know very little about Java, and even less about Android.
> 
> Welcome!
> 
> I did port Kawa to Android years ago, but I generally don't do much if any
> Android programming.  I know very little about the state of Android programming,
> but I believe there are people on this list who know more.

I successfully integrated dx.jar with Kawa, though would need more work (and guidance).  My approach was to expose some parts of KawaClassLoader so that I could implement a separate DexKawaClassLoader.

There’s also https://github.com/medranocalvo/gradle-kawa-plugin <https://github.com/medranocalvo/gradle-kawa-plugin>.  I worked on updating it for newer Android Plugin for Gradle, but never published the updates.

I have very little free time.  If I find any, I’ll clean up the changes open a pull request for further discussion, and update the gradle plugin.

Best regards,
Adrián.

> 
>> - is there some class that could be used to represent the Kawa closures in
>> Java that could be stored in an array and invoked from Java?
> 
> If you eval Scheme lambda (as  a string or an s-expression) the result is a Java object -
> specifically an instance of the class gnu.mapping.Procedure.  You can definitely
> store that in an array and invoke it from Java.
> 
>> In the documentation, I have found this:
>> https://www.gnu.org/software/kawa/Evaluating-Scheme-expressions-from-Java.html
>> but the question is whether the Scheme.eval method compiles the expression
>> (if it's, say, a function) or only interprets it?
> 
> The terms "compiling" and "interpreting" are vague and have various gray areas.
> Kawa on normal platforms (i.e. not Android/Dalvik) doesn't really distinguish:
> When a Scheme form it evaluated (as in the eval function/method or a REPL),
> it is parsed, compiled to a bytecode class, and then a method in that class
> is called.  Then the bytecode is thrown away.  However, if the eval result
> is a function (or an object like a list that contains a function), then
> of course the function is preserved as long as there is a reference to it,
> which means that the bytecode is preserved and reused each time the function is called.
> 
> So yes, the evaluating a function compiles it to bytecode only once, and
> reuses the bytecode each time it is called.
> 
> On Android the situation is different. It used its own non-standard bytecode and
> virtual machine "Dalvik". Generating "Dalvik" bytecode is not supported by Kawa,
> so instead Kawa just generates its internal "AST" data type (the Expression
> class) and then evaluates it.
> 
> It should be possible to generate regular JVM bytercode and then convert them
> as needed to Dalvik using dx.jar.  However, I haven't tried that - someone else may have.
> 
> The Dalvik VM is discontinued, but Dalvik bytecode is still used for
> distribution.  I don't know what tools are used these days to generate
> code on-the-fly on Android.
> 
>> - given some text file, is there any way to obtain some representations of
>> the subsequent s-expressions from that file?
> 
> If you literally means the s-expressions, that is what the standard Scheme read
> procedure does.  If you mean the Kawa AST, I don't think there is a official
> documented way to do that, but it is of course possible and probably simple.
> 
> The --debug-print-final-expr will print out the resulting (pre-bytecode-generation)
> Expression in human-readable form, but it is purely for debugging, and is not
> meant to be parseable.
> 
>> Does the above idea have any chance to work, or is there some other way you
>> would recommend?
> 
> Well, it's pretty vague, but it can definitely be made to work.
> 
> If performance of the Scheme code is an issue, you will need to find a
> way to compile Kawa to Android internal format.
> 
> -- 
> 	--Per Bothner
> per@bothner.com   http://per.bothner.com/

      parent reply	other threads:[~2020-01-23 22:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-19  9:44 Panicz Maciej Godek
2020-01-20 15:13 ` Per Bothner
2020-01-20 15:26   ` Per Bothner
2020-01-23 22:47   ` Adrián Medraño Calvo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5ADDBD63-E3E2-4A55-992A-FDD77FEA55D1@medranocalvo.com \
    --to=adrian@medranocalvo.com \
    --cc=godek.maciek@gmail.com \
    --cc=kawa@sourceware.org \
    --cc=per@bothner.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).