How to learn nearly any programming language in half an hour or less!

in #technology6 years ago (edited)

brainfuck.png

“Truth can only be found in one place: the code.” - Robert C Martin

I've mentioned before that I'm a programmer - I'm going on five years (I think?) of Java and a host of other languages I've played with. While my main motto is that if you know Java, you can learn any language, today I'll show you an easy shortcut that'll allow you to learn a language in half an hour or less. Or perhaps the time it'd take to read this post! I'm not entirely sure. Let's conduct an experiment, shall we?

I propose that learning a new programming language in half an hour or less rests on learning one language. It's bizarre, it's confusing, and it's an utter nightmare to use... We call it Brainfuck.

BF is a turing-complete language. What this means is that, given enough memory, it can compute any algorithm written for the language. While I won't get into computability theory here, I will tell you that's a great quality any language should have. BF, however, takes it to the extreme: Memory consists of a number of cells whose value can take on any whole integer between 0 and 255, and is accessed via pointers. It has arithmetic functions, loops, even I/O capability... The kicker? There are ONLY EIGHT COMMANDS! They are depicted in the table below.

1_pwIFl2C9iHl3xKje83qt7Q.png

That's... pretty much it. If it's not on the table, the interpreter ignores it. It's pretty self-explanatory once you imagine the memory as a tape - the commands > and < cause the memory pointer to go back and forth; you're able to operate on the one it's currently pointing to. As it stands, it's an extremely minimal language. So why bother mentioning it here?

I treat BF not as a language per se, but rather a philosophy. I noticed how much in common BF has with nearly all other programming languages - ranging from variable arithmetic to loops and complex I/O handling. And then it struck me: What if you take each command from BF, and use them as a concept to learn in your desired language?

For example: With the commands > < + -, one may apply them to variable creation and manipulation, as well as basic arithmetic statements. With , and . you can learn basic I/O capabilities. And with ] and [, a basic conditional WHILE loop. Everything you'd need to know about learning the basics of any language is right there in BF! Now, I'm the kind of person who'd eat their own cooking, so I'll illustrate with a language I've never learned... quickly googles top languages AHA! Elixir! This ought to be fun!

1_1JUfnJLEtIXHB_ygoy5uKg.png

I have absolutely no clue what I'm doing. - Mindpixel

So, at the time of writing, I have no experience in, nor any information about, Elixir. All I know is that it has a neat logo. Here we go!

7:30 AM - Downloaded Elixir. Wonder if it comes with an IDE.
7:32 AM - Reading about it while waiting for it to install. Scared sh*tless at the fact they call it a functional language. Reminded of Haskell.
7:33 AM - Installation complete. Hey look, a console!
7:35 AM - Covered output. Code:

IO.puts "Hello, readers!"

Alright, not bad. Let's try some loops!
7:37 AM - Realized it's a functional language. Recursion. Oh dear god help me.
7:43 AM - Recursion also covered functions, math, and console output. Code:

iex(5)> defmodule Loop do
...(5)> def countdown(n) when n <= 1 do
...(5)> IO.puts n 
...(5)> end
...(5)> def countdown(n) do
...(5)> IO.puts n
...(5)> countdown(n - 1)
...(5)> end
...(5)> end

Also discovered typing "x = 3" will assign the variable X to a value of 3. It works the same for "X = Y + 2" and "Y = 38 / 2" All that's left is console input.

7:44 AM - That was easy. Code:

IO.gets "Prompt of some kind: "

Which returns a string.

7:45 AM - BF learning philosophy complete!

So, all it really took was googling "Elixir loops" and a bit of experimentation. I now know how to write basic functions, some recursive loops, a little bit of variable working around, and even console I/O. All of which the BF philosophy covers... It was just that easy. And now, you can do it too!

So, to sum it up: BF provides a philosphy to get a crash course in nearly any programming language. To get up to speed with one you've never worked with, just remember the eight commands of BF:

(> and <) represent variable creation and manipulation
(+ and -) represent basic variable arithmetic functions
([ and ]) represent loops and functions
(, and .) represent basic console I/O

With these in mind, you can tackle any language you decide to do. And, thanks to this post, I now know enough Elixir to play around with!

So, let me know if this works for you. I definitely appreciate any feedback you can give me, and would be MORE than happy to do this again with a language anyone would suggest!

Thanks for reading!

Sort:  

so now please code a steem monsters bot in BF :P

Challenge accepted! I’ll do it later today. Stay tuned!

Hello! Your post has been resteemed and upvoted by @ilovecoding because we love coding! Keep up good work! Consider upvoting this comment to support the @ilovecoding and increase your future rewards! ^_^ Steem On!

Reply !stop to disable the comment. Thanks!

Coin Marketplace

STEEM 0.24
TRX 0.25
JST 0.039
BTC 96247.25
ETH 3349.36
USDT 1.00
SBD 3.28