简体   繁体   English

有通用语言吗?

[英]Is there a universal language?

We're designing an app that will run on Windows, OSX, iOS, and Androids. 我们正在设计一个可在Windows,OSX,iOS和Androids上运行的应用程序。 It would be really nice to at least have most of the code in a single language rather than having to use Objective C for the Apple versions, C# or C++ for Windows, and Java for Android. 至少在单一语言中使用大部分代码而不是必须使用Objective C用于Apple版本,C#或C ++用于Windows,以及Java用于Android,这将是非常好的。

We were looking at Flex (with all of its problems) as a way to avoid having to use a different language for each version, but Adobe has thrown in the towel and in the long run that's not going to do the job. 我们正在考虑将Flex(及其所有问题)作为一种避免为每个版本使用不同语言的方法,但Adobe已经抛弃了这一点,从长远来看,这是不可能的。 Java used to promise to be universal, but it looks like Apple no longer supports it as a part of the distributed OS, and as far as I can tell Microsoft never supported it. Java曾经承诺是通用的,但看起来Apple不再支持它作为分布式操作系统的一部分,据我所知,微软从未支持它。 We don't want our users to have to download and install something just so they can use our app. 我们不希望我们的用户必须下载和安装一些东西,以便他们可以使用我们的应用程序。

Is there a solution? 有解决方案吗? Or are we stuck with building the app in multiple languages? 或者我们是否坚持用多种语言构建应用程序?

HTML + css + JavaScript! HTML + css + JavaScript!

Run your app on a standard web server. 在标准Web服务器上运行您的应用程序。 All of the above have standards compliant web browsers, all of the above support JavaScript and AJAX. 以上所有都具有符合标准的Web浏览器,所有这些都支持JavaScript和AJAX。 The only thing that really varies is screen size and this can easily be dealt with by using a custom .css file for each target browser. 唯一真正变化的是屏幕大小,这可以通过为每个目标浏览器使用自定义.css文件轻松处理。

You could host a web application on a server and use the app browsers to interact with the application. 您可以在服务器上托管Web应用程序,并使用应用程序浏览器与应用程序进行交互。

Although not a native application, all devices would be able to use it. 虽然不是本机应用程序,但所有设备都可以使用它。

The downside is that server connectivity would be required, however this may not be an issue. 缺点是需要服务器连接,但这可能不是问题。

“全球”语言最有可能使用虚拟机,所以你无法逃避“用户必须下载和安装一些东西,以便他们可以使用该应用程序”...我认为Java是你最好的选择,如果你不我不想处理编译成本机代码的语言问题。

You could use C# on all those platforms: 可以在所有这些平台上使用C#:

(If you ever wanted to write an app for Windows Phone 7, you'd be fine there too.) (如果您曾经想为Windows Phone 7编写应用程序,那么您也可以。)

Of course the UI part will have to change significantly between different platforms, and I doubt that it'll be particularly seamless , but it's worth considering at least. 当然,UI部分必须在不同平台之间发生显着变化,我怀疑它会特别无缝 ,但至少值得考虑。

i am not very sure, but i have heard python is a universal language. 我不太确定,但我听说python是一种通用语言。 I have tried this with both mac and windows, not sure about the other plactforms 我用mac和windows试过这个,不确定其他的plactforms

I believe C++ code can be run on all those platforms: Windows has full support for it; 我相信C ++代码可以在所有这些平台上运行:Windows完全支持它; Android has NDK; Android有NDK; and you can use Objective-C++ on iOS (and I assume OSX as well!). 你可以在iOS上使用Objective-C ++(我也假设OSX!)。

I wouldn't go so far as to claim it's the best option, but I figured it was worth mentioning. 我不会说它是最好的选择,但我认为值得一提。

Ultimately a lot will depend on the nature of the app you are developing. 最终,很大程度上取决于您正在开发的应用程序的性质。 If it's a large app I'd strongly suggest doing some detailed consultation with someone with experience in the area: because of the vagaries of the different platforms, this is one area where experience counts for an awful lot. 如果它是一个大型应用程序,我强烈建议与在该领域有经验的人进行一些详细的咨询:由于不同平台的变幻莫测,这是一个经验非常重要的领域。

There are multiple options, depending on your app requirements: 有多种选择,具体取决于您的应用程序要求:

First , Web app, as many said before. 首先 ,Web应用程序,正如之前所说的那样。 It is the same as the greatest common divisor - very small 它与最大公约数相同 - 非常小

Second Build the core of your app in c/c++, and for the interface use a framework that fits your needs. 第二 ,在c / c ++中构建应用程序的核心,并为界面使用符合您需求的框架。 These suggestions are really, really great. 这些建议真的很棒。 You can even develop the interface separately for each platform, in Java for Android, Objective C for iOS, etc 您甚至可以为每个平台单独开发界面,包括Android for Java,Objective C for iOS等

Do not forget that never, ever you will be able to make the same code run on all platforms. 不要忘记,从来没有,你将能够在所有平台上运行相同的代码。 There will always be some part with #define MAC or #define ANDROID . 始终会有一些#define MAC#define ANDROID It's just impossible to run identical code, even for the simplest app. 即使对于最简单的应用程序,也无法运行相同的代码。

Unless is a 除非是

void main(void){}

Even a web app will have a code like 即使是网络应用也会有类似的代码

if(browser()==Safari) {}
else {}

I think the answer depends on what kind of app you are going to build. 我认为答案取决于您要构建的应用程序类型。

If it's like twitter, a good web interface is the answer. 如果它像推特一样,那么一个好的网络界面就是答案。 Each client just need to handle the GUI work, with the platform's own language and lib. 每个客户端只需要使用平台自己的语言和库来处理GUI工作。

If it's a game, no communication with server. 如果是游戏,则不与服务器通信。 I prefer C and a script such as Lua to build the core of your app. 我更喜欢C和像Lua这样的脚本来构建应用程序的核心。

"Is there a solution? Or are we stuck with building the app in multiple languages?" “有解决方案吗?还是我们坚持用多种语言构建应用程序?”

No, no solution for this. 不,没有解决方案。 We use different languages because they run in different platforms. 我们使用不同的语言因为它们在不同的平台上运行 Universal languages, such as HTML, have lots of constrains because to be universal you must cut all the differences. 通用语言,例如HTML,有很多限制,因为要普及,你必须削减所有的差异。 It is the intersection set of all platforms, which is very very small . 它是所有平台的交集,非常小。

Using HTML and Javascript is likely to be the best approach. 使用HTML和Javascript可能是最好的方法。 Another option which runs on these platforms is Java FX 2.0. 在这些平台上运行的另一个选项是Java FX 2.0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM