Lazarus Pascal on Android - performance - java

Although a long-time developer, I've never seriously used an Android device - let alone programming one. So I'm new to this platform.
I'm looking at Lazarus for Android and found this link that has the following lines:
LCL-CustomDrawn-Android utilizes a minimal Java application which
communicates with our Pascal library and sends all events to it and
also obeys commands from it.
This raises a bunch of question for me.
In other words, is Lazarus running on the Android like a Windows app running on Wine (for Linux)?
If Java has to get in the way, wouldn't it be faster to directly run Java code without creating Lazarus/Pascal code?
Thanks!

In other words, is Lazarus running on the Android like a Windows app
running on Wine (for Linux)?
No. While there is a light preference for Java, native is quite common on Android, and they all need to connect to OS services via a Java skeletal application.
If Java has to get in the way, wouldn't it be faster to directly
run Java code without creating Lazarus/Pascal code?
No. The code that runs is native, only GUI events trigger some minimal java overhead.

The ARM CPUs on phones can execute Java bytecode natively, it's built into their instruction set. So it doesn't need to run through an interpreter like on Windows or Linux. Java doesn't provide such a speed penalty there as everywhere else. That's not true of x86 Android but ARMs were built partly to run Java. https://en.m.wikipedia.org/wiki/Qualcomm_Snapdragon

Is Lazarus running on the Android like a Windows app running on Wine (for Linux)?
Actually, it sounds more like a Java (Swing) application running in Windows. Swing is known for drawing its own controls, rather than using the controls provided by the host operating system (OS). The only connection between Swing and the host OS (Windows, etc) is the window chrome around the application and how the host OS controls this window chrome.
If Java has to get in the way, wouldn't it be faster to directly run Java code without creating Lazarus/Pascal code?
It would be faster, as Android is natively based on Java. In fact, if you can write Android apps in Java, I recommend you to pick that as your first choice. Start here to learn the basics.
I believe the purpose of this Lazarus/Pascal library is to help run Pascal apps on Android, or otherwise help Pascal programmers write apps for Android. It may also help write apps where any limitations of Java would require the use of Pascal.
To take the analogy further, C++ and C# apps generally run faster on Windows as the OS is natively based on these languages. However, many applications are still written in Java using Swing interface for various advantages such as programmer familiarity or cross-platform availability of the app.

Related

How is to run applications on Android?

First I'm sorry because my English language is poor.
But is my question.
How is to compile and run application written in c/c++ and under NDK on Android OS??
Does it application compiling and running in Dalvik or ART?
Or independent is that VM??
In the case of programs written in other languages, how is it?
For example (C# in Xamarin) or (Delphi in Firemonkey) or (Basic) or (Python)? Thanks a lot for my question answers.
Please, do a research.
Basically yes, almost all non native solutions use some kind of VMs. For example Xamarin use MonoVM for Android platform. The C# code is compiled into CIL, which is executed by the Mono execution environment. This execution environment is run side by side with the Java Virtual Machine, which means the applications are not executed the same as native application, however they are executed in a equivalent way. This means that the performance is tied to MonoVMs implementation.
MonoVM is packaged with the application, which means that Xamarin Platform applications can be installed in the same way as a native application, without any additional installs.

Is there a legitimate, automated, method for deploying Java applications on iOS4?

I'm wondering if there is a standard method for deploying applications originally written in Java, to iOS4 devices.
I assume that the application in original format cannot be deployed - is there perhaps an emulation layer that I can use, or a stable compiler that compiles Java to ObjectiveC?
Option 1:
Use one of several cross compilers, compiling Java to ObjectiveC:
http://www.xmlvm.org/overview/
http://www.flexycore.com/ispectrum-overview.html
Option 2:
Package custom JVM with java application, with restrictions that meet the latest agreement (including no byte-code download capability and no JIT compilation). No JVM specifically designed for the iPhone is currently (Oct 2010) available, though the IKVM might run on top of Monotouch, and Oracle may build a version of the Java SE for the iPhone eventually.
Option 3:
Cross compile Java to one of the existing interpreters that are already accepted on the iPhone (eg, cross compile Java to C# and run the app on monotouch)
With the new current iOS SDK agreement and App store rules, it may be possible for you to embed a Java applet with your own JVM interpreter and runtime engine (but no byte-code download capability and no JIT compilation allowed).
Another seldom mentioned possibility for deploying any non media or graphic intensive networked app, such as many typical Java applets, is to run a customized RDP or VNC viewer on the iPhone and and view a Java app that is being hosted and run remotely.
Mechanically translating some of your code will likely work pending finding a cross compiler / translator. Trying to run a Java based GUI on iPhone is just plain stupid in my opinion. So the smart thing would be to port the GUI by hand.
The problem of course is if the app is mostly GUI you might as well write the whole thing over. Likewise if the app uses APIs that there is not a simple translation for you again might as well rewrite the entire app.
In a nut shell I think Steve J. Was right here, the route you are comtemplating just leads to poor user experiences. It actually makes me wonder why you would even think that a Java based app would be successful on iPhone.

What environment is more portable QT or java and which do you suggest using for my application needs?

I want to wrap a website and create an application around it (kind of like the iPhone/iPod Facebook app) and i want the application to be as portable as possible so with a very few modification to the code it can run on pc, mac, iPod, android or any other.
I know that Java is known for it's portability but i dislike it and i don't know about QT.
I know this question is quite subjective but can you give me a couple of opinions and reasons for them any way?
Thanks in advance,
Dante
Qt is portable enough for the major platforms (Windows, Linux and MacOS). It has the advantage of being native code, so no virtual machine is needed. And it provides rich graphics and other powerfull features, and the GUI look and feel of the specific platform.
If you are considering the same code base to be shared between desktop and mobile platforms, think again. There are different constraints in terms of resources, screen dimensions, etc. Qt can be used for some mobile platforms (mainly Symbian, Maemoo), Java for Android and ObjectiveC/C++ for iPhone/iPod. So a cross mobile platform application using the same technology is not feasible (at least for the moment).

Starting with Android: Java or Python (SL4A)

I just ordered an Android smartphone and want to start playing around with creating my own applications. Now the question is which language to use, the native Java or Python using SL4A (former ASE).
I tend to Python, as I know it much better than Java, but I'm wondering what I would be missing using a "second class" language on Android. On the SL4A website it is also stated to be alpha quality software, which is not exactly encouraging.
I'm also not quite sure what the limitations of the scripting environment are and if they would be problematic.
At the moment you cannot create a releasable program with Python (or any other scripting language) using SL4A. I have heard rumours that this is something Google is working on, but even if they do enable it Python apps are likely to be slow and power-hungry compared to Java. Also the scripting API only gives you access to a limited subset of the native Java API. I would not consider using SL4A for serious development work at the moment, only for one-off scripts and prototyping.
Take a look at Scala. It is a statically typed language on the JVM, but uses type inference to remove most of the noise that you get in Java. It also fully supports functional programming, and has a lot of pythonish features. Because it is statically typed it is as efficient as straight Java with none of the disadvantages. IMHO it is the language that Java should have been in the first place.
A lot of people are blogging about using Scala on Android, so Google around for more information.
More likely will depend what type of applications you will develop.
I would start with Java to become familiar with Android SDK. Anyway first you need to look into some examples, tutorials. Most of them are done in Java, and only a few, probably on the dev site of SL4A for that.
Also there is native development Android NDK, that can be programmed with C++.
But anyway Java rules for general applications.
Adding an update to Dave Kirby's answer:
Issue 55, Distribute scripts as APKs, in the issue tracker at SL4A deals specifically with that.
There is a solution being worked out (may be complete by now) described at SharingScripts. The only issue seems to be that you need to have a interpreter APK already installed.
you may want to check out Ruboto it is a framework for developing Android apps based on JRuby which means your JRuby code can call Android APIs and can also be called back from the Android Java side.
Here is an introduction article .
Consider ising Kivy, if you want to write Android apps with Python. The process of packing script to .apk file is described here.
The problem is, resulting .apk will be big (~7Mb for 300Kb data). It is obvious, because you need to pack there Python runtime and all libraries.
Another solution I have heard of, is Pygame for Android, but it works on lower lewel, so you need to draw graphics manually.
Unfortunately, I have not tried any of this ways yet, but it looks, that I'm going to start using kivy soon.

Suggestions for an embeddable scripting language for iPhone and Java app?

I'm developing an app for iPhone with a Java desktop companion that it synchs to over the network. I'd like to embed a scripting language into both apps so that end users can write scripts that add new behaviours and interact with the object model, and so that I can more rapidly develop some features.
Any suggestions for this, or anyone done this before and got experiences to share? I'm thinking of something like tcl which I've used in the past, but not tcl itself as I'm not a big fan of the language.
Main criteria are that it should be
lightweight as poss (memory usage)
easy to interface and extend with java and objective-c
(nice to have) readable/approachable for people with limited programming experience
My initial hunch is that I should be using one of python, ruby, or lua. My preference would be ruby, as I already have some experience with it and don't know much about the others. However my main unknown is which of these is easiest to get integrated with iPhone and Java.
edit 2: per Jason Coco in the comments, the SDK terms prohibit embedded scripting languages. Checking into this it does indeed seem to, but I read it to preclude dynamic installation and extension only. I would still be interested in answers here, as the agreement doesn't seem to preclude having prepackaged scripts inside the application bundle itself - Apple would still get to vet that code.
The agreement also seems to allow use of Apples "interpreters"...what are these? Javascript and what else? Any route to use those here?
JavaScript
As I understand the iPhone SDK Licence, there is nothing preventing you from using a scripting language in your app - just that you cannot intall any interpreters or runtimes of your own. You can only use those scripting languages for which Apple provides the interpreter in the SDK.
Given that you want to run the same scripts in your iPhone app and in a Java app, the obvious choice is JavaScript. You can use Apple's APIs in your iPhone app, and something like Rhino (http://www.mozilla.org/rhino/) in your Java App.
You have to be aware that there may be slight differences between the two interpreters in the more obscure regions of syntax or object model.
P.S. I assume that users are going to be writing their own scripts to run on their own device/desktop. These would be part of the application data, and should be fine under Apple's licence
The only thing I've seen that allows a non-objective-c/c/c++ application to run on the iPhone is Unity3d (http://unity3d.com/unity/features/iphone-publishing) - BUT, it uses C# via Mono and does a full static compilation (http://tirania.org/blog/archive/2008/Nov-05.html) down to native code in order to do it. So, by the time the app is on the phone, it's no longer C# so it's allowed by Apple (and several apps have already made it into the App Store - so this does seem to be acceptable).
I don't think you would be able to do the idea you're talking about even if you could do the equivalent for Java/Ruby/Lua/Python/other (so having your desktop app pre-compile and upload just the native code to the device). As far as I know, you can't execute code outside of your application bundle...and if you modify the application bundle, then you invalidate the codesigning Apple does which allows the app to run on your phone in the first place. So even if you could get executable code to the phone, I'm not sure that you would be able to run it if it didn't come along with the app in the first place.
I was researching this too, and it seems that it's possible to pre-compile a Lua script (by converting it to C using Lua and then compiling the C file). Because all of your code could then be part of the application bundle (including the embedded Lua interpreter), it should be acceptable as an iPhone app.
See here for a discussion and sample script:
http://lua-users.org/lists/lua-l/2008-11/msg00453.html
*Note that I haven't tried this (yet)

Categories