Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

No matter how much you love a programming language, there are always a few details in it that aren’t quite as nice as they could be.

In this question, I would like to specifically focus on syntax elements. In a programming language that you use frequently (perhaps your favourite programming language, or perhaps the one you are forced to use at work), which syntax element do you find most unreadable, unclear, inconvenient or unpleasant?


locked by Yannis Oct 1 '13 at 10:37

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

closed as not constructive by Morgan Herlocker, NickC, ChrisF May 26 '11 at 20:37

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

Is "Java" an acceptable answer? – Nathan Taylor Sep 3 '10 at 1:47
@Nathan Taylor, not for this question, but for another question. – finnw Sep 11 '10 at 23:49
Did this question get modified? Because when I answered, it wasnt focused on "syntax elements"... I will have to modify my answer now. – Talvi Watia Sep 20 '10 at 0:08
@Talvi: No, it was about syntax right from the start. – Timwi Sep 20 '10 at 11:35
@Timwi weird, it must be a case of 'answering a question thinking it was a different one' then. – Talvi Watia Sep 21 '10 at 11:27

36 Answers 36

REGEX / preg_match() in PHP

Firstly, its completely different syntax than PHP uses. While the preg_match() function emulates regex quite excellently, I have to completely switch my mode of thinking to work with it.

Secondly, its just plain obscurification half the time. I usually have to quite literally take out a scratch pad and figure out WTF its doing half the time.

Besides, I program in PHP, not Perl. If I liked Perl, I would program in Perl. (no, sir I don't like it.)

To make matters worse, with the new PCRE delimiter format, you can practically use any character, which includes having to escape that same nested character, making the pattern even more obscure.

Sure, its great if you want to be cryptic.. or even efficient... but holy hell the amount of time it wastes to normally perform simple tasks.

The fact that you have your answer written with PERL in all caps tells me that you've never actually looked into the language at all and don't know anything about it. – Daenyth Sep 17 '10 at 19:06
PHP is sometimes too slow to do parsing any other way than with regexes. – Joeri Sebrechts Sep 18 '10 at 12:54
@daenyth you are right, I haven't much, however I wouldn't say don't know anything. But what Joeri said is correct.. it is needed occasionally and is the one thing that throws a monkeywrench in coding PHP without having to reference docs much. – Talvi Watia Sep 20 '10 at 0:03

I know this is an older question, but how come no one mentioned.


<% %> <-- Regular

<%= %> <-- Buffalo style

<%:%> <-- extra crispy


$this->... in PHP ... unnecessary, looks bad and considerably slows down "quick-grasp-on-short-glance" (my closed thread on SOF).

as optional is useful, as mandatory is unnecesary... – umlcat Mar 15 '11 at 21:23

SSIS - SQl Server I hate everything about the Expression Builder. I already know how to write these types of conditions in t-sql. Why can't they Expression builder use the same syntax t-SQl would use (especially The equivalent to the CASE statement)? Or let me write t-sql statements instead of creating stupid wierd expressions. And why am I stuck doing complex conditions in a form that only allows me to use one line so I am in scroll bar hell?

This answer seems to be all about UI and has nothing to do with syntax elements. – Timwi May 27 '11 at 13:36

& && | || in C

C++ has rectified it to some extend with explicit "and" "or" keywords. Many a bugs and torn hair could have been avoided in C if logical operations and bitwise operations weren't so hard to differentiate.

The and and or keywords are provided by <iso646.h>. #include that your C programs and that's a complete non-issue. C++ is also required to provide the same header. – greyfade Oct 29 '10 at 18:16
I've never ever had trouble distinguishing the two... – Carson Myers Dec 7 '10 at 4:13
That's nonsense, it's trivial to remember and optically very different. Using the keyword and is even a bigger nonsense. Without reading the definition, what does and mean? Is it logical or bitwise? People confused by the difference between & and && probably need something like logand and bitand. – maaartinus Apr 27 '11 at 3:04

Ternary statements. They are generally much harder to read yet only save a few lines of code.

if (myCondition) {
    return firstAlternative();
return secondAlternative();


return myCondition ? firstAlternative() : secondAlternative();
Ergh. If you are going to write it longhand, at least use an else. – Tom Hawtin - tackline Feb 27 '11 at 14:28
Your example saves 3 out of 4 lines of code, i.e. 75%. This means that significantly more code will fit on my screen at a time. I think that is a pretty clear benefit. If you find statements involving the conditional operator “harder to read”, you probably just need to train yourself a bit more, and then you’ll have no trouble with them :) – Timwi Feb 27 '11 at 16:16
In addition, there is no such thing as a "ternary statement". It's an expression and he who doesn't recognize the difference should go look for another job. – Ingo Sep 6 '11 at 11:32
Perhaps this is better rectified by if expressions, ie return if myCondition then firstAlternative else secondAlternative, a la haskell/functional languages. – alternative Oct 31 '11 at 1:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.