Why compiling a script is bad
1. Or, why greycat yelled at you when you asked for a script compiler
Consider the shell script. What are its properties? What are its strengths and weaknesses?
- Simple, easily understood
- Quick to write
- Doesn't take up much disk space
- Reasonable chance of working on multiple operating systems without modification, if you know what you're doing
- Slow execution (typically)
- No sane or robust access to floating point math, complex data structures, database query results, etc. (depending on language)
- Shebang line must be edited for each target system
Of course, I'm assuming a properly-written shell script. I therefore don't include things like "prone to newbie syntax and logic errors", because that's characteristic of any kind of programming.
Take a look at that first strength I listed again: Simple, easily understood. What does that imply? For starters, it implies that people can look at it!
If you compile a shell script, you're doing so for one of two reasons:
- You want it to run faster, or
- You want to hide it from people.
Now, take a look at this page you're reading. What is it? It's a rant. Where is it? It's on some guy's wiki. What's a wiki? It's a way of openly, collaboratively editing information. Where do wikis live? On the World Wide Web. What's the WWW? It's a system for sharing information openly with the entire world. (At least, that's what it was until the corporate realm decided to try to make money from it.) Where does the WWW live? On the Internet. What's the Internet? It's the meta-network of all the world's computer networks that have decided to talk to each other. Why did they do that? Because they like sharing information!
Information wants to be free.
The sharing of information enriches us all. Thomas Jefferson wrote,
- He who receives an idea from me, receives instruction himself without lessening mine; as he who lights his taper at mine, receives light without darkening me. That ideas should freely spread from one to another over the globe, for the moral and mutual instruction of man, and improvement of his condition, seems to have been peculiarly and benevolently designed by nature, when she made them, like fire, expansible over all space, without lessening their density in any point, and like the air in which we breathe, move, and have our physical being, incapable of confinement or exclusive appropriation.
If I'm writing a rant, on a wiki, on the World Wide Web, on the Internet, do you really think I'm the type of person who would sympathize with your attempts to hide information? Don't you think we've seen your question frequently enough that we know that's what you're trying to do?
Why do people want to hide their shell scripts?
- They're trying to sell them.
- They're ashamed of them.
If you're asking us for help selling a product, then you are a spammer and we want nothing to do with you.
If you're ashamed of your script because you know it's a piece of shit, but you would prefer to hide its crappiness from people (but still have them use it!) instead of fixing it, then you are a blight upon humanity.
If you just wanted your script to run faster, then you're really going about it the wrong way. Shell scripts just aren't built for speed. There are ways of speeding them up within certain limits (algorithmic optimizations, replacing external commands with builtins, etc.), but in the end the final answer to speed is rewrite it in another language.