Pages

Sunday, 24 October 2021

Chapter 22 // Exercise 5 - Principles & Practice Using C++

Chapter 22 // Exercise 5

Write a "Hello, World!" program in each of the languages mentioned in this chapter.


[Preface] Ok so....not counting various revisions of languages (like C98, C11); I counted 29 (?) languages. Now I don't know if we're just supposed to write the hello world program or actually get it to compile and execute?...I'm guessing the latter. That means I have to figure out at least 27 ways to build a language and a lot of these aren't in use anymore....hooo boy.

LETS BEGIN.

1) C++
The most obvious and easiest (for me):
This was extremely nostalgic and I had to pause for a moment as it took me back to January 2016 when I first saw "Hello, world!" in C++ and wondered "how the hell am I ever gonna remember what all this shit does?"

2) LISP
Lisp is quite honestly, disgusting, and I never want to look at it again.

3) FORTRAN
Trying to get Fortran to build on Windows honestly went over my head. Apparently there is an Intel Fortran compiler for Visual Studio but  I couldn't find it. I ended up using an online compiler again.

4) COBOL
Oh my christ; what is this?? It's like assembly and the terminator had a child.

5) ALGOL68
So this is where Python comes from? The Algol68 Hello, World is more efficient than the normal Algol but it took me a while to figure out how to add comments.

6) SIMULA87
This is a strange one. It's kind of like pseudocode but it runs....the comments also need semi-colons at the end which is weird. It's like a combination of Fortran and Pascal syntactically.

7) BCPL (Basic Combined Programming Language)
Apparently this the language that they used to program compilers with! The very first Hello, World! was written in this language as well so doing this felt like some sort of programmers pilgrimage. The language was created by Martin Richards who rivals Bjarne himself for the most "programming language creator" website in the world:
Sometimes I feel like blogger is too much and I too should resort to plain HTML.
More fun facts, it was the first brace language! And introduced // for comments (which C rejected).

Unfortunately there is no online compiler for BCPL, however it was recently revised by Martin himself as recently as 10th October 2021! So for this one I ended up getting the most recent version of the compiler and then spent all Friday evening trying to get it to work. Narrator: it did not work.

Even using the pre-compiled applications wouldn't work and it would exit immediately with an error. I think it's something to do with the date as it thinks it's January 13th 2020. Excellent. Oh well. I learnt a lot about batch files in this one so there's that!

8) PL/1
The aptly named "Programming Language 1" language also doesn't have an online compiler; or any compiler for windows. Just Linux and something called z/OS. I'm not interested in going to great lengths to get these to work. I did look at the hello world sample on Wikipedia though and I hate it.

9) PASCAL
Pascal I've come across before. Chapter 18 Exercise 11 asks you to implement a skip list and I used a paper that used Pascal. It's not completely awful. Fortunately it has an online compiler.

10) C
Ah C, my old friend. Compiling C with Visual Studio is quite simple but at least you can just create a new C++ project, add C files to it and VS should compile with the C compiler if it sees .c extensions.

11) HASKELL
This one was simple enough. It looks a bit strange; not sure how I feel about it.

12) EULER
The wiki page is short for this one and I can't find much about it. It seems it fell out of favour and no one is really using it anymore.

13) MODULA
Niklaus Wirth really loved creating programming languages. Apparently Modula 3 had an online release in 2010 but the websites look really dodgy and I don't fancy downloading weird applications off websites to try and compile it.

14) OBERON
Niklaus Writh is back in this list for the 5th time! (I think). Oberon had a stable release last year however there's no online compiler apart from one that converts Oberon to Javascript?? I did find this amazing website though:
I must check out lolcode. It seems like the language for me.

15) TURBO PASCAL
Ok so Turbo Pascal isn't actually a language; it's a compiler/IDE for Pascal??

16) DELPHI
Delphi also isn't a language; its an IDE and another Pascal compiler.

17) ADA
Not the bitch in the red dress, a programming language. Another Pascal-like language with what wikipedia says "extremely strong typing", not just strong but "extremely". 

Also, this quote from Bjarne's Website:

Do you really recommend Ada over C++ for larger projects?

No. I have no idea who started that rumor, but it must have been an over-enthusiastic or malicious Ada devotee.
 

18) SCHEME
Oh no....a LISP language KILL IT WITH FIRE.

19) CPL
So this is the predecessor to BCPL? It seems to be maintained which is cool however it's only for Linux and even the Windows version wants you to have a Linux subsystem so no thank you. 

20) B
I feel like when I'm on Wikipedia looking at pages for the Jurassic age with all these ancient languages and "predecessors"/"ancestors" talk. B is very similar to C and someone made a working compiler for it but it's janky. Also, just use C. I learnt that B was implemented and then C immediately came out. I've read a few comments around saying how small B is and "any good programmer should be able to implement it". Sounds like a good exercise.

21) SMALLTALK
Another object-orientated language derived from Simula. Wikipedia says its an entirely reflective system which is interesting and could be worth learning to understand how Unreal Engines Reflection system works (it uses reflection for the editor/blueprints). The hello world is a one liner in this project and looks completely unlike an object-orientated language.

22) EIFFEL
An object oriented language that ended up influencing Java and Microsoft Java and is still in use today! You have to make a class and then do things with that class...a true Java Parent....disgusting. Also, if you google eiffel stuff it almost always brings up pictures of the eiffel tower.

23) VISUAL BASIC
In all seriousness though I actually didn't mind this one? I think it's because it was extremely easy to set up and run thanks to Visual Studio. I kind of like how it looks as well, plus it comes with a console window....Also, Excel uses a form of VB, maybe I'll finally become an Excel wizard?

24) PYTHON
Oh Python...how I detest you. We had a brief module in the first year of Uni where we had to create a networked version of noughts and crosses using Python. I hate Python. However back then, Visual Studio had only begun to toy with the idea of adding Python support so I had to use the Python thing; Idle (which I also hate). Now VS has full Python support and makes this Hello World a painless 1 liner.

25) PHP
I was weirdly looking forward to this one as everyone online seems to think PHP is the anti-christ or something. Yeah it looks a bit strange but have they ever used Lisp??? To be honest I don't understand the fuss with this language? It's basically just HTML with added functionality.

26) JAVA
I also detest Java with a passion however I am strongly team Android and as such use Android Studio quite often. Even though I hate it, I'd say it's my second most-used language and thanks to learning C++ first I didn't really even need to learn Java. I just google what I need to know as I go along. I used an online compiler for this as it's a nightmare installing IntelliJ IDEA and Android Studio takes 5 years to boot.

27) PERL
I don't really have any strong opinions on this one. Basically looks like Python.

28) C#
Sometimes I'm not sure which I hate more Java or C#. I have to use C# at work sometimes (as all our tools are written in it) and I hate it. Sure, it's fast to get things working and you see results quickly but the language is not for me. It does have an edge over Java though because I can use Visual Studio. 

Microsoft though has a really cool interactive website that takes you through learning the basics of C#:

29) JAVASCRIPT
And last (and certainly least) is Javascript where everything is THIS and VAR. Like PHP, this is just another way to add functionality to HTML. Due to its C++ style syntax I find it easier to understand than PHP but I don't like using it. I think it's safe to say I don't like any form of web programming.

And with that I'm done! I managed to compile and run 20/27 languages which is pretty cool and it gave me a real insight into language similarities/differences. It also made me seriously appreciate Visual Studio more than I already do. I think at this point I'm too far down the VS rabbit-hole and giving it up would feel like losing something dear to me.

I don't think using Online Compilers is cheating though; setting up language environments is tough and honestly one of the worst aspects of programming; I think that's why VS wins for me and a deciding factor over which languages I choose in the future.

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. you're really completed this task! bjorne is really crazy with all this useless exercises, i usually just skip them. check hugo framework, i think it is what you want instead of blogger

    ReplyDelete
    Replies
    1. This was one of my favourites! it's interesting to see all the differences and similarities between languages. Also Blogger is great lol. It allows me to put the least amount of effort into a website but still have it be functional.

      Delete