[ EN | US ] Is Batch Script still a good option? - Batch Script ainda é uma boa opção?

in HiveDevs3 months ago

Is Batch Script still a good option?

English version

Batch Script, Microsoft's scripting language, has been with the average Windows systems administrator since the early days of home and business computing, more precisely since MS-DOS, and it really was something almost mandatory for everyone who wanted to learn how to use systems Windows. But, currently, the scenario has changed, and companies, in general, no longer depend on Batch, although it is still one of the system's native tools. But is it still worth learning this archaic scripting language?

Firstly, we have to make it very clear that, even with the most outdated technologies, there will still be cases in which it can be useful to use, such as when administering legacy systems or making any changes to a standard Windows installation (without internet or anything else). , so the question is more whether it is worth the effort than whether it is of any use. Furthermore, I will limit myself to discussions about the Windows platform, without focusing on Unix systems or things that do not necessarily have any relation to the topic.

Lack of practical examples

The bulk of Batch Script's features do not have good examples, so you are restricted to documentation ( which doesn't have as many practical examples as would be ideal). Furthermore, most of the examples come from the MS-DOS and PC-DOS era, and may have discrepancies in both operation and syntax. Furthermore, the language syntax itself is not very intuitive for users of more modern scripting languages, such as Python, and does not support many data types, which brings us to the second problem.

The language is outdated

The bulk of the language's functions, such as loops or functions, use a GOTO-based syntax and separate files. Of course, terminal languages usually don't propose this, but even the Shell Script language has these functions. Furthermore, the data types within the language are few, and do not accurately reproduce the needs of a scripting language that can be easily used.

For example, what will you do when you have to use floating point in numbers? What about when you have to create a function to perform certain functions in the code? What if you have to create a key-attribute vector or an object? You'll see that you can use other languages.

Powershell

New versions of Windows aim to be completely compatible with Powershell and can even use it as the system's main shell. It is able to compensate for Batch Script's flaws and bring a modern approach to the Windows terminal. However, this also highlights the fact that even Microsoft itself is moving away from Batch Script, just as it previously did with VBScript.

Python

Python also enters this dispute, being a modern language, easy to use and you can even call Batch commands within a Python script. Furthermore, the language still maintains a much wider range of functions than Batch, such as RegEx support, and a package manager with all kinds of interesting utilities. Other than that, there is still a huge amount of examples and tutorials about the language and its varied uses, from managing Windows registries to creating web servers and tools of all types.

But, being the devil's advocate...

Being a main language was never the intention of Batch Script, but rather to perform small tedious tasks in a simple and practical way, and, although it doesn't have the same features as Shell Script, it fulfills its purpose well. Furthermore, it is an easy and simple language, which can be learned in a single day, and mastered in its entirety in less than a week (largely due to the lack of advanced resources, but also because it is actually a simpler language).

It was not created with the aim of creating complex graphic screens, but rather to call pre-installed resources in the system in a simple and practical way, and have its range of resources expanded. Furthermore, the evolution of Windows itself has always prioritized graphical interfaces to the detriment of interfaces via the command line, which explains why it has not evolved as much as other languages of this type, such as Shell Script.

So, when you always need to execute those three or four commands successively, you can use Batch Script for that, and create specific files to perform these actions, such as assembling the .jar file of a Java program, cleaning the cache of a project, installing certain dependencies, changing specific registries to perform certain functions, among others.

Conclusion

Although Batch Script is slowly falling into disuse, it is still an extremely useful tool for managing resources, especially for simple functions, such as executing sequential commands or specific tasks. Even so, it is still important to keep in mind that this language will not be your primary language (unless you administer a legacy server running MS-DOS or PC-DOS), but rather a complement for when you are working on Windows systems. This way, you can get the most out of your system in a simple and practical way.

So, if your goal is to choose a main language or opt for a multipurpose tool, Batch Script probably won't be worth the effort in learning, while other languages, such as Python and JavaScript, will be more useful. However, if your goal is to be a systems administrator specializing in Windows, or even if you intend to use Windows as your primary operating system as a programmer, it will probably be beneficial to learn.

Anyway, if you have absolutely nothing to do, it doesn't hurt to learn an extra tool, after all, you can never have too much knowledge, right? Yet another tool with such great historical importance, and such a vast number of possible applications.

Batch Script ainda é uma boa opção?

Versão em português

Batch Script, a linguagem de script da Microsoft, está acompanhando o administrador de sistemas Windows médio desde os primórdios da computação residencial e empresarial, mais precisamente desde o MS-DOS, e realmente era algo quase obrigatório para todos os que queriam aprender a usar sistemas Windows. Mas, atualmente, o cenário mudou, e as empresas, em um geral, não dependem mais do Batch, masmo que ainda seja uma das ferramentas nativas do sistema. Mas então ainda vale a pena aprender essa linguagem arcaica de script?

Primeiramente, temos que deixar bem claro que, mesmo nas tecnologias mais ultrapassadas, ainda vão existir casos em que pode ser útil a utilizar, como ao administrar sistemas legados ou fazer alguma alteração em uma instalação padrão do Windows (sem internet ou qualquer outra coisa), então o questionamento é mais se vale o esforço do que se tem alguma utilidade. Além disso, vou me limitar a discussões sobre a plataforma Windows, sem me ater a sistemas Unix ou a coisas que não necessariamente tem alguma relação com o tema.

Falta de exemplos práticos

O grosso das funcionalidades do Batch Script não possui bons exemplos, aí você fica restrito à documentação (que não tem tantos exemplos práticos quanto seria o ideal). Além disso, boa parte dos exemplos vieram da época do MS-DOS e do PC-DOS, e podem ter discrepâncias tanto em funcionamento quanto em sintaxe. Além disso, a própria sintaxe da linguagem não é muito intuitiva para usuários de linguagens de script mais modernas, como Python, e não suporta muitos tipos de dados, o que nos leva ao segundo problema.

A linguagem é ultrapassada

O grosso das funções da linguagem, como laços de repetição ou funções, usa uma sintaxe baseada em GOTO e arquivos separados. Claro que linguagens de terminal normalmente não se propõem a isso, mas até a linguagem Shell Script possui essas funções. Além disso, os tipos de dados dentro da linguagem são poucos, e não reproduzem com precisão as necessidades de uma linguagem de script que possa ser facilmente utilizada.

Por exemplo, o que você vai fazer quando tiver que usar ponto flutuante nos números? E quando tiver que criar uma função para realizar determinadas funções no código? E se tiver que criar um vetor chave-atributo ou um objeto? Vai ver que recorrer a outras linguagens.

Powershell

As novas versões do Windows tem como pretensão serem completamente compatíveis com o Powershell e até podem o utilizar como shell principal do sistema. Ele é capaz de compensar as falhas do Batch Script e trazer uma abordagem moderna ao terminal do Windows. Porém, isso também evidencia o fato de que até mesmo a própria Microsoft está deixando de lado o Batch Script, assim como fez anteriormente com o VBScript.

Python

O Python também entra nessa disputa, sendo uma linguagem moderna, fácil de usar e você ainda pode chamar comandos de Batch dentro de um script Python. Além disso, a linguagem ainda mantém uma gama de funções muito maior que o Batch, como suporte a RegEx, e um gerenciador de pacotes com todo o tipo de utilitários interessantes. Fora isso, ainda tem uma quantidade enorme de exemplos e de tutoriais sobre a linguagem e seus usos variados, desde gerenciar registros do Windows até criar servidores web e ferramentas de todos os tipos.

Mas, sendo o advogado do diabo…

Ser uma linguagem principal nunca foi o intuito do Batch Script, e sim executar pequenas tarefas maçantes de forma simples e prática, e, embora não tenha os mesmos recursos do Shell Script, cumpre bem o seu propósito. Além disso, é uma linguagem fácil e simples, que pode ser aprendida em um único dia, e dominada em sua totalidade em menos de uma semana (muito pela falta de recursos avançados, mas também por ser realmente uma linguagem mais simples).

Ela não foi criada com o objetivo de criar telas gráficas complexas, mas sim de chamar recursos pré-instalados no sistema de forma simples e prática, e ter sua gama de recursos expandida. Além disso, a própria evolução do Windows sempre priorizou as interfaces gráficas em detrimento de interfaces via linha de comando, o que explica o porquê de não ter evoluído tanto quanto outras linguagens do tipo, como o Shell Script.

Então, quando você precisa executar sempre aqueles três ou quatro comandos de forma sucessiva, você pode usar o Batch Script para isso, e criar arquivos específicos para realizar essas ações, como para montar o arquivo .jar de um programa em Java, limpar o cache de um projeto, instalar certas dependências, alterar registros específicos para realizar determinadas funções, entre outros.

Conclusão

Apesar do Batch Script estar caindo em desuso aos poucos, ainda é uma ferramenta extremamente útil para gerenciamento de recursos, ainda mais para funções simples, como executar comandos sequenciais ou tarefas específicas. Mesmo assim, ainda é importante ter em mente que essa linguagem não será sua linguagem principal (a menos que você administre um servidor legado rodando MS-DOS ou PC-DOS), mas sim um complemento para quando você estiver trabalhando em sistemas Windows. Dessa forma, é possível extrair o máximo possível de seu sistema de forma simples e prática.

Então, caso seu objetivo seja escolher uma linguagem principal ou optar por uma ferramenta multiuso, provavelmente o Batch Script não vai compensar o esforço em aprender, enquanto outras linguagens, como Python e JavaScript serão mais úteis. Entretanto, se seu objetivo é ser um administrador de sistemas especializado em Windows, ou mesmo se pretende usar Windows como seu sistema operacional principal como programador, provavelmente será proveitoso aprender.

De qualquer forma, caso você esteja sem absolutamente nada para fazer, não custa nada aprender uma ferramenta a mais, afinal, conhecimento nunca é demais, não é mesmo? Ainda mais uma ferramenta com uma importância histórica tão grande, e uma quantidade tão vasta de aplicações possíveis.

Sort:  

Obrigado por ter compartlhado essa postagem na Comunidade Brasil.

Metade das recompensas dessa resposta serão destinadas ao autor do post.

Vote no @perfilbrasil para Testemunha Hive.

Yay! 🤗
Your content has been boosted with Ecency Points, by @arthursiq5.
Use Ecency daily to boost your growth on platform!


Your post was manually curated by @KaibaGT.
banner_hiver_br_01.png

Delegate your HP to the hive-br.voter account and earn Hive daily!

🔹 Follow our Curation Trail and don't miss voting! 🔹

Obrigado por promover a Língua Portuguesa em suas postagens.

Vamos seguir fortalecendo a comunidade lusófona dentro da Hive.

Metade das recompensas dessa resposta serão destinadas ao autor do post.

Vote no @perfilbrasil para Testemunha Hive.