Why Programming Languages Are Hard

Years ago when I first tried learning Python, within the first five minutes of playing around with it I encountered one of these error messages:
SyntaxError: invalid syntax
It sounded like Python was telling me: you did something bad, and you should feel bad.

I did feel bad, in part because I had no idea what a SyntaxError meant, and the phrase "invalid syntax" didn't help clarify anything at all.

Today, I know a lot more about programming languages and about how parsers work. But the error message is still bad. It's bad UX, or more precisely: bad DX (developer experience).

If you're learning programming for the first time, then the error is a bad experience on two levels:

  1. First, it doesn't tell you what just happened. Did I do something wrong? Did my program do something wrong? Or did Python do something wrong?
  2. Second, it offers no indication of what the reason for the error might be, or what I could try to do to fix it.

Now, the reality is that syntax errors happen all the time (even after years of experience) and that most of a developer's life is spent fixing bugs and troubleshooting all kinds of coding problems.

But as a beginner, you don't know that.

When you're a beginner, this error actually sounds like it's a big deal, and more critically, it sounds like you did something wrong.

The problem: programming languages are created by programmers

Programming languages are created by programmers, for programmers.

That's a problem when you want to make programming more accessible and easier to learn. It's a target audience mismatch.

On top of that, there are limitations that come from how programming languages are created. We end up with messages like "invalid syntax" not just because someone wrote the error message like that, but because of the way that the language grammar and parser work. Maybe the parser actually doesn't have access to the exact grammar rule that caused the syntax error, because it was coded that way. So the error message isn't capable of being more helpful for technical reasons.

It's very likely that it just wasn't one of the priorities for Guido when he was writing the first version of the Python parser. He was writing it for himself and for other programmers.

After all, when Python was first released in the early 1990s, it was already much simpler and easier to learn than most other languages at the time. (I think that might still be true today.)

A secondary problem: programming languages which are designed to be easy to learn tend to be useless

There are lots of programming languages that are designed to be easier to learn and to be accessible to beginners. Very few of them are successful or popular, and the problem is that you can't do any serious work with them.

They may achieve their goal of making it easier for people to get started with programming. But a lot of the time they fail to illustrate what problems programming can solve, and how it fits into a bigger picture.

So in a way, they actually sabotage themselves before they can fulfill their goal.

If you want to show people why programming is worthwhile and help them understand how they can use it, you need to show them how to solve a real-world problem. Otherwise, most of the time, it ends up looking like a toy.

HyperCard and Excel

HyperCard was one of those applications that emerged in the late 1980s that had an influence on a huge number of computer users and I would bet that it inspired a lot of people to become programmers.

The programming language that was available inside of HyperCard, called HyperTalk, wasn't particularly great. But it was aimed at non-programmers while at the same time being capable enough to solve real problems.

Many people who thought they would never be able to program a computer started using HyperCard for many automation and prototyping tasks, a surprise even to its creator. (Wikipedia)

Excel is the other application that was huge in bringing programming to non-programmers.

Based just on formulas and cells, Excel's model managed to be half-code and half-graphical. It's generic enough to solve a whole range of problems, but it still sticks to a sweet spot: it's specific to problems that can be expressed as a spreadsheet. That's what keeps Excel so powerful: it doesn't try to do everything. It's a spreadsheet.

Making a tool customizable until it becomes a poorly designed programming language

In software, we're always faced with a trade-off between writing code that solves a specific solution, and writing code that allows the user enough customizability to solve a wide variety of problems.

It's the tool specificity problem.

Excel and HyperCard are tools, not programming languages. But both of them were pulled in the direction away from specificity, to try to solve all problems for everyone.

What's the most customizable form of a piece of software? It's a programming language itself. So if you take those tools to an extreme point of customizability, they become poorly designed programming languages.

Why is HyperCard dead today? I think it's because it was too generic and wasn't a perfect fit for any specific problem.

While it did put a lot of power into the hands of non-programmers, eventually it turned out that the economics of software is such that it's usually more worthwhile to have specific tools built for specific problems.

Programmers solve their own problems

It's normal to expect that if you leave programmers to their own devices, they're going to make tools to make their own work easier.

Sometimes programmers are guilty of a certain kind of elitism, where they put up barriers to entry instead of making things easier for newcomers.

Once you get past the initial hurdles and you learn how to write code, you start to forget what it felt like when you were just getting started.

It's remarkably easy to forget how helpless you felt when you were trying to learn the basic syntax of your first programming language and everything seemed stacked against you.

Everyone starts out as a beginner.

So, what can we do to make things better?

Rants aside, here are some actionable suggestions.

  • If you're an experienced coder, share stories about your first encounters with programming to show that we all start out clueless and intimidated before we got the hang of it.
  • If you're a beginner, try to forgive the creators of programming languages for the cryptic and unhelpful error messages. Creating a programming language is a lot of work, and it's not always obvious how to make it easy for beginners while also making it useful for solving real problems.
  • Also if you're a beginner, you can help the programming language community by sharing your experiences and your feedback. A lot of the time, the experienced programmers need a reminder that beginners don't see things the same way that they do, and they need to snap back to reality sometimes.
  • Forgive the beginner-friendly programming languages if you can't make anything useful with them. They can still be worthwhile learning tools, and if they can get people excited to learn more about programming in general, then that's the best we can hope for.

Let me close with one last thing.

I was too harsh above when I called those languages useless, but I meant it in relation to real-world, so-called "business" problems.

If you can use a tool to make cool or creative things and then show those things off, then that tool is 100% useful and valuable to humanity. Let's make more of those.

From: Marek Zaluski
Source: Why Programming Languages Are Hard


  1. My book on C++ for beginning programmers, "C++: A Dialog", includes a dialog with a beginning programmer that, among other benefits, makes it obvious that it is normal to make errors when programming.

    1. As the author said: Most of a developer's life is spent fixing bugs and troubleshooting all kinds of coding problems, so totally agree with your comment!

  2. I'm not a Python programmer, so I don't know if a non-specific syntax error message is the norm, but most mature compilers/interpreters tell you exactly where and what the problem is.

    1. You're right! Needs to be mentioned also that IDEs help us fix these errors directly when we type them.

  3. Dude. Can I quote you on "A secondary problem: programming languages which are designed to be easy to learn tend to be useless" - Marek Zaluski? For nearly five years now, I've been forced to use such "easy to learn" languages and there have been unfortunate consequences due to poor language design. More mature and "harder to learn" languages often seem to prevent many kinds of bugs that the "easy to learn" languages just let fly right on by.

    I think more people need to consider learning Haskell. Haskell is a bit odd to learn at first, but I think it ultimately makes the developer's life easier because it prevents some bad programming practices and the compiler seems to provide better insight about possible logical errors. There is a lot of unfortunate cussing in this book and other bad references, but if one wants a gentle introduction to Haskell then she/he might consider reading:
    If you actually read it chapter by chapter from front to the end, it will get you up to speed really quickly. The only big Haskell "trick" you need to develop is a basic understanding of recursion.

    Another really powerful language is Microsoft C# and/or Visual Basic.NET. If you have spent any time in both languages, you will know that C# and VB.NET are practically the same language. The only difference is that VB.NET is less "intimidating" to people with little or no programming experience. The awesome thing is that you can write just about any code in VB.NET with an ease that blows the socks off all other languages. The same goes for C#, but it just has a few ugly curly braces that tend to freak non-programmers out. In my opinion, VB.NET and C# are both *much* better languages than the more popular Python while Haskell is the best overall language of all time with C++ not being too bad either.

    People need to stop being afraid of advanced tools. It's "easier" to teach a child learn to ride a bicycle with training wheels but some serious cyclists will tell you to skip the training wheels altogether. If you do start with training wheels, you will eventually have to take them off. That's easy to do with a bicycle, but isn't not so easy to take the "training wheels" off after millions of lines of Spaghetti Code have already been written in Python. Seriously people, stop learning Python and get with a REAL programming language.

  4. Some language implementations are just BAD when it comes to error messages. In C++ you get crashes a dozen levels deep in system code. C++ generates a never-ending series of "errors" in parts of the system you never knew existed. Paradoxes are common, where the compiler flags an error in a line that you could swear was correct.

    These problems rarely happen in C#.

  5. Try using a real IDE like Visual Studio, and a better language, like C# or VB.NET (although Visual studio does support the use of Python).

    Syntax errors? If you don't know what that means, take a programming course or two.

    Don't know where the error occurred? Visual Studio tells you where, what, and lots more.

  6. As far as I know real programming falls into four categories:

    - Assembly
    - C/C++
    - Java
    - C#

    All of which have books spanning volumes since the yonder years of inception. None of the modern day programming languages target Beginners or even Absolute Beginners. This is because the idea foreshadows prior knowledge of knowing anyone of the listed languages above. So fact is you are pretty much stuck with learning the hard way or finding another hobby.



5G,1,Business,2,Bussiness,3,C,2,C++,4,CodeProject,3,Companies,5,Computer,1,Dev.to,1,Facebook,1,Featured,1,Future,2,Google,4,Javascript,2,Microsoft,2,Motivation,6,PHP,3,Programmer,6,Programming,14,Projects,1,Python,3,Quantum,1,Quora,10,Software Development,3,Tech,4,VS Code,2,
9to5Programmer: Why Programming Languages Are Hard
Why Programming Languages Are Hard
If you can use a tool to make cool or creative things and then show those things off, then that tool is 100% useful and valuable to humanity. Let's make more of those.
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy