views:

1027

answers:

33

It's easy to think of features to add to a language. What feature would you cut from a language, and why?

Douglas Crockford says don't use JavaScript's "with" statement. What are the hazard areas in other computer languages? What features have you seen get in the way of software engineering?

+16  A: 

Checked exceptions in Java.

cletus
+1 my first thought, too
ammoQ
On the contrary, I think checked exceptions are important. Plenty of people misuse them however, and you end up with catch statements littered everywhere.
Adam Batkin
Why are checked exceptions bad? They augment static typing. If someone is just ignoring every exception they are a bad developer, an exception means something went wrong, you have to handle it in order for your code to be robust...
Longpoke
+3  A: 

Protected implies package private access in Java.

cletus
+5  A: 

Magic quotes in PHP (to be deprecated in PHP 6).

cletus
Deprecated in 5.3. Removed in 6. It's already gone. http://us2.php.net/manual/en/info.configuration.php#ini.magic-quotes-runtime
jmucchiello
But the scars will remain forever!
alberge
... but the rest of PHP is still around.
Nikolai Ruhe
...and register_globals, and remote includes, and weak typing, and pointless file wrappers, and ...
Longpoke
A: 

goto statement in c/c++

Umair Ahmed
Useful for certain types of error handling and for implementing state machines.
anon
Agreed. Less necessary in C++, but very useful in C.
HVS
I've never understood why people want to remove goto completely. It's occasionally useful, people have gotten the message not to abuse it, and it doesn't interact poorly with any other parts of the language.
dsimcha
+1  A: 

register_globals in PHP

mabwi
Is it fair to pick a language feature that is already being removed from the language? PHP 6 removes that feature.
jmucchiello
@jmucchiello: yes it's fair, seeing as it's been there for 5 versions.
Longpoke
A: 

I've heard people say that the ternary if

(exp) ? (exp) : (exp)

may lead to confusing/unreadable code and shouldn't be used.

Christo
And the ternary has worked its way into many C-derived languages.
Nosredna
I just love ternary ifs.
Arnis L.
I believe we should not confuse bad practices with bad language/platform design. If one throws tons of expression inside the ternary operator its not necessarily a problem with the language.
Ionuț G. Stan
I know it is available in many languages and I've used it often. That doesn't mean that it's useful other than a shorthand for writing "if else".
Christo
it's simply very terse and may actually improve readability once you're familiar with the syntax used.
none
@Christo, you can use the ternary operator in places where if-else wouldn't be allowed, so it's more than just shorthand.
Iceman
I've seen it for years and years and it's still harder for me to read than an if/else.
Nosredna
I would only include this construct in PHP since operator precedence causes it to work the opposite of how it works in C. If you are going to steal from another language don't change how it works.
jmucchiello
The only time I dislike this is when developers use ternary statements which expand accross and off the screen.
Peter
They are great for trivial if/else constructs. I would not do away with them.
Ed Swangren
Ternary can be really useful. For example, here's some code from Eclipse that would look a lot worse with a bunch of if/elses: InputStream input = loader == null ? ClassLoader.getSystemResourceAsStream() : loader.getResourceAsStream(); But I agree, I hate seeing this construct when an if/else would have worked, and would have been a lot easier to read...
Troy Nichols
+8  A: 

Overloading of operator comma in C++. Some would say all operator overloads but some overloads are useful. Overloading operator comma is just a nightmare waiting to happen.

jmucchiello
Jonathan Leffler
jmucchiello
Although Blitz++'s use of overloaded commas is pretty cool - http://c2.com/cgi/wiki?OverloadingCommaOperator
Josh Kelley
Don't forget boost::lambda, that overloads just about every operator.
Joe D
+1  A: 

In SQL:

select *
RedFilter
SELECT * FROM table WHERE 1=0 is useful for portably obtaining a list of column names.
anon
There are metadata tables for those type of operations.
RedFilter
Not portably there aren't, unfortunately.
anon
But this is very handy to have a quick look at a table content, no ? I use it every day.
Sylvain
Ok, so do I - my point is that many developers put this in production queries and I wish they wouldn't...
RedFilter
SELECT * is also useful in subqueries when using EXISTS. Abuse of SELECT * is unfortunate but cutting it does more harm than good.
Einstein
I have to agree it's bad in code, but in admin use it's darn useful (especially with rowcount or top).
C. Ross
Why?SQL sucks; specifying every column sucks ten times more!
alamar
I have to agree with others: it might suck in most production code, but even there it has rare uses. From the admin side of things, it prevents rapid lost of sanity...
mavnn
+4  A: 

Option Strict Off in Visual Basic .NET.

mutable local "variables" in F#.

*See this question

Dario
VB.NET without option strict can become nightmare easily. :)
Arnis L.
In an imperative environment such as .NET, mutable variables, even in a functional language, can be a great help.
Zifre
Option Strict Off is great for a good bit of COM work...so great, in fact, that C# 4 gets dynamic. That said, the fact that Option Strict allows both narrowing conversions and late binding is a shame. Implic narrowing conversions are always bad, but late binding can be good. I wish they'd seperate the 2.
Mark Brackett
A: 

Another vote for checked exceptions in Java. If you include libraries are part of the language, I would have 100,000 more things to say ;)

sehugg
I'm not a Java guy, so can you tell me what's wrong with checked exceptions in Java?
Nosredna
Nice discussion here about checked exceptions in java and why they did had them to C# : http://www.artima.com/intv/handcuffs.html.
Sylvain
A: 

In C#:

The goto case statements.

Aistina
How else would you do fallthroughs?
Zifre
C++ style; case 0: case 1: case 2: Console.WriteLine("0 to 2"); break;
Aistina
A: 

In C# and VB.NET :

I would remove XML Comments.

Problem : they are often quite messy on screen and pretty hard to maintain. I know it can be really handy for third-party developers and for Microsoft itself, but for the in-house projects I worked on (banking, insurances), it was really overkill and most comments were anyway useless (as before) or outdated. (Maybe Microsoft and 3rd-part developers could use a special edition ?)

Since it have been widely accepted that XML Comment were good, developers spend a lot of time juggling with XML attributes (and generating cool chm documents that no one ever read) and a little less time writing comments...

We were very happy to get Code Behind to seperate html from code. How could adding XML to code would be a better idea ?

:o)

Sylvain
It's not really a feature of the language, just don't use them if you don't like them.
Zifre
+2  A: 

The "functional" parts of Python, specifically zip/map/reduce/filter/lambda.

They have their uses (and I wouldn't actually suggest they be removed), but always seem to be mis- or over-used, instead of slightly more verbose, Python'ish methods.

dbr
It seems to me that most people who advocate against functional programming just don't really understand it. Map/reduce is an extremely useful operation (see Google).
Zifre
I don't think he's arguing against it--just saying that Python shouldn't embrace it. Or at least that's how I read his answer.
Nosredna
Meh. <3 functional programming. Maybe reduce is used too much, but the others are great.
alberge
+16  A: 

In C/C++/Java:

Numbers starting with 0 are assumed to be octal. So 034 means decimal 28. Makes it too easy to specify octal values by mistake, since you might think you want to add a zero to line up a group of numbers.

Also, switch statement flow-through. If a case doesn't terminate with a break statement, it automatically flows through to the next case.

Chi
I TOTALLY agree with the octal nonsense. I ran into that just the other day. Other bases require a 'b' or a '0x', but Octal starts with 0. It's not even 'O' (the letter). That makes it far too easy to accidently use octal. That said, I like the switch statement.
MBCook
I think I've only once ever accidentally "octalized" a number.
cletus
But it's utterly ridiculous.
Nosredna
Absolutely agree.
ilya n.
+1 for getting rid of octal, -1 for getting rid of switch flow-through. Although that's only from a C perspective. I suppose in a language like Java switch should not automatically flow-through as you say.
Chris Lutz
i disagree with switch statement flow-through. In fact its a feature I miss in nearly every other language that implements switch.
Ape-inago
I like fall through (I always though it was fall not flow). But I would add an explicit keyword. Thus stopping accidental fall through.
Martin York
I'd vote instead for making fall-through be the exception, not the default. 99.9% of the time each case ends with break. How about omitting the break and indicating which cases fall through with "continue"?
Barry Brown
The python developers agree with you, too. 0o is the prefix for octal numbers in python3.
alberge
Is octal even used enough to be worth being a built in language feature? The only use case I even know of it is the God forsaken *nix file modes. (Which everyone just uses decimal for anyways...)
Longpoke
You could always propose, for C1X, to deprecate the '0' prefix and replace it with '0o'. Not sure if the commitee would consider it though....
Joe D
A: 

In C#, using.

When I first used it for consuming an ASMX based service, I thought it was great. But then I tried using it to consume a WCF service and discovered that there is a problem if the service throws an exception before it is completely set up in the using() clause, Dispose() still gets called on the invalid object and will throw another exception that masks the original exception.

Here is a good explanation http://blogs.msdn.com/salvapatuel/archive/2007/04/25/why-using-is-bad-for-your-wcf-service-host.aspx

Jeff Leonard
Just because using does not work very well due to a poor implementation in WCF should not overlook how useful it is in other parts of .NET
Kev Hunter
Yeah, using is generally a great construct imo.
Ed Swangren
+8  A: 

The "switch" statement in Java. It was copied nearly intact from C, including the break/fallthrough nonsense, and it's just awful.

skaffman
Yeah JavaScript got it that way, too.
Nosredna
Fallthrough is not nonsense; I've found it quite handy in some situations.
zvrba
It is handy, but it make maintenance difficult. When I see it used intentionally, it's often commented with apologies.
Nosredna
Break-to-label can be handy also. That doesn't make either of them a good idea.
skaffman
Actually it would have made more sense to make break the default and require a fallthrough keyword.
jmucchiello
Cobol 85's CASE statement is even more powerful than Java's, sad to say.
Jim Ferrans
This was changed for C#, wasn't it?
Nosredna
Yup, no fallthrough in C#, though I like the idea of a "fallthrough" keyword. Though, it may be a bit much as it would not be needed often.
Ed Swangren
there's not much additional functionality of "fallthrough" over "goto" though. I hear goto isn't considered that harmful in this context.
Jimmy
not using a switch statement because a future maintainer might not know it is a silly argument. If anyone is maintaining C / C++ / Java, they should understand how a switch statement works, or they aren't good at their job. The same arugment could be said about for loops (why not use while loops, the future maintainer might not understand for-loop syntax).Besides, switch statements can and typicaly will generate faster code due to jump lists. http://www.eventhelix.com/RealtimeMantra/Basics/CToAssemblyTranslation3.htm
Ape-inago
A: 

Array covariance in C# (and in .Net generally).

Doug McClean
+3  A: 

Silent/Implicit destructive conversions between data types in C/C++.

int i = 5.6; // well-formed

Faisal Vali
+3  A: 

in SQL (especially in PL/SQL): INSERT statement without column list. Breaks when a new column is added to the table.

ammoQ
+7  A: 

I hate how JavaScript adds a semicolon to the end of lines if you don't do it.

Nosredna
+16  A: 

Bad type systems need to go:

<?php echo (3 == '3 little pigs') ? 'True' : 'False'; ?>

I shake my head when I see this return 'True'.

tremoloqui
Is that because casting int on 3 little pigs returns 3 ? gah, I never knew this!
alex
It's a typeless language. Why complain? You can always use ===
jmucchiello
The 'identical' and 'equal' operators semantically mean different things, so I don't think you can just replace one with another. The problem is that the 'equal' comparison above is not semantically correct, at least not in any conventional sense of the property of equality. This means that this odd type inference can cause bugs that are very difficult to detect and correct.This isn't limited to PHP either, Perl has a very similar typing system which is unfortunate for an otherwise very useful and elegant language.
tremoloqui
"Weak typing considered harmful".
Longpoke
+2  A: 

From C, bitfields, because they aren't endian clean, and technically are even compiler dependent (though in practice, it tends only to be endian differences that you actually run into.)

smcameron
Agreed. The limited use they provide isn't worthwhile. In this day and age, no one really needs to pack values in that tight to make sure they don't waste memory.
Chris Lutz
The times i've used them (or changed code to avoid using them) it wasn't about packing for space, it was about packing to match whatever was in a hardware register or the like.
smcameron
@smcameron: I agree, the only time you need to use them is when doing something low-level, when you actually know the endianness of the target machine.
Joe D
+1  A: 

The C++ export keyword. Because it seems to be of very limited use, and because Herb Sutter says so.

kotlinski
+1  A: 

Java, and definitely container managed persistence EJBs.

stevedbrown
A: 

null pointers/references, in pretty much any language that has them.

Niki
Do you mean that *bugs* are a bad part of some languages? If so, I agree, they should be removed from any language!
Nikolai Ruhe
@Nikolai Ruhe: well some languages ignore things like null pointer references, undefined variables, etc, and proceed to launch the missile anyways.
Longpoke
+4  A: 

In Perl, inconsistent rules on using parenthesis.

When you print, you can use parenthesis or not:

print("Hello, world!\n");

print "Hello, world!\n";

But if you print to a filehandle, you can't use them:

print FILE "Hello, world!\n";

(This also brings up the awkward syntax for printing to files - look, Ma, no comma! - but that's not what this post is about.)

However, flow control statements must have parenthesis:

while(1) {

...unless you use postfix notation:

dosomething() while(1);

dosomething() while 1;

Personally, I'm a fan of dropping the parenthesis altogether, except when you need them to resolve ambiguities (which is what parenthesis are for) and typing:

while 1 {

Because we all know that anything after the while and before the { is the condition.

Chris Lutz
technically, printing to a file handle is a multi argument operaion... so [ print FILE, "hello,world!\n"; ] # should workIt is completely consistent.
Ape-inago
I agree - there should be a comma. But I tried to keep this to one argument.
Chris Lutz
+2  A: 

In .NET, Try / Catch needs a re-think. It's too easy to hide code from yourself and create circumstances where things don't do what you think they should.

Shamelessly stolen from http://www.joelonsoftware.com/articles/Wrong.html , but its stuck with me.

Kyle Hodgson
+1  A: 

The comma operator in C. Guess what this does:

SomeFunction(1, 2, 3);
Dour High Arch
Calls SomeFunction with three arguments, duh.
Mike Daniels
+5  A: 

Not requiring {}'s for if / for's etc in C / C++

if( true )
{
     dostuff();
     return 1;
}

Without braces:

if( true )
    dostuff():
    return 1;

Will still work, but when you go to add more code below you will run into problems.

Deinumite
Actually, those are exactly the same.
Dour High Arch
@Dour High Arch. Haha! Good catch.
Nosredna
Less commonly hit now that debuggers are better than printf, but I'm still picky about this one. Without {}, chaos rapidly ensues. A quick literally one-line (as in, fits on the same line as the if) that "couldn't possibly" need more body might be ok, but really, why chance it? It's only a few more characters, and it's a lot more comfortable.
Kim Reece
Oops bad example, i will edit again.
Deinumite
I didn't switch over to the habit of always using braces until just a couple years ago. Now, I ALWAYS use them in C and JavaScript.
Nosredna
A: 

Not a true language feature but, I would get rid of /* */ comments in C++ and C# as code in them shows up in searches without an indication that it is not used.

I would also get rid of most conditional compilations within a file in C++ - many times the code can be structured better to get the same effect.

Maggie
-1, because /* */ comments aren't meant for commenting code - use `#if 0 ... #endif` for that. I agree with you mostly on the second point though, check out the D programming language - better metaprogramming than C++, no preprocessor and optional garbage collection (C++ done right ;)
Joe D
but other people use /* */ to comment code regardless of what it may be meant for.
Maggie
+3  A: 

extract() in PHP. A horrible, horrible function.

Artem Russakovskii
Not really, great for making your own short template system without littering the namespaces. `function display($file, $args) { extract($vars); include($file); }`
tj111
+1  A: 

In C++:

  1. local functions declarations (if only one allowed, this will be this one)
  2. goto
  3. macros
Kirill V. Lyadvinsky
+2  A: 

Java: maintaining backwards compatibility at all costs. It would free the designers and implementors from a huge burden and allow the language to evolve more gracefully.

Robert Munteanu