
Ask HN: I want to learn a low-level, compiled language. What should I chose? - Jmoir
My background is mainly in Python and Java. I am currently considering C, Go or Rust. Which should I go with and why?
Thanks.
======
dman
Pick C or C++. There is a huge amount of code out there in these languages and
learning one of them will open the door to you being able to benefit / learn
from it.

------
kibwen
Rust makes a fantastic first systems language, due to the fact that the
compiler guides you in learning correct low-level memory management and
prevents things that would just cause your C program to crash unhelpfully.

If you don't need a language that's as low-level as possible, then Go is also
a good language to learn. It doesn't have much to teach in the way of memory
management, but it does have pointers.

------
jtchang
Learn C. Specifically learn pointers and memory management. Just these two
concepts will give you a huge understanding of any other language.

------
kristianp
C and Go are quite small languages. I love C for its history and low-level
view of the machine. It's worthwhile learning C I think, as a way to
understand part of the history of programming. However it makes it time
consuming to program even simple things. Go is more productive, with maps,
strings and a garbage collector.

C++ and Rust are both relatively complex. If you have aspirations to working
on large native projects, then C++ might be the way, with Rust becoming more
prevalent in the future.

~~~
Tiksi
While I'm a fan of Go, I don't see it as a low level language. I suppose in
terms of language features you could argue that simple/small is low level, but
from a machine point of view, I feel like anything that doesn't let you manage
memory manually can't really be considered low level.

I'd probably throw my vote at C for a low level language. Even if you never
actually write anything in C, being able to understand the massive amount of
code out there in C is a definite plus, and it gives you a good understanding
of what's happening at the machine level and underneath the abstraction of
other languages.

------
johan_larson
I'm not familiar with Rust, so I can't advise you there. But I have worked
with the other two languages.

Go is not a great choice, because it's not very low level. You don't allocate
and free memory explicitly, and you often work with maps, slices, and
channels, which are quite high-level.

C is a reasonable choice, since the core of it is fairly simple. I expect that
forty years of incremental additions have added quite a bit of cruft though,
which you have to be able to see though. There also isn't very much work done
in plain C these days. Most people in this space use C++, which is even more
complicated.

May I ask what you are hoping to do with this skill? If you just want a chance
to learn more about how computers work, an artificial assembly language like
MMIX may teach you more while avoiding much of the cruft that real languages
pick up as they evolve. If you actually want to use this for work, C++ is the
way to go, but expect to be a beginner for a long time.

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

~~~
brudgers
Are there any workbooks with challenging exercises for MMIX?

~~~
johan_larson
I haven't used it, but this supplement to Knuth's classic The Art of Computer
Programming is bound to be instructive:

[http://www.amazon.com/gp/product/0133992314](http://www.amazon.com/gp/product/0133992314)

------
stray
Why not step off the beaten path and try a language that is safer than Rust,
has a better concurrency story than Go, performance similar to C (but without
as many ways to shoot yourself in the foot)?

Ada.

~~~
kibwen
Ada doesn't have Rust's concurrency-safety guarantees, and if you're using
dynamic allocation then Ada requires a garbage collector to maintain memory
safety whereas Rust doesn't.

~~~
zerr
Overall, I got an impression that Ada encourages value-based programming. It
is possible to do a lot of things without dynamically allocating a memory.

------
woolybully
C because, a) every language we're currently using is a reaction to C (or a
reaction to a reaction to C, etc.), and b) it is still going strong in areas
such as Linux development, and is enjoying a huge resurgence in areas such as
Arduino.

~~~
hanniabu
You're saying people are moving away from C++ to C for the Arduino? What's
your guess for reason of the resurgence?

------
SixSigma
You don't say why you want to do it.

I would really recommend learning to program in assembler. And I think the
best way to do that is something like AVR [1] or ARM on an embedded device but
X86 is do-able with NASM [2] [3]

There's always MIPS via SPIM [4]

Learning assembler will give you more than simply swapping one imperative
language for another. Python / Java -> C / Go / Rust is really not that large
a leap. You will have the basics down in a few evenings.

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

[2] [http://www.nasm.us/](http://www.nasm.us/)

[3]
[https://en.wikipedia.org/wiki/Netwide_Assembler](https://en.wikipedia.org/wiki/Netwide_Assembler)

[4]
[http://programmedlessons.org/AssemblyTutorial/](http://programmedlessons.org/AssemblyTutorial/)

------
drallison
I'd recommend learning assembly language using a macro assembler. Getting up
close and personal with actual hardware without a particular programming model
being interposed will give you an appreciation for the conceptual and
practical support programming languages provide. Writing programs that run on
bare metal and programs that run with operating system support is an
educational experience of the first order. Just writing a program that
bootstraps itself is a right of passage.

------
MalcolmDiggs
Given your background, I think you'll enjoy C. The standard Python interpreter
is written in C, and the Sun JVM runtime is C. So if you learn C, you'll start
to understand the building blocks that came together to make those higher-
level languages.

After you get the fundamentals down, take a look at the source code behind
those runtimes, and it'll make you a much stronger programmer in all the
languages you know.

------
JoachimSchipper
Aside from everything already said, C integrates very well with Python;
understanding C will let you write Python bindings for new libraries and will
let you easily rewrite performance-critical chunks of Python in a faster
language.

For Java, you could learn C++ (via JNI) for the same reasons - but Java is
less likely to use C libraries, and going from Java to C++ usually doesn't
produce as much of a speedup as going from Python to C.

------
kele
When I started learning low level programming, I've studied C and x86 assembly
simultaneously. This gave me a somewhat broader perspective.

From my experience with learning Rust, it might be a little hard to grasp both
"the low level world" and Rust-specific things at once.

------
ddgflorida
Choose C because of the huge amount of source code still out there, plus
coding that close to the machine will help you be a better programmer.

------
tim333
Depends a bit what you want out of it. C for fundamentals, Go for fast web
serving, Rust for stuff that's memory safe?

~~~
Jmoir
Honestly, I have no projects or specific uses for these languages. Rather, I
am treating it as a tool for learning and to experience low level programming.

I might make some kind of machine learning application in it later down the
line though.

~~~
tim333
The usual recommendation "for learning and to experience low level
programming" would be C. See this for example
[http://www.joelonsoftware.com/articles/CollegeAdvice.html](http://www.joelonsoftware.com/articles/CollegeAdvice.html)
although that was written before Go and Rust.

Also if you're mucking about with machine learning a lot of the libraries seem
to be in C or C++. I played about a bit with computer vision using Python but
sometimes the Python bindings don't work or don't exist and I was thinking it
would be easier to just call the things from the C/C++ they are written in.

~~~
kibwen
We're actually growing a rather nice machine learning ecosystem on the Rust
side, though obviously it's much less mature than the C/C++ solutions. See
[https://github.com/autumnai/leaf/blob/063ce978004b8bf4b7fc74...](https://github.com/autumnai/leaf/blob/063ce978004b8bf4b7fc7481fdd58fed0515cfd8/RELEASE.md)
for an example.

------
chmielewski
REBOL and/or red-lang.org

------
syllogism
Cython

------
tomyncy618
test comment, sorry!

