views:

426

answers:

9

Hello, 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.

A: 

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!

BobbyShaftoe
+1  A: 

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....

A: 

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...

Franci Penov
On a side note, it'd be interesting to see how soon I would be downvote punished for the heresy of "bashing" Bash. :-)
Franci Penov
I'm not planning on downvoting. It's as if you said you thought typing worked just fine with two fingers. More to be pitied than censured. ;-)
Jon Ericson
I don't necessarily agree with your analogy. I never said to not learn tools, just that there are more important things to learn.Though, good luck ten-finger typing on the iPhone. I suspect it will be quite less productive than the two-finger typing. :-)
Franci Penov
I don't plan on typing in an iPhone with any number of fingers. ;-) I've updated my answer with an example of how learning the tools could greatly improve productivity over the course of a career.
Jon Ericson
+3  A: 

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.

postfuturist
I wouldn't say shell scripting is useless, but I would tend to agree Perl can be more convenient. I disagree that Python "will" run faster than shell scripts.
Jon Ericson
In my job, Javascript has approximately zero chance of being useful. That's not to say learning Javascript has no use to anyone, nor that learning it would not help me if I needed to move jobs, but it is 100% unnecessary for my current job.
Jonathan Leffler
Just think about it, many lines in a shell script cause new processes to spawn to perform operations. Many of these operations can occur natively within the Perl or Python execution framework. That overhead is often significant for shell scripts making their Python or Perl counterparts much faster.
postfuturist
The world of software is moving toward the web and the browser. Most software job listings mention some web development. Every web developer needs Javascript knowledge. Hence, every programmer should know Javascript in case they get let go and need (or want) to find another position.
postfuturist
I think you vastly over estimate the cost of spawning a process and underestimate the advantages of pipelining. I wouldn't try calculating primes or something in native shell, however.
Jon Ericson
Shell scripts (the Bourne shell in particular) are used all over the place in a Linux system and the ability to write them (even simple ones) allows you to work more effectively. It may not expand your mind (e.g., like learning Scheme/LISP) but it will make your day-to-day work more efficient.
Emil
I'm kind of torn because the top 2 answers have polar opposite opinions lol.
outsyncof
If the guy just wants to launch couple of processes and tie them together somehow, Perl or Python would be overkill. It seems to me that this answer is written from programmers point of view and completely misses the question IMO
ADEpt
My answer does not miss the point of the question. "How beneficial do you think this would be to an aspiring programmer?" Is what he asked. That's why the answer is from a programmer's perspective.
postfuturist
+1  A: 

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

mxc
Out of curiosity, do you ever use a command line? I have a hard time believing people who say bash is for system administration have ever learned how to use it.
Jon Ericson
Sure I make use of the nautilus scripting integration and have my bash scripts to auto check in jar files into the maven repo, do svn updates etc. The point is most entry level programmers can use an ide to code and the build process is already setup. You can't program an large app in bash?
mxc
Ok. I think it's weird that we expect so little of entry level programmers.
Jon Ericson
+6  A: 

Sounds like a fine plan. Some suggestions:

  1. 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.

  2. 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. ;-)

  3. Customize your .bashrc file. Know what settings you like and which ones don't work for you.

  4. 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:

  1. Find all the files created by the testing user.

  2. 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.

Jon Ericson
Knowing one particular tool on one particular platform is an useful skill, but is hardly career-essential. Understanding the basic principles of the software engineering process on the other hand is priceless.Just a different perspective...
Franci Penov
I'd say that knowing a platform and a work environment inside and out will be a substantial leg up on a career. I hope the school work is teaching the basic principles.
Jon Ericson
I've worked in environments were senior programmers who can write amazing code have trouble figuring out build and infrastructure problems b/c they can't read/write shell scripts and Makefiles. Know how your tools work.
Emil
thank you for your advice, I'll definitely try to get familiar with shell. Sorry it took me a while to choose a best answer because there are so many drastically polar opinions to this question!
outsyncof
Don't worry. It gave me an incentive to flesh out my answer a bit.
Jon Ericson
+1  A: 

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.

Yikes! I read the question as being more about getting used to the command line environment than writing systems and such. Shell scripts certainly have limitations that Perl, at least, goes a long way to correct. Would you expand on the bad habit you mentioned?
Jon Ericson
I think you misread; he has limited time that he wants to apply to learning practical programming. sh was written ages ago on a pdp11 and has grown ad hoc; it wasn't designed as a programming language, so scripts are collections of kluges.
A: 

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.

Cheery
A: 

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.

roamn