DEV Community

Ben Halpern
Ben Halpern

Posted on

Which mainstream programming language has the ugliest syntax?

Regardless of the language's usefulness, which language fails the beauty contest the worst?

Oldest comments (232)

Collapse
 
ryanhaber profile image
Ryan Haber

PHP

Oldschool-wise, I can never forgive Pascal it's := operator.

Collapse
 
ben profile image
Ben Halpern

Can you tell me more about the := operator?

Collapse
 
lavigi profile image
eva

In Pascal, a:=33 would assign the value 33 to variable a. The is-equal operator was just =. It was less error prone than what finally stuck, thanks to C and Java ---> = to assign values, == to compare them.

Collapse
 
michaelgv profile image
Mike

PHP: it’s not a bad syntax, it’s just not what some people like, and they’ve formed opinionated debates over it.

Collapse
 
anasik profile image
Anas Ismail Khan

I agree. There's nothing bad about the syntax. True, the language could be better. There are 99 reasons to dislike PHP but syntax is definitely not one of them.

Thread Thread
 
jeroendedauw profile image
Jeroen De Dauw

PHP has been my main language for 10 years.

-> instead of . is rather unfortunate. Much harder to type :/

$var instead of var is also not idea if you ask me, though at least not as silly as needing to hit 3 keys.

That does not make the syntax as a whole ugly though.

Thread Thread
 
ryanhaber profile image
Ryan Haber

Lol. It helps. :D

Collapse
 
antjanus profile image
Antonin J. (they/them) • Edited

Especially if you look at more modern PHP. I really like Laravel's code style.

For non-PHP developers, a few syntax niceties:

  1. All variables have a $ prefix. So $post = getPost($id).
  2. Accessing class properties (non-static) is done via an arrow: $request->has('name')
  3. Accessing static properties is done via :: (by far my favorite). Route::get('/api/posts', function() {});

I also like PHP namespacing:

namespace Vendor\Lib\Class;

and accessing the namespace:

use Vendor\Lib\Class;
Thread Thread
 
ethan profile image
Ethan Stewart

As someone who's used PHP in the past, all of your niceties are among the many reasons I don't care for the language 😆 to each their own though! 🤷🏻‍♂️

Thread Thread
 
antjanus profile image
Antonin J. (they/them)

Haha, I can understand that. I actually liked the namespacing so much, I wrote a babel plugin that rewrites import paths in JS to work similarly. Not EXACTLY the same, but it's very similar.

Thread Thread
 
moopet profile image
Ben Sinclair

I really dislike PHP namespacing.

Collapse
 
ryanhaber profile image
Ryan Haber

True enough. The syntax isn't bad as in defective or overly verbose. It does look inelegant to me, though.

Collapse
 
chainq profile image
Károly Balogh

I strongly disagree, with the Pascal remark, but I'm a Pascal lover, so I'm probably biased the other way. I'd say := vs. = is much better and a lot less error prone and ugly than = vs. == let alone === in some languages.

Also := was not even a Pascal invention, but much older. It comes from ALGOL actually, IIRC.

Collapse
 
ryanhaber profile image
Ryan Haber

All very fair points. I never minded Pascal as a language. Just that assignment operator.

I had forgotten it came from ALGOL.

But you agree PHP is hideous?

:D

Thread Thread
 
chainq profile image
Károly Balogh • Edited

I believe there's worse than PHP, but that alone doesn't make any PHP better for sure. :)

BTW, I always think about replacing : with be and = with equal in my mind when reading Pascal code. So a:=1; is let a be equal 1. Same works with colon elsewhere, for example type definitions like var x: integer; can be read as let var x be integer; ... It makes the whole syntax quite readable for me.

But I'm not a native English speaker, so sorry if this just makes it even worse. :P

Thread Thread
 
ryanhaber profile image
Ryan Haber

No, it's a nice thought. It does work, as far as I can remember. Maybe it's what Pascal's creators were thinking.

Collapse
 
databasesponge profile image
MetaDave 🇪🇺

And there was me thinking it was from ADA ... it's like archaeology, this, just stripping layers away.

Thread Thread
 
ryanhaber profile image
Ryan Haber

Historical linguistics is a real discipline in natural languages. I love the analogies between natural languages and computer languages.

Thread Thread
 
databasesponge profile image
MetaDave 🇪🇺

Yes, and there's definitely a "thing" with code quality being correlated to natural readability too.

I come from an ORACLE background originally, and it would drive me insane to see people uppercasing their SQL, like it was an act of kindness to the compiler, and us humans have to suck up the inconvenience. I used to send people photos of major highway direction signs and ask "WHY DO YOU THINK WE DO NOT PUT INFORMATION THAT HAS TO BE QUICKLY ABSORBED IN UPPER CASE? Which do you find easier to read?".

I was also once instructed that all text in a BI system's reports should be in fixed pitch uppercase – got out of it by showing how wide that made every text-heavy report.

TL;DR; People are sometimes quite dumb.

Collapse
 
qm3ster profile image
Mihail Malo

=== and !== look rad in Fira Code

Collapse
 
databasesponge profile image
MetaDave 🇪🇺

You might have to blame ADA for that.

PL/SQL also uses it – it is very closely related to ADA.

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

A C++ variadic template, with move operations, lambdas, and static conditions, is essentially unreadable.

Collapse
 
eljayadobe profile image
Eljay-Adobe

All of C++ is a syntactical morass.

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

True, but filled with little hidden gems, thus we continue to slog through it.

Collapse
 
skyrpex profile image
Cristian Pallarés

We need a simpler syntax for C++ :)

Collapse
 
ybalrid profile image
Arthur Brainville

Some recent addition to the language help with that. Things like "if constexpr" permit to get rid of some SFINAE, and lambdas are generally helpfull into simplifying some code.

Well, even if the syntax for lambdas is...

[&](const std::string& some_adjective){std::cout << "... a bit " << some_adjective << " sometimes ...\n";}("laborious");

(this is just an useless example of code that nobody should ever write)

;-)

Thread Thread
 
skyrpex profile image
Cristian Pallarés

Indeed. +1 for using \n instead of std::eol.

Thread Thread
 
ybalrid profile image
Arthur Brainville

Indeed! (You probably mean std::endl ;-))

And yes, this thing is the devil and should not be used. I'm sad so much books and courses about C++ use this thing as a "new line" character, it is not. It happens to print one before flushing.

std::cin and std::cout will synchronize themselves, you don't need to flush by hand, you just makes your program slower that it should be, and this tend to make me angry ;-)

Thread Thread
 
skyrpex profile image
Cristian Pallarés

Oh yeah, I meant std::endl... haha I have read too much about LF and CRLF eol's these days

Thread Thread
 
ybalrid profile image
Arthur Brainville

Remark, I wouldn't be a bad thing to have a global called "eol" or "lf" in std that doesn't flush the output. :-)

But it's really a shame that they called this thing "endl"...

Collapse
 
cbordeman profile image
Chris Bordeman

We need to switch to Rust. :)

Collapse
 
danielsarmiento profile image
Daniel

Ada 95 or Lisp.

I actually enjoyed Lisp's parentheses art, but still ugly.

Collapse
 
lavigi profile image
eva

Writing LISP with a simple editor that didn't "match" opening and closing parentheses automatically. That was fun!

Collapse
 
cbordeman profile image
Chris Bordeman • Edited

LOL I learned Ada in college, just before 95. I thought it was very elegant. Then Ada 95 tacked on OOP and ruined it.

Collapse
 
jwbowen profile image
Jason Bowen

Java

Collapse
 
defman profile image
Sergey Kislyakov

Brainfuck.

Collapse
 
engineercoding profile image
Wesley Ameling
Collapse
 
jacoby profile image
Dave Jacoby

"mainstream"?

Collapse
 
ben profile image
Ben Halpern

dev.to is built with Brainfuck.

Thread Thread
 
anasik profile image
Anas Ismail Khan

No kidding?

Thread Thread
 
defman profile image
Sergey Kislyakov

Open-Source it and we will see ;)

Thread Thread
 
mouvedia profile image
G.
Collapse
 
maestromac profile image
Mac Siri

lol best answer.

Collapse
 
erikthered profile image
Erik Nelson • Edited

Java's verbosity gets old pretty fast. Especially after seeing what's possible with other JVM languages.

Kotlin is a joy to use, in part because of how expressive yet succinct it is. Going back and forth between the two makes Java's flaws much more visible, unfortunately.

Collapse
 
nektro profile image
Meghan (she/her)

To each his own haha, I love Java for how verbose it is and really dislike Kotlin. Operator overrides are a really neat idea but I can't get over the fun/func craze of using it instead of just saying function. Swift, Go, Rust, they all do it.

Collapse
 
chrisvasqm profile image
Christian Vasquez • Edited

I agree with you on the fun part. I've been getting more into JavaScript recently and I can see the use of the full word (function) being better for beginners overall.

Thread Thread
 
hrmny profile image
Leah

"fun is short for function"

"Oh ok"

Thread Thread
 
chrisvasqm profile image
Christian Vasquez • Edited

Yeah, but I still haven't seen the first person who doesn't question what fun is the first time they see it.

Sometimes being clear and short don't go hand to hand.

Thread Thread
 
nektro profile image
Meghan (she/her)

there's a readability factor that I feel is added when you use the whole function. Especially for compiled languages, the "less characters" argument has no weight at all.

Thread Thread
 
series0ne profile image
series0ne

It’s actually a “fewer characters” argument.

Thread Thread
 
aramix profile image
Aram Bayadyan • Edited

Actually in javascript es6 you don't have to type any word to create a function just () => {} which is the best notation IMHO

Collapse
 
hrmny profile image
Leah

What's the benefit of typing out function?

There is none, it just adds more characters

Thread Thread
 
chrisvasqm profile image
Christian Vasquez • Edited

Then we should use f because "un" would just add a few more characters 🤔.

I think there's a fine line between short and too short.

Thread Thread
 
alainvanhout profile image
Alain Van Hout

There's a reason why we don't all prefer our Shakespeare or our technical documentation in SMS/text speak :).

Thread Thread
 
juhohame profile image
Juho Häme

Writing code Shakespeare style would be awful.

Thread Thread
 
awwsmm profile image
Andrew (he/him)

f already stands for function in mathematics:

y = f(x)
Thread Thread
 
hrmny profile image
Leah

it's just what you start with, the next one would be g(x)

Collapse
 
xtabdeveloping profile image
Márton Kardos

Rust goes like: Fn... And I don't think there's anything wrong with writing instead of function, with good syntax highlighting there's barely a difference. I don't think code becomes any more readable by writing longer words. And Java's verbosity doesn't increase the readability at all. "final public static void" Btw you don't even have a function keyword in Java and nobody tends to make a problem of it.

Thread Thread
 
mojo2012 profile image
Matti

the modifiers are necessary to differentiate non-final private/protected non-static methods with a return type ... it makes total sense 😅

Collapse
 
tobias_salzmann profile image
Tobias Salzmann

Java Syntax has the weird ability to direct the attention to the less important parts of the code first.

Collapse
 
jacoby profile image
Dave Jacoby

Ugliest I ever dealt with is BASIC. Not Visual Basic from MS, but old-school 20 GOTO 10 BASIC.

But that was 30 years ago and I never did it for pay.

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

I always hate dealing with our VB code base. You thought parenthesis and curly braces were bad, what about a whole statement to terminate a block: End If End Case End For.

Then there is having to continue a multi-line statement with an ending underscore _.

If condition1 And condition2 _
   And condition3 Then

End If
Enter fullscreen mode Exit fullscreen mode

Then there's Sub vs Func keywords. If I use Sub then later decide I need to return a value, I have to change the keyword to Func in order to do so or it will not compile.

There are probably more I'm not thinking of.

Collapse
 
codemouse92 profile image
Jason C. McDonald

VB.net was my first language, and I have a special hatred of it. (What sort of lunatic thought Dim made even the SLIGHTEST bit of sense for initializing a variable???)

Collapse
 
anasik profile image
Anas Ismail Khan

HAHAHAHA That's literally the first thing all VB.net developers, who generally tend to hate VB.net, say.

Even I was like "Hey what's this Dim.. oh wait, that's a variable being declared."

Thread Thread
 
kspeakman profile image
Kasey Speakman

I believe Dim is short for dimension. Not sure why the syntax is so array-focused.

Thread Thread
 
dmfay profile image
Dian Fay

Technically a scalar value is just a special case where an array only has one dimension and one element... I remember it from QBasic in the 90s and apparently it goes back to Fortran.

Thread Thread
 
codemouse92 profile image
Jason C. McDonald • Edited

True point. Although. technically declaring a value is also called instantiation, but that doesn't make Instant a good keyword for declaring a variable. :-P

Thread Thread
 
tinsoldier6 profile image
Jason Gade

Dim goes back to VB's BASIC roots. You didn't have to declare most scalar variables, but you had to use 'Dim' to 'Dim'ension arrays.

In some dialects, strings were treated as scalars and didn't require declaration, but other dialects required you to 'Dim' them as arrays.

As was mentioned, it may even go further back to FORTRAN, but that's a bit before my time.

/grognard hat off.

Collapse
 
daniel15 profile image
Daniel Lo Nigro

Be glad ReDim Preserve isn't a thing any more :P

Collapse
 
cbordeman profile image
Chris Bordeman

DIM was short for dimension. In early BASIC forms, it was to declare an array by indicating its size. Later it was repurposed to do any sort of declaration.

Collapse
 
jacoby profile image
Dave Jacoby

Back in the day, I worked on a VB Embedded program but didn't have the devices yet so worked in VB 6. All well before .NET.

When I started to port it over, I found that VB differed. Like, VBe and VB6 had incompatible for loops. Or maybe while. I didn't like VB much either way, but it worked. It's the incompatibility that's ugly to me.

.NET ftw

Collapse
 
ryanhaber profile image
Ryan Haber

I suddenly remembered my very first programming language back in 1989 (?). GW-BASIC. And line numbers.

😐

Collapse
 
cbordeman profile image
Chris Bordeman

GW-BASIC was my very first language, too! :D

Collapse
 
nektro profile image
Meghan (she/her)

For as many under-the-hood advancements they have when I first came across Go and Rust I denounced them at first because of how ugly they are.

Collapse
 
dfockler profile image
Dan Fockler

With Rust's lifetimes and it's type system you sometimes end up with pretty crazy type signatures. RefCell<Rc<'a &Mutex>>> mostly that's if you are trying to write concurrent code though.

Collapse
 
nestedsoftware profile image
Nested Software • Edited

Yeah, Rust is awful in my opinion! I mean, if you value some of the compiler guarantees it offers, I guess that's fair enough, but it seems more like an academic exercise to me than a usable programming language. One should not have to struggle with a language just to get frequently-used and standard types of logic working.

Collapse
 
ethan profile image
Ethan Stewart

I get put off by the parenthetical soup that Lisp can sometimes become, but I've never encountered a syntax I hated more than Objective-C. Had to dig in some old iOS code in Obj-C at a previous job for an app we were planning to build, it made me want to tear my eyes out

Collapse
 
eronaeon profile image
eronaeon

Golang

Collapse
 
dmfay profile image
Dian Fay

I still love it, chunky retro capitalization and awkward indentation and all, but even I have to admit that the inner elegance of a well-designed SQL query only shines through sometimes.

Collapse
 
felipperegazio profile image
Felippe Regazio

php by far

Collapse
 
anasik profile image
Anas Ismail Khan

I nominate C++.

Collapse
 
jakebman profile image
jakebman

I like that C++ has the Spiral Rule.

I'm worried that it needs it.

Collapse
 
eljayadobe profile image
Eljay-Adobe

C has the Spiral Rule. C++ broke it.

Collapse
 
chocolim profile image
Choco Lim

Objetive-C have a special place in the darkness places of my heart.

Collapse
 
danielkun profile image
Daniel Albuschat

I vote for Objective C as well

Collapse
 
shaioz profile image
Shai Ohev Zion

"Wait, how many [ do I have? [[[[[ fuck this shit!"

Collapse
 
eljayadobe profile image
Eljay-Adobe

[[[alloc Shit] init] intercourseWith:Penguin]]]

Thread Thread
 
mouvedia profile image
G.

Reminds me of ClojureScript.

Collapse
 
cbordeman profile image
Chris Bordeman

And yet there are people who insist Objective-C is somehow a great language, ahead of its time. Like Javascript and C++. LOL

Some comments may only be visible to logged-in visitors. Sign in to view all comments.