我可以用 Perl 开发 Android 应用程序吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12212827/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I develop Android applications in Perl?
提问by Andreas
I know that I can runPerl on Android, but I'm looking to write an app that can be released on Google Play, for anyone to download and run. Is Perl still a viable choice?
我知道我可以在 Android 上运行Perl,但我希望编写一个可以在 Google Play 上发布的应用程序,供任何人下载和运行。Perl 仍然是一个可行的选择吗?
采纳答案by Andreas
This Google project packages Perl scripts and Perl into a self-contained APK, not requiring any further downloads, that can be uploaded to Google Play:
这个谷歌项目将 Perl 脚本和 Perl 打包成一个独立的 APK,不需要任何进一步的下载,可以上传到 Google Play:
http://code.google.com/p/perl-android-apk/
http://code.google.com/p/perl-android-apk/
It provides Android API access through SL4A - see the following page by one of the authors:
它通过 SL4A 提供 Android API 访问 - 请参阅作者之一的以下页面:
http://www.github.com/damonkohler/sl4a
http://www.github.com/damonkohler/sl4a
So yes, Perl is a viable option if it's your preferred language to work with.
所以是的,如果 Perl 是您首选的工作语言,它是一个可行的选择。
回答by Borodin
I highly recommend Perl for Android together with SL4A for prototypingapplications. From there it isn't too much of a leap to refactor your code to Java, as all the system calls are the same on both platforms.
我强烈推荐将 Perl for Android 和 SL4A 一起用于原型应用程序。从那里开始,将您的代码重构为 Java 并没有太大的飞跃,因为所有系统调用在两个平台上都是相同的。
Knowledge of Java is an excellent new string to your bow, and the basics - mainly that everything is a class - can be learned in an afternoon and can largely be replicated in Perl
Java 知识是一个很好的新字符串,基础知识 - 主要是一切都是一门课 - 可以在一个下午学习,并且可以在很大程度上在 Perl 中复制
回答by zostay
The short answer is: no, you cannot use Perl in a deployed, native Android app. There's no practical way to do this. There are ways to sort of do it, but none that are feasible.
简短的回答是:不,您不能在已部署的原生 Android 应用程序中使用 Perl。没有实际的方法可以做到这一点。有一些方法可以做到这一点,但没有一个可行。
As others have pointed out, there are some things like SL4A and such to make prototyping possible and you might even be able to run a real app on your phone, but deploying it to a wide base of phones will be problematic.
正如其他人指出的那样,有一些像 SL4A 之类的东西可以使原型制作成为可能,您甚至可以在手机上运行真正的应用程序,但将其部署到广泛的手机基础上将是有问题的。
For 95% of the apps out there, a Java application of some sort is the best option. Yet, a native Java application is not the only alternative available to you.
对于 95% 的应用程序,某种 Java 应用程序是最好的选择。然而,本机 Java 应用程序并不是您可以使用的唯一替代方案。
Other options include:
其他选项包括:
You can develop an app that is primarily driven on the server side, which is running Perl. This could be through some sort of socket connection, REST API, or a web-based mobile app wrapped in a thin Java app that installs onto the client. However, your application will only work while the phone or tablet has a working data connection. There are many applications (including my own) that work this way.
You can try out PhoneGap, which uses HTML5 and JavaScript (and Java if you want to extend it to do something PhoneGap doesn't support on Android). This framework also has the advantage of making it possible to run your app on iPhones and other smartphones with very little effort. This also has it's own support base and community separate from Android and Google, if that's a concern.
You can also try Scala, which is a functional language (i.e., more Perlish than Java) that builds to the JVM and has some toolsto aid in the construction of Android projects. This is not as mature, not supported by Google, and harder to start, but not Java for those offended by Java.
您可以开发一个主要在运行 Perl 的服务器端驱动的应用程序。这可能是通过某种套接字连接、REST API 或包装在安装到客户端的瘦 Java 应用程序中的基于 Web 的移动应用程序。但是,您的应用程序仅在手机或平板电脑具有工作数据连接时才能工作。有许多应用程序(包括我自己的)以这种方式工作。
您可以试用PhoneGap,它使用 HTML5 和 JavaScript(如果您想扩展它以执行 PhoneGap 在 Android 上不支持的操作,还可以使用 Java)。该框架还有一个优势,即可以轻松地在 iPhone 和其他智能手机上运行您的应用程序。如果这是一个问题,它也有自己的支持基础和社区,与 Android 和 Google 分开。
您还可以尝试Scala,它是一种函数式语言(即比 Java 更 Perlish),它构建到 JVM 并具有一些工具来帮助构建 Android 项目。这不是那么成熟,不被谷歌支持,也更难开始,但对于那些被 Java 冒犯的人来说不是 Java。
Ultimately, it should be possible for someone to deploy apps to Perl and I'd love to see that happen. I'm unwilling, though, to spearhead that project.
最终,有人应该可以将应用程序部署到 Perl,我很乐意看到这种情况发生。不过,我不愿意带头进行该项目。
Update Jan 2014:Sadly, my original answer from August 2012 still applies despite what others have said. The SL4A + perl installed solution is closer, but SL4A does not allow you to actually build native Android applications. It, basically, gives you the ability to build a locally hosted web application that has access to some of the phone's native features. This may serve the needs of some, but certainly not all application developers. I still don't know of a project that will allow you to build a native Android application in Perl.
2014 年 1 月更新:遗憾的是,尽管其他人说了些什么,但我 2012 年 8 月的原始答案仍然适用。SL4A + perl 安装的解决方案更接近,但 SL4A 不允许您实际构建原生 Android 应用程序。基本上,它使您能够构建本地托管的 Web 应用程序,该应用程序可以访问手机的某些本机功能。这可能满足某些应用程序开发人员的需求,但肯定不是所有应用程序开发人员的需求。我仍然不知道有什么项目可以让您在 Perl 中构建本机 Android 应用程序。
回答by Marcin Orlowski
Technically you can release anything that conforms Google Play policy and is distributed in APK form. But in case of perl you'd either have to bundle perl with your app or expect user to have it (barely noone), not to mention UI. My answer is - it's not really best idea and if you can rethink it, you might come up with something requiring less hassle.
从技术上讲,您可以发布任何符合 Google Play 政策并以 APK 形式分发的内容。但是在 perl 的情况下,您要么必须将 perl 与您的应用程序捆绑在一起,要么期望用户拥有它(几乎没有人),更不用说 UI。我的回答是 - 这不是最好的主意,如果你能重新考虑它,你可能会想出一些不需要那么麻烦的东西。
回答by Helen Craigman
Google claims that Perl is supported by the "Scripting Layer for Android" (SL4A).
Google 声称“Android 脚本层”(SL4A) 支持 Perl。
See here: http://code.google.com/p/android-scripting/
请参阅此处:http: //code.google.com/p/android-scripting/
and a Perl apk: http://code.google.com/p/android-scripting/downloads/detail?name=perl_for_android_r1.apk
和 Perl apk:http: //code.google.com/p/android-scripting/downloads/detail?name= perl_for_android_r1.apk