Programming Theory: What is it, and do you really need to know it (and when)?

I read the following statement a few days ago 'learning programming theory is more important than syntax because if I know the theory I can search the syntax and make what I want in any programming language" being new to programming I never really thought about theory before. Is it something that you just need to learn? And how soon do you need to start learning it? As far as I can see theory isn’t really taught, but I’m guessing to be a higher level programmer you would need to know theory. Also would this be a thing only taught to CS students?

Thank you for your responses

Programming theory could be described as the patterns and practices inherent to practically all programming languages. This can range from basic data types like int, boolean, string etc. to patterns such as functions, composability, closures, IFFE, objects, inheritance. There are two main types of programming: functional and object oriented. Many programming languages like javascript support both approaches but there definitely exist preferences, pros and cons. It is true, however, that many of these concepts cross-over among practically all programming languages and as a foundation, it is important to grok.

1 Like

Thanks for the reply. I think I will focus on learning the basics before worrying about the theory.

Theory probably isn’t quite the right term, but I understand what they are getting at.

It’s easy enough to learn the syntax of JS for loops, but more important is to understand the “theory” behind for loops:

  • what’s the difference between a for loop and a while loop? When you should you use one vs the other?
  • how is a for loop best used?
  • when should you not use a for loop?
  • generally, when and why should you use a for loop vs some other control structure?

These sorts of questions can be asked of almost any topic in programming.

1 Like

To understand the difference between practice and theory, think about this: knowing how to program something is to be able to write a code that does what you expect.
Well, you could have a million different ways to write such a code. it means you have a million different algorithms. But they aren’t equivalent at all.

In practice maybe, one is good as another else. In theory, not at all.

Every algorithm has an own time of execution, an own allocated memory and so on… to be able to tell which one is good for your purpose is part of the theory.
Theory goes beyond “write something that does this stuff”, that’s a good starting point anyway. But theory helps you in understanding and planning what technologies and king of code could best fit your purpose.
And in many fields this is much more important than just “writing code”.
Many fields: APIs, Real Time programming, Machine Learning, Engineering and so on…

3 Likes

Let’s say you’re a monster hunter. You don’t need any knowledge to be a monster hunter, only willingness to fight monsters (and a weapon maybe). But knowing what types of monsters there are and what works best on them certainly increases your chances of defeating a monster.

Same goes for software engineers. Ability to categorize a problem you want to solve and knowledge what patterns work best for a given problem category are quite useful.

3 Likes

A programming theory is a theory that should be as good as physics. These are three properties of desired programming theory

  1. Well-defined Terms and Definitions like the ones in Physics.
  2. Unique (NonRedundant) terms
  3. Closure of Concepts

This is my take, the programming theory I invented.

Programming Theory

Some readers of the webpage initially thought that the content is about NUSA programming-language. No, it’s about programming theory. NUSA is the initial programming-language used.

How that programming theory is used? I use it to teach whatever programming-language. Hence I use the terms and definitions in that webpage to teach Java, SQL, HTML. The terms and definitions in my invented programming theory can be used to explain any programming-language virtually without adding any term. In fact, no extra basic terms. Few extra derived terms are needed, if any, and that is very rarely.