Wish Inline Java?


Well-Known Member
Licensed User
Now, I've not thought this through, and it's a complex issue with many aspects, so please bear with me and think of it as a very vague idea that might work (or not). I'm just posting it to get some input and thoughts.

Some languages, such as C (and it's variants), many .Net languages and PowerBasic has support for inline assembler. In other words, you just ad a precompiler directive and switch language.

Example (in very rough pseudosyntax):

Sub Encrypt(file as string) as string
  dim Text as string = ReadFile(file)
  dim ResultText as string
    Do the encryption in assembly here
  #End Asm
  Return ResultText
End Sub
When the compiler comes to the #Asm directive, it "simply" reads the assembler code as it is, no compiling, just assembling it.

Inline assembly is often used for very performanceintensive stuff that lends itself well to assembly, like encryption.

Now, that's not very useful in our case, when we don't even know the target hardware platform.

However, I thought, what if we could have inline Java? We wouldn't get any performance benefits worth the trouble, but there could be other benefits. The main benefit I see is that we maybe could get access to a lot of stuff which now requires reflection. Perhaps it would be easier to use libraries not designed for B4A? Perhaps there are other benefits as well?

Of course, there are also risks. The main risk I see is "cargo cult programming", when people include code thay don't really understand, but seems to do the job. On the other hand, that's pretty much what we do every time we use a lib...

Do these benefits outweigh the cost and risks? I have no idea.

What I do know is that it's an interesting idea, from a theoretical viewpoint. Your thoughts on the subject?


Well-Known Member
Licensed User
Wow, I've missed that (probably because I don't care about i*-devices). Cool! Had I been more excited, leg humping would have ensued. :)