DEV Community

Discussion on: Which mainstream programming language has the ugliest syntax?

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.