Jumat, 29 Juni 2018

3 Worst Programming Languages to Avoid Like the Plague

worst-programming-languages

There are lots of awesome programming tutorials out there to get you started with coding. But before you dive into them, you’ll have to answer a very difficult question: Which programming language should I learn?

Some languages are easier for beginners to learn. Others are most useful for the future. And others are most likely to help you land a programming job.

In this article, we’ll approach it from the opposite end: Which programming languages should you avoid?

1. Esoteric as %^&*!

Let’s start with an easy one. Esoteric programming languages (or esolang for short) are designed to push programming to its limits of simplicity. In doing so they succeed in making it incredibly complicated.

While this seems like a contradiction in terms, a quick look at the unfortunately named Brainf&*k language:

++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.

This monstrosity is functional, Turing-complete code. The function of this program? It prints Hello World! to the screen. Simple, isn’t it?

The language consists of eight characters, which move the data pointer within the program array, and modify or output the data held in each position. This all adds up to a simple language which is an absolute mind destroyer to use. Hence the unfortunate name. By the way, Brainf£$k is not the only esoteric language with a “colorful” name, so be curious at your own risk!

Brainf^&k is one of the better known esoteric programming languages, though many more can be found. Perhaps you want to build a program using the one-liners of Arnold Schwarzenegger? Chef is particularly notable as the code you write ends up reading like a recipe.

Esoteric languages are designed more like a fun challenge to programmers than for everyday use. As a general rule, these languages are Turing Tarpits and will cause more frustration than anything else if used for actual programming tasks. In the same way that going over Niagara Falls in a barrel isn’t necessary, I’m sure some of you will program in esoteric languages regardless!

2. PHP

This is where things may get contentious. PHP is a server-side language designed for web development. Originally released in 1997, PHP quickly took over the web. You’d be hard pushed to find any large web entity that doesn’t use PHP. PHP introduced the concept of Dynamic Websites, allowing users to query databases in real time rather than loading static pages on each interaction.

A recent Stack Overflow survey shows PHP as the ninth most popular language, and there is still a considerable demand for PHP developers. So far so good. Widely used, in demand, long-standing, what isn’t there to like?

Well, depending on who you ask, quite a lot!

Inconsistency

PHP wasn’t meant to be a language and grew piece by piece rather than with a general structure. This makes learning PHP a frustrating experience.

An example of this provided by aptly named phpsadness is PHP’s get function:

gettype()
get_class()

These little inconsistencies in the naming of in-built functions are part of a much larger problem. Small differences in syntax and semantics make PHP difficult to learn when coming from another language.

In an age of programming language polyglots, these issues might not be a big deal to you, but it is enough to make some developers run for the hills.

One more thing before we move away from these types of inconsistencies. In PHP, function and class names are not case sensitive, but variables are.

Wait, what?

The Ternary Operator

Whether it is a product of PHP’s ad-hoc structure or the mad whim of one of its creators, the ternary operator in PHP is baffling. Consider this:

$a = 11; 
echo ( 
    $a == 10 ? 'ten' : 
    $a == 11 ? 'eleven' : 
    $a == 12 ? 'twelve' : 
    $a == 13 ? 'thirteen' : 'something else'); 

echo "\n";
//this code prints 'thirteen' to the console

As you can see in the above example, PHP does strange things with ternary operators. In almost all other languages you would expect this code to output eleven. PHP disagrees.

This strange behavior comes from PHP using a left associative ternary operator. This somewhat mind-bending behavior is utterly unintuitive to many programmers, and even after reading a detailed explanation of how it works, it’s still baffling.

PHP is still used widely, and many people claim it has improved hugely over its 20-year tenure.

If you want to create your own WordPress plugins, then it’s certainly worth learning. There are great resources out there to get you started learning PHP, and its popularity means you will likely land a development job once you have.

The real question is: with so many other languages out there, and the rise of other frameworks like node.js and Ruby on Rails, do you really want to?

3. JavaScript

Can you hear that? It’s the sound of a thousand developers cracking their knuckles, ready to defend JavaScript’s honor in the comment section!

JavaScript is the language of the internet. There is no disguising its dominance. If you are using a browser, the page you are looking it will almost certainly be using JavaScript. When you watch Netflix or use PayPal, you are using servers running node.js, JavaScript’s server-side runtime. A quick skim of any job board for programmers shows demand for JavaScript developers.

Why does it belong on this list? Well, the darling of front-end has a few quirks.

Automatic Semicolon Insertion

If you are familiar with Java or any of the C family programming languages, you’ll know that semicolons are used to denote the termination of a statement. The interpreter sees the semicolon and knows to move on.

In JavaScript things are a little different. Semicolons are optional. While that might seem impossible, many people want to drop semicolons from JavaScript altogether.

While this is a nice idea, it is not without its problems. Self-confessed semicolon denier and YouTuber Kyle Robinson Young makes a good case for why they should be used by beginners.

The issues raised in this video point to a wider problem. JavaScript works fine without semicolons most of the time. This is because the semicolons aren’t gone at all, they are just automatically inserted where the interpreter thinks they should go.

While the cases when the interpreter gets it wrong are seen as “edge cases” by more experienced coders, they are all things beginners are likely to run into, thereby making the experience of using JavaScript unwelcoming.

A short search on the subject of semicolons in JavaScript will lead you down a rabbit hole of opinion and speculation with almost no end. When a language requires a full page of reading just to understand where you should use a semicolon, only to conclude that you should make up your own mind, it’s forgivable to think that something is wrong!

An Array of Weirdness

Anyone who has taken a beginner coding class will be familiar with arrays. They are a simple way to collect lots of data of the same type and order them to easily get it back later.

This is a fundamental of programming, so they should be pretty simple to understand right? Actually no, not right. The first example in James Mickins’ hilarious talk on JavaScript sums it up nicely:

“JavaScript arrays are array-list-dictionary combined multi-type objects.”

Right then. Clear as day.

These are just a few small examples of why JavaScript could be seen as a terrible language to learn and to use. For every case here, and the thousands of others all over the web, there is an army of people ready to defend these behaviors. One thing is for sure, JavaScript isn’t going anywhere, and neither are the endless online arguments about it.

For a final bit of fun, which harks back to esoteric languages discussed earlier: open up a JavaScript console in your web browser and paste in this monster:

alert((![]+[])[+[]]+(![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]);

A World of Programming Languages

Can you hear the sabers rattling? The angry devs ready to strike down every point made in this article? In truth, they would not be wrong. There are thousands of other cases in almost every language out there I could have used.

With the exception of the esoteric languages, each programming language has its good and bad points. As with all tools, a feature which makes one user’s blood boil is a cherished functionality to another. Semicolons may be one person’s kryptonite, whereas whitespace might keep others up at night.

For a beginner, any programming language is hard, and you should spend time learning the fundamentals of programming before worrying too much about what language to choose.

Image Credit: fizkes/Depositphotos

Read the full article: 3 Worst Programming Languages to Avoid Like the Plague

Tidak ada komentar:

Posting Komentar