JavaScript API Deprecation in the Wild: A First Assessment (SANER 2020)
andrehoraa
38 views
49 slides
Jul 25, 2024
Slide 1 of 49
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
About This Presentation
Building an application using third-party libraries is a common practice in software development. As any other software system, code libraries and their APIs evolve over time. In order to help version migration and ensure backward compatibility, a recommended practice during development is to deprec...
Building an application using third-party libraries is a common practice in software development. As any other software system, code libraries and their APIs evolve over time. In order to help version migration and ensure backward compatibility, a recommended practice during development is to deprecate API. Although studies have been conducted to investigate deprecation in some programming languages, such as Java and C#, there are no detailed studies on API deprecation in the JavaScript ecosystem. This paper provides an initial assessment of API deprecation in JavaScript by analyzing 50 popular software projects. Initial results suggest that the use of deprecation mechanisms in JavaScript packages is low. However, we find five different ways that developers use to deprecate API in the studied projects. Among these solutions, deprecation utility (i.e., any sort of function specially written to aid deprecation) and code comments are the most common practices in JavaScript. Finally, we find that the rate of helpful message is high: 67% of the deprecations have replacement messages to support developers when migrating APIs.
Size: 1.28 MB
Language: en
Added: Jul 25, 2024
Slides: 49 pages
Slide Content
JavaScript API Deprecation in the
Wild: A First Assessment
Romulo Nascimento, Aline Brito, Andre Hora, Eduardo Figueiredo
IEEE SANER 2020
Motivation
JavaScript is the most popular
programming language for the seventh
consecutive year
2
Motivation
GitHub also reports JavaScript as a
popular language
3
There are several JavaScript libraries
Lodash
Axios
Angular
4
There are several JavaScript libraries
Lodash
Axios
Angular
5
Library for
static analysis
There are several JavaScript libraries
Lodash
Angular
6
HTTP client
Axios
There are several JavaScript libraries
Axios
Angular
7
Utility library
Lodash
Library services are provided via APIs
8
Libraries and their APIs evolve over time
9
API Deprecation
Deprecation mechanisms help clients to
migrate to new API versions
10
Example of API Deprecation
11
Example of API Deprecation
The question has
17K views
12
Example of API Deprecation
13
Example of API Deprecation
A developer recommends
two options
14
Example of API Deprecation
JSDoc deprecated
annotation
15
Example of API Deprecation
Console warning
message
16
How do developers
actually deprecate
JavaScript APIs?
17
Outline
18
1.Dataset
2.Searching for deprecation occurrences
3.Results
Dataset
19
Dataset
20
50 popular JavaScript projects
Metrics from GitHub repositories
Searching for Deprecation
Occurrences
21
We downloaded the source code of the 50 projects
(latest stable version)
22
We downloaded the source code of the 50 selected projects
(latest stable version)
We discarded files that are not part of the core systems
23
We downloaded the source code of the 50 selected projects
(latest stable version)
We discarded files that are not part of the core systems
We used a regular expression to find deprecation occurrence
candidates
24
We downloaded the source code of the 50 selected projects
(latest stable version)
We discarded files that are not part of the core systems
We used a regular expression to find deprecation occurrence
candidates
25
29 projects (58%)
Results
26
RQ1: How do Developers
Deprecate JavaScript APIs?
27
How do Developers Deprecate JavaScript APIs?
DATASET
1,279 deprecation
contexts
29 project (58%)
28
Deprecation
utility
Any set of code functions to
aid code deprecation
88 occurrences (33%)
32
How do Developers Deprecate JavaScript APIs?
Code
comment
/* */
Use of code comments
excluding occurrences of JSDoc
27 occurrences (10%)
33
How do Developers Deprecate JavaScript APIs?
JSDoc
Use of the
JSDoc annotation
22 occurrences (8%)
34
How do Developers Deprecate JavaScript APIs?
Deprecation
lists
List of deprecated elements
18 occurrences (7%)
35
How do Developers Deprecate JavaScript APIs?
Console
Use of the JavaScript engine
native console API
11 occurrences (4%)
36
RQ2: Are JavaScript APIs
Deprecated with Replacement
Messages?
37
Are JavaScript APIs deprecated with
replacement messages?
67%
Replacement messages to support developers to
migrate to new versions
38
Example: Replacement Message
39
handleExceptions(...args){
...
console.warn('Deprecated:
.handleExceptions() will be removed in
winston@4. Use .exceptions.handle()' )
...
}
Example: Replacement Message
40
handleExceptions(...args){
...
console.warn('Deprecated:
.handleExceptions() will be removed in
winston@4. Use .exceptions.handle() ')
...
}
Are JavaScript APIs deprecated with
replacement messages?
Deprecation
utility
75 occurrences of
replacement messages
41
Code
comment
/* */
4 occurrences of
replacement messages
Are JavaScript APIs deprecated with
replacement messages?
42
Are JavaScript APIs deprecated with
replacement messages?
JSDoc
10 occurrences of
replacement messages
43
Conclusion and Discussion
44
Conclusion and Discussion
Deprecation adoption is not frequent in
JavaScript APIs
Only 3% of all analyzed files contain
occurrences of deprecation mechanisms
45
Conclusion and Discussion
Only 22 occurrences (8%) of JSDoc
JSDoc is not popular among deprecation
mechanisms
46
Future Studies
Survey with API developers about
motivation and impressions behind the
usage of JavaScript deprecation practices
47
Future Studies
Tool
Identification of
deprecation contexts
Alert about missing
replacement messages
48
JavaScript API Deprecation in the
Wild: A First Assessment
Romulo Nascimento, Aline Brito, Andre Hora, Eduardo Figueiredo
IEEE SANER 2020