“We are Forerunners. Guardians of all that exists. The roots of the Galaxy have grown deep under our careful tending. Where there is life, the wisdom of our countless generations has saturated the soil. Our strength is a luminous sun, towards which all intelligence blossoms… And the impervious shelter, beneath which it has prospered.”

Domain Query: The programmed mind

by | Jul 7, 2024 | Domain Query | 4 comments

LRFotS took a moment out of his sojourns through East Asia to write in about the utility and usefulness of programming as a skill, and how one might go about learning it in the most time-efficient way possible:

Didact, I have been looking into programming for sometime now for making some side projects but I am running into one problem, I can find plenty of information online about coding in different languages but I feel like I need the basic programming fundamentals that seem to apply across all languages.

Finding both what these fundamentals are and good sources for teaching these fundamentals is a bit difficult. Your experience would be appreciated. The other thing is that I am debating between putting my focus into the C language family (C, C++, C#, and Goolang) or the python language. I remember you saying in one of your posts you have experience with the former, in particular C++? What is your experience with it?

This is a subject with which, by (un)happy coincidence, I happen to be somewhat familiar. I am a (mostly) self-taught programmer – I did take a few programming courses during my Master’s degree, but I absolutely stank at it, at the time. I literally got a C in my C++ class, a D in my Python class, and a B+ in my MATLAB class. I also learned R, a little bit, during that same time.

Then I started working, and – through happy accident – my first boss insisted that I spend the first two weeks of my job, learning how to code in VBA. And I started to get pretty decent at that.

Once I began to understand how programming really works, and how powerful it can be, I started expanding my horizons. Perhaps because I did not have very much formal training in programming, but rather came at things with a mathematical bent, I was able to ignore the how and what of programming, and start with the why of it, instead.

That is why I tried out a book called Linux and the Unix Philosophy by Mike Gancarz, which explains, among other things, how to write good programs in a way that is portable, extensible, and powerful. The UNIX/Linux philosophy is one that every programmer should embrace, and it really comes down to a handful of core ideas:

  • Small is beautiful – use small subroutines, functions, and programs that you can reuse constantly;
  • Keep It Simple, Stupid – the simplest solutions are almost always the most elegant and easiest to understand;
  • Flat files are your friend – store as much data as possible in flat files, so that you can access them easily, and read them in quickly;
  • Comment your code heavily – make it easy for you, and others, to debug what you have done, by walking them through your thought process with comments;
  • Try-Fail-Learn is a good approach to programming, especially when you have lots of system resources;
  • Error-handling matters and is vitally important;
  • Always define the end goal – write with a clear objective in mind, keep it mind, and do not deviate from it once you have defined it;

There are plenty of others, but these are the basics. This is the philosophy of programming, which in my opinion far too many CompSci graduates no longer learn. This is part of the reason why you end up with the corpulent pile of junk that is modern WinDOZE – the Microsoft engineers just cannot resist cramming it full of every last piece of junk they think the consumer needs, instead of leaving it up to the consumer to decide what he wants.

With that out of the way, now we can get to which language to learn. Here, our friend is absolutely correct – the fundamentals apply across (just about) ALL programming languages. (The exceptions are really weird, archaic, yet very powerful languages like APL, and perhaps assembly-language, but then no one in his right mind uses assembly-language for serious industrial-scale programming anyway.)

It does not matter whether we are talking C/C++, FORTRAN, R, MATLAB, Java, Python, Rust, Perl, Lisp, or whatever – the basics remain the same. You have to know the basic datatypes; you must understand their uses and limitations; you need to comprehend control structures and loops; and you must be able to grasp error-handling routines.

It is precisely because I know these things, at least to some level, that I am not bragging when I say that I can program in something like 8 languages, to varying degrees of proficiency – in descending order of skill, I would say I can program in R, VBA, a proprietary language used at a bank called DBScript, SQL, Python, MATLAB, Java, Javascript, and C/C++.

It is also precisely because I know these things, that I am not afflicted with false modesty in saying: that list really is not anywhere near as impressive as it might seem to a non-programmer.

It really isn’t. Programming is all the same stuff, at a fundamental level.

Indeed, based on my experience, I can say the hard part of programming is similar to the hard part about most human languages. (English and French being perhaps notable exceptions – because they are utterly illogical and irregular.)

If you learn Russian, for instance, you very quickly must come to terms with all the rules that govern the language. Memorising them, however, is the easy part. Putting them in action, with the right vocabulary, is VERY, VERY HARD.

It is the same with Japanese, which has a completely different linguistic structure from Russian. Yet, the fundamental rules are easy enough to figure out. It is the vocabulary and the usage that is hard.

How, then can one overcome this hurdle in programming?

My recommendation is to start with the language that forces you, from the outset, to exercise serious discipline in how you declare variables, how you use control structures, and how you marshal resources when running code.

That language is, of course, C. If you really want a challenge – try C++. It is C with object-orientation, and trust me, that makes it a lot harder.

Learning how to program in C can be an exercise in severe masochism, at times. But, it also forces you to be highly disciplined in how you code. You force yourself to start small, building up toward bigger and better programs over time. There are plenty of courses online to teach you how to do this – I recommend the free courses at W3C Schools, or Codecademy.

Only once you have mastered the fundamentals of programming using C, should you move on to a scripting language like Python or R, where you do not have to declare the variable types directly. The program interprets them for you.

Of the two, I strongly prefer R, but that is because most of my work is in the realm of statistics and data analytics. For other applications, like webscraping, Python reigns supreme for its extensibility, flexibility, and power.

The thing I like about Python, is that it was created by a mathematician, which means there is an imposed discipline in how you write code. You MUST use a lot of whitespace to write good Python code – if you do not indent your code the right way, the program literally fails to run, because the interpreter cannot figure out whether you are using a loop or not. This also, by definition, makes your code easy to read, therefore to debug.

R, and MATLAB, by contrast, allow for vectorised handling of calculations, which greatly speeds things up and avoids the need for messy and complex looping structures – which are also inefficient in terms of memory usage, when you have vectorised alternatives available. For scientific and statistical computing, these are the languages I would use.

As for VBA… honestly, I consider it to be a toy language, that is useful for getting Excel to do interesting things. Its purpose and utility has largely been superseded, thanks to the new Excel data model, which is REALLY FRAKKIN’ COOL, and which allows one to utilise SQL-like power with a user-friendly interface.

That being said, I cannot, for the life of me, figure out how the hell one is supposed to use M-code properly in the Excel Power Query/Data Model interface. The language seems really weird to me, and the documentation is – to use a technical term – SHITE.

As for my experience with C++ – well, be prepared for a lot of screaming incoherently at your computer screen, trying to figure out why the Niflheim your program refuses to compile. This is particularly true when you get to large and complex programs, with pointers (though perhaps they got rid of that in the latest definitions of the language – I have not kept up with this for some years now).

Nonetheless, if you learn how to write good, solid, non-smelly C/C++ code, you are set, in my view, for more complex and difficult programming tasks.

The other language I recommend learning is SQL. This is very different from interpreted and scripting languages. It is a database language, and as such, has its own unique syntax and methodology. Mathematicians and logicians love it, because it operates along very straightforward concepts of set theory. Given its power, speed, flexibility, and sheer range of uses, if you want to learn how to use and manipulate databases, you MUST learn SQL, at least at a basic level.

Again, use W3C Schools and Codecademy to do it. The basics are actually quite easy to grasp.

That is all for now – I hope that fully answers the questions.

Subscribe to Didactic Mind

* indicates required
Email Format

Recent Thoughts

If you enjoyed this article, please:

  • Visit the Support page and check out the ways to support my work through purchases and affiliate links;
  • Email me and connect directly;
  • Share this article via social media;

4 Comments

  1. Randale6

    Thank you for the write up Didact, a podcast would have been…painful for this subject.

    Reply
  2. furor kek tonicus ( dicks out for Harambe )

    how about for video? i have a special use case which would involve stitching the output from at least 6 different cameras together, connecting the R and L borders with everything time synched.
    .
    C++?

    Reply
    • Didact

      Very doubtful – that strikes me as a level of editing that only really high-end software can manage, and that is not something you just code on your own over the weekend. It is also not my area of expertise, I’m afraid…

      Reply
  3. MrUNIVAC

    Realize this is a cold thread, but any recommendations for a Linux version that a lifetime Windoze user could get into without having to be in the command line every ten seconds? Use cases would be almost purely gaming and mostly older games.

    I’m going to be building a new machine in the not too distant future and while it’s going to have Windoze 11 as a base (yeah…I know), I’d like to start experimenting with Linux in the hope of eventually weaning myself off of Microsoft’s monopolistic teat.

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Didactic Mind Archives

Didactic Mind by Category