Currently I have listed down learning Unix/Shell Scripting and reading CLR Algo book as the most important priority for me. I was thinking if I could solve the algorithms questions mentioned i开发者_如何学编程n CLR using shell scripting. Mind you I'm a complete newbie to Unix/Shell Scripting.
No, it's not. Shell scripting is definitely not designed for writing algorithms. You should use a general-purpose programming language like C, C++, Java, Python, or [insert your favorite general purpose language here].
That's not to say that you couldn't use bash or something for algorithms -- it's Turing-complete AFAIK -- but you really wouldn't want to. It'd be a huge pain, you wouldn't learn a lot of the skills you need (like modeling algorithms in common programming languages or styles), and your solutions would be cryptic. Do yourself a favor and use something else. Shell scripting is for automating tasks, not solving algorithms.
Also, most shell script languages (bash most notably) are weakly typed, which a.) hurts performance and b.) will make your program harder to reason about. Dynamic typing is OK for algorithms, weak typing, not so much. Performance will be abysmal, regardless.
If you're trying to learn both shell scripting and algorithms, you can still do it at the same time. Write scripts to compile and test your programs and write your programs in a general purpose-language.
Shells like Bash are quite powerful but I think you'll find that their limited support for arrays, no support for hashtables, and other limitations would make it tedious to implement anything more than very basic algorithms. Python or Perl would be a much better general scripting language.
(added later) Since learning that Bash 4 has associative arrays, I'd like to add that implementing some algorithms with shell scripts could be done. It wouldn't be fast, and wouldn't be elegant, would be tedious as hell, and limited in its application; but if you want to be forced to learn the intricacies of the shell while you learn to implement algorithms, that is, purely as a mental exercise, this might be a good thing for you.
Not at all. Shell scripting is good when you want a one point stop to perform all your UNIX/Linux system related activities. You can go for C/C++, Python, Java.
Universities usually prefer one of the following (not a complete list, just heard ones):
- C
- C++
- Java
- C#
- Python
- Matlab
- Scheme
You should pick a language based on your need (learning programming is not a need, you do it for achieving something). some examples (not a complete list):
- You have interest in unix-linux programming at system level: C, C++
- You are interested in being a software engineer: Java, C# (maybe C++)
- You are interested in web programming: PHP (maybe Python)
- You are interested in mathematical/statistical programming, linear algebra etc: Matlab
etc. First: determine your programming aim, then search it on the web to see what people are using, then learn it
精彩评论