Ask HN: If I learn one programming language, what should it be?

11 points by reesdreesd ↗ HN
I want to dedicate a few months to learning a programming language (part time) in order to achieve the following two goals:

1) Be better prepared, as a founder, to understand engineers. 2) Add a "hard" skill I can use to earn money on the side (e.g., while bootstrapping).

To clarify, I'm not a founder yet, but that may change soon. I have very basic knowledge of programming: a semester of C++ (15 years ago) and some dabbling in AppleScript, shell scripts, and html/php/css.

Of course, I realize that I won't master anything with only a few months of study. Nevertheless, I'd like to do what I can to improve my chops in the time I have.

If you were in my shoes, what language would you invest in? Can you recommend any resources to help me learn it (e.g., books, online resources)?

I'd really appreciate advice from the HN community.

47 comments

[ 3.5 ms ] story [ 106 ms ] thread
Python if looking at a dynamic language! It will get you up and running in no time; the syntax is also very easy to understand and easy on the eyes...If you want a statically typed language then go with Go..it feels like python with types
First pick a platform, are you more interested in native mobile or something web based. I primarily work with PHP but I've also tried Ruby and Python. Either one could be my next. Truth be told, just make sure you keep asking "why" and understand the basics. After that, switching to a different language will be pretty easy and you'll mostly have to worry about learning the popular frameworks and libraries.
Javascript is pretty widely applicable these days, even if it's maybe not a thing of beauty.
I'd second this choice. Especially if making money on the side is a factor in your thinking.
Agree. JavaScript usage is growing by the day (nodejs, drones, IoT etc.)
JavaScript is running on drones?
I agree. A lot of people have adopted it and there's a large community. Perfect for someone starting out. You will be googling/stack overflowing a lot so its good to know there are a lot of resources behind it. Plus you know th e language is growing not dying.
I really appreciate the feedback. JavaScript is supposed to be complicated. Let's say I study 20 hours a week for three months. Can I get off the ground with it?
Having taught javascript to coworkers who were proficient in other languages (c++, c#, ect), javascript was confusing to them since many things act differently in javascript from other languages. That said, with the availability of online help and tutorials, you could definitely get off the ground with it, but it will give you a very different experience than something like python. Depends if you are more interested in programming fundamentals or in web programmings. If you are looking for fundamentals, I would learn Python or Java.
in response to qzcx's reply, it's true. If you want fundamentals then something like Java, Python, or C, C++.

JavaScript really is the way to go to get your feet wet just because it'll give you the experience to build a wide range of platforms such as: Mobile (Cordova, Appcelerator, React Native), Desktop (AngularJS, RequireJS, Dojo, jQuery, Vanilla JavaScript/ECMAScript 6), and Server Side (NodeJS - basically you don't need to learn a front end and back end language).

But still, you should definitely learn one of the more traditional languages at some point in time, especially if you're doing this for a living.

And I would recommend just figuring out something you want to build and just build it. Focus on building and everything will start coming together. You should definitely study, but studying alone will not get you anywhere unless you apply it. And if you're planning on doing this for a living, nothing beats being able to show potential employers your previous projects.

As for your plan, that's definitely enough time. You will definitely get somewhere with it!

Java. Despite what you may hear about it, this remains the number one or two (depending on who you ask) language in use.

It has a HUGE amount of libraries available and the standard library (SE and EE) cover a lot of ground.

nada, too much overhead... get something lightweight... you can run python in the terminal.
You are aware that you can also run Java "in the terminal" right?
python might be best for a non-technical person to pick up.
Python 3.

It is fairly simple to learn. It is cross-platform. It is suitable for server-side programming. It has an extensive standard library and an active ecosystem for additional libraries. It has IPython. It uses, and therefore helps you learn, but does not force object-oriented programming. It has enough functional programming to let you explore that concept. It is widespread and easy to find support for. It has numerous tutorials taking a wide variety of approaches, you can easily find something that works for you. It has more active projects on GitHub than any language but JavaScript or Java (http://githut.info/).

Why not Python 2? Python 3 is better out of the box (comes with pip, has better standard libraries) and more consistent. As a new programmer, you won't need anything that's limited to Python 2.

Why not JavaScript? It's too strange. Most of what you learn in Python is fairly applicable across languages. JavaScript has a strange object model, doesn't distinguish int/float, has odd rules for scoping (var/no var, hoisting), has too many ways to do the same things (function / var f = function, new Object() / {} / Object.create), has a confusing concept of 'this'. Learning JavaScript will not help other mainstream languages click the way Python will.

Why not Ruby? Ruby and Python are, from a new programmers' perspective, completely equivalent, but Python seems to be winning the popularity contest, so you'll likely find more libraries, more tutorials, more help, etc. Ruby also tends to be more web-focused and thus less general-purpose (by the numbers, not by any technical limitation).

Why not C/C++? They are simply too low level for someone who isn't interested in programming full-time.

Why not Java? Java is improving but is historically bloated and incredibly verbose. You have deal with compilation and probably need an IDE. You absolutely must use object-oriented programming. Support for functional programming is either effectively non-existent or simply not as smooth depending on which version of Java you're using. Too much overhead (in terms of what you have to understand and deal with) for small, simple programs.

Why not Go or Rust? Too new to have thorough support. Uncertain future.

Why not Haskell / Clojure / Erlang / Factor / etc / etc / etc? Too esoteric for a new programmer.

Why not Objective-C or Swift? Too limited in scope.

Why not C#? Actually, if you're on Windows, this is a pretty good choice, but it's not fully cross-platform (yet) and doesn't have the variety of choices for server-side programming that Python does. It also doesn't have as extensive a set of open source libraries.

Thank you for the detailed reply! A number of comments here favor Python for ease of entry and utility.

Do I understand correctly that Java is important, but with a much steeper learning curve?

Java is widespread. Whether it's important or not depends on the project. It's not so much that Java has a steep learning curve, it's that Java has the Java way of doing things (namely, object-oriented programming taken to the extreme) and you are required to do things that way. It's less flexible than Python in the way you can write your code. You have to have a firm grasp of object-oriented programming to do anything in Java. There's a lot of theory you have to learn just to get started, which in Python can just be brushed aside until you're ready to tackle it.

And with Java, you're probably going to need a heavyweight IDE instead of just being able to use a plain text editor or a REPL or other interactive environment (which Java doesn't have).

Yeah, that is right (though some will have a hard time agreeing because your definition isn't very conclusive/complete)

Job wise: if you only had one language (and did not have history as a programmer) I think it would be easiest to find employment using Javascript. The need is huge and growing all the time.

Python or Ruby are pretty easy to learn and can be used for a number of different ways.

If you had plenty of time (read money) then Java would be the best choice. Java easily has ten times the amount of jobs available, so you can imply that it's more useful if you want to accept that metric.

There's no point in only learning one language. If you can only program in one language, you literally can't program.
I've had the same thought myself. However, I'm willing to take the risk. Besides, one thing leads to another.
This is not to say that learning one language is a waste of time when you then proceed to another language. But, learning one language isn't learning how to code, any moreso than learning how to punch is the same as learning karate -- you haven't begun learning karate until you have the basics of a wide variety of punches, kicks, and blocks; in the same way, you haven't begun to learn programming until you know the basics of a wide variety of languages and techniques.

At best, stopping at your first language will give you a false sense of competence that will lead you into making poor decisions.

By all means, learn a first programming language. But, which you choose doesn't much matter, because you'll need to learn a second and a third before you start to understand what it's all about.

You don't know 'true' mathematics until you study 18th century books in German ... I sense some sort of logical fallacy here.

If you can work with frameworks, write loops, classes, know inheritance, side-effects, polymorphism etc but don't know functional programming, then you're still a programmer in my eyes.

It's a scale imo, everything is relative.

Being a programmer implies a kind of mastery over the concepts, of the type that you only get with experience. You only get that experience by having experience with a variety of tools.

Knowing how to use a hammer doesn't make you an engineer. Knowing calculus doesn't make you a mathematician. Knowing how to make a fist doesn't mean you know karate. Knowing C doesn't make you a programmer. Instead, to be any of these things in any meaningful way, you need mastery of a whole constellation of related tools and techniques and ways of thinking, as well as the practice and experience to make them work together.

You can do a lot of things with a hammer, just as you can do a lot of things with any given programming language -- both are very useful general-purpose tools. A programmer should understand the hammers of the programming world (C), the flathead screwdrivers of the programming world (python), the phillips head screwdrivers of the programming world (SQL), the power jigsaws of the programming world (prolog), the needlenose vice-grips of the programming world (awk), and even some of the nylon jeweler's mallets of the programming world (erlang, haskell, befunge) in the same way that you would expect even a relatively mediocre mechanic to recognize and understand the use of all these tools.

A language is a single tool. Concepts are concepts, and you can apply concepts with inappropriate tools just fine (you can write object-oriented code in c or functional code in java the same way you can remove a bolt with vice grips or hammer in a nail with the handle of a chainsaw).

I'd have to say Python; while its not always the best choice to use, its a great language to learn, because its used in lots of domains and because it a very good place to learn the basics of lots of different aspects of programming, and it has great learning material available for both general programming and many specific application domains and platforms, so it supports lots of approaches. If you decide to continue with it, its easy to keep learning with it; and if you decide to switch languages, its easy to take the lessons learned in Python to lots of other languages.
While I hate actually using it for production tasks, I have to admit that Python is the best language ever to learn. Its syntax doesn't really get in the way at all and it is extremely understandable. It's also widespread.
Why do you hate using Python for production tasks?
In my experience/opinion: get over a certain number of lines of code and the type system starts getting in the way rather than getting out of the way. This number is not obvious and is very easy to pass without realizing it until it's too late.
Hey, not arguing, just curious, do you have some examples of times where the type system has gotten in the way? And what languages you prefer to use for production systems that don't have those problems?
Simple example: Say you're working with an external library. And say you need to work with this function:

    def convert_to_int(val):
        ....
What type should val be? Do you pass the object, or a string representation of the object, or...?

The problem with Python - and non-statically-typed languages in general - is that function signatures don't need to be defined upfront, which leaves it up to the programmer to figure out the inner workings of the functions. This is a huge pain point when working with other people's code.

Python 3 introduced function annotations, which is great. But again, the problem here is that function annotations are opt-in. It's still up to the developer to add the annotations.

I can't give concrete examples because it's closed source code. But my personal biggest issue is class inheritance. It just becomes a complete mess. Very difficult to find what is set where, what is overridden where, what gets called where.

I know I'm going to get some crap for this, but for big prod systems I prefer C++.

Blackthorn is spot on. It's not enough to just "upvote" it.
There are a number of good answers here on general programming. If you want your knowledge to be relevant to your startup, it might depend on what kind of startup you're doing. Will it be mobile focused or Web, for example?

If web, you might go after JavaScript and some back end language (you already have some PHP background), plus HTML and CSS. Build a simple Web site.

If mobile, pick your poison. Many mobile startups start with iOS. Now is a great time to learn iOS since Swift lowers the barrier to entry significantly. If you're going after the larger Android ecosystem, then Java. Android also has the advantage that you can develop on other OS'es like Windows.

I would also recommend getting a great book and working though the examples. Then supplement with what you can find on the Web.

Good luck learning and with your startup!

Java it teaches you how to use pure programing schemes :)
I would recommend Java. Recent surveys of programming languages have ranked Java as the second most widely used programming language after JavaScript.

Java is a strongly-typed "classical" object-oriented language with C-like syntax. These characteristics make it an ideal foundation upon which to build your knowledge of programming.

Many of the newer and more popular languages deviate from the "classical" way of doing things. For example, many are loosely typed. Some use a simpler syntax without semicolons or curly braces. Others have a non-traditional OO model, or a hybrid OO / functional model.

You will likely encounter problems if you skip over the "classical" style languages and head straight for something like Ruby or JavaScript. For example, when you start to get into the more advanced parts of JavaScript, all of the books and tutorials explain things by contrasting with Java or C#. Therefore, if you don't have that classical knowledge, the comparisons will be meaningless.

If you start with a loosely typed language, you won't understand why your JavaScript developers are debating using TypeScript, or why your Ruby devs are debating switching to Java or Scala to build the app to scale. If you start with Ruby or Python you will never be comfortable with languages that use curly braces and semicolons.

I started out by learning PHP. It was a mistake. If I could go back in time I would have learned Java first. When I started to learn object-oriented programming it was tough because I had to unlearn the procedural way of thinking which was very common amongst PHP developers at the time. When I wanted to learn Android development I was confused by the use of types in method signatures. I had to go and learn Java-101 before I could do anything more than write a layout file.

I hope this helps...

Why learn a single programming language? Why not several? and by doing so get an understanding about what programming and computation is all about. From 100,000 feet, most programming languages are similar. When you know several you begin to see the unifying structures they support, and that may give you some insight into how computation is related to problems.
I think learning one sounds hard for someone new, so learning two sounds impossible.

Inch by inch...

I strongly disagree. Learning multiple languages imparts understanding and provides an important perspective on what programming is about and how programs work, and how they go together. Languages are, for the most part, easy. What's hard is the other stuff.
A multi-paradigm, multi-type-system, multi-runtime, cross-platform one: C#.
Really should tailor it somewhat to what you intend to build.

I'd recommend Python or Javascript without knowing more.

Python is useful in a variety of applications, both web and desktop, multi-platform, low barrier to entry but will get you a long way.

Javascript can be all you need on the web (though my stacks all have another language involved).

Python is great for the web as well, but you'll need javascript, too. It's pretty inescapable.

I'd vote python. It's pretty easy to learn and is very helpful for many types of programming.
> Be better prepared, as a founder, to understand engineers.

Be careful, you may start to suffer from the Dunning-Kruger effect[0]. You would only begin to understand what engineers are doing after a substantial experience with programming real world applications. However, your limited experience may make you over-confident in your abilities.

[0]: http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect

Whatever strikes your fancy. If you're pursuing startup culture at your age, and you aren't trying to become a developer/engineer yourself -- you have all the freedom in the world.

You've probably got more honed skills to contribute actively, and you won't have opportunity to make especially useful contributions programming in anything that's widespread. So you can dable in something popular to be able to read it better, explore something esoteric to have something novel in your toolkit, or just pursue something that's personally practical like the systems scripting and web stuff you've already been toying with.

Don't overthink it. Just find the one that gets you excited and spend whatever time on it you'd like.

Only 1? C++. Performance and good compilers for every platform. Raii makes handle management easier than the nested try/catch mess found in java and similar GC Lang's.

Is you can have 2 langs then pick lisp.