
Ask HN: What language should I learn first? - mhorne27
I want to learn to code. Which language should I start with, and why?  Just signed up for Codeacademy...
======
tel
There will be a thousand opinions. Ignore them.

The problem is that you're asking the wrong question. If you want to "get
into" programming you need to do roughly two things to start.

    
    
        1. Find a reason to care. This can be a pet project, 
           a particular question, an application domain, a 
           partner or team you'd like to work with, the desire
           to understand someone's work you admire, etc.
    
        2. Learn how to think formally as a programmer. This
           is sort of like learning how to code, but it's 
           different from learning any one language.
    

The point is that as you discover greater passion for something in (1) you'll
discover greater need for (2). Simultaneously, as you improve (2) you'll
become more sensitive to (1).

The other point is that languages are dumb. There are lots of reasons to learn
one or another, but by and large becoming an "X programmer" is a non-goal
unless it is somehow required for (1). For instance, joining a team of Ruby
programmers may require becoming a Ruby programmer yourself.

So, discarding the philosophy, what do I recommend?

Learn whatever language you can the most quickly. Then learn another. Python
may already be installed on your computer, so you can get started quickly. The
story is probably the same for C, Ruby, Java, and Perl. If you know how to
launch web pages online then PHP is probably available.

Recognize that programming has a large comparative linguistics component. No
single language will teach you (2) above, but solving many diverse problems in
a single language might get you a lot of it. Studying many languages expands
your familiarity with _how to represent things_ and that can be a big boon to
(2). Later on in your career, it's often very valuable to explore languages
with vastly different background models and assumptions. Early on, I'm not
convinced it's such a huge deal... so long as you don't get stuck with a
single choice for too long.

And above all, have fun. CS/Programming/Software is a fascinating world for
all kinds of reasons.

------
joemccall86
Whatever you choose, learn git along with it. It helps to answer the question,
"This used to work, what did I do to break it?"

Also, call me sentimental but I learned C/C++ as my first language and would
recommend it. I don't see a codeacademy class for that though, and it's not
really perfect for web development.

If you find that codeacademy isn't working out, I've also personally used
codeschool.com and had great experiences there.

~~~
iamwithnail
Actually, I should have mentioned this in my own post. I can't emphasise the
point about git enough. I didn't _really_ get it at first so shied away.
Version control is one of THE most important things you'll learn, for a whole
variety of reasons.

When it clicked I remember thinking: "Oh, it's like save games for coding."

------
chrismaeda
Here's my path (~30 years worth).

high school:

    
    
      basic
      6502 assembly
      a little FORTRAN
      a little pascal, but didn't understand it
    

mit:

    
    
      scheme (sicp omfg)
      symbolics lisp
      common lisp
      clu
      pdp-10 assembly
      connection machine
      a little C
      a little more FORTRAN
    

grad school / 90's:

    
    
      a lot of C (system programming / unix kernel hacking)
      Obj-C / NeXTStep (reappears later as OSX / iOS platform)
      MIPS assembly (branch delay slots ftw)
      x86 assembly (segment registers wtf)
      ALPHA assembly
      a little C++, but hated every minute of it
      Visual Basic
    

dotcom years to present:

    
    
      Java
      C#
      SQL (Oracle, Sybase, MSSQL, DB2, MySQL, etc)
      Python (scheme without parens!)
      ETL platforms (visual programming environments for data manipulation)
      PHP
      Obj-C / iOS (oh hi, you're back)
      Groovy / Grails
      a little Ruby / Rails
    

I'm a little weird because I did a lot of Lisp early, and then became an OS
hacker. Once you can find single-line errors in assembly code, everything else
is easy.

I learned a lot doing C and assembly; especially the importance of working
clean, checking results, and being careful with pointers. Lisp teaches you how
good the world can be; C and assembly teach you how to cope with how bad it
really gets. However, I'm not sure I would recommend a new person to spend as
much time on this since the world has moved to languages with garbage-
collected heap storage.

I never cared for the functional languages (ML, etc), mostly because I found
the functional programming zealots to be such insufferable bores.

If I were starting today, I would start with Java or Ruby, since they are
modern OO languages with good deployment options. Once you know these, it's
easier to "downgrade" to simpler languages like Python, PHP, and JS.

But the real takeaway is that you should learn them all.

~~~
danesparza
"I'm a little weird because I did a lot of Lisp early, and then became an OS
hacker."

+1 for introspection! (Or do programmers call that reflection?)

------
iamwithnail
Slightly against the flow here: I chose Python (and Django) when I learned to
code (and built our MVP for www.gmbl.io, still a few rough edges - plug, plug)
Python's GREAT, no doubt, and Django is also very good.

But I've repeatedly found myself wishing I'd gone with Ruby/Rails (it was
basically a coin toss.) because I've ended up in an environment where everyone
else is working in Ruby for their pet projects - and it would be great to be
able to tap their knowledge.

So, have a look around, what are people you know using? It's probably really
useful to choose something that your friends know (if any of them code), or
that you know there's a decent support for in your area - but beyond that, it
doesn't really matter. And Python's really nice.

~~~
mrharrison
I agree, the opposite happened to me. I learned Ruby on Rails, but everybody
around me was Python/Django, so inevitably I made the switch because friend
knowledge makes it easier to pick up.

~~~
iamwithnail
Shall we swap friend groups? :-D

I'm thinking about switching to Ruby (or at least learning enough I can join
in.)

------
azdle
Call me old fashioned, but I'm going to suggest learning C. It's one of the
smaller languages around so you'll be quickly able to get past the "learning
the language syntax" stage and into the "learning to program" stage. It's also
still one of the most widely used and supported languages out there. It's also
closer to how computers actually work so you'll learn more of what is actually
happening when the computer runs your code.

Pick up a copy of K&R [1], read enough to do a hello world and start playing.

[1]
[https://en.wikipedia.org/wiki/The_C_Programming_Language](https://en.wikipedia.org/wiki/The_C_Programming_Language)

~~~
hackerboos
I disagree. The C syntax is small and pretty easy to learn but the a learner
will be stumped when it comes to installing the compiler, dealing with cryptic
compiler errors, pointers and weak typing.

I'd recommend Python as it's easy to setup on any platform, has a clean easy
to read syntax (newbies don't need to worry about generators or decorators
early on), has a REPL and has a ton of good _free_ learning references [1].

[1] -
[http://learnpythonthehardway.org/book/](http://learnpythonthehardway.org/book/)

------
valarauca1
Python is a good pick.

The goal of learning to program shouldn't so much be about one language, but
learn about the concepts of what variables, control structures, operators, and
data structures. So that you can apply them in different languages, and be
more flexible.

------
Argorak
All languages present on codeacademy are worth learning.

But: if you have something in mind you want to build, pick a language and
environment that fits it. If you want to code on microcontrollers, python and
ruby are not a good idea. Want to build a website? python or ruby + javascript
are a great idea! Use something that people commonly use to solve such a
problem.

Your first implementation will be bad in any case, regardless of language. You
will laugh at it in a few years. Rebuild it after a whilse. But thats no
problem: everyone of us went through this process.

------
PeterWhittaker
What are your short, medium, and long term goals? How much do you understand
about how computers and networks work?

If you want to start by creating web pages but eventually move to programming,
learn HTML. Get really, really good at it - but without CSS. Then learn CSS,
and learn how they work together, how they complement each other. Then add
Javacript and DOM manipulation. You can do some very cool stuff, you'll learn
a lot of logic along the way, make interesting mistakes, etc.

If you want to control a computer, get something that speaks Bourne shell
(OSX, Linux, etc.) and get really, really good at defensive-minded shell
scripting (by defensive-minded I mean always being alert for errors, always
quoting variables, always checking return codes, etc.). You will learn a lot
about how computers work, how they are structured, etc.

In both cases, you will also begin to feel the frustrations of working with
these tools: Why doesn't this work, why is this so hard, etc., etc.

You could start with something more modern, more powerful, like Python or PHP
or Ruby, but will you appreciate their power if you don't have a good
understanding of the problems they were created to solve?

But that may not matter, if you want to build web apps using powerful modern
frameworks. Where are coming from, where do you want to go?

There are many, many other ways to answer the question, depending on what it
is you actually want to accomplish and how much you understand about how
computers work.

------
fnordsensei
It depends what your goal is. Do you want to learn to be a good programmer, or
are you looking to, for example, make a website as soon as possible? Is your
vision to eventually make apps? Do you want to learn the "art" of programming
or the "craft" of programming? You'll end up learning both if you pursue it,
but this may impact where you start out.

Some people argue that starting with a functional language will make you a
better object oriented programmer later on, while the reverse is less often
true. If you believe in this, I would recommend Clojure from personal
experience.

In my first programming courses at university, we used Lisp and ML. This was
for learning the "art" of programming, i.e., learning to think like a
programmer. Once you picked a course that was arguably more about the "craft",
you were exposed to a language more native to the domain. As I choose to go
towards front end related stuff, I was exposed to JavaScript and (at the time)
ActionScript.

I ended up not working as a programmer; I'm UX designer. When I need to, I
program most of my interactive prototypes in ClojureScript. Two years ago,
that would have been JS, but I found that Clojure conforms to my thoughts
rather than the other way around.

So, depending on where you are and where you are going, you might benefit from
different advice, I think.

------
dennybritz
It doesn't really matter, but Python is a good choice. It's intuitive, has a
great ecosystem, and lots of different practical applications.

------
pavlov
How about learning BASIC first?

You'll hear people say that exposure to BASIC will rot your mind... But most
of today's best programmers started out with BASIC simply because that's what
you got when you started up a 1976-86 vintage microcomputer or played with MS-
DOS. Clearly they were not permanently damaged by it.

The good thing about learning BASIC is that you won't be accidentally
comparing your work to that of professional programmers. If you start with
JavaScript, you'll be exposed to amazing JS tricks anywhere you look. Any
Google search or "View Source" will show you stuff that you'll be struggling
to understand. That can be very discouraging.

Here's a totally retro web-based BASIC environment:

[http://www.quitebasic.com/](http://www.quitebasic.com/)

There are of course much better modern BASICs around, e.g. Microsoft's Small
Basic
([http://en.wikipedia.org/wiki/Microsoft_Small_Basic](http://en.wikipedia.org/wiki/Microsoft_Small_Basic)).

------
projectramo
I am sure others are going say, or have said, something similar:

If you had to learn a _second_ language, the question has many great
candidates for answers. Python, Ruby, Scala, or a more functional language.
Maybe a rapid prototyping language. If you believe in mobile first, then
Swift, or Objective-C, or Java. If you need to manipulate data then Python, R
or Julia. If you believe that you should learn the "foundations" first (read:
legacy language) you could go back to C. If you like the Microsoft ecosystem,
C#. If you work with Excel (what a beautiful product) then VBA and so forth.

But if you want the first language, then I think the answer is simple:
Javascript.

I think it is an ugly language, and I wish another language had become to
dominant, but history is what it is. Its in the browser, and so it is
everywhere. You have to work with it for the most interfaces anyway.

A little sooner, and I am sure this would start a mini flame war, but as it
is, this comment is safely tucked down the chain.

------
spot
javascript because

1) you can program anywhere, 2) it has incredible libraries for multimedia and
interaction which makes it fun, 3) you can share the results with one click to
anyone 4) it is a highly marketable skill

a lot of other people are recommending python which is fine if you are into
the command line and file IO. if you prefer the web, then JS is the way to go.

------
porter
Python. Just pick it and move on.

------
yk
Does not matter, you will pick the wrong one. Thing is you will always regret
not coding in X because of feature Y, when you actually have a project. On the
other hand, you will not notice all the times that features A, B and C of your
language of choice are helpful. So at least subjectively, another language
would have been better.

As actual advice, it depends on your goals. If you want to build websites,
then you should start with Java Script and perhaps another language for the
backend. If you want to understand computer systems on a fundamental level or
hack the Linux kernel, then you should pick C. And if you want to see
progress, pick Python. But it is not too important, since a large part of
programming is language agnostic. So just pick one, and learn another when the
pain becomes unbearable. ( Then return to the first one, once you realize your
mistake.)

------
rafaelm
What do you want to achieve when you learn how to program? Mobile dev, web
dev?

I'm on a similar path. I've been learning to code now for like 3 years, never
really having the time. Now that I'm out of a job, I've got some free time and
I've always had some web projects I wanted to work on. So even though I've
been trying to learn python for the past 3 years, I've recently started
following the reddit learnjavascript course that started last week [1]

I figured that with JS, I can learn Node.js and have some frontend and backend
knowledge as well. Maybe someone much more knowledgeable than me can chime in
on my approach?

[1]-[http://www.reddit.com/r/learnjavascript/comments/2c5aue/lear...](http://www.reddit.com/r/learnjavascript/comments/2c5aue/learn_javascript_august_2014_session_omnibus/)

------
dragonwriter
I'd lean slightly toward recommending Python to beginners, but don't get stuck
on whatever you learn first. Try to learn at least one new language a year
till you have several under your belt -- and even then, its not a bad idea to
continue to do that.

And try to mix families -- each provides different insights. The first few
might be something like:

1\. One of Python or Ruby 2\. JavaScript 3\. One of Java or C# 4\. Erlang 5\.
C/C++ 6\. One of Haskell, Scala, F#, or OCaml (but I'd lean heavily toward
Haskell)

(Also, if you are going to use relational databases, learn SQL -- yes, there
are frameworks that abstract it largely away for you, but you _really_ want to
understand what's going on behind the scenes. But that doesn't need to be in
among the first things, unless heavily RDBMS-dependent stuff is going to be an
initial focus...)

~~~
danesparza
Good recommendations, I think.

Thank god you didn't recommend Perl or PHP.

 _shivers_

------
orclev
For serious work, starting with something like Python is probably a good idea
(as many people have suggested), but if your goal is to learn about
programming, I'd actually suggest you start with assembly. Assembly is really
tedious to do anything practical with, but as a way to understand some of the
most fundamental concepts in programming it really can't be beat. Doing the
equivalent of hello world, in assembly and really understanding exactly what
each line of the program is doing will pretty much make you better than most
newbie programmers right from the start. If you jump to C next, do a little
bit more there, and then finally jump to something like Python (bonus credit
for calling C code from Python and vice versa) you'll be well on your way to
being a fairly well rounded programmer.

~~~
PeterisP
Definitely NO. Assembly is okay as a second or third language, but not as the
first one.

Python->C->ASM will have a much larger chance of success than ASM->C->Python;
there's a good reason why college programs don't start with assembly first.

~~~
logicalmind
In my experience, there are two kinds of programmers. Top down and bottom up.
Top down programmers have good success going from high-level languages to low-
level. Though, learning a low-level language for them is not really necessary.
Bottom up programmers don't grasp many of the fundamentals of programming
until they can build them from basic underlying concepts. Some bottom up
programmers may never get to a higher level language and end up as systems
programmers or embedded programmers, maxing out with C as a high level
language.

Personally, I am a bottom up programmer. I started with C and I found it
confusing and ended up really disliking programming (I was in an EE program).
Then in a later term we used assembly and once I got that foundation,
everything clicked. I suddenly realized why C was necessary and what it
provided. High level languages were then built up from there.

Everyone is different. There won't be one path.

------
facorreia
I believe that you can't go really wrong with any of the languages offered at
Codecademy. If you have to pick one I would suggest JavaScript. It's not
uncommon for projects to involve another language + JavaScript, so the syntax
knowledge should be useful for years.

~~~
mkaziz
I would actually recommend against using JS as your first, since it's so
atypical.

~~~
danford
I would have to disagree. It all depends on how you learn JS. I really liked
the book _JavaScript: The Definitive Guide 6th Ed._ which at many points
talked about the differences between JS and C. As someone who learned JS as a
first language, I find the syntax is close enough to C and C-Like languages to
make picking them up fairly easy, but I'm still a novice and while I know JS
pretty well I've only dabbled in C, D, and Rust as lower level languages. I
found these languages to be almost like "extended" JavaScript because I didn't
have many issues reading simple functions, and that's why I think it's a good
language to start on, you can learn how to actually read and understand code
with C-like syntax which, for me, made understanding lower level C-like code
seem a lot easier.

Plus I think JS is fun to use because of how fast you can see your work "come
to life". JS is also in high demand.

~~~
DaCapoo
Choosing any language because it's in high demand is a bad decision, see "Why
SICP matters"[0].

" I tell my students, "the language in which you'll spend most of your working
life hasn't been invented yet, so we can't teach it to you. Instead we have to
give you the skills you need to learn new languages as they appear." "

With regards to your statement, "It all depends on how you learn JS": That
could be said of any language. The fact that you learned the differences
between JS and C is what helped you when you were beginning, not that you
learned JavaScript instead of Java, Ruby, or Python.

[0] -
[http://www.eecs.berkeley.edu/~bh/sicp.html](http://www.eecs.berkeley.edu/~bh/sicp.html)

~~~
gnur
That is odd advice, the top programming languages currently used have been
around for at least 19 years (python, ruby, javascript, php, java, c,
objective c) and while there are new languages being developed I don't see
languages like go, rust or swift pushing any of those languages out of the
market.

If anything, programming languages are a long term investment and I think that
learning a language that is in high demand isn't that bad of a decision, you
could learn some obscure super expressive, highly functional, statically typed
language, but there is large chance that you'll come in contact with
javascript at one point in your career.

------
agxbr
Doesn't matter, pick one and move your focus to algorithms and data
structures.

~~~
jimktrains2
Exactly. Don't learn to write code, learn to program. Even BASIC or PHP will
do; learn how to think about problems and how to bare different tools on it.

------
lsiebert
Why do you want to learn to code is a detail you left out, that's very
important.

It's like saying, I want to learn to drive: If you are going to be a trucker,
that's going to mean something different from being a biker.

I'd recommend Python as a first language. It wasn't my first language, but
it's general purpose enough that you can do a lot with it, and popular enough
that you can interview/get work/meet other people who use it. Oh and it runs
from the command line straight off, and you are going to want to learn a bit
about the command line.

------
aaachilless
When you don't have a Jeep, don't take the shortcut that runs through the
jungle. You're goal should be to keep moving and not get discouraged when you
get stuck on something. I would learn a language that lets you take the
highway instead of the shorter but trickier jungle road. Ruby, Python, Basic,
and Javascript could be considered "highway" languages while C, C++, Java, and
most other languages could be considered "jungle shortcut" languages.

------
jameskilton
If you want to jump in and go, I highly recommend Ruby, though I will warn
that Rails can be very imposing if you aren't familiar with web development
already.

If you want to understand more low level concepts, you can never go wrong with
C, and these days Rust is a good choice for that as well (though steep
learning curve if you have no previous experience).

------
vkjv
C. It's low enough that you don't get to skip out on core concepts. I notice a
lot of younger programmers who have only used high level languages use
inappropriate data types because they do not understand the implications of
their choices.

It's also high level enough that you won't waste time in minutia of just
making something work.

------
moron4hire
JavaScript. Why?

Extremely low barrier to entry: you already have everything you need.

Results are immediate: you don't have to wait around for an app approval
process to share your stuff.

It sucks: teaching a healthy respect for learning a language _well_ and
finding all of the pitfalls. Every language has them. Best not to start out
assuming they don't.

------
kp25
Python + Django, Ruby + Rails, Javascript + Nodejs..

Most people are in love with Python, Not everyone. You may or may not love it,
So try experimenting and choose the one.

Codecademy is good place to learn syntax and language basics, but books are
the best choice to improve your skills.

Never stop learning, Try some Open Source Project, You'll learn much more..

Have Fun, Good Luck

------
fdik
[https://docs.python.org/3/tutorial/index.html](https://docs.python.org/3/tutorial/index.html)

It's very easy to learn, at the same time a very good language to be capable
of writing code. It's multi paradigm, so you can learn a lot of different
things.

------
jimktrains2
Whichever language you choose, pick a project you want to do with it. I find
that having a goal, even a silly or small one, presses me through some of the
more frustrating parts of learning a language and the time commitment it
brings.

------
aioprisan
Pick JavaScript or Ruby. JS because you can go full stack and can move on from
some client-side work to full stack pretty easily with node.js. Ruby because
it had beautiful data structures and I'm not a fan of forced whitespacing.

------
dyeje
Whichever one looks interesting. Once you get one down, picking others ones up
isn't as challenging. The important thing is keeping your motivation up, so
pick one that excites or intrigues you if possible.

------
davewiner
Why JavaScript is the language to learn.

[http://scripting.com/2014/08/15/whatLanguageToLearn.html](http://scripting.com/2014/08/15/whatLanguageToLearn.html)

------
cratermoon
LISP, using Peter Seibel's book "Practical Common LISP":
[https://cmdev.com/isbn/1430242906](https://cmdev.com/isbn/1430242906)

------
kasperset
I guess this will also help-
[http://www.charlespetzold.com/code/](http://www.charlespetzold.com/code/)

~~~
farresito
That's a very very good book, although what he is probably asking for is a
programming language :)

~~~
kasperset
I think it would help OP to understand programming in general sense but then I
am still a newbie so correct me I am wrong.

------
ingend88
I started learning with Python and then HTML, CSS, JS with Angular+Firebase!
This allows you to start building stuff right away.

------
cafard
What is your preferred computer? If Windows, then I must agree with myddle's
recommendation of Python.

~~~
babo
I don't get your comment. Python is great on each platform but Windows where
you must put some extra effort to get it running.

~~~
jensnockert
Python is just some extra effort. While Ruby is much more of a pain on
Windows.

------
nyddle
Python seems like a good choice as it is simple and can be used in a wide
variety of applications.

------
Artemis2
Python would be a good choice since it's easy to learn but very powerful.

------
davewiner
JavaScript. Everyone has the runtime already installed.

------
osconfused
Learn Swift. Mobile is the future.

~~~
dragonwriter
Mobile may be the future, but Swift is limited to one vendors mobile platform,
while there are a ton of languages (C#, JS, Python, Ruby, even Haskell) that
you can use for mobile that aren't limited to one vendor''s platform. Plus,
"mobile" usually has a server component, and those other languages can also be
used for the server end.

~~~
osconfused
Where can you run python on Mobile? Also, yes of course it's one vendor. One
vendor that also has the world's most profitable app store. OP asked for a
language to get started with. In my personal experience, being able to see
items move on screen is a lot more intriguing to beginners than doing some
server specific tasks like building an API.

------
tvirelli
Why is everyone hating on PHP?

------
Pururim
Pascal.

------
obeid
Python

------
gb2312
c#是我第一个学的语言。

------
renang
Pseudocode is a good start unless you already have a project in mind?

Remember there is no one-language-solves-all-problems, you gotta pick the
right tool for the job and you shouldn't be afraid to hop between those tools.

~~~
Artemis2
Pseudocode is only good for theoretical algorithms as it does not provides
immediate result, and can at most do the work of a Ti calculator. Learning a
real language provides a lot more interest and satisfaction.

