Reputation: 2000
I am in desperate need of some advice.
I'm almost done with my junior year as a CS major. I sort of feel like a late comer because I didn't really get into computer science until sophomore year... Through hard work, lots of credit hours during the year and summer school I am almost caught up to my peers but here come the worries:
All of my school work has taught me a lot about computer science but little about practical programing. Although I have a lot of motivation, I simply have almost no free time to allow me to pick up side projects. This upsets me for 2 reasons, 1) I genuinely am becoming very passionate about the field and 2) I understand that many employers like to see students with some experience outside of school.
So I recently had an idea: what if I were to make Linux my primary OS but restrict myself to the terminal as much as possible in an attempt to naturally (with the help of google) become familiar with the command line and hopefully gradually pick up shell scripting using online tutorials.
How beneficial do you think this would be to an aspiring programmer? How realistic is it? Do you have any other suggestions for small projects a student with barely any free time can pick up outside of school?
Thank you so much, I love this website (and podcast), and will appreciate any feedback.
Upvotes: 13
Views: 14110
Reputation: 127
if you are going to be stuck in a linux shell all day...definitely dedicate a week or a month of your life learning bash. seriously its just something every hard core linux person needs...regardless of what anyone says.... once you have invested that time it will help you understand init scrips, and lots of other things you will be able to do quickly with a script. Its a serious skill worth investing a week or month of your time in ... YOu will never regret it.
After that little intro you allowed yourself...go and learn a proper lanaguage like python or pearl..spend years getting comfortable with the language of your choice...but in the meantime for quick and nasty scripts and understanding the linux operating system startup files etc...your week of bash learning will always be with you
eventually you will probably use pearl for everything ...but it will certainly take a year or two of experience before this happens.
i only wish i had just dedicated a full week to bash when i started linux. im alway stuck when looking at some scripts and hence had to time out and just do a short spell of learning bash.
Upvotes: 2
Reputation: 21525
Sounds like a fine plan. Some suggestions:
Learn to automate everything you can. Make it a habit. If you do something more than a couple times, put it in a script. It's not just to avoid typing but to document the process. Improve your scripts as you notice problems. Share your scripts when appropriate.
Learn the power of pipelining. Discover the purpose of the xargs
command. Re-write a standard command line utility like grep
or sort
in the language of your choice. (I'm partial to Perl, but that's almost cheating. ;-)
Customize your .bashrc
file. Know what settings you like and which ones don't work for you.
Use ksh
rather than bash
for scripts. There aren't many differences, but ksh
has a few extra features that are very nice to have. I prefer bash
for interactive shells, however.
Seems like the other answers suggest focusing on "real programming languages". I won't say that's bad advice, but in my experience too few programmers make good use of the command line. Over a career, good use of shell scripting saves countless hours and lots of tedium.
Let me give you an example. This weekend I began putting new code into our production system. We had spent the previous week testing it and everything looked good. Ideally, you'd want to have a perfect clone of the operational system so that you're testing apples to apples. But we can't afford two copies of the hardware, so we borrow production machines to run tests on and swap them into production when we perform the upgrade.
Now to distinguish between our operations and testing, we use two different accounts. So before putting a system into operations, we clean out certain files generated by the testing account. Basically it's a two step process:
Find all the files created by the testing user.
Blow them away.
I imagine it would take me a minute or two to write the code to do that in Perl and another couple of minutes to test it. It's a simple job. I'm not even sure how to go about it in C/C++. I think you'd start with a stat
of the root directory.
But everyone who has mastered shell scripting is jumping up and down, waving their hands and shouting out the answer, because you can write the code in the time it takes to type it:
$ find /data -user test | xargs rm -rf
Testing consists of running the command and watching for errors. This particular problem is a softball pitch right in the wheelhouse for bash
. Perl gets the job done, but it's a bit less natural. (I'd use find2perl
, which just adds a step.) Attempting this in C or C++ would be a quixotic quest. Those languages are designed to solve different problems.
Now if you don't work in a UNIXy environment, there's probably a toolset designed for doing this sort of thing. (I'm no expert, but in Windows I'd probably run a search to get all the files in one window, select all and delete. Very nearly as easy. I don't know how to automate it, however.) But if you plan on finding a job in the UNIX/Linux world, you must be familiar with the command line so that you don't take 5 minutes to do a 30 second job.
Upvotes: 12
Reputation: 161
I highly recommend perl to anyone who uses linux as a tool for automation and making life easier. With perl you can write quick and easy programs that will actually accomplish a real task in a small amount of time. Python is a good alternative and handles objects much better, though it strays away from the C style and I'm guessing that's what most of your experience has been with.
Upvotes: 0
Reputation: 25443
I don't know how to make sh scripts, but occassionally I find out I need something that can't be achieved by my current programs but that I could compose my tool out from programs already existing in my system.
At the point when I need them most, I will just pick a bash scripting tutorial and check up what kind of syntax is necessary for the kind of constructs I need. Been learning some sh scripting over the time, but it's not my main interest.
sh scripts are terrible looking enough that you don't really need them except when you are truly really needing them anyway.
Upvotes: 0
Reputation:
Why would you want to waste a lot of your time learning shell scripting? Once upon a time I was a master of it and wrote entire systems with sh scripts, but that was before perl and other scripting languages. sh is a horrible language that encourages bad habits, and isn't in demand. Learn only minimal basics -- what you can get from one or two reads of the sh man page. Then learn something useful -- perl and python are good bets for someone with limited time resources.
Upvotes: 1
Reputation: 1003
If you are going to be a programmer I would suggest sticking with your primary language and learning the various libraries and frameworks that come with it. Bash scripting is extremely helpful but it will be used mainly for system administration.
If you are planning on becoming an infrastructure or system admin person then learn bash scripting. Otherwise spend time on programming. You could choose a scripting language as your primary focus then you will be able to use it for shell scripting as well such as python.
hth
Upvotes: 1
Reputation: 22646
Shell scripting is mostly useless. I'm a Linux guy, and I can write a shell script if I have to, but any task that would normally need a shell script can be done in a more programmer-like way in Python. If you need a lot of scripts, you can factor out some of your more useful code into classes that can be shared and consumed by multiple scripts. The Python scripts will run orders of magnitude faster than the pure shell counterparts. I find that shell script syntax (Bash, for example) doesn't support decent data structures. Even Perl is an improvement over pure shell scripting.
If you are looking to expand your horizons learn different programming languages and paradigms. If you were taught with Java, learn a dynamic language like Python or Perl, and a low-level language like C or Pascal. If you wrote CLI apps, write an application that has a GUI layer. If you only learned how to write traditional desktop applications, write a database backed web application.
Oh, yeah, learn Javascript. It is probably the single language that every programmer should know for career advancement purposes.
Upvotes: 5
Reputation: 76001
I would definitely suggest you learn at least the basics of C/C++ to get an understanding of how computers work.
You should also learn the basics of C# or Java in order to learn about the managed world and concepts like garbage collection, byte code/IL, jit compilation.
You should at least glance in Ruby and Python's direction to get yourself acquainted with the idea of dynamic languages.
Throw in Rails, PHP or ASP.NET to get an idea about web programming and concepts like MVC.
Read about unit testing, test-driven development, dependency injection/inversion of control, ORM. Make yourself comfortable in the world of source control and continuous integration. At least check on Wikipedia buzzwords like agile, scrum, lean and kanban.
If you want to have any experience outside of school, get yourself involved in a small open source project. There are plenty out there on any of the languages, platforms or frameworks I mention above. You don't have to start your own, nor do you have to spend a lot of time. Start small, by dabbling here and there and submitting a bug fix or a small incremental feature.
These are all very important aspects of today's programming field.
Where exactly does Bash fit into all this, I am not sure. It can be a very useful tool and can make your daily tasks quite easier, but so can quite lot other tools. However, I don't necessarily think Bash will be helpful to teach you much about modern programming and prepare you for a carrer as a software engineer.
Then again, I personally don't know much about Bash myself, so maybe I am totally wrong...
Upvotes: 0
Reputation: 4883
Do what interests you - if Linux and shell scripting turns you on - run with it. Though, these days, there are plenty of avenues to learn to code on Windows or OS X or any other operating system. You can download any of the following for free on multiple platforms....PHP, Ruby, SQL Server, Oracle, Java, C, C# .... and Google (and of course SO) have everything you need in terms of documentation for any problem you run into.
You are absolutely right - the "practical" aspect is really all that matters - and it's quite a bit different than your school work. You are right to be looking to do projects on your own - that's the only way to really get your hands around this stuff. And as you're doing it - make sure that you actually like doing it - not just the idea of doing it... because it tends to take a lot of patience....
Upvotes: 3
Reputation: 28499
Well, with a good understanding of Computer Science, the so-called "practical programming" is not that difficult to learn. This is not to say there is not much to learn; however, having a mastery of Computer Science implies, in essence, that learning various programming languages will not be very difficult. Have you taken an Operating Systems course yet? If not, you should pick up the so-called Dinosaur book and begin studying it. Bash programming is very simple. You should be learning languages like C and so forth; shell programming is rather trivial compared to these. Although, it is important to learn. If you haven't taken Operating Systems, then surely you will as part of your degree, if your program is worth its salt. In that course, you should go through many exercises and even implementing your own simple shell is a very common introductory project.
Anyway, sure start learning about Linux. Find the classic HowTos on Bash, Kernel programming, and so forth. As far as how realistic ... I expect all CS students to understand all of these concepts rigorously. I wouldn't allow a student to receive his or her degree without it!
Upvotes: 1