How would you answer: "What programming language should I learn first?"

Recently via email I had someone tell me that they want to get into development and they asked me what programming language they should learn first.

That’s a really specific question that, ultimately, cannot be decided without first defining some basic long-term goals. The advice I gave was basically in the form of numerous questions that they need to answer before they can pursue any such endeavor. For example:

  • Do you want to build websites? Or do you want to build native apps?
  • Do you want to build mobile apps? Or cross-platform experiences?
  • Do you want to work with the design side of things? Or are you more of a behind-the-scenes-processes kind of worker?
  • Do you want to build stuff for other people, or for yourself?
  • Are you planning to build personal projects on the side, while continuing in your current field of work?
  • Will this just be a hobby? Or a full-time goal?
  • Do you want an in-house job, working in a team?
  • Are you planning to “flip” your projects after you build them? Or are you planning to maintain them?

I could probably think of another dozen of such questions, but that kind of sums it up. It all boils down to long-term goals. So while I could have just said “learn Objective C” or “try PHP” or “focus on JavaScript”, none of that would help them unless they knew what they eventually wanted to do with it all.

So I suppose I could answer their original question, but only after getting answers to some of the questions listed above.

Have you ever had someone ask you something like this? What was your response?

This editorial appears in this week’s issue of the SitePoint newsletter.

There is a parallel issue when asked by new computer science majors - which language to learn first. I think the same principle should apply to web design and programming in general. Here’s what I’ve found to work. Since all of the languages of whatever discipline you talk about apply, when you have to learn something about all of them. The major universities have adopted the approach of shotgunning the spectrum at the students by starting with a base like HTML5, add just enough CSS to get a page to look somewhat presentable, add a little PHP to talk to a server, blend in enough JavaScript to do something on the page. Then assign projects to test this first level of engagement. Each session add a new piece to the mix to reach towards a goal set in the first session. There is no need to try to teach any of these languages in depth. Once a student is proficient in building an useful web page, they will naturally pursue expanding on language areas they have not mastered yet. As we know, new “languages” that can’t be ignore crop up every year, so stressing out on leaning one major one all at once is fruitless. For instance: jQuery into Node.js.

I would recommend learning Java. A bit strange, but here are my reasons:

  • It is object oriented
  • It is strongly typed
  • It forces good code structure - like declaring variables before you use them
  • It is multi-threaded

Once I had a firm grasp of Java it was easy to pickup other languages such as PHP and Python. And, while I now work mostly in PHP - the lessons I learned with Java have served me very well.

1 Like

This is a question that I asked myself when I was at a crossroad in my career choice. It’s so true that all comes down to long-term goals. However, the problem is that someone asking that kind of question probably hasn’t worked out their long-term goals and think that, if an expert in the field comes up with a definite answer, that would also provide a solution to the real problem of clarifying what they ‘want to be when they grow up’.

Eventually, people will find out for themselves, by asking around as well as by trial and error. The great thing about programming languages is that there’s so much that’s transferable from one to the other: most of what you learn can hardly be said to be a complete waste of time.

Besides, the field of development is so fast moving that the same question is likely to come up later down the road in a more nuanced form: which new technology (in my field of expertise) should I learn first - or is even useful for me to invest my precious time learning? Is it a passing fad or something solid that’s worth while pursuing?

1 Like

Very true!

I don’t think it really matters, but I think that people should steer away from certain languages until they have a better grasp on certain CS principles. It’s very hard to unlearn things. PHP "Arrays" and JavaScript "Objects" are 2 things that come to mind. Having either of these concepts cemented in a person’s brain early on could lead to struggles down the road and could possibly mean they would always have to translate concepts in the future to these paradigms. This is not a good foot to start out on. An object in JS is not really an object and an array in PHP is certainly not an array.

Then there are other languages that are just too intimidating and can hurt new programmers by simply giving them too much too fast, like C++. As someone who started with C++, it was hard. Very hard. Having to understand pointers, objects, headers, and memory management when you don’t even really know when you should a for loop instead of a while loop, is very hard and it caused a lot of people to quit. Now that I’m through all of that, I’m glad I started with C++ because it’s probably one of the most solid foundations you can start your CS journey on, but if I were to do it again I would absolutely not go that route.

If I were to suggest something to someone just starting out, it would probably be Java, Python, C#, or C. All of these will be relatively easy to pick up for a beginner and give them a solid foundation. I don’t think their goal matters as much as understanding core CS principles. I try to be as language agnostic as I can. If you understand the core concepts, picking up a different language to perform a certain task is fairly trivial.

Most new programmers are probably on Windows machines, so if I had to pick a single language to start with it would probably be C#. It’s just a good language. It properly follows CS principles, it had modern features, it has both dynamic and static typing, it has a ton of resources, and it can be used to make just about anything. (and it’s very similar syntactically to Java)

1 Like

I would suggest learning Lua first.

  • It is a language with a compact syntax.
  • You can start coding right away.
  • It is portable to pretty much any platform that has a C compiler.
  • It supports major programming paradigms: structured, modular, object-oriented, functional, even prototype-based.
  • It has a very powerful C interface so you can use it to interface directly with the OS.
  • It has powerful language constructs like closures, exceptions, metaprogramming and functions as first-class objects.
  • It doesn’t have a built-in reflection mechanism but implementing one is fairly straight forward.
  • If you’re really concerned about performance, you can use LuaJIT which is blazingly fast.

And my favorite reason to like Lua:

  • It implements proper tail calls in a way that is simple to understand and use.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.