Archive

Posts Tagged ‘newbie’

So… Where Do I Begin?

January 27th, 2009

Previously I made the claim that learning a language affects how you think. Here’s my take on what you might want to try, if you are thinking about picking up programming.

This article, while designed for someone who hasn’t yet started programming, must needs contain some technical terminology. I originally considered littering the text with footnotes, but who likes reading footnotes? (Unless they’re written by Dave Barry, of course!) Instead, read this glossary thingy first, which should serve a as a mild introduction to some basic “lingo.”

This is obviously going to be for a very specialized audience–the intersection of the set of people who read my blog and the set of people who aren’t programmers but could see themselves maybe becoming one someday. Hopefully it will be at least mildly interesting to those of us who don’t belong to the empty set :)

My reasoning behind my suggestions is based on equipping you not only with a tool that will help you accomplish some task, but that will stimulate you intellectually and help you think about programming. It will also hopefully provide a solid foundation that you can build upon so that you will find it easier to program in future languages you may learn (perhaps ones that are more task-oriented).

As such, I will start with some I think you should not learn as your first language, and why. Obviously, I’m not saying you should never learn these (quite the opposite in the case of some); just that they maybe shouldn’t come first.

  • C – An excellent language, and incredibly useful (still today one of the most-used languages in spite of its simplicity). It also has a small syntax and standard library, making learning it on a superficial level quite easy. However, based on the criteria I mentioned above, I cannot recommend it as a first language. It lacks too many helpful abstractions, and indeed tends to force you into pretty specific coding styles. This is a pity, because I’d really love to recommend it on the virtue of what it teaches you about how many other programming languages work “under the hood.” Learn it second!
  • C++ – Built off C, C++ had the aim to deal with the aforementioned lack of abstraction–in other words, just as you don’t need to know how a car works to drive one, you shouldn’t necessarily have to know how a computer works to write programs for it–but still be compatible with C code. It became quite popular in its day, and indeed there is still an enormous amount of programs written in C++ around. However, while I applaud its goals, its execution is lacking. It’s ridiculously complicated in about every way you can think of, and when you combine that with the lack of any training wheels or even safety belt (a wrong move can crash your program or corrupt data, and often it is unable to tell you why)… you’re asking for trouble. There are certainly C++ zealots around, but I’m just as certainly not the only one who thinks that learning it well is not worth the titanic time investment.
  • Java – Many people will disagree with my putting Java on the not-learn-first list; indeed it’s the one they teach you first at BYU and lots of other schools (although only ones striving to be “practical”–Computer Science programs that take a more academic approach tend to use other example languages). Java came along as an answer to the madness that was/is C++, and became very popular in the business world. I reckon it’s still the Biggun’. One of its most interesting features is that it is cross-platform–that is, your program will run on Windows, Mac OS X, Linux, etc. (This is not a typical thing!)

    I say don’t learn Java first, because quite frankly of the Java-like languages it’s not the best. It lacks some features and is quite verbose; you end up writing a lot of boiler-plate code all the time. I can also say that from personal experience, if you learn it first, it makes you think “in Java.” And in hindsight, that’s not how I want to think :)

  • Javascript and PHP – Two good languages, and ones you more-likely-than-not will learn eventually. I don’t recommend them as first languages for a couple reasons. For one thing, they are very loosely typed–this means they are very willing to “try and guess what you meant.” This is a pro as well as a con, but I think you will appreciate it more–and it will bite you in the butt less–when you have some experience under your belt and you actually understand what “loosely typed” means and how it applies to code you write. Another reason to steer clear of them is that they are almost the trademark “newbie languages.” This has a number of implications:
    • No real community to speak of. Most of the people who program in them do so not out of a love for the language, but out of desire to get something done quick. The “community” is a lot of people who would be new like you–and when you’re new to a language, I’ve found it’s helpful to know where to find experienced people.
    • Lots of code for these languages that’s out there on the internet–both example code and libraries (that is, code that others have written to perform a task so you don’t have to write it) are written by people new like you. Again, as a newbie programmer, you want to learn from and use code that is as close to professional quality as possible.
    • Security gotchas. Though this kind of thing does of course get better as time goes on, rapscallions are well aware that code in these languages is both very popular and often written naively. Thus if there are vulnerabilities, they are going to be found out and exploited.
    • General lack of emphasis on proper coding style, algorithms, etc. As very permissive languages, they permit you to write steaming piles of… code.
  • Perl – I have a soft spot for Perl, but as one of the most organic languages out there, it has become a bit overgrown with decade-old weeds. Additionally, it has a lot of subtlety and complexity, and lots of syntax. Unlike C++, it can’t wreak havoc on your whole system, but I have accidentally erased files before by getting the file-opening syntax wrong. (I know that came off as anecdotal FUD, but I was merely listing an example. Again, I like the language, in spite of its quirks.)

    Perl has a dedicated and experienced community behind it, that I’ve found to be helpful and excellent. It’s also got probably the largest collection of freely-available libraries of any language out there. But in reality, I wouldn’t recommend it as a first language, and even as a second language I’d recommend waiting for its next incarnation to come out (which has been in the works for many years now. The language’s designer recognized that Perl needed a complete rewrite, and so it’s taking awhile).

  • Visual Basic – If we were speaking of “classic ASP” or Visual Basic 6, all of the above commentary would apply, and then some. Nowadays, however, you’d be more likely to encounter VB.NET, which is built on the .NET framework and (though I’m overgeneralizing) is essentially a way to write the same code as you could in C#, but with different syntax. However, that being said, there are no benefits to doing so, and the code you write is both ugly and dissimilar to any good language. So there’s simply not a reason to start here.

I believe that about covers the most common starting points for a new programmer that I wouldn’t endorse. There may be others, but I don’t feel qualified to comment on languages that I myself haven’t learned to at least some degree.

Anyway, the more interesting stuff: what do you learn, then? Haven’t I just ruled out like every popular language?

Well, understand it is quite random which languages end up becoming popular; indeed, the only thing they really have in common is that they are generally not the best of their kind–or even if they were originally, others took what they did right and combined them with other stuff done better.

Assuming you fall into my target audience (you want to learn what will be helpful in the long run, recognizing that as a brand new programmer you won’t be writing 3D games and huge financial systems for a while anyway), you are have lots of pretty good options available. Here’s a list! I’m going to put it in order of “amount of brain-stretching required”–you can decide for yourself, based on your various capabilities, which might work best for you.

  • C# – I’m a tad hesitant to recommend this as a first language. It was my first language, and it is a good language, yadda yadda. Syntactically, you can think of it as a significantly better version of Java: it has several constructs that Java doesn’t, making it much nicer to code in. It’s also got tremendous IDE support, which I think is good and bad as a programmer seeking to learn the ropes (but that’s a topic for a different blog). And when it all comes down to it, it will get you in a mode of thinking that is similar to a Java programmer’s: somewhat roundabout, somewhat repetitive, somewhat verbose.

    If you do choose C#, try and take advantage of the features that new versions have offered, and continue to make a great effort to do so as future versions are released. One of its big advantages over Java is it continues to introduce solid ideas from other languages every couple years. Note that it isn’t strictly Windows-only anymore; the effort to get it on other platforms has been actually quite successful.

  • D – I’m going to make an exception to my rule here, and list a language I’ve never learned. I do so because D is one of the languages I’ve only ever heard good things about–which is rare in the world of programming languages. D is, in short, what C++ should have been (or should be). It’s even designed to be able to fill that close-to-the-machine niche if needed. If you learn it, let me know how it goes!
  • Python – This is probably the most popular language out there that is the most solid and straightforward. It was designed to avoid trickiness and to be very uniform; indeed, their motto (paraphrased) is “There should be one way to do things.” This even includes how the code looks on a piece of paper: all very uniform. There are lots of newbie resources available, tons of example projects written in good style that you can study, and plenty of libraries to help you do all sorts of stuff.

    With as much praise as I have for it, I’m actually not the hugest fan of the language, simply because I tend to prefer a system that allows for a bit more cleverness. (There are also some aesthetic quibbles I have with it.) But you could do a lot worse than learning Python first. It will especially help with getting you in the habit of writing well-formed code, in any language.

  • Ruby – Ruby is similar to Python in some ways, but different in philosophy and in the sort of coder it tends to attract. It was my favorite language for a long time, and I think it scales well: you can start by writing in Python-like style, and as you learn new tricks, incorporate them. The result is both simple and concise. It commonly uses certain programming constructs that, while they may exist in a language like C#, don’t play as big a role–therefore in Ruby you get to appreciate their power more frequently and understand them sooner.

    Ruby was also designed with “metaprogramming” in mind–that is, you can play with how the language works. This isn’t really important to know as a newbie; I mention it as part of showing that there’s definitely “growing room” for your brain as you learn this language.
    Note: Don’t confuse Ruby with “Ruby on Rails,” which is a framework written in Ruby. I don’t recommend jumping into Rails right off the bat, without learning Ruby first.

  • Scheme – Scheme is a great little language, unfettered by frivolous syntax and unnecessary complexity. It is a “Lisp,” meaning one of a family of languages that share an important trait: they are incredibly easy for humans and computers to parse. This means you can easily write code that writes code. Programming in a Lisp is very fun if you don’t mind stretching your brain a bit–and I’m writing this blog for those that don’t.

    One nice thing about Scheme, is it is used as the example language in several books about how to learn programming the right way. (Most programming books are closer to either “how to learn Language X the right way” or “how to do task X with Language X”.) Also great is a couple of these books are free: SICP and How to Design Programs. I also recommend The Little Schemer.

  • Haskell – I’m learning Haskell now, and consider it to be the closest thing out there to the “holy grail” of languages. It’s incredibly well-designed, and is packed with cool features, and it has one of the most helpful communities I’ve yet encountered. It’s also the most brain-stretching of any language I’ve mentioned on this page. Though I’m sure some would disagree with me, I am of the opinion that it was designed by smart people, for smart people. Or, that is to say, that smart people will be able to harness it best. (Standard disclaimer about not measuring your self-worth by whether you can code in Haskell, yadda yadda [even though I personally measure my self-worth by everything I can't do... but that's for another blog.]

    I just mean that there is a lot you can do with a language like it if you have the tools upstairs, unlike, say, PHP–which is like “programming to the lowest common denominator.”) I won’t launch into any significant description of the language here, as someday I plan on writing about it more–hopefully in a fairly approachable way.

Of course, there are many other good languages out there. Again, I’m a bit limited by what I’ve had time to digest personally. Also, some languages are worth learning, but perhaps not first. Let your intuition guide you–learning a language should be fun and interesting, and if it’s not, something is going wrong. If you absolutely aren’t enjoying one of my recommendations, don’t let that turn you away from programming in general; by all means give something else a shot.

I’m only able to speak out of hindsight, and indeed it’s probably that warped kind of hindsight wherein if you went back to your old self and gave him advice, he’d probably just look at you funny. But such is life, and such is programming.

Vaguely Instructional , ,

Programmer Vocab Crash Course

January 27th, 2009

Sometimes I wax nerdoquent in my posts. Hopefully this little glossary-type-thing will help.

  • Syntax – This basically amounts to what you have to physically write in order to make a program do what you want it to do. If your language has “lots of syntax,” you need to remember how lots of symbols interact with each other. (Note that “symbols” here can mean words or word-looking things, not just brackets and stuff.)

    A “lots of syntax” example (from C++) (of course!):

      template <typename _id_t, typename _mem_t>
      void exchange(map<_id_t, _mem_t>& ref, const _id_t& id1, const _id_t& id2)
      {
          typename map<_id_t, _mem_t>::iterator it1 = ref.find(id1);
          typename map<_id_t, _mem_t>::iterator end = ref.end();
     
          if (it1 != end)
          {
              typename map<_id_t, _mem_t>::iterator it2 = ref.find(id1);
              if (it2 != end)
              {
                  _mem_t tmp = it2->second;
                  it2->second = it1->second;
                  it1->second = tmp;
              }
          }
      }
  • Libraries, Standard Library – Where do you go to get books you didn’t write? The library! (Okay, pay no more heed to that analogy before it starts to fail.) A library refers to code that someone else has written that you can use. The “standard library” of a language refers to libraries that are included with the language itself; you don’t need to buy them or go find them on the internet or anything like that.
  • Abstraction – A way to view something in more simple terms. You can view a toaster as a fairly complicated combination of small circuits and whatnot, or you can view it as something that you put bread into and get toast out of. This is very important in programming, as at the lowest level you are dealing with a bunch of 1’s and 0’s–but you can get more work done if you don’t have to worry about them.
  • (Strongly/Loosely) Typed – This one is harder to simplify, because the issue of “types” in programming is a fairly complex one. But basically, it is talking about how much leeway your language gives you when you make computations. If you give a program something that’s not a number, but looks like a number, should your language treat it as a number? But what if it does and you weren’t expecting that? The less permissive languages (the “strongly typed” ones) tend to require more input from you, the programmer, on how to handle things, but they tend to alert you of potential errors sooner. Like many things in programming, there are tradeoffs.
  • Community – There are lots of communities on the internet. Each programming language has one too–a group of people of varying levels of experience and background who use that language. A friendly community is important, because that is where you go when you are stuck. Certain programming communities are quite elitist and, well, made up of jerks. (I’m looking at you, Common Lisp…)
  • Algorithm – A formalized procedure or formula for doing something. You use these all the time without maybe realizing it. For example, how do you choose which way to drive home from Point X? Do you pick certain streets with less stop signs? Avoid that place with the bad speed bump? Choose a different route during rush hour? These are all part of your algorithm for getting home.
  • ASP, .NET, Ruby on Rails – These things are not programming languages, but rather frameworks that are connected with programming languages. See below.
  • Framework – A framework is a broad term for a collection of libraries (see above) and recommended ways to use those libraries. You might have a framework for making websites, or a framework for interacting with graphics, etc.
  • IDE – This stands for “Integrated Development Environment,” which is a big huge program that helps you write programs. They can do anything from telling you when you forgot to type a semicolon to helping you debug and test your program.
  • Platform – A platform is a place where programs can be run–that is, a place that is programmable in one way or another. Windows, Linux, and OS X are platforms, as are the Xbox 360, the iPhone, and big-ass tables – to name a few.
  • Metaprogramming – “Sup, dawg. I heard you like programming so I put programming in your programming!” When you can program your programming language, this is called metaprogramming.
  • Parse – To parse means to interpret or understand. We do it as humans when we read written language: we look for the combination of verbs, nouns, adjectives, and punctuation that delimits a thought. Computers do the same thing when reading your code: they turn your ideas, represented by syntax (see above), into tangible instructions it can use. (A bit of an oversimplification, but that’s the general idea.)

Vaguely Instructional , ,