Reply To: People just don't program any more program
More people (programmed, but substitute in any activity) before because they were forced too. I’m not sure “more people” is correct, rather a higher percentage of computer users. There are more computing devices in use today, possibly because there is less of a learning curve compared to when the only application available was a BASIC interpreter. There weren’t that many PC owners back then so the number of amateur programmers might actually have remained constant.
It’s too bad more people don’t get into it because there are better tools for programming today than ever before. Doing something that required writing 20 lines of code years ago might require only 2 lines in a modern programming language. Also, most of the popular ones today are scripting languages which make programming faster as there’s no compiling step. There’s huge libraries of code available that will do 95% of whatever you might want. All that’s left is for you to fill in the gaps for your specific task.
Most of the programs I write are just a handful of commands. One advantage of a command line interface is that any sequence of commands can be put in a text file named .bat (on Windows) or .sh (in Mac or Linux), then run later as a program.
Here’s a .sh script for recording the show:
#!/bin/sh FOLDER='~/music/soundbytes' sleep 50 mplayer -playlist $FOLDER/soundbytes.m3u -dumpstream -dumpfile $FOLDER/soundbytes_$(date +%F).mp3 -vc dummy -vo null
#!/bin/sh sleep 30 killall mplayer ~/scripts/soundbytes-opus.sh
The first script begins saving the streamed mp3 audio into a file with the current date. The second script stops the recording then runs a third script which creates second copy of the show in a more compressed format. I left out some lines which create links to my web folder (for making the show available on the internet). Then to automate these I put these two lines in my crontab (Mac and Linux tool for running programs at specific times, Windows has TaskManager):
2 12 * * 6 ~/scripts/start-record-soundbytes.sh 57 13 * * 6 ~/scripts/stop-record-soundbytes.sh
The first line for example says “run the program at 12:02 on Saturdays”. In the crontab you can only control start time down to the minute so I added the sleep commands to get the starting and stopping time closer to that of the show.
For Windows users, a simple program to try writing is a backup script. Most users aren’t already doing it, and it would be a simple script to write, consisting of one line for each file or directory you wanted backed up. Though uglier and less powerful than bash, the Windows batch language is well documented and comes built-in to Windows. Here’s an example:
and a much more complicated example:
Another area where scripts are useful is bulk video or image conversion. Say for example I wanted to make a smaller copy of every file in a folder named “images” for use in email and put them in another folder called “images_small”:
#!/bin/bash for i in $(ls images/) do if [ ! -f images_small/$i ]; then convert images/$i -resize 50% images_small/$i fi done
The above script requires the “convert” command which is part of the ImageMagick program, a sort of “Photoshop for the command line”.
Put the below in ~/.gnome2/nautilus-scripts/
#!/bin/bash convert $1 -resize 50% small_$1
Now when you’re using your file browser and you right-click on an image, you’ll get an option to run the script which will create a smaller image in the same folder with the prefix small_.
I’ve used a lot of ready-made software. Most of the time there were small bits that I wished I could change. What I like about scripting is the ability to make something that does exactly what you want, without having to adapt yourself to how another programmer expects things to work.
Another (not really a programming language but a gateway to programming) thing to try learning is HTML. Put these lines in a text file (use Notepad) and save it with a .html extension.
<html> <body> <h1>This is a large heading.</h1> <h3>This is a smaller heading.</h3> <p>This is a paragraph.</p> </body> </html>
Now open the file with your web browser. Neat isn’t it? Here’s a guide to get you further.
Sorry this post is so long. Oh no I just made it longer. Oh no I just made it longer again! Agggghhhhhh!