
Ask HN: Ruby, Python, or JavaScript for teenager? - tmaly
If you were going to recommend a language to a teenager about to turn 18, that wants to try to learn something on their own, what would it be and why?
======
zubat
Python, because it's the rare combination of "wildly popular" and "keeps you
out of trouble". Ruby has always had a one-framework-town kind of feel to it,
with Rails being the one thing people automatically associate with the
language. Javascript has the popularity, on the other hand, but it's a
minefield in so many ways. The browser is not fun to work with for anything
serious, and code written in node bitrots very easily.

So, it's Python. Python has footholds in a variety of places. It's not the
most expressive in some respects, but the built in types are more than
sufficient to power any student code.

A possible alternate is Go. Go doubles down on keeping you out of trouble by
pressing so much code into a uniform style. This may excite some students and
frustrate others depending on which threads of thought they're trying to
follow.

~~~
DiNovi
Sounds good, but then someone asks: Python 2 or Python 3? And then you realize
python has it's own problems...

Ruby and Python are so similar though just go with one.

Also, a plug for Hanami, because people are still supporting non rails
frameworks despite Rails dominance.

[http://hanamirb.org/](http://hanamirb.org/)

~~~
narimiran
> but then someone asks: Python 2 or Python 3?

And then you say: It is 2017. Python 3.

~~~
DiNovi
Sure, but a lot of useful machine learning libs are still dependent on 2

~~~
narimiran
> a lot of useful machine learning libs are still dependent on 2

If they are a beginner, they would probably start with scikit-learn, which
works on Py3.

As does TensorFlow. As does Theano. Etc.

------
nonsince
I have 3 languages that I would and do recommend for any new programmer:

\- Python, because it looks like pseudocode and it's hard to fuck up as a
beginner. Plus, if you're trying to do something real/effectful (rather than
write implementations of algorithms) imperative code matches your intuition.

\- Haskell, because it looks like maths and it's hard to fuck up as a
beginner. It's really easy to convert any maths stuff that they know verbatim
into Haskell and have it Just Work without accidentally having to worry about,
for example, how many times a piece of code is run.

\- C, ASM or LLVM IR (leaning towards the first because it has great
tutorials), because it matches how a computer really works. Ok, yeah I know,
it doesn't, but it's closer than anything else that you'd actually want to
use. C and manual memory management has gotten a bad rap recently, mostly
because of all the security vulnerabilities it causes. Sure, you don't want to
have to think about memory safety as an application developer but when you're
learning it's OK to accidentally read or write uninitialized memory or cause a
segfault as long as you've got good debugging tools to turn it into a useful
learning experience.

~~~
afarrell
Haskell has a steep learning curve. This is not a bad thing: it means that you
climb so much higher in the early days of learning if you are successful. You
learn more.

But! It also means that it is harder to climb that hill and you might just
slide down. You need good support.

------
just-for-fun
I would recommend Python because I think it is best option to learn
fundamental programming concepts like conditionals, loops, functions,
recursion, data types, basic algorithms like sorting and searching. It has
beautiful semantics which is more consistent than in Ruby or JS.

After learning fundamental concepts he can easily start learning more complex
languages and concepts with practical applications. For example he can learn
Java and Android programming or alternatively Web programming with
Python/Django or Python/Flask.

------
dqdo
Depends on what you want to do. Each language has an advantage in its own
domain.

If you want to build for the web then I would recommend learning Javascript.
You really can't avoid Javascript on the web so it is a good thing to learn it
well. You can even learn Node in order to make it easier to set up a backend
for your web app. The quickest way to get started with the web these days is
to learn Javascript and use it with a Node server on the backend. There is a
lot of noise in the Javascript community with tools such as React, Angular,
Webpack, Typescripts, etc. that are very good for advanced production code.
For a beginner, I recommend that you just stick with Jquery until you have to
write a large codebase (>50,000 unique lines of code).

Python is just a pleasure to work with. I personally use Python to write code
that solves math problems and to build small personal projects. Some people
say that there is a problem with Python version 2 to 3 transition. As a new
programmer this should not be a problem for you. Just start with Python 3. If
there is a package that you want to use, it will probably be ported over soon.
If you start with Python 2 then you will need to update your codebase for the
transition which is neither fun nor worth your time as a beginner.

Ruby is a great scripting language. I think that many of the things that you
can do with Python you can do just as well with Ruby. If you are already good
at Ruby or know some people who can help you then you should go with Ruby. If
you are new to both Ruby and Python, I would recommend learning Python since
there are way more applications for Python (i.e., data science and machine
learning).

~~~
eevilspock
> You really can't avoid Javascript on the web

WebAssembly is coming. So unless they need to code for the web right away,
pick the best language for learning, and/or the most productive language,
because getting relatively fast results is how you keep young people (unless
they're natural programming nerds) interested.

------
deeteecee
Not Javascript since he's going to end up hitting a lot of confusion if he's a
curious cat. Ruby or Python.

------
neilsimp1
Is there any reason you're only asking about those three languages? I'd say
cater to the teenager's interests.

Do they like PC games? Maybe look into C# scripting for Unity. Lua is used for
scripting/modding in tons of games. Minecraft I believe is one of the big
ones.

Do they like mobile apps? Java, Swift, Xamarin, NativeScript all come to mind.

JavaScript, Python, and Ruby are all wonderful, but I'm just wondering if
there's a reason to limit it to those three. I'd say whatever technologies
fall in line with the kids interests are best.

~~~
tmaly
I picked those 3 because they have quite a bit of a community around each. If
you are going to self learn, I thought it would be important to have a good
amount of learning material both online and in book form to learn from.

~~~
brudgers
The communities around Ruby, Python and Javascript are probably more oriented
toward professionals than is ideal for a new programmer. While there is good
content for beginners, there is also a mountain of mediocre and obsolescent
content and another mountain of content that is only partially related, e.g.
Rails, TensorFlow, React respectively.

~~~
tmaly
How do handle sorting through that mountain of mediocre and obsolescent
content?

I think that is going to be a big problem for a beginner

------
jonSson99
Everyone should start with the perl camel book,
[http://shop.oreilly.com/product/9780596000271.do](http://shop.oreilly.com/product/9780596000271.do)

~~~
ChristianGeek
I hope you're joking.

~~~
vgy7ujm
Actually those Perl books are cleverly written and fun to read (like much of
the official documentation) as opposed to the dry literature of many other
programming languages. You may like Perl or not but that is a fact.

------
karmajunkie
I would say he or she should pick up whatever the people close to them use,
because that's who they're going to turn to for help first. Yeah, there's a
lot of online resources for just about every language and platform out there,
so you've got plenty of people in the world who have blogged about X or asked
questions about Y on stackoverflow, but ultimately its hard to beat sitting
there with someone who walks you through the rough parts like stack traces
that are absolutely shit and don't point to the root of the problem in that
one out-of-the-way class method, or can point you in a more productive
direction when you decide to rewrite a framework you didn't know existed.

Of course, some people learn things better the hard way, but that's what I
wish I'd had...

------
JCharante
I'd argue your age is irrelevant, your age is only a limiting factor if you
choose for it to be.

------
csdreamer7
Ruby, specifically Ruby on Rails. There are alot of plugins and resources to
quickly setup a website. Ruby does have a learning curve, but activerecord,
devise, carrierwave, and Rails' industry support really help you use alot of
different technologies quickly.

~~~
hobs
As a person who loves Ruby, I would 100% avoid rails at every juncture.

If you want to write business software or "get things done", rails can help
you to do things in the rails way.

However, I dont think its good to have a very VERY large set of conventions;
you spend most of your time learning those and dont really spend your time
solving problems in a way that teaches you about how to think about computing.

------
brudgers
Maybe Processing because it is about making things rather than writing
programs _and_ it's community is not caught up in computer science; instead it
is built around creativity.

But in general, I would not focus on which language is better but which
language can be used to improve something that they already do. For a writer,
Emacs Lisp might be a good choice. For a photographer, Lua and Darktable might
be a good choice. For a graphic artist, Python and Gimp or Inkscape. It's not
programming language that matters so much as programming practice.

There are also languages like Snap that are beginner friendly.

BTW, if it's on their own, then it might make sense if the 18 year old
chooses. It's ok if they change their mind.

Good luck.

~~~
anta40
>> it's community is not caught up in computer science We're not talking about
Haskell/Scheme/Lisp/ML/etc, right?

If memory serves me right, I started learning Python in 2003 (still in high
school at that time). My impression was Python is easy to understand, pretty
much like good old BASIC.

~~~
brudgers
_Processing is a flexible software sketchbook and a language for learning how
to code within the context of the visual arts. Since 2001, Processing has
promoted software literacy within the visual arts and visual literacy within
technology. There are tens of thousands of students, artists, designers,
researchers, and hobbyists who use Processing for learning and prototyping._
[https://processing.org/](https://processing.org/)

    
    
          versus the landing page for Python
    

_Python is a programming language that lets you work quickly and integrate
systems more effectively._ [https://www.python.org/](https://www.python.org/)

------
vorg
Each of those languages has its downside:

* Ruby and its clones are declining as their signature frameworks (Rails, Grails, etc) are replaced by newer ones like Node, Go Http, etc

* Python has the version 2 or 3 problem for now

* Javascript is too complicated

I think in 20 years time when the dynamic language fad has well passed, like
the 4GL fad before it, there'll only be 2 dynamic languages left in the
market, just as the 4GL's dwindled to only Visual Basic and perhaps Delphi.

They'll be Python 3 and Javascript, so choose one of those.

------
amorphid
I will recommend learning any two of those three. They are all useful,
commonly used, and it's super helpful to understand how to do things in a
couple different languages. Basically, it'll be hard to feel like you really
understand programming until you start thinking about the strengths and
weaknesses of any given language.

------
wikibob
Is this their first time programming? If yes, the approach to learning
computer science is more important than the particular language used.

There's something to be said for David Malan's approach in Harvard's CS50 [0].
He and his team work very hard to make computer science exciting and get the
students to have some results quickly. The production values are incredibly
high. He takes the class through C and Python.

Coming from a very different approach, you have Matthias Felleisen at
NorthEastern University and his How to Design Programs (HtDP) book [1].
Matthias has written extensively on the decisions behind HtDP [2][3]. HtDP
uses teaching languages built into DrRacket (which was originally based on
Scheme) to gradually introduce new concepts to students.

HtDP is based on the classic Structure and Interpretation of Computer Programs
(SICP) from MIT [4], but it addresses some criticisms of SICP as an
introductory text. Namely that SICP leans too heavily on domain knowledge
outside of computer science.

The course webpage [5] for Fundamentals I from NorthEastern is not very useful
for self-study. Instead check out the EdX course "How to Code: Simple Data and
Complex Data" [6] by Gregor Kiczales at University of British Columbia.

Unfortunately the course has been branded as "how to code" for marketing
reasons, but overlook that because it is a very solid offering that is
directly based on HtDP. In fact, Gregor's page outlining and summarizing the
HtDP design recipes for How to Design Functions, How to Design Data, and How
to Design Worlds, is significantly clearer and easier to comprehend than the
original explanation from the book.

The only limitation with the EdX _How to Code_ course is that for some reason
they are only "open" for enrollment once pear year. Fortunately the first
course is currently open at the moment. Obviously don't bother with the
verified certificate/MicroMasters stuff, the content is the only important
thing.

Also of note if you're still looking for Python based, is the newish Berkeley
CS61A course taught by John DeNero [7]. It is the most all-in-one option for
self-learners as the book, the course assignments, and the videos, are all
freely available online, and well organized. Similar to HtDP, DeNero's CS61A
is also based on Structure and Interpretation of Computer Programs. I have not
yet gone through this course so I can't speak to the content first-hand. Of
historical note, the course was taught by Brian Harvey using SICP and Scheme
up until he retired a few years ago. Brian wrote his thoughts on the change
and there was a discussion here on HN [8].

DeNero has written his own book called _Composing Programs_ [9]. Additionally
the couse uses Phillip Guo's pythontutor.com for visualizing assignments.

All in all I would say if you are good at self-teaching and don't mind the
lack of videos or course materials, check out SiCP. Otherwise, if high
production values are appealing then check out CS50. And if you want an all-
in-one package that has some of the same solid foundation as SiCP, then go for
Brian Harvey's CS61A.

Hope this is useful to someone.

[0] _CS50 at Harvard:_ [https://cs50.harvard.edu](https://cs50.harvard.edu)

[1] _How to Design Programs book:_
[http://www.ccs.neu.edu/home/matthias/HtDP2e/](http://www.ccs.neu.edu/home/matthias/HtDP2e/)

[2] _Essay by Matthias on The Philosophy of HtDP:_
[http://www.ccs.neu.edu/home/matthias/OnHtDP/turing_is_useles...](http://www.ccs.neu.edu/home/matthias/OnHtDP/turing_is_useless.html)

[3] _Essay by Matthias on Growing a Programmer:_
[http://www.ccs.neu.edu/home/matthias/Thoughts/Growing_a_Prog...](http://www.ccs.neu.edu/home/matthias/Thoughts/Growing_a_Programmer.html)

[4] _The Structure and Interpretation of the Computer Science Curriculum:_
[http://www.ccs.neu.edu/racket/pubs/jfp2004-fffk.pdf](http://www.ccs.neu.edu/racket/pubs/jfp2004-fffk.pdf)

[5] _Fundamentals I at NorthEastern:_
[https://course.ccs.neu.edu/cs2500/](https://course.ccs.neu.edu/cs2500/)

[6] _EdX course based on How to Design Programs:_
[https://www.edx.org/micromasters/software-
development](https://www.edx.org/micromasters/software-development)

[7] _John DeNero 's CS61A at Berkeley in Python:_ [http://www-
inst.eecs.berkeley.edu/~cs61a/fa16/](http://www-
inst.eecs.berkeley.edu/~cs61a/fa16/)

[8] _Brian Harvey: Why SICP matters_
[https://news.ycombinator.com/item?id=4784827](https://news.ycombinator.com/item?id=4784827)

[9] _John DeNero 's Composing Programs Book:_
[http://composingprograms.com](http://composingprograms.com)

------
a3n
Whatever his friends, you, or other go-to mentor use.

------
macscam
Javascript because its used for websites.

~~~
tmaly
I can agree this is one good reason for Javascript. I am just worried about
there being too many mine fields in the language for a beginner.

~~~
medemi68
I think that Javascript is great for it's implementations in NodeJS, but yeah,
I see two sides to the argument:

The syntax, semicolons, etc are minefields.

or

The syntax, semicolons, etc can teach good habit and save a lot of headaches
in the future (missed a semicolon here, missed a semicolon there.. etc)

------
bwbw223
Rust because it's fast and safe

------
bakoo
I love both Ruby and Python, but would actually recommend Go.

Go is easy to get started with, has very readable code, fewer keywords to
remember and internalize, and lets you fire up a webserver in a few lines of
code on all platforms without having to install any extras.

It's also extremely performant, which isn't really important, just attractive.

------
tysonstewart
Go with Python. It is easier to understand and some really good tutorials out
there.

~~~
brudgers
Which Python?

~~~
narimiran
> Which Python?

You mean Python 2 or Python 3? If you are a beginner and just starting -
Python 3, without a doubt.

(Well, even if you aren't a beginner you should use (or switch to) Python 3)

~~~
brudgers
That "Which Python?" is an important question and that the existence of two
versions of Python can make finding correct information harder is one of the
reasons I am not wild about recommending Python to beginners -- particularly
those who are going to be learning on their own.

~~~
curioussavage
I think your making an overly big deal about this. Never really had an issue
with this doing simple python stuff.

~~~
brudgers
The functional trio: map, filter, reduce is one place where it matters. In
Python2 that was simple Python stuff. In Python3 map, filter, reduce is
unPythonic.

------
PaulHoule
Python.

