views:

352

answers:

3

I recently read Eric Steven Raymond's article "How To Become A Hacker" and I like his suggestion of learning 5 key languages (he suggests Python, C/C++, Lisp, Java, and Perl) as a way of covering the main programming paradigms in use today.

His advice is that it's not so important which specific languages a programmer knows. It's more important to know different approaches to programming, for two reasons.

The first reason is that it makes it trivial to pick up a new language, once you know the general approach to the way it solves problems.

The second reason is that there is no one best language - they all have trade-offs. It would be best to know what type of language to pick given a specific type of problem. This is what I'm most interested in, but I'm having a problem really distinguishing between the 5 languages he suggests. There seems to be a lot of overlap.

So my specific question is, given these 5 languages, what is their intended programming paradigm, and give one example of the type of problem it would be best suited for.

An example answer (and I'm not sure this answer is correct):

Perl
- mainly a functional language
- great for quick text substitutions in multiple files from the command line.

I found a few other similar questions posted, but I'd like to know about these 5 languages in particular. I'm just looking for a starting point, nothing too detailed. Thanks in advance!

A: 

If you can, go to a school that will give you experience with a variety of languages.

  • Python: multi-paradigm, focused on OO and polymorphism-based generic programming.
  • C/C++: Are two separate languages. Having grouped them together reflects ESR's level of, er, practicality.
    • C: classic imperative language.
    • C++: multi-paradigm, focused on OO and template-based generic programming.
  • Emacs Lisp: Obsolete, learn Haskell or Clojure or OCaml or Scheme. It is a functional language.
  • Java: Classic OO, designed for trustworthiness. But that doesn't help you learn anything.
  • Perl: Do yourself a favor and don't learn Perl. It's not designed around any discernible paradigm and writing good code in it is difficult. Try Awk instead.

ESR isn't exactly down to earth. He's well known as a philosopher, but what significant code has he written?

To learn today's popular paradigms, just start coding in any up-to-date project. Currently popular paradigms are the easiest to be exposed to. Trying to "learn" all of a complicated language like C++ or Java, though, will just be confusing. Every language has depth and takes time to master through application to real projects. You can't just sit down and do it.

That said, it's certainly worthwhile to write some toy projects in

  • some functional language (OCaml was used at my school, it is very easy to learn)
  • assembly code (use a real assembler, not GNU as which is not intended for human use)
    • or an extremely lightweight system such as Forth
  • a (relatively) simple text-processing language such as Awk
  • a logic solver, namely Prolog (Thanks @Thorbjørn!)

Hmm, that's all I can think of. Anyway, paradigms solve problems, so the important thing is to be solving a problem that leads you to a particular way of thinking, not to find a language that tries to force every problem into a particular form.

Potatoswatter
Explain downvotes, please.
Potatoswatter
Gladly. About code ESR has written, here you go: http://www.catb.org/~esr/software.html. Also see 'Product credits' in his resume at http://catb.org/~esr/resume.html. Lisp is not obsolete: see http://clojure.org/. Perl bashing does not help anything or anyone, and perpetuates the current bias against it. Perl *is* multi-paradigm.
Pedro Silva
@Pedro: I don't doubt he's written a large volume of code, but that actually supports my assertion. NetHack, Intercal? The most important things are Fetchmail (not to be confused with Sendmail), which isn't conceptually difficult, and ncurses, which is a dubious credit. A lot of things are retro-oriented, or simply were done a long time ago. Mainly he lists insignificant small or toy hacks. His recent work has been as a kind of spokesman or ambassador. He is not a successful programmer.
Potatoswatter
@Pedro: Clojure is not Lisp. It's an extension of Lisp. Perl is not multi-paradigm in the sense of Python or C++, and all the code I've seen in it is awful. I think that says something.
Potatoswatter
@Potatoswatter. Clojure is a _dialect_ of Lisp. There is no "Lisp" as an implemented language. You might as well say that Scheme or CL not Lisp but "extensions" of it. They are all dialects of the same "language".
aaronasterling
Also, Haskell,and OCaml, don't have macros. Only lisps have those.
aaronasterling
@Aaron: http://clojure.org/lisps - Common Lisp is what is usually understood as "Lisp", although ESR speaks of "LISP" which might be something older. Anyway Clojure has several extensions which aren't mentioned on that page. It's well and good to use a very pure language. I fool around with my lambda-calculus interpreter, I think it'll possible to develop a library for it with multithreading and various nice semantics, without adding any syntax outside the basics.
Potatoswatter
I added Clojure to the list. The point is, Googling Lisp won't lead you to a Clojure tutorial. Scheme, maybe. I suspect the only thing ESR has in mind is Emacs plugins…
Potatoswatter
@Potatoswatter. The link doesn't do anything to persuade me that clojure isn't lisp. In fact, its header is "differences with other lisps". I'm largely in agreement with you BTW about ESR and perl.
aaronasterling
@Aaron: Is lisp, in turn, just lambda-calculus with some sugar added? ESR is consistently using all-caps "LISP", and places it among other specific languages, which doesn't sound like a reference to the family in general. Anyway, I'm falling asleep too much to type… gnight.
Potatoswatter
Perl is awesome, come over to the dark side!
Powertieke
Perpetuating the current bias against Perl is exactly why bashing Perl is a good idea, because the current bias against Perl is good and proper and should only be strengthened.
Glenn Maynard
ESR sees the typical Lisp as multi-paradigm (functional, imperative, object-oriented, meta). The part that's particular 'enlightening' is the meta-programming part (code as data, macros, symbolic programming, ...).
Rainer Joswig
@ PotatoSwatter, if it makes you feel any better, I've only gotten one more upvote than you ;)
aaronasterling
@Aaron: Lol yeah, I kinda knew what I was getting into anyway ;v) .
Potatoswatter
@Ranier: Scheme and Clojure have no less of that than Common Lisp or whatever Emacs uses. Lisp as a family, no doubt is valuable knowledge. It's not even about extensions so much as cleanliness… Heck, I plan on having those things in my lambda-calculus by implementing all literals with one operator that returns the following text as a bit-string.
Potatoswatter
-1 for the self-righteous comment on Perl
Mike
Writing good code for Perl is easy. You should try tools like perltidy and perlcritic.
Alexandr Ciornii
@Alexandr: Looking at perltidy, it's a pretty-printer. That solves nothing but lazy typing. I'm talking about the conceptual errors that result from overreliance on regular expressions and poor fundamental semantics. Sorry, but Perl is not a clean or scalable language. It is good for some system administration tasks, but that is not what I do.
Potatoswatter
@Potatoswatter: who, exactly, relies on regex? The language? Its users? What does that have to do with cleanliness or scalability? The regex engine is a good one (so good, in fact, that other languages follow it), but that doesn't mean you should try to parse friggin' XML with it. 'Poor fundamental semantics' is semantically null, frankly. A case can certainly be made against Perl on various grounds, but you're doing a poor job of it.
Pedro Silva
Potatoswatter: Python zealots often say that Python cleanness is n formatting. And regexes are used in every language, in Perl they are better due to named matches, qr//, etc.
Alexandr Ciornii
+11  A: 

I think you're approaching it wrong. As esr himself says, it's not the language that matters, it's the paradigm. So when you say that

  1. Perl is a functional language
  2. It's great for quick text substitutions in multiple files from the command line

you are missing one of the main points of a functional language which is that they are great for building large systems using a bottom up approach: solve a bunch of (well chosen) small problems with well designed functions until we have a complete system. We cut down on code duplication by identifying what algorithms that we are using have in common and using higher order functions to encapsulate their commonality. We minimize (overt) branching behavior by using higher order functions to cook up just the function that we need for a given situation.

Likewise, I could say that

  1. Java is mainly an OOP language
  2. It's good for writing large, robust systems,

but that misses the point that OOP languages are about modeling concepts from the problem domain in code so that we are left with a clear way to imperatively solve the problem at hand. We cut down on code duplication by identifying what the relevant concepts have in common and encapsulating the code that deals with those commonalities in a class that describes it. We minimize (overt) branching behavior by providing different subclasses of an abstraction with appropriately different behavior.

On the whole, the basic point of programming languages and their associated paradigms is

  • to allow you to not think about anything that doesn't affect the quality of the resulting program. If that wasn't a (largely) desirable thing, then we would all be writing machine code.

  • This is accomplished by (among other things) providing a set of tools for building abstractions.

Shop around and pick one that you like and get good at. Just make sure that you learn when the other ones allow for a better solution (this will probably mean getting good at them eventually too ;). I think that you can mainly take "good solution" to mean, "clear mapping of code to ideas". (modulo concerns about efficiency that would force you (provide an excuse?) to write in a language like C)

aaronasterling
A: 

ESR's choice of language is based not only based on the paradigms, but also on their usage, with each is represented by:

  1. C/C++: system programming language (the metal)
  2. Lisp: functional paradigm (the enlightenment)
  3. Java: Object Oriented (the framework)
  4. Perl: better shell language (the administrator)
  5. Python: Because it's python, doh. (the paradise -- http://xkcd.com/353/)

More seriously, python is the most well-designed language; all of its features just fits together very nicely into a clean, well-designed, and easy-to-learn language that isn't a toy language. It's a versatile, well-rounded, general purpose language that has been in use in almost any situations: desktop applications, web applications, embedded scripting language, system administration, etc, and from the very smallest one-liner script to the hundreds of thousands of lines. Its highlight is the language's design itself. AFAIK, there is no other language in this class.

Perl represents a class of language used for shell scripting or job automation, where you need to call a series of programs, do some transformation on its output and feed the result as on input of another program. Other languages in this class is bash, however bash lacks the many powerful string manipulations that perl has (don't start saying that bash can call perl or sed or awk).

Java represents a class of language that is used widely in the industry and has a large amount of time and money invested on them. Because they're ubiquitous, there is wide range of good libraries and framework for nearly anything; if you can think of a problem, it's likely the problem has been solved by someone else and they have written a library for it. A hacker should know these languages since it increases productivity if you can avoid writing any code (or avoid writing too much code). Other languages/frameworks in this class are .NET, Django, RoR.

Lisp represents the functional paradigm. Knowing how to think and write in functional paradigm has many benefits that I won't reiterate here. Additionally, Lisp has a very powerful meta-programming features, which is almost unique to Lisp. Other language in this class (functional, not meta-programming) includes Haskell, Scheme, Clojure, F#, etc.

C/C++ represents the low-level languages used for writing OS kernel, device drivers, and speed-critical codes. This class of language have semantics that is close to the bare metal (especially C, less so in C++), and a hacker should know how the metal called CPU works, otherwise he can't call himself a hacker. Other language in this class is Assembly, but I think even ESR agrees that Assembly is too low-level to do anything productive.

While it's true that many of the languages he mentioned shares a large portion of overlaps (e.g. Python, C++, Perl supports OOP, for example); each of the classes of languages have a highlight that is unique to its own class.

Personally, if I were to be given the opportunity to add one other language, I'd add PHP to the mix. Web application is getting more and more ubiquitous. PHP represents a class of language used for web applications, other languages in this class includes JSP, ColdFusion, etc.

In short, a hacker is someone that:

  1. knows how computer works in low level
  2. knows how to think in abstract terms
  3. knows how to use frameworks appropriately
  4. knows how to administer his own system
  5. knows the design a good language
Lie Ryan
I think you are missing ESR's point a bit; he doesn't suggest learning those programming languages because there is large support for them in industry, as you suggest for C#, VB and PHP. He's suggesting languages that one might learn things from, and I would submit that there is not much significant to be learned from VB or PHP that is not better learned elsewhere.
Peter
I agree, I probably should emphasize more on the "framework" part instead of the support. From what I can tell, ESR's POV on Java is that it has a very large supporting libraries, which is useful for productivity, but could harm learning the basics.
Lie Ryan