I tried 10 programming languages and I liked it

karataev profile image Eugene Karataev ・4 min read

For the last several years I've been using JavaScript in my day-to-day work. But what about other programming languages? Most of them grow and evolve as well as JS. I thought it'd be interesting to take a look at the structure and syntax of 10 different programming languages.

I deciced to write FizzBuzz program with every language. It's a simple algorithm, but requires to know how to write loops, conditionals and declare variables. That's should be enough for introduction.

1. JavaScript

I'll start with the most familiar one.

for (let i = 1; i <= 100; i++) {
  let result = '';
  if (i % 3 === 0 && i % 5 === 0) result = 'FizzBuzz';
  else if (i % 3 === 0) result = 'Fizz';
  else if (i % 5 === 0) result = 'Buzz';
  else result = i;

Short and easy. Feels like a breeze.

2. TypeScript

Just add types and you're ready to go.

let result: string;
for (let i:number = 1; i <= 100; i++) {
  if (i % 3 === 0 && i % 5 === 0) result = 'FizzBuzz';
  else if (i % 3 === 0) result = 'Fizz';
  else if (i % 5 === 0) result = 'Buzz';
  else result = String(i);

3. Python

I tried Python couple of times in the past, but I can say that I spent no more that 10 hours programming Python in my whole life. I just remember it's necessary to use indentation instead of curly braces 😂
Here come the first difficulties. How do I create a loop? What is the syntax for logical operators? If/elif. Google, google, google.

result = ''
for i in range(1, 101):
  if i % 3 == 0 and i % 5 == 0:
    result = 'FizzBuzz';
  elif i % 3 == 0:
    result = 'Fizz'
  elif i % 5 == 0:
    result = 'Buzz'
    result = i;

4. Basic

Time for the nostalgia. QBasic is the language of my childhood. I remember drawing complex pictures with LINE and CIRCLE commands 🤓
And 20 years ago GOTO instructions were used everywhere even Go To statement considered harmful was written in 1968.
Writing FizzBuzz, I noticed that string variables MUST end with dollar sign, otherwise the compiler will scream at you, wow.
Also it's neccessary to explicitly coerce types. No dynamic type coercion like in JS!

result$ = ""
FOR i = 1 TO 100
IF i MOD 3 = 0 AND i MOD 5 = 0 THEN
  result$ = "FizzBuzz"
  result$ = "Fizz"
  result$ = "Buzz"
  result$ = STR$(i)
PRINT result$

5. C++

I remember C++ as a language for "real programmers" with pointers, manual memory allocation and all that low-level stuff.
Again explicit coercion from number to string. Also it's necessary to include standard libraries for useful functions.

#include <iostream>
#include <string>

int main() {
  std::string result = "";
  for (int i = 1; i <= 100; i++) {
    if (i % 3 == 0 && i % 5 == 0) result = "FizzBuzz";
    else if (i % 3 == 0) result = "Fizz";
    else if (i % 5 == 0) result = "Buzz";
    else result = std::to_string(i);
    std::cout << result << std::endl;


6. Java

The language of bloody enterprise. It was a surprise for me that Java looks like TypeScript. Learn TypeScript to know two languages for the price of one! 😄

class Main {
  public static void main(String[] args) {
    String result = "";
    for (int i = 1; i <= 100; i++) {
      if (i % 3 == 0 && i % 5 == 0) result = "FizzBuzz";
      else if (i % 3 == 0) result = "Fizz";
      else if (i % 5 == 0) result = "Buzz";
      else result = String.valueOf(i);

7. Rust

I know almost nothing about Rust. It's like C++, used by Mozilla and is handy to write a core of an operating system. Not really handy for frontend development.

fn main() {
  let mut res = "";
  for i in 1..101 {
    if i % 3 == 0 && i % 5 == 0 {
      res = "FizzBuzz";
    } else if i % 3 == 0 {
      res = "Fizz";
    } else if i % 5 == 0 {
      res = "Buzz"
    } else {
      println!("{}", i);
    println!("{}", res);

8. PHP

It looks funny that every variable have to start with $.


for ($i = 1; $i <= 100; $i++) {
  if ($i % 3 == 0 && $i % 5 == 0) $res = "FizzBuzz";
  else if ($i % 3 == 0) $res = "Fizz";
  else if ($i % 5 == 0) $res = "Buzz";
  else $res = $i;
  echo "$res \n";

9. Ruby

Ruby has definitely different syntax for loops than other languages.

res = ""
1.upto 100 do |i|
  res = ""
  if i % 3 == 0 && i % 5 == 0
    res = "FizzBuzz"
  elsif i % 3 == 0
    res = "Fizz"
  elsif i % 5 == 0
    res = "Buzz"
    res = i

  puts res

10. (((Clojure)))

Clojure it's an interesting functional language with parenthesis flying everywhere. Functional programming is another world with different mindset to adopt. Who writes arithmetic expressions like (+ 1 2), right?
Actually FizzBuzz in Clojure inspired me to learn the language and ecosystem deeper.

(defn FizzBuzz [] (
  (loop [x 1]
  (when (<= x 100)
    (if (= 0 (rem x 15)) 
      (println "FizzBuzz")
      (if (= 0 (rem x 3)) 
        (println "Fizz")
        (if (= 0 (rem x 5))
          (println "Buzz")
          (println x)
    (recur (+ x 1))))



That's all! It was an interesting and sometimes frustrating experience to try ten different programming languages. They might look different, but I think all of them have a lot in common - they are just tools to help translate thoughts humans can understand to the instructions computers can understand.

Posted on by:


markdown guide

Hehe, I think that in this case the post'd take a couple of months longer to complete 😂


This is really very common fallacy. Actually assembly language programming is much easier for programming than is commonly considered.

I am working on several big projects in asm and it takes only a little bit more time than in conventional languages. But the results are really much better. With less bugs, less memory usage and higher performance.

Are you serious?
Programs written with Assembler are long as hell. And AFAIK there are goto (jump) instructions used everywhere, which makes a program hard to follow.
I can understand that's it's sometimes necessary to write assembler code to fix performance bottlenecks or with a very limited resources (RAM).
But it's hard for me to believe that nowdays regular projects are written with assembler when there are so many high-level programming languages available with handy abstractions.
Can you please share what projects are you working on?

Well, the contemporary assembly language is a little bit different. With good IDE and decent libraries, the programming in assembly language is almost as productive as with the high level languages, but still keeping all the advantages of the low level programming.

Yes, it has less abstraction levels, but IMO it is actually an advantage that helps to solve the problems in the most simple way.

Anyway, here are several of my free assembly language projects. Some of them are huge and actually contain several sub-projects:

Fresh IDE - advanced assembly language IDE. (the source ) It contains as a sub-project the library FreshLib that is for writing portable applications. It contains OOP macro library as well, used mainly in the GUI widget toolkit of the library.

BTW, the web site from the above links is served by assembly written web server (not my project), the ultra-fast RWASA and is managed by my CMS, MiniMagAsm written in assembly language.

Another my web project is the web forum engine AsmBB. The source code is here.

You can browse the sources from the links above and see, that they are not so unreadable and hard to understand and maintain as you think.

Thanks, this is really insightful. My perception of assembler shifted from "used for close-to-hardware tasks only" to "might be useful in different domains, even for the web".
Also thanks for your one hour video of assembly programming. It gives the picture of current development process with asm: IDE, code highlighting, syntax, structure, e.t.c.


This post loads slow as hell!


Yep, maybe it was not a good idea to inject repl.it sandboxes inside the post, but provide links for those who interested instead.
I just wanted to make it possible to edit and run the code right in the post, without leaving DEV.
Thanks for your feedback!

Edit: I replaced repl.it sandboxes with code snippets because of loading performance issue.


well when a person knows a lot of programming languages. I'm still learning python.


I know JavaScript only. Most of other languages in this post are new to me. I googled every syntax construction in every language in order to complete this post 😄