On the usage of functional programming concepts in JavaScript programs
Autor(a) principal: | |
---|---|
Data de Publicação: | 2022 |
Tipo de documento: | Dissertação |
Idioma: | eng |
Título da fonte: | Repositório Institucional da UFPE |
dARK ID: | ark:/64986/0013000010ng7 |
Texto Completo: | https://repositorio.ufpe.br/handle/123456789/46446 |
Resumo: | Language constructs inspired by functional programming have made their way into most mainstream programming languages. Many researchers and developers consider that these constructs lead to programs that are more concise, reusable, and easier to under- stand. Notwithstanding, few studies investigate the prevalence of these structures and the implications of using them in mainstream programming languages. This paper quanti- fies the prevalence of four concepts typically associated with functional programming in JavaScript: recursion, immutability, lazy evaluation, and functions as values. We divide the latter into two groups, higher-order functions and callbacks & promises. We focus on JavaScript programs due to the availability of some of these concepts in the language since its inception, its inspiration from functional programming languages, and its pop- ularity. We mine 91 GitHub repositories (more than 22 million LOC) written mostly in JavaScript (over 50% of the code), measuring the usage of these concepts from both static and temporal perspectives. We also measure the likelihood of bug-fixing commits remov- ing uses of these concepts (which would hint at bug-proneness) and their association with the presence of code comments (which would hint at code that is hard to understand). We find that these concepts are in widespread use (478,605 occurrences, 1 for every 46.65 lines of code, 43.59% of LOC). In addition, the usage of higher-order functions, immutabil- ity, and lazy evaluation-related structures has been growing throughout the years for the analyzed projects, while the usage of recursion and callbacks & promises has decreased. We also find statistical evidence that removing these structures, with the exception of the ones associated to immutability, is less common in bug-fixing commits than in other commits. In addition, their presence is not correlated with comment size. Our findings suggest that functional programming concepts are important for developers using a multi- paradigm language such as JavaScript, and their usage does not make programs harder to understand. |
id |
UFPE_5117c5562e9ac748f5bb00118f1dfc40 |
---|---|
oai_identifier_str |
oai:repositorio.ufpe.br:123456789/46446 |
network_acronym_str |
UFPE |
network_name_str |
Repositório Institucional da UFPE |
repository_id_str |
2221 |
spelling |
ALVES, Fernando Henrique de Albuquerquehttp://lattes.cnpq.br/1250398679855381http://lattes.cnpq.br/7310046838140771http://lattes.cnpq.br/8246690925340020LIMA FILHO, Fernando José Castor deDELFIM, Fernanda Madeiral2022-09-15T15:57:17Z2022-09-15T15:57:17Z2022-07-08ALVES, Fernando Henrique de Albuquerque. On the usage of functional programming concepts in JavaScript programs. 2022. Dissertação (Mestrado em Ciência da Computação) - Universidade Federal de Pernambuco, Recife, 2022.https://repositorio.ufpe.br/handle/123456789/46446ark:/64986/0013000010ng7Language constructs inspired by functional programming have made their way into most mainstream programming languages. Many researchers and developers consider that these constructs lead to programs that are more concise, reusable, and easier to under- stand. Notwithstanding, few studies investigate the prevalence of these structures and the implications of using them in mainstream programming languages. This paper quanti- fies the prevalence of four concepts typically associated with functional programming in JavaScript: recursion, immutability, lazy evaluation, and functions as values. We divide the latter into two groups, higher-order functions and callbacks & promises. We focus on JavaScript programs due to the availability of some of these concepts in the language since its inception, its inspiration from functional programming languages, and its pop- ularity. We mine 91 GitHub repositories (more than 22 million LOC) written mostly in JavaScript (over 50% of the code), measuring the usage of these concepts from both static and temporal perspectives. We also measure the likelihood of bug-fixing commits remov- ing uses of these concepts (which would hint at bug-proneness) and their association with the presence of code comments (which would hint at code that is hard to understand). We find that these concepts are in widespread use (478,605 occurrences, 1 for every 46.65 lines of code, 43.59% of LOC). In addition, the usage of higher-order functions, immutabil- ity, and lazy evaluation-related structures has been growing throughout the years for the analyzed projects, while the usage of recursion and callbacks & promises has decreased. We also find statistical evidence that removing these structures, with the exception of the ones associated to immutability, is less common in bug-fixing commits than in other commits. In addition, their presence is not correlated with comment size. Our findings suggest that functional programming concepts are important for developers using a multi- paradigm language such as JavaScript, and their usage does not make programs harder to understand.Constructos de linguagem de programação inspirados pelo paradigma funcional che- garam à maioria das linguagens convencionais. Muitos pesquisadores e desenvolvedores consideram que esses constructos tornam programas mais concisos, reutilizáveis e mais fáceis de entender. No entanto, poucos estudos investigam a prevalência dessas estruturas e as implicações de usá-las em linguagens de programação convencionais. Este trabalho quantifica a prevalência de quatro conceitos tipicamente associados à programação funci- onal em JavaScript: recursão, imutabilidade, avaliação preguiçosa e funções como valores. Dividimos o último em dois grupos, funções de alta ordem e callbacks & promises. Fo- camos em programas JavaScript devido à disponibilidade de alguns desses conceitos na linguagem desde seu início, sua inspiração em linguagens de programação funcionais e a popularidade da linguagem. Mineramos 91 repositórios GitHub (mais de 22 milhões de linhas de código) escritos principalmente em JavaScript (mais de 50% do código), me- dindo o uso desses conceitos de perspectivas estáticas e temporais. Também medimos a probabilidade de commits de correção de bugs removendo usos desses conceitos (o que sugeriria propensão a bugs) e sua associação com a presença de comentários de código mais longos (o que sugeriria um código difícil de entender). Descobrimos que esses con- ceitos são de uso generalizado (478.605 ocorrências, 1 para cada 46,65 linhas de código, 43,59% de linhas de código). Além disso, o uso de funções de alta ordem, imutabilidade e estruturas relacionadas à avaliação preguiçosa vêm crescendo ao longo dos anos para os projetos analisados, enquanto o uso de recursão e callbacks & promises diminuiu. Tam- bém encontramos evidências estatísticas de que a remoção dessas estruturas, com exceção das associadas à imutabilidade, é menos comum em commits de correção de bugs do que em outros commits. Além disso, a presença dessas estruturas não está correlacionada com o tamanho do comentário associado. Nossas descobertas sugerem que os conceitos de programação funcional são importantes para desenvolvedores que usam uma lingua- gem multiparadigma, como JavaScript, e seu uso não torna os programas mais difíceis de entender.engUniversidade Federal de PernambucoPrograma de Pos Graduacao em Ciencia da ComputacaoUFPEBrasilhttp://creativecommons.org/licenses/by-nc-nd/3.0/br/info:eu-repo/semantics/openAccessEngenharia de softwareProgramação funcionalJavascriptOn the usage of functional programming concepts in JavaScript programsinfo:eu-repo/semantics/publishedVersioninfo:eu-repo/semantics/masterThesismestradoreponame:Repositório Institucional da UFPEinstname:Universidade Federal de Pernambuco (UFPE)instacron:UFPETEXTDISSERTAÇÃO Fernando Henrique de Albuquerque Alves.pdf.txtDISSERTAÇÃO Fernando Henrique de Albuquerque Alves.pdf.txtExtracted texttext/plain137780https://repositorio.ufpe.br/bitstream/123456789/46446/4/DISSERTA%c3%87%c3%83O%20Fernando%20Henrique%20de%20Albuquerque%20Alves.pdf.txta896f736c58f9880cdb1eeb34ea37caeMD54THUMBNAILDISSERTAÇÃO Fernando Henrique de Albuquerque Alves.pdf.jpgDISSERTAÇÃO Fernando Henrique de Albuquerque Alves.pdf.jpgGenerated Thumbnailimage/jpeg1235https://repositorio.ufpe.br/bitstream/123456789/46446/5/DISSERTA%c3%87%c3%83O%20Fernando%20Henrique%20de%20Albuquerque%20Alves.pdf.jpgf6c503cdcffc5cc42fca122dfef478c5MD55CC-LICENSElicense_rdflicense_rdfapplication/rdf+xml; charset=utf-8811https://repositorio.ufpe.br/bitstream/123456789/46446/2/license_rdfe39d27027a6cc9cb039ad269a5db8e34MD52LICENSElicense.txtlicense.txttext/plain; charset=utf-82142https://repositorio.ufpe.br/bitstream/123456789/46446/3/license.txt6928b9260b07fb2755249a5ca9903395MD53ORIGINALDISSERTAÇÃO Fernando Henrique de Albuquerque Alves.pdfDISSERTAÇÃO Fernando Henrique de Albuquerque Alves.pdfapplication/pdf837693https://repositorio.ufpe.br/bitstream/123456789/46446/1/DISSERTA%c3%87%c3%83O%20Fernando%20Henrique%20de%20Albuquerque%20Alves.pdfae7612cd34a35a70ed83be6c6972c4adMD51123456789/464462022-09-16 03:00:39.372oai:repositorio.ufpe.br:123456789/46446VGVybW8gZGUgRGVww7NzaXRvIExlZ2FsIGUgQXV0b3JpemHDp8OjbyBwYXJhIFB1YmxpY2HDp8OjbyBkZSBEb2N1bWVudG9zIG5vIFJlcG9zaXTDs3JpbyBEaWdpdGFsIGRhIFVGUEUKIAoKRGVjbGFybyBlc3RhciBjaWVudGUgZGUgcXVlIGVzdGUgVGVybW8gZGUgRGVww7NzaXRvIExlZ2FsIGUgQXV0b3JpemHDp8OjbyB0ZW0gbyBvYmpldGl2byBkZSBkaXZ1bGdhw6fDo28gZG9zIGRvY3VtZW50b3MgZGVwb3NpdGFkb3Mgbm8gUmVwb3NpdMOzcmlvIERpZ2l0YWwgZGEgVUZQRSBlIGRlY2xhcm8gcXVlOgoKSSAtICBvIGNvbnRlw7pkbyBkaXNwb25pYmlsaXphZG8gw6kgZ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IGRvd25sb2FkIChhcXVpc2nDp8OjbykgYXRyYXbDqXMgZG8gc2l0ZSBkbyBSZXBvc2l0w7NyaW8gRGlnaXRhbCBkYSBVRlBFIG5vIGVuZGVyZcOnbyBodHRwOi8vd3d3LnJlcG9zaXRvcmlvLnVmcGUuYnIsIHF1YW5kbyBmaW5kYXIgbyBwZXLDrW9kbyBkZSBlbWJhcmdvIGNvbmRpemVudGUgYW8gdGlwbyBkZSBkb2N1bWVudG8sIGNvbmZvcm1lIGluZGljYWRvIG5vIGNhbXBvIERhdGEgZGUgRW1iYXJnby4KRepositório InstitucionalPUBhttps://repositorio.ufpe.br/oai/requestattena@ufpe.bropendoar:22212022-09-16T06:00:39Repositório Institucional da UFPE - Universidade Federal de Pernambuco (UFPE)false |
dc.title.pt_BR.fl_str_mv |
On the usage of functional programming concepts in JavaScript programs |
title |
On the usage of functional programming concepts in JavaScript programs |
spellingShingle |
On the usage of functional programming concepts in JavaScript programs ALVES, Fernando Henrique de Albuquerque Engenharia de software Programação funcional Javascript |
title_short |
On the usage of functional programming concepts in JavaScript programs |
title_full |
On the usage of functional programming concepts in JavaScript programs |
title_fullStr |
On the usage of functional programming concepts in JavaScript programs |
title_full_unstemmed |
On the usage of functional programming concepts in JavaScript programs |
title_sort |
On the usage of functional programming concepts in JavaScript programs |
author |
ALVES, Fernando Henrique de Albuquerque |
author_facet |
ALVES, Fernando Henrique de Albuquerque |
author_role |
author |
dc.contributor.authorLattes.pt_BR.fl_str_mv |
http://lattes.cnpq.br/1250398679855381 |
dc.contributor.advisorLattes.pt_BR.fl_str_mv |
http://lattes.cnpq.br/7310046838140771 |
dc.contributor.advisor-coLattes.pt_BR.fl_str_mv |
http://lattes.cnpq.br/8246690925340020 |
dc.contributor.author.fl_str_mv |
ALVES, Fernando Henrique de Albuquerque |
dc.contributor.advisor1.fl_str_mv |
LIMA FILHO, Fernando José Castor de |
dc.contributor.advisor-co1.fl_str_mv |
DELFIM, Fernanda Madeiral |
contributor_str_mv |
LIMA FILHO, Fernando José Castor de DELFIM, Fernanda Madeiral |
dc.subject.por.fl_str_mv |
Engenharia de software Programação funcional Javascript |
topic |
Engenharia de software Programação funcional Javascript |
description |
Language constructs inspired by functional programming have made their way into most mainstream programming languages. Many researchers and developers consider that these constructs lead to programs that are more concise, reusable, and easier to under- stand. Notwithstanding, few studies investigate the prevalence of these structures and the implications of using them in mainstream programming languages. This paper quanti- fies the prevalence of four concepts typically associated with functional programming in JavaScript: recursion, immutability, lazy evaluation, and functions as values. We divide the latter into two groups, higher-order functions and callbacks & promises. We focus on JavaScript programs due to the availability of some of these concepts in the language since its inception, its inspiration from functional programming languages, and its pop- ularity. We mine 91 GitHub repositories (more than 22 million LOC) written mostly in JavaScript (over 50% of the code), measuring the usage of these concepts from both static and temporal perspectives. We also measure the likelihood of bug-fixing commits remov- ing uses of these concepts (which would hint at bug-proneness) and their association with the presence of code comments (which would hint at code that is hard to understand). We find that these concepts are in widespread use (478,605 occurrences, 1 for every 46.65 lines of code, 43.59% of LOC). In addition, the usage of higher-order functions, immutabil- ity, and lazy evaluation-related structures has been growing throughout the years for the analyzed projects, while the usage of recursion and callbacks & promises has decreased. We also find statistical evidence that removing these structures, with the exception of the ones associated to immutability, is less common in bug-fixing commits than in other commits. In addition, their presence is not correlated with comment size. Our findings suggest that functional programming concepts are important for developers using a multi- paradigm language such as JavaScript, and their usage does not make programs harder to understand. |
publishDate |
2022 |
dc.date.accessioned.fl_str_mv |
2022-09-15T15:57:17Z |
dc.date.available.fl_str_mv |
2022-09-15T15:57:17Z |
dc.date.issued.fl_str_mv |
2022-07-08 |
dc.type.status.fl_str_mv |
info:eu-repo/semantics/publishedVersion |
dc.type.driver.fl_str_mv |
info:eu-repo/semantics/masterThesis |
format |
masterThesis |
status_str |
publishedVersion |
dc.identifier.citation.fl_str_mv |
ALVES, Fernando Henrique de Albuquerque. On the usage of functional programming concepts in JavaScript programs. 2022. Dissertação (Mestrado em Ciência da Computação) - Universidade Federal de Pernambuco, Recife, 2022. |
dc.identifier.uri.fl_str_mv |
https://repositorio.ufpe.br/handle/123456789/46446 |
dc.identifier.dark.fl_str_mv |
ark:/64986/0013000010ng7 |
identifier_str_mv |
ALVES, Fernando Henrique de Albuquerque. On the usage of functional programming concepts in JavaScript programs. 2022. Dissertação (Mestrado em Ciência da Computação) - Universidade Federal de Pernambuco, Recife, 2022. ark:/64986/0013000010ng7 |
url |
https://repositorio.ufpe.br/handle/123456789/46446 |
dc.language.iso.fl_str_mv |
eng |
language |
eng |
dc.rights.driver.fl_str_mv |
http://creativecommons.org/licenses/by-nc-nd/3.0/br/ info:eu-repo/semantics/openAccess |
rights_invalid_str_mv |
http://creativecommons.org/licenses/by-nc-nd/3.0/br/ |
eu_rights_str_mv |
openAccess |
dc.publisher.none.fl_str_mv |
Universidade Federal de Pernambuco |
dc.publisher.program.fl_str_mv |
Programa de Pos Graduacao em Ciencia da Computacao |
dc.publisher.initials.fl_str_mv |
UFPE |
dc.publisher.country.fl_str_mv |
Brasil |
publisher.none.fl_str_mv |
Universidade Federal de Pernambuco |
dc.source.none.fl_str_mv |
reponame:Repositório Institucional da UFPE instname:Universidade Federal de Pernambuco (UFPE) instacron:UFPE |
instname_str |
Universidade Federal de Pernambuco (UFPE) |
instacron_str |
UFPE |
institution |
UFPE |
reponame_str |
Repositório Institucional da UFPE |
collection |
Repositório Institucional da UFPE |
bitstream.url.fl_str_mv |
https://repositorio.ufpe.br/bitstream/123456789/46446/4/DISSERTA%c3%87%c3%83O%20Fernando%20Henrique%20de%20Albuquerque%20Alves.pdf.txt https://repositorio.ufpe.br/bitstream/123456789/46446/5/DISSERTA%c3%87%c3%83O%20Fernando%20Henrique%20de%20Albuquerque%20Alves.pdf.jpg https://repositorio.ufpe.br/bitstream/123456789/46446/2/license_rdf https://repositorio.ufpe.br/bitstream/123456789/46446/3/license.txt https://repositorio.ufpe.br/bitstream/123456789/46446/1/DISSERTA%c3%87%c3%83O%20Fernando%20Henrique%20de%20Albuquerque%20Alves.pdf |
bitstream.checksum.fl_str_mv |
a896f736c58f9880cdb1eeb34ea37cae f6c503cdcffc5cc42fca122dfef478c5 e39d27027a6cc9cb039ad269a5db8e34 6928b9260b07fb2755249a5ca9903395 ae7612cd34a35a70ed83be6c6972c4ad |
bitstream.checksumAlgorithm.fl_str_mv |
MD5 MD5 MD5 MD5 MD5 |
repository.name.fl_str_mv |
Repositório Institucional da UFPE - Universidade Federal de Pernambuco (UFPE) |
repository.mail.fl_str_mv |
attena@ufpe.br |
_version_ |
1815172964602085376 |