26
votes

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?

6
  • @Nathan Taylor, not for this question, but for another question.
    – finnw
    Sep 11, 2010 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. Sep 20, 2010 at 0:08
  • @Talvi: No, it was about syntax right from the start.
    – Timwi
    Sep 20, 2010 at 11:35
  • @Timwi weird, it must be a case of 'answering a question thinking it was a different one' then. Sep 21, 2010 at 11:27
  • If you can vote and think this is a useful question or it have useful answers below, please vote up. StackExchange sites need votes to build a good community. You can give 30 votes per day, don't waste them. Specially users with high reputation and low counting votes given please read this: meta.programmers.stackexchange.com/questions/393/…
    – Maniero
    Oct 5, 2010 at 19:30

36 Answers 36

1
2
0
votes

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.

3
  • 5
    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, 2010 at 19:06
  • PHP is sometimes too slow to do parsing any other way than with regexes. Sep 18, 2010 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. Sep 20, 2010 at 0:03
0
votes

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

CODE NUGGETS

<% %> <-- Regular

<%= %> <-- Buffalo style

<%:%> <-- extra crispy

-1
votes

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

1
  • 1
    as optional is useful, as mandatory is unnecesary...
    – umlcat
    Mar 15, 2011 at 21:23
-1
votes

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?

1
  • This answer seems to be all about UI and has nothing to do with syntax elements.
    – Timwi
    May 27, 2011 at 13:36
-2
votes

& && | || 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.

3
  • 1
    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, 2010 at 18:16
  • 4
    I've never ever had trouble distinguishing the two... Dec 7, 2010 at 4:13
  • 1
    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, 2011 at 3:04
-5
votes

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

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

versus

return myCondition ? firstAlternative() : secondAlternative();
4
  • 1
    Ergh. If you are going to write it longhand, at least use an else. Feb 27, 2011 at 14:28
  • 4
    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, 2011 at 16:16
  • 1
    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, 2011 at 11:32
  • Perhaps this is better rectified by if expressions, ie return if myCondition then firstAlternative else secondAlternative, a la haskell/functional languages. Oct 31, 2011 at 1:49
1
2

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