最合适的平台独立开发语言
一个项目迫在眉睫,我将编写的一些代码可以部署在潜在客户碰巧拥有的任何硬件上。 它是一个 24/7 运行的业务应用程序,因此我设想大多数主机将是服务器类型的机器,但较小的客户端可能只拥有一台简单的 PC。
关于我将要编写的代码的更多详细信息:
将没有 GUI。
它将需要通过以太网与另一个定制的“黑匣子”设备进行通信。
它将需要与网络上某处的 MySQL 数据库进行通信。
我没有任何性能问题,因为 a) 与黑匣子的通信次数会很少,大约每秒 1 次,并且交换的数据量会很小(每次大约 1K),b)数据库的读/写次数会很小,大约每分钟 5 次,并且交换的数据量也会很小,并且 c) 需要执行的处理相当简单。
我所做的一切都不是非常“接近金属”,所以我不想使用太低级的语言。 易于开发和易于部署是我的主要优先事项。
我并不期望有一个完美的解决方案,所以我可以忍受诸如 Windows 机器与 Linux 机器的配置文件等略有不同的情况。我想避免编译如果可能的话,为每台主机提供软件。
我会重视您对您认为最合适的开发语言的想法。
干杯,
吉姆
A project is looming whereby some code that I will be writing may be deployed on any hardware that potential clients happen to have. Its a business application that will be running 24/7 so I envisage that most of the host machines will be server type boxes but smaller clients might, for example, just have a simple PC.
A few more details about the code I will be writing:
There will be no GUI.
It will need to communicate with another bespoke 'black box' device over an Ethernet network.
It will need to communicate with a MySQL database somewhere on the network.
I don't have any performance concerns as a) the number of communications with the black box will be small, around 1 per second, and the amount of data exchanged will be tiny (around 1K each time), b) the number of read/writes with the database will be small, around 5 per minute, and again the amount of data exchanged will be tiny and c) the processing that needs to be performed is fairly simplistic.
Nothing I'm doing is very 'close to the metal' so I don't want to use languages that are too low level. Ease of development and ease of deployment are my main priorities.
I'm not expecting there to be a perfect solution so I can live with things like, for example, having to have slightly different configuration files for Windows machines than for Linux boxes etc. I would like to avoid having to compile the software for each host machine if possible though.
I would value your thoughts as to which development language you think is most suitable.
Cheers,
Jim
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
Python 或 Java。 它们都很容易部署在您提到的服务器环境和桌面环境(即 Linux/Solaris 和 Windows)上。
Perl 也是一个不错的选择,但这取决于您对 Perl 的了解程度、维护您代码的其他人对 Perl 的了解程度,以及足够精通 Windows Perl 版本安装的桌面用户数量。
由于 Java 通过 Jython 支持 Python,因此我自己会满足 JVM 要求,但我个人会一直使用 Java 应用程序来支持您所描述的这样的系统。
Python or Java. They both are easy to deploy on both the server environments and the desktop environments you mention - i.e., Linux/Solaris and Windows.
Perl is also a nice choice, but it depends on how well you know Perl, how well other people that will maintain your code know Perl, and number of desktop users that are savvy enough to handle an install of the Windows Perl version(s).
As Java supports Python via Jython, I'd go with a JVM requirement myself, but I'd personally go with a Java application all the way for such a system you describe.
我会说使用 C 或 C++。 它们是平台无关的,尽管您必须针对每个平台进行编译。
或者使用Java。 它在虚拟机中运行,因此是真正的跨平台,并且不像 C 那样慢。
I would say use C or C++. They are platform independant, though you will have to compile for each platform.
Or use Java. That runs in a Virtual Machine so is truely cross platform and not a slow level as C.
我个人会选择一种不错的脚本语言,例如 Python、Perl 或 Ruby。 所有这些都具有良好的库支持,可以轻松地与本地和远程 MySQL 数据库通信,并且非常独立于平台。
I'd go with a decent scripting language such as Python, Perl or Ruby personally. All of those have decent library support, can communicate easily with both local and remote MySQL databases and are pretty platform independent.
我们首先需要知道的是你已经具备哪些语言技能? 这可能是您理想选择的一个相当大的决定因素。
如果我这样做,我会建议使用 Java,原因如下:
另请注意,如果您更熟悉 Ruby 或 Python,则可以在 JVM 上用其他语言编写它。
The first thing we need to know is what language skills you already have? This is likely to be a fairly big determiner of what choice you would ideally make.
If I was doing this I'd suggest Java for a couple of reasons:
Also note that you could write it in another language on the JVM if your more comfortable with Ruby or Python.
听起来 Perl 或 Python 非常适合这个要求。 您选择哪一个取决于构建和支持系统的人员的专业知识。
Sounds like Perl or Python would fit the bill perfectly. Which one you choose would depend on the expertise of the people building and supporting the system.
关于脚本语言与 Java 的比较,我对使用 Java 开发命令行工具感到失望。 你不能直接执行它们,你必须(1)编译它们并(2)编写一个shell脚本来执行jar文件,这个脚本可能因平台而异。 我推荐 Python,因为它可以在任何地方运行,并且有一个很棒的 SQL 库, mysql-蟒蛇。 该库可以在 Windows 和 Linux 上使用。 Python 的样板文件也少了很多,你将编写更少的代码来完成同样的事情。
编辑:当我谈论 JAR 是否可执行时,我谈论的是它们是否可以通过操作系统直接执行。 当然,如果您的文件管理器已设置为这样做,您可以双击它们来运行它们。 但是,当您在终端窗口中并且想要运行 java 程序时,您必须使用“java -jar myapp.jar”而不是通常的“./myapp.jar”。 在 Python 中,只需运行“./myapp.py”,而不必担心编译或类路径。
On the subject of scripting languages versus Java, I have been disappointed with developing command line tools using Java. You can't directly execute them, you have to (1) compile them and (2) write a shell script to execute the jar file, this script may differ between platforms. I recommend Python because it runs anywhere and it's got a great SQL library, mysql-python. The library is ready to use on Windows and Linux. Python also has a lot less boilerplate, you'll write fewer lines of code to do the same thing.
EDIT: when I talked about JARs being executable or not, I was talking about whether they are directly executable be the OS. You can, of course, double click on them to run them if your file manager is set up to do so. But when you're in a terminal window and you want to run a java program, you have to "java -jar myapp.jar" instead of the usual "./myapp.jar". In Python one just runs "./myapp.py" and doesn't have to worry about compiling or class paths.
如果所有平台都是标准 PC(或至少运行 Linux),则应考虑 Python。 如果您的版本不存在包,您可以自行编译它。 此外,您可以轻松地从标准库中删除不可用和不需要的内容(例如声音支持)。
Python不需要大量资源,它很容易学习和阅读。
如果你了解 Perl,你可以尝试一下。 如果您不是每天都使用 Perl,那就不要使用。 Perl 语法很难记住,一周后,您会想知道代码做了什么,即使是您自己编写的。
If all platforms are standard PCs (or at least run Linux), then Python should be considered. You can compile it yourself if no package exists for your version. Also, you can strip the standard library easily from things that aren't available and which you don't need (sound support, for example).
Python doesn't need lots of resources, it's easy to learn and read.
If you know Perl, you can try that. If you don't use Perl on a daily basis, then don't. The Perl syntax is hard to remember and after a week, you'll wonder what the code did, even if you wrote it yourself.
Perl 可能对您有帮助,因为它可用于许多平台,并且您只需安装 CPAN。
Perl may be of help to you as it is available for many platforms and you can get almost any functionality by simply installing modules from CPAN.