Other What's the go-to scripting language to learn for general purpose-scripting on freebsd?

I used to read some people saying bad things about Tcl, sometimes repeating some very old and wrong ideas.
Decided to give it a try.
Compared its speed against another candidate, Raku (Perl 6) and for my test case, Tcl single threaded was as fast as Raku multi-threaded.
TCL manufactured my TV and the OS is Roku :cool: Tcl/Raku might be interesting on search results :p

I don't like Python at all. I find the indentation of the lines being part of the syntax too avant-garde for my tastes.
Google SRE wanted Python experience; I didn't understand the appeal of wrapping OS commands/management into higher-level generic Python scripting and thus didn't have the desire to want to learn Python (I can tune the kernel for network and automate the OS config through bash/sh scripts which seems like the basics for site reliability; Python seems like slower abstraction for the same objective but why introduce Python vs native OS methods?)

Maybe Python's better for general scripting cross-OS, but Java's my preference for one language running everywhere :D
 
data speaks a different language than your personal experience: https://survey.stackoverflow.co/2025/technology#2-programming-scripting-and-markup-languages

Anyway, the OP will probably find out after reading a few scripts if he is more a Perl or a Python guy ;-)
In what respect? If I'm reading that graph right, a bunch of people think they like Python, but don't actually use it. I mostly pointed to point out that it's far better to know some programming, at least enough to know what sort of debug code to include and how to work with dynamic types before trying Python. The syntactic white space sucks, but at least there are pre-processors out there that allow people to code in Python without having to worry about that. It's a silly thing to do and from what I can tell only about 2% of all programming languages have syntactic white space.
 
It's not a bad language for some uses, but most of the things that it's good for use C libraries anyways and there's no inherent reason why they need to be for Python.
I second this.
I believe some of this comes from the refusal posture against C.

There are several programming languages particulary created to be beginner's languages.
What their creators all understood is, which programming language you start on is pretty secondary, as long as it's not too far from "real" languages, and does not teach bad programming habits soon need to be unlearned again. Nobody sticks exclusively to the one language first learned, only.
Even if it makes a lot of sense to chose a programming language for the start which can also be used on real projects later, a beginner's language needs to be at first newbie friendly. Already slightly advanced, but especially hardcore hackers may quickly miss, that for a beginner already most basic things are already hard to grasp: code is written with a text editor. what is a text editor? the code (file) needs to be compiled; and corrected ("debugged") until it's errorless. then executed. and to understand basic core concepts like what variables are. which type is for what. I experienced for many i=i+1 is really hard to grasp, because nobody explained to them, it's not an equation seen by the computer at the same time, but an allocation done in at least two steps.
First things need to be learned are conditions, branches, loops, and why there are different kinds of loops, and not to be concerned about garbage collection and memory safety.

Most programming beginners are also texteditor noobs. When they not only have to grasp the concepts of paranthesis, and command lines, their separation and termination not by signs, but by how the text is formatted, and then wonder why their shit does not run while it's obviously errorless after checking it the 30th time character by character, then learn the hard way, indents can come from tabs and spaces, while exactly 4 spaces are needed or it's a syntax error... I can understand when not a few then turn their back on programming before they even actually started.

While C can become complex, tricky and needed to be handled thoughtfully with deliberation at advanced programming levels, ain't for sure not suitable for everything (none is), and it can be discussed (among pros) on which real world projects it can be used, or shall not, and why, IMO it's a very suitable beginner's language: Its syntax is easy, short, simple, and clear. And many languages copy their syntax from C. Even if one does not dig in deeper and decides not to keep on programming in it (for whatever reasons), it teaches you the most important basics with the least fiddle-faddle around - especially because it's so close to machine level. Anybody who not only owns a copy of the KR for just being decorative in the bookshelf, but actually worked consequently through it - not just peeked at some of the excersises, got a quick idea about how to solve that, and judged it as simple and trivial, but actually did them (all), would agree the KR provides a very good, total programming newbie friendly, and at the same time fundamental, solid beginners class on programming at all.

But to get back to topic:
C ain't no scripting language.
Automation of the things you do with your OS and filesystems one better does not do in C, but in a more suitable (scripting) language, sure.
Apart from especially (ba)sh sometimes is pretty weird, especially when one brings experience from C (or others) it becomes even more weird, those are also programming languages. So it's better to bring some basic programming understanding before to start on such.

Don't get me wrong.
I don't say: "First learn C before you touch anything else." That's BS. Neither I'm saying everybody has to learn C.
All I'm saying is:
While Python is a very good and very powerful language - no question - I'm also not that convinced like many others that it's a good choice for a beginner's language. While C may be not a good choice to be the only one for everything in the long term to me it's one of the better choices for on starting to learn programming with.
But again: Learning to program and learning a language are not the same.

So, pick one language to get at least the fundamental basics, to get the idea how programs work by principle. It doesn't really matter which language you pick. Learning the basic concepts of programming is by far not the same as to dig deep into a language. There are many to chose from. And sure, some are more easy to learn than others, and as I said above, it makes sense to better pick one widely used. But above all: Look at some, and pick the one, which feels rights for you, above all you feel most comfortable with. You can change to another language anytime - and sooner or later you will anyway. Or, correct: Add additionally languages to your personal portfolio.
It does not have to be the one the majority agrees with - this also changes every decade. What is currently widely agreed on, sometimes even hyped, is not just by reasons only, but also kind of a fashion. Anybody >50 looking back could name several languages which at a time were THE only ones must be learned.
Always beware of dogmas are not axioms.

After all, fundamental programming basics are mostly independent of a certain language. Which to me is a reason to chose a language for the very start which bothers as least as possible with language specific idiosyncracies.

Programming is like writing books. It cannot be learned in classes. Classes teach you the grammar and the technique how to combine letters to words, and words to sentences, but not how to write a thrilling novel, or a funny comedy. This comes by experience, by doing it yourself, only.
If you just need to pass a programming class, you don't give a shit anyway. But if you wanna be a programmer, you better already know some programming before you even enter any class. Which language the class teaches doesn't really matter then. :cool:
 
data speaks a different language than your personal experience: https://survey.stackoverflow.co/2025/technology#2-programming-scripting-and-markup-languages

Anyway, the OP will probably find out after reading a few scripts if he is more a Perl or a Python guy ;-)
They combine scripting, programming and mark up language based on being "admired". Whatever that might mean for the given context.

I admire Ruby and think it has some wonderful concepts but I've yet to run into a situation where I've found it worth my time to learn its intricacies when I need to get something done.
 
I admire Ruby and think it has some wonderful concepts but I've yet to run into a situation where I've found it worth my time to learn its intricacies when I need to get something done.

Continuations can be handy and do things you don't get otherwise. But there isn't much demand for them, and preparing a language to have continuations puts limits of speed optimizations.
 
I've always found them "complex",
Code:
(ql:quickload :cl-cont)
(cl-cont:with-call/cc
  (let ((x (cl-cont:call/cc (lambda (k) (setf *saved-k* k) 10))))
    (+ x 5)))
 
The syntactic white space sucks,
And for that reason alone, apart from anything else, I could never take python seriously in an industrial development or production environment. Guido had an idea that eliminating the block start/end keywords from the language would make python easier for beginner students to learn, as a teaching language for uni CS courses, which was its original purpose. Someone said "python is more modern than perl"... but they actually date from around the same time, they are both about the same age. I remember they both came out around the late 80s. Python evolved out of academic CS teaching and Perl evolved from a need for a better way to do unix admin scripting, before it briefly became popular as a way to write websites in the dot-com boom; but as a way to write websites perl was in turn rapidly superceded by php (which itself started life as a perl library), and the main use of perl went back to being a unix scripting tool.
 
Python evolved out of academic CS teaching and Perl evolved from a need
Even while Perl was not my first choice for a beginners language neither, I find it way better than its reputation.
In my eyes Perl is bad-mouthed, was simply dumped for no real reason, but maybe because of arrogance or ignorance by those who wanted to hype another language (Python?) Computer universe is full of such petty-minded, religious hillbilly brawls, who when they finally learned one thing trash anything else they don't know. (People prefer to have as many choices as possible. But when there actually are real choices, they are overchallenged. And then they become aggressive, like any other kind of chimp.🙈)
Most argument against Perl is, it produces hard to read code. With almost any language you can do obfuscation. So with Perl you can also create very readable code. One of the powers of Perl come from the possibility to write efficient code, which is hard to read, not matter which language, and another point computer people can start the next brawl on. While personally I differ between code I write for myself, and code I write in cooperation with others.
Since I'm not too lazy to refuse documenting my code properly, I can afford efficient code. 😁
Personally I find obfuscated but well explained (documented) code more comprehensible, than easy to read but completely undocumented code. But that's my very own personal opinion, of course.

Perl is easy to learn, also not suitable for everything (none is), but a very good supplement to sh scripts. If I had to chose between Python and Perl I personally prefer Perl (knowing I'm in the minority.)
I started on Perl many years back when I still used Windows, before "power-shell" (sorry, but to me that's a joke for itself, a one-worder.) I never gave "power-shell" a closer look (I left Windows world before "power-shell"), but I bet a crate bavarian beer, Perl is the better choice anyway.
 
what's the go-to scripting language that evreybody endorses on freebsd and maybe the other bsd's in general too ?

For me its POSIX sh(1) with or eventually sed(1) or awk(1) scripts where it fits better.

I wrote all my tools with POSIX sh(1) like:
- beadm(8)
- automount(8)
- lsblk(8)
- sensors(8)
- ufsbe(8)
- jmore(8)

... and about learning that POSIX sh(1) I wrote here:

- https://vermaden.wordpress.com/2021/09/13/ghost-in-the-shell-part-6-learn-shell-scripting/
 
perl was in turn rapidly superceded by php (which itself started life as a perl library)
php is another superfluous language.

Even while Perl was not my first choice for a beginners language neither, I find it way better than its reputation.
In my eyes Perl is bad-mouthed, was simply dumped for no real reason
With perl and Tcl there were enough choices. Perhaps Ruby as 100% object oriented is more an alternative than python.
 
I can't wait to read this today.
I'm glad alot of advanced users joined the discussion . This post will also serve a lot of new users in the future for sure.
Thank you so much.
Whatever you choose, just start with smaller tasks first. Part of the practice of scripting starts with identifying what you need to do and the script utility can be rather helpful in terms of capturing the things that you're doing to later add logic and variables to in order to have a script.

That's regardless of what language you choose, I'm not sure that I'd recommend starting with something like Bourne shell scripts, but it is doable and quite useful, just start small and get used to putting in debugging information with whatever you choose.
 
kind of followup on hedwards what language (not just scripting) can be driven by the requirements and the scope. I've seen scripts (bash) that are multi-thousand lines. Trying to debug is friggin next to impossible.

The start small is very good advice.
 
For me its POSIX sh(1) with or eventually sed(1) or awk(1) scripts where it fits better.

I wrote all my tools with POSIX sh(1) like:
- beadm(8)
- automount(8)
- lsblk(8)
- sensors(8)
- ufsbe(8)
- jmore(8)

... and about learning that POSIX sh(1) I wrote here:

- https://vermaden.wordpress.com/2021/09/13/ghost-in-the-shell-part-6-learn-shell-scripting/
I've written scripts in sh and bash, sure.
But I compare sh, bash to C. They're full of pitfalls. sh and bash have so many rules to follow that it's very unproductive for me.
There's where Tcl shines. Only has twelve rules. "Everything is a string", so no issues dealing with strings like sh or bash.
I read many individuals praising Lisp. Tcl is like Lisp in the regularity of the grammar. But it's simpler.


One other scripting language (and not only a language, also a protocol) I'm curious to learn someday is kermit.
For automation with remote systems should work wonderfully
It's simple, very different from the heavy weight and complex mainstream Ansible.
Kermit works in many systems and platforms, it's easy to compile. I just wonder how fast do executions compare to the programming languages mentioned in this topic.
 
When I think about it, I'd probably start with bourne shell scripts and then stop when I hit the point of needing arrays and switch to something else. The reason being that the early stuff like variables, conditionals and looping through a directory aren't that hard, but it gives you a few tools that you can later on use to do things like automate setting up your initial scripting environment for more flexible languages that allow you to do more.

The other thing that I haven't seen anybody mention, is that for some of this stuff you can create your own port to drag in all the stuff that you commonly install when setting up a new computer. I haven't personally done so, but it's on my list of stuff to do and writing a script to put the meta port into the ports directory is probably one of the easier things to do with a script.
 
The other thing that I haven't seen anybody mention, is that for some of this stuff you can create your own port to drag in all the stuff that you commonly install when setting up a new computer. I haven't personally done so, but it's on my list of stuff to do and writing a script to put the meta port into the ports directory is probably one of the easier things to do with a script.
You are not wrong here, but the easier thing to do is create/keep a "pkg prime-list".
Example (very short) based on what I do. I prefer tcsh as my shell, WindowMaker as my graphical environment, emacs, DarkTable, Gimp, xpdf, claws-mail.
So my "prime-list" for this means I would do:
pkg install tcsh windowmaker gimp emacs darktable gimp xpdf claws-mail

If you keep your home directory separate from a system keep your primelist in a file, then just using pkg and base install you recreate your preferred.

Heck it's very useful when you are creating a new system. Take your existing system, run pkg prime-list > mypackages.lst put that on a USB drive install your new system then "for I in `cat mypackages.lst`; do pkg install $I ; done"
 
Back
Top