Work the Shell - Coping with Aces
Good. Indeed, it's my belief that the best programmers are actually lazy and want to solve problems in the easiest and most efficient way possible. Laziness breeds ingenuity, remember, so although I could have rewritten the blackjack script to use an array of possible hand values to model the multivalue hand, why bother? The fact that a given hand has more than one value isn't really important as long as we can compensate for that fact correctly in the code.
A lot of programmers talk about highly efficient code as being “elegant”, but in my experience, most elegant code is also lazy code. I know that I'm constantly looking for those smart shortcuts, those insights that let me create something that might be less efficient in its performance, but far easier to code, far faster to debug and far speedier to deploy in the field.
One great skill that programmers can nurture is being able to recognize quickly the good enough solution too. Highly analytic by nature, we code geeks suffer from a little bit of perfectionism, and writing the perfect routine at the cost of additional days or weeks of development easily can end up being less utilitarian and less useful than having a pretty decent routine that does the job and can be improved later, in the next release, a maintenance patch or whatever.
Is this laziness what causes us to have software with so darn many bugs though? I don't think so. I think bugs in products are due to the ever-increasing level of complexity of software, be it an administrative tool for a Linux box, an Apache module or an Ajax-y Web-based utility. And software like an operating system or kernel? Of course it's going to have bugs. It's far too complex ever to test for all possible conditions, cases and situations. In fact, seeking efficient solutions that can be pushed out into the field can help reduce bugs. It's not testing software that finds the most egregious problems, but customers putting software through real-world tasks.
I'm not advocating that we should ship sloppy code, however. Simply that in the classic model of alpha and beta releases, getting code into the field ultimately can produce far more robust applications than having it stay in development forever as more and more complex test cases and usage scenarios are pushed through simulators.
But, ahem, I digress!
For now, we've come up with a nice, simple solution to the dual-value problem with Aces, and let's leave our script here for this month. Next month, we'll reintegrate the new code into the main game and add some additional code to detect when either the player or dealer has a blackjack (a two-card 21).
Dave Taylor is a 26-year veteran of UNIX, creator of The Elm Mail System, and most recently author of both the best-selling Wicked Cool Shell Scripts and Teach Yourself Unix in 24 Hours, among his 16 technical books. His main Web site is at www.intuitive.com.
Dave Taylor has been hacking shell scripts for over thirty years. Really. He's the author of the popular "Wicked Cool Shell Scripts" and can be found on Twitter as @DaveTaylor and more generally at www.DaveTaylorOnline.com.
Practical Task Scheduling Deployment
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.View Now!
|The Firebird Project's Firebird Relational Database||Jul 29, 2016|
|Stunnel Security for Oracle||Jul 28, 2016|
|SUSE LLC's SUSE Manager||Jul 21, 2016|
|My +1 Sword of Productivity||Jul 20, 2016|
|Non-Linux FOSS: Caffeine!||Jul 19, 2016|
|Murat Yener and Onur Dundar's Expert Android Studio (Wrox)||Jul 18, 2016|
- The Firebird Project's Firebird Relational Database
- Stunnel Security for Oracle
- My +1 Sword of Productivity
- Non-Linux FOSS: Caffeine!
- SUSE LLC's SUSE Manager
- Managing Linux Using Puppet
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- Parsing an RSS News Feed with a Bash Script
- Google's SwiftShader Released
- Doing for User Space What We Did for Kernel Space
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide