scala 没有 Java 的安卓
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3242034/
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
Android without Java
提问by mhd
After doing the whole "enterprise" programming for a while, I'm seriously disillusioned by the language itself and always feel quite hampered if I have to go back to it. The project size of your average Android app isn't too intimidating and the libraries are actually quite nice regarding their coding style, but if I could avoid Java, I'd certainly do.
在完成了一段时间的整个“企业”编程之后,我对语言本身感到非常失望,如果我不得不回到它,总是感到很受阻。您的普通 Android 应用程序的项目大小并不太令人生畏,而且这些库实际上就其编码风格而言非常好,但如果我可以避免使用 Java,我当然会这样做。
So that's the question: Can I avoid it? While there are lots of JVM language that would be an option on desktops and servers, the Dalvik VM and the devices themselves pose some limits. This seems to be a bit better in 2.2 with the JIT, but limiting myself to the cutting edge would be a rather harsh decision.
所以这就是问题:我可以避免它吗?虽然有很多 JVM 语言可以用于台式机和服务器,但 Dalvik VM 和设备本身存在一些限制。这在 2.2 中使用 JIT 似乎要好一些,但将自己限制在最前沿将是一个相当艰难的决定。
The only alternative I know that's used somewhat seems to be Scala. Is there some possibility I'm missing? Clojure seems to run in exactly the problems I've illustrated above with Dalvik, but as the AppInventor is built on Kawa there might be hope for a Lisp on the mobile platform?
我知道使用的唯一替代方法似乎是 Scala。有没有我失踪的可能性?Clojure 似乎遇到了我上面用 Dalvik 说明的问题,但是由于 AppInventor 是建立在 Kawa 上的,所以在移动平台上有可能出现 Lisp 吗?
What other languages are already usable or make strides towards that?
还有哪些其他语言已经可用或正在朝着这个方向迈进?
采纳答案by dbyrne
Personally, I'd say Scala is your best bet right now. It works really well, with the one drawback being that you are required to include Scala as a dependency (which will increase the size of your application).
就我个人而言,我认为 Scala 是您目前最好的选择。它工作得非常好,一个缺点是您需要将 Scala 作为依赖项包含在内(这会增加应用程序的大小)。
回答by apg
回答by CommonsWare
Is there some possibility I'm missing?
有没有我失踪的可能性?
Tons of 'em!
成吨的!
Clojure seems to run in exactly the problems I've illustrated above with Dalvik
Clojure 似乎遇到了我上面用 Dalvik 说明的问题
I'm not aware of this. Any JVM language that is an ahead-of-time compiler (i.e., generates Java bytecode on the developer PC) should work with Dalvik.
我不知道这一点。任何作为提前编译器的 JVM 语言(即在开发人员 PC 上生成 Java 字节码)都应该与 Dalvik 一起使用。
but as the AppInventor is built on Kawa there might be hope for a Lisp on the mobile platform
但由于 AppInventor 是建立在 Kawa 上的,所以在移动平台上可能会有 Lisp 的希望
AFAIK, App Inventor is only using Kawa for code generation.
AFAIK,App Inventor 仅使用 Kawa 进行代码生成。
What other languages are already usable or make strides towards that?
还有哪些其他语言已经可用或正在朝着这个方向迈进?
Well, there's HTML5 (Javascript), which works OK in offline mode.
嗯,有 HTML5 (Javascript),它可以在离线模式下正常工作。
Or, there's PhoneGap (HTML+CSS+Javascript).
或者,还有 PhoneGap(HTML+CSS+Javascript)。
Or, there's Rhodes (Rails-esque apps in Ruby on the device).
或者,还有 Rhodes(设备上的 Ruby 中的 Rails 式应用程序)。
Or, there's Titanium Appcelerator Mobile (HTML+Javascript, but with Javascript hooks to render native UI widgets).
或者,还有 Titanium Appcelerator Mobile(HTML+Javascript,但带有 Javascript 钩子来呈现本机 UI 小部件)。
Or, there's Flash, at least for Android 2.2+.
或者,有 Flash,至少适用于 Android 2.2+。
Or, there's AIR...well, OK, that's still in pre-release.
或者,有 AIR ......好吧,那仍处于预发布阶段。
As Elfred noted while I was writing this, there is JRuby with Ruboto.
正如 Elfred 在我写这篇文章时所指出的,JRuby 和 Ruboto。
There are Bedrock, Corona, DroidScript, Flixel, MobiForms, MonoDroid, MoSync, Squeak, and SuperWaba.
有 Bedrock、Corona、DroidScript、Flixel、MobiForms、MonoDroid、MoSync、Squeak 和 SuperWaba。
There's C/C++ through the NDK, though that's mostly for adding extension libraries to a Java app more so than writing full-on native-code apps.
NDK 提供了 C/C++,尽管这主要是为了向 Java 应用程序添加扩展库,而不是编写完整的本机代码应用程序。
There's SL4A (formerly the Android Scripting Environment, or ASE), which is your gateway to Python, Perl, Lua, and other scripting languages. As of this moment, you cannot package these scripts up as APKs, but they're working on that.
有 SL4A(以前称为 Android 脚本环境或 ASE),它是您通往 Python、Perl、Lua 和其他脚本语言的门户。目前,您无法将这些脚本打包为 APK,但他们正在努力解决这个问题。
Now, none of these are going to give you precisely the look of a "regular" Android app. For those, you need a JVM language with ahead-of-time compilation. And there is no question that bog-standard Java Android apps are far and away the most numerous. But unlike some fruit-flavored operating systems that block this sort of thing, you have lots of places to experiment with alternatives to traditional Java coding with Android.
现在,这些都不会准确地为您提供“常规”Android 应用程序的外观。对于那些,您需要一种具有提前编译功能的 JVM 语言。毫无疑问,沼泽标准的 Java Android 应用程序无疑是数量最多的。但与阻止此类事情的某些水果味操作系统不同,您有很多地方可以尝试使用 Android 进行传统 Java 编码的替代方案。
Some balding guy is writing a book that is going to review all of these options, but that's only partially ready right now.
一些秃顶的家伙正在写一本书,将回顾所有这些选项,但现在只是部分准备好了。
回答by Elfred
回答by David
DroidScript is probably one of the easiest of the above mentioned development tools to use for Android development. Like Cordova you use JavaScript, but unlike Cordova you have the choice of using native Android GUI's or HTML5 to build your App interfaces.
DroidScript 可能是上述用于 Android 开发的最简单的开发工具之一。与 Cordova 一样,您使用 JavaScript,但与 Cordova 不同的是,您可以选择使用原生 Android GUI 或 HTML5 来构建您的应用程序界面。
Also you still have access to all the devices sensors/hardware without needing to import loads of complicated plugins. Plus you get the bonus of being able to develop actually on your mobile device if you need to (you can even build APK's and publish them from your device).
此外,您仍然可以访问所有设备传感器/硬件,而无需导入大量复杂的插件。此外,如果需要,您还可以在移动设备上进行实际开发(您甚至可以构建 APK 并从您的设备发布它们)。
I would say its very good for beginners or prototyping but perhaps not flexible enough for seasoned developers.
我会说它非常适合初学者或原型设计,但对于经验丰富的开发人员来说可能不够灵活。
回答by qwr
I have never used it, but Kotlinis a new language that runs on the JVM developed by JetBrains (the maker of Android Studio) that deserves a mention. The Kotlin website claims the language is 100% interoperable with Java and has a tutorial for Getting started with Android and Kotlinand Android Studio now actually comes with Kotlin support.
我从来没有用过,但Kotlin是一种运行在 JVM 上的新语言,由 JetBrains(Android Studio 的制造商)开发,值得一提。Kotlin 网站声称该语言与 Java 100% 可互操作,并提供了Android 和 Kotlin 入门教程,Android Studio 现在实际上支持 Kotlin。
回答by vikram
Xamarin Studio let's you build in C#/Mono and build apps for both Android and iOS. Now the presentation layers have to be implemented differently on both platforms, but for the ability to use C#, it's a big Win.
Xamarin Studio 可让您在 C#/Mono 中构建并构建适用于 Android 和 iOS 的应用程序。现在表示层必须在两个平台上以不同的方式实现,但对于使用 C# 的能力来说,这是一个很大的胜利。
回答by Bipin Paudel
You can build an android app with the knowledge of just Html/css/Js. So there is no need of Java to create an android applications. Visit here for some basic knowledge. [1]http://www.chromeearth.com/requirements-cordova-platform/
您可以仅使用 Html/css/Js 的知识构建一个 android 应用程序。因此不需要 Java 来创建 android 应用程序。访问这里了解一些基本知识。[1] http://www.chromeearth.com/requirements-cordova-platform/

