test
test

Reputation: 18198

Why do frameworks and such deprecate functions instead of just updating them?

For example, jQuery's .live() is deprecated and instead we must use .on() and for MySQL, mysql_* will soon be deprecated and move onto something else... more noteably... mysqli.

Why do frameworks and programming languages deprecate old functions instead of just updating them? Sorry if this is in the wrong place. If it is, tell me where I should post.

Upvotes: 2

Views: 222

Answers (7)

Explosion Pills
Explosion Pills

Reputation: 191779

There has to be a step in the release process that allows for simultaneous compatibility between a deprecated feature and its replacement (as in .live and .on). If this step didn't exist and .live was replaced to have .on's functionality immediately, anyone who was depending on the old behavior of .live and wanted to update to the next version would have to deal with completely broken code which would be a lot harder.

Other reasons are a lack of compatibility between the two APIs on the back end. This probably applies moreso for ext/mysql vs. mysqli than it does for .live vs. .on (which probably have similar and much smaller back ends). mysqli and PDO have both been around for a very long time and started as projects independent of ext/mysql and were probably maintained by different people (I assume so). Eventually, mysqli/PDO were introduced into the php core after having been developed separately from ext/mysql. Neither the back nor front ends for either of these are even close to compatible.

I don't think you're asking for specific reasons why they're getting rid of .live/ext/mysql (you seem to understand that they're inferior), but at least PHP has a FAQ about it: http://www.php.net/manual/en/faq.databases.php#faq.databases.mysql.deprecated

Upvotes: 0

tadman
tadman

Reputation: 211670

mysql_query is an interface that's dangerous by default. There's no way to update it without breaking every application out there built around it, so the best plan is to retire it. The world truly is better off without it.

Although a framework should do everything it can to promote backwards compatibility, there are occasions where dropping features helps the platform advance more quickly or become more consistent.

I'm not sure why jQuery dropped live() but sometimes functions like that are difficult to support or have significant feature overlap with other elements of the API. Keep in mind that jQuery is not only a framework, but is also something that needs to be very careful about code size. Every extra kilobyte of code in the core library is something that causes additional terabytes of data to be downloaded over the internet. When you add things, something's got to go.

Why did the Linux kernel drop support for the 80386? It's because maintaining features that you don't want takes away effort from the features you do want.

Upvotes: 0

Hussein Nazzal
Hussein Nazzal

Reputation: 2557

with all do respect to all frameworks and languages .. here is why deprecation happen..

1- Oops , what the hell am i thinking !

i'd love to consider this one of the main reasons why methods are deprecated .. at some point who ever made php/jquery or the computers made a mistake , and the only way to fix that mistake is by giving other solution ..

best example is the mysql_ library

2- you cant make every body move into your new functionality .. let's say for example i love to type .live cuz it feels more natural , so instead of just breaking all of what i have built with jquery library , they will tell me it's bad and then they creat something better , and finally they will deprecate the old functionality ..

3- i dont want to make the same mistake , so just to look more cool , i will give ppl time to test the new function and they will tell me if there is anything wrong ..cuz i dont want to fix a mistake with other one

4- and most importantly core changes and new thinking ..

thats the way i think about it .. sure thing every method has been deprecate has it's own reasons .. but let's face it , they know what they are doing better than us .

Upvotes: 0

jfriend00
jfriend00

Reputation: 707706

When the design of the function has changed, they want to offer a period of time where both old and new functions are offered (a transition time) and then at some future date, the old version is removed. This could not be done if they kept the same name for the new behavior. .live() and .on() take different arguments and work differently. .on() is more powerful and can be made to simulate .live() if desired, but the two are not compatible without changing the calling code.

Introducing the new feature with a new behavior, also simplifies the documentation process since it's completely clear which behavior is documented (by which name it's writing about).

And, when old code includes the newest latest version that no longer supports the old way of doing things, it is much clearer why things don't work when .live() is not even present than if it was present, but had the wrong behavior.

And, old behaviors like .live() are eventually removed from the code because they are a bad way of doing things (that can lead to significant inefficiencies) so jQuery wants everyone to eventually stop using them. Removing it from future versions is a way of forcing it's usage to decline and eventually go away. The transition period gives the developers a significant amount of time to learn about the need to change and to implement/test the change.

Upvotes: 3

kahowell
kahowell

Reputation: 30216

Check out this from Oracle's Java documentation:

Valid reasons for wishing one's users to migrate to the new API include: - the old API is insecure, buggy, or highly inefficient - the old API is going away in a future release - the old API encourages very bad coding practices

Upvotes: 0

cwallenpoole
cwallenpoole

Reputation: 82048

Often things are deprecated so that people know not to use them and so that they know that at some point in the future they will no longer exist. In the meanwhile, however, deprecation means that they can move forward with linguistic/framework development without breaking old code.

Upvotes: 0

Tristan
Tristan

Reputation: 2399

The answer is simple. When one updates their version of software. Why should everything they have already coded break? When things become deprecated they not only fix security flaws, but also change the way it should be used.

Upvotes: 0

Related Questions