简体   繁体   English

我应该制作Linux Shell脚本还是Java程序?

[英]Should I make Linux Shell Script or Java program?

I need to generate multiple databases to SQL, so I need script/program to automatically generate those to SQL and generate files to jboss server. 我需要为SQL生成多个数据库,所以我需要脚本/程序来自动将这些数据库生成为SQL并生成文件到jboss服务器。 Our client server is running in Linux, but I develop on Windows machine. 我们的客户端服务器在Linux上运行,但是我在Windows计算机上开发。 Should I make script with as Linux script or write Java program that could make same things? 我应该用Linux脚本制作脚本还是编写可以做同样事情的Java程序?

A shell script will usually be a lot easier and quicker to develop. Shell脚本通常会更容易,更快速地开发。

Write a Java app if you need a robust, user ready application. 如果您需要功能强大且易于使用的应用程序,请编写Java应用程序。 That's not the case here so just make your life easy. 这里不是这种情况,所以让您的生活变得轻松。

Unless it is very simple it is far less painful to do it in Java. 除非它非常简单,否则用Java来完成它要痛苦得多。 So I think you should write a Java program. 所以我认为您应该编写一个Java程序。

But have you considered writing it in Perl or Python? 但是您是否考虑过用Perl或Python编写它? These are very powerful scripting languages and the resulting program can be much shorter and/or more concise than a corresponding Java program. 这些是非常强大的脚本语言,并且与相应的Java程序相比,生成的程序可以更短和/或更简洁。

我经常将shell脚本用于一次性任务,例如生成大量testdata。

The Linux shell script languages are easy and quick to develop for simple things. Linux Shell脚本语言可以轻松快速地开发简单的事物。 They are very easy to maintain because they're pure text, interpreted by the shell. 它们非常易于维护,因为它们是纯文本,由Shell解释。

They are painful to use for anything more complex than a few dozen lines of code. 除了几十行代码之外,它们很难用于任何复杂的事情。 They aren't proper programming languages. 它们不是正确的编程语言。 If you have any text substitution or calculation of sizes, it becomes difficult to write. 如果有任何文本替换或大小计算,将很难编写。

If you're doing only directory creation and file copies, use a shell script. 如果仅执行目录创建和文件复制,请使用Shell脚本。

Java programs are hard to develop because they require compiling (and perhaps a complete IDE). Java程序很难开发,因为它们需要编译(也许需要完整的IDE)。 They are hard to maintain because they are compiled. 它们很难维护,因为它们已被编译。 You can use properties to enhance maintainability, but that's quite a bit more programming. 您可以使用属性来增强可维护性,但这需要更多的编程。

Java programs are great for things that are complex. Java程序非常适合复杂的事情。 If you have a lot of text substitution, or calculation, Java works out better. 如果您有大量的文本替换或计算,Java会更好地工作。 Java is a proper language with lots of features for doing lots of things. Java是一种适当的语言,具有许多功能,可以完成很多事情。

You have a middle ground: the flexibility of scripting, the sophistication of a full programming languages. 您有一个中间立场:脚本编写的灵活性,完整的编程语言的复杂性。 Tools like Groovy or Python are "dynamic" languages -- they are very easy to write and maintain -- but they're also full programming languages, not just the shell. 诸如GroovyPython之类的工具是“动态”语言,它们非常易于编写和维护,但它们也是完整的编程语言,而不仅仅是shell。

If your script involves any text manipulation or calculation, you might want to consider Groovy or Python instead of the shell or Java. 如果您的脚本涉及任何文本操作或计算,则可能需要考虑使用Groovy或Python而不是Shell或Java。

Beware what you build, as it will last a lot longer than you think. 当心您构建的内容,因为它的持续时间比您想象的要长得多。

If the effort to code it either way is roughly equal, then code it in the language which is most widely used by your organization. 如果以任何一种方式进行编码的工作量大致相等,则可以使用组织中使用最广泛的语言进行编码。

One thing I see over and over at companines is the "wow, I can code this using shiny new (or shiny old) technology BZUP12G with Frammoplatzes". 我在陪伴中一遍又一遍地看到的一件事是“哇,我可以使用带有Frammoplatzes的闪亮的新(或闪亮的旧)技术BZUP12G对此进行编码”。 This does a disservice to the rest of the development team, who now have to learn BZUP12G with Frammoplatzes in order to modify what got built. 这对其余开发团队不利,他们现在必须学习Frammoplatzes的BZUP12G才能修改所构建的内容。 Working to keep the basic set of technologies on which your application is constructed to a reasonably small set is a really good idea. 努力将构建应用程序所依据的基本技术集保持在相当小的范围内,这确实是一个好主意。

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

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