The document compares the performance of different programming paradigms and JVM languages for solving the FizzBuzz problem. It finds that imperative code with inline logic has the best performance, while functional programming with streams has the worst performance. Kotlin and Scala generally perform comparably to Java, while Groovy's dynamic nature makes it slower. The key takeaways are that trivial examples don't tell the full story, function call overhead is significant, and reducing code complexity may be more important than raw performance in many cases.
Why we are submitting this talk? Because Go is cool and we would like to hear more about this language ;-). In this talk we would like to tell you about our experience with development of microservices with Go. Go enables devs to create readable, fast and concise code, this - beyond any doubt is important. Apart from this we would like to leverage our test driven habbits to create bulletproof software. We will also explore other aspects important for adoption of a new language.
Most computers today have multiple cores and processes. That means, if you really want to fully explore the capabilities of them, you must explore concurrent programming resources. Go was developed with this in mind, offering goroutines and channels.
Although concurrent programming may seem simple with Go, there are a couple of details to keep in mind, to avoid problems. In this talk, I’m going to show a couple of practical examples with goroutines and channels, and some common pitfalls
This presentation is part of a talk by Martin j. Logan on the essentials of programming in the erlang language. The talk covers:
Data Types
Modules and Functions
State Management
Distribution
Fault Tolerance
The code for this talk can be found at github:
git://github.com/martinjlogan/ErlangBootstrap.git
https://github.com/martinjlogan/ErlangBootstrap
I have create slides which lists examples of oops programming concepts including looping,enums,structures,linq,threading,delegates,generics,inheritenc..so on.
Asterisk: PVS-Studio Takes Up TelephonyAndrey Karpov
Asterisk is a software implementation of a telephone private branch exchange (PBX); it was created in 1999 by Mark Spencer of Digium. Like any PBX, it allows attached telephones to make calls to one another, and to connect to other telephone services, such as the public switched telephone network (PSTN) and Voice over Internet Protocol (VoIP) services. Its name comes from the asterisk symbol, *.
Asterisk is released under a dual license model, using the GNU General Public License (GPL) as a free software license and a proprietary software license to permit licensees to distribute proprietary, unpublished system components.
In this article, we are going to discuss the results of the check of the Asterisk project by PVS-Studio 5.18.
The project seems to be regularly checked by the Coverity analyzer, which is indicated by comments like this one:
/* Ignore check_return warning from Coverity for ast_exists_extension below */
However, I still found some disappointing typos in the code. Let's try to figure them out as well as other potential issues. The source code was downloaded from the project's SVN repository.
C++ How I learned to stop worrying and love metaprogrammingcppfrug
Cette présentation parcours quelques applications directes de la méta-programmation en C++(11/14) avec comme objectif de démontrer son utilité dans un cadre applicatif.
Why we are submitting this talk? Because Go is cool and we would like to hear more about this language ;-). In this talk we would like to tell you about our experience with development of microservices with Go. Go enables devs to create readable, fast and concise code, this - beyond any doubt is important. Apart from this we would like to leverage our test driven habbits to create bulletproof software. We will also explore other aspects important for adoption of a new language.
Most computers today have multiple cores and processes. That means, if you really want to fully explore the capabilities of them, you must explore concurrent programming resources. Go was developed with this in mind, offering goroutines and channels.
Although concurrent programming may seem simple with Go, there are a couple of details to keep in mind, to avoid problems. In this talk, I’m going to show a couple of practical examples with goroutines and channels, and some common pitfalls
This presentation is part of a talk by Martin j. Logan on the essentials of programming in the erlang language. The talk covers:
Data Types
Modules and Functions
State Management
Distribution
Fault Tolerance
The code for this talk can be found at github:
git://github.com/martinjlogan/ErlangBootstrap.git
https://github.com/martinjlogan/ErlangBootstrap
I have create slides which lists examples of oops programming concepts including looping,enums,structures,linq,threading,delegates,generics,inheritenc..so on.
Asterisk: PVS-Studio Takes Up TelephonyAndrey Karpov
Asterisk is a software implementation of a telephone private branch exchange (PBX); it was created in 1999 by Mark Spencer of Digium. Like any PBX, it allows attached telephones to make calls to one another, and to connect to other telephone services, such as the public switched telephone network (PSTN) and Voice over Internet Protocol (VoIP) services. Its name comes from the asterisk symbol, *.
Asterisk is released under a dual license model, using the GNU General Public License (GPL) as a free software license and a proprietary software license to permit licensees to distribute proprietary, unpublished system components.
In this article, we are going to discuss the results of the check of the Asterisk project by PVS-Studio 5.18.
The project seems to be regularly checked by the Coverity analyzer, which is indicated by comments like this one:
/* Ignore check_return warning from Coverity for ast_exists_extension below */
However, I still found some disappointing typos in the code. Let's try to figure them out as well as other potential issues. The source code was downloaded from the project's SVN repository.
C++ How I learned to stop worrying and love metaprogrammingcppfrug
Cette présentation parcours quelques applications directes de la méta-programmation en C++(11/14) avec comme objectif de démontrer son utilité dans un cadre applicatif.
Thrift vs Protocol Buffers vs Avro - Biased ComparisonIgor Anishchenko
Igor Anishchenko
Odessa Java TechTalks
Lohika - May, 2012
Let's take a step back and compare data serialization formats, of which there are plenty. What are the key differences between Apache Thrift, Google Protocol Buffers and Apache Avro. Which is "The Best"? Truth of the matter is, they are all very good and each has its own strong points. Hence, the answer is as much of a personal choice, as well as understanding of the historical context for each, and correctly identifying your own, individual requirements.
Presented on 27th September 2017 to a joint meeting of 'Cork Functional Programmers' and the 'Cork Java Users Group'
Based on the Kotlin Language programming course from Instil. For more details see https://instil.co/courses/kotlin-development/
Are you a C# developer who has embraced the language’s functional concepts such as lambda expressions and LINQ, but have not yet embraced F#?
In this talk I’ll compare and contrast code written in both C# and F# that will highlight the differences between the two languages while also showing how a functional-first language like F# can be a great tool for solving problems.
Помните легендарные Java Puzzlers? Да-да, те самые, с Джошом Блохом и Нилом Гафтером? Ну, по которым ещё книжку написали? Так вот, в Groovy всё ещё веселее.
В смысле — задачки ещё более странные, и ответы ещё более поразительные. Этот доклад для вас, Groovy-разработчики, мы покажем вам настоящие, большие и красивые подводные камни! И для вас, Java-разработчики, потому что таких вещей на Java-подобном синтакисе вы точно никогда не видели! И для вас, PHP-разработчики… хотя, нет, не для вас :)
Всем точно будет весело — ваши ведущие Женя и Барух будут зажигать, шутить, спорить, бросаться футболками в публику, и самое главное — заставят вас офигевать от Groovy.
Do you want to learn Kotlin programming language from scratch? This is the 2nd episode of a simple course, focused on function and functional programming
This talk will explore inference from the perspective of protocols and generics and is based off a series of blog posts I've written(foxinswift.com) on the topic. In the first part of my talk casting number types through inference. I'll then show you struct serialization example demonstrating inferring a type through a mapping function. My last example will take you through inferring an associatedtype on a barebones promise implementation and we'll use it to in the context of making a network request. To finish things off I'll briefly speak on what's new in swift generics and some limitations of those features.
Gradle is the build system you have been waiting for or maybe the build system that has been waiting for you. The adoption rate is incredible from being the new Google Android development tools build system to most new Java opensource projects to JavaScript based front-end and back-end projects.
Large Language Models and the End of ProgrammingMatt Welsh
Talk by Matt Welsh at Craft Conference 2024 on the impact that Large Language Models will have on the future of software development. In this talk, I discuss the ways in which LLMs will impact the software industry, from replacing human software developers with AI, to replacing conventional software with models that perform reasoning, computation, and problem-solving.
Listen to the keynote address and hear about the latest developments from Rachana Ananthakrishnan and Ian Foster who review the updates to the Globus Platform and Service, and the relevance of Globus to the scientific community as an automation platform to accelerate scientific discovery.
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I didn't get rich from it but it did have 63K downloads (powered possible tens of thousands of websites).
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
Cyaniclab : Software Development Agency Portfolio.pdfCyanic lab
CyanicLab, an offshore custom software development company based in Sweden,India, Finland, is your go-to partner for startup development and innovative web design solutions. Our expert team specializes in crafting cutting-edge software tailored to meet the unique needs of startups and established enterprises alike. From conceptualization to execution, we offer comprehensive services including web and mobile app development, UI/UX design, and ongoing software maintenance. Ready to elevate your business? Contact CyanicLab today and let us propel your vision to success with our top-notch IT solutions.
Unleash Unlimited Potential with One-Time Purchase
BoxLang is more than just a language; it's a community. By choosing a Visionary License, you're not just investing in your success, you're actively contributing to the ongoing development and support of BoxLang.
Navigating the Metaverse: A Journey into Virtual Evolution"Donna Lenk
Join us for an exploration of the Metaverse's evolution, where innovation meets imagination. Discover new dimensions of virtual events, engage with thought-provoking discussions, and witness the transformative power of digital realms."
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
The U.S. Geological Survey (USGS) has made substantial investments in meeting evolving scientific, technical, and policy driven demands on storing, managing, and delivering data. As these demands continue to grow in complexity and scale, the USGS must continue to explore innovative solutions to improve its management, curation, sharing, delivering, and preservation approaches for large-scale research data. Supporting these needs, the USGS has partnered with the University of Chicago-Globus to research and develop advanced repository components and workflows leveraging its current investment in Globus. The primary outcome of this partnership includes the development of a prototype enterprise repository, driven by USGS Data Release requirements, through exploration and implementation of the entire suite of the Globus platform offerings, including Globus Flow, Globus Auth, Globus Transfer, and Globus Search. This presentation will provide insights into this research partnership, introduce the unique requirements and challenges being addressed and provide relevant project progress.
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
top nidhi software solution freedownloadvrstrong314
This presentation emphasizes the importance of data security and legal compliance for Nidhi companies in India. It highlights how online Nidhi software solutions, like Vector Nidhi Software, offer advanced features tailored to these needs. Key aspects include encryption, access controls, and audit trails to ensure data security. The software complies with regulatory guidelines from the MCA and RBI and adheres to Nidhi Rules, 2014. With customizable, user-friendly interfaces and real-time features, these Nidhi software solutions enhance efficiency, support growth, and provide exceptional member services. The presentation concludes with contact information for further inquiries.
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Mind IT Systems
Healthcare providers often struggle with the complexities of chronic conditions and remote patient monitoring, as each patient requires personalized care and ongoing monitoring. Off-the-shelf solutions may not meet these diverse needs, leading to inefficiencies and gaps in care. It’s here, custom healthcare software offers a tailored solution, ensuring improved care and effectiveness.
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Software Engineering, Software Consulting, Tech Lead.
Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Security,
Spring Transaction, Spring MVC,
Log4j, REST/SOAP WEB-SERVICES.
In software engineering, the right architecture is essential for robust, scalable platforms. Wix has undergone a pivotal shift from event sourcing to a CRUD-based model for its microservices. This talk will chart the course of this pivotal journey.
Event sourcing, which records state changes as immutable events, provided robust auditing and "time travel" debugging for Wix Stores' microservices. Despite its benefits, the complexity it introduced in state management slowed development. Wix responded by adopting a simpler, unified CRUD model. This talk will explore the challenges of event sourcing and the advantages of Wix's new "CRUD on steroids" approach, which streamlines API integration and domain event management while preserving data integrity and system resilience.
Participants will gain valuable insights into Wix's strategies for ensuring atomicity in database updates and event production, as well as caching, materialization, and performance optimization techniques within a distributed system.
Join us to discover how Wix has mastered the art of balancing simplicity and extensibility, and learn how the re-adoption of the modest CRUD has turbocharged their development velocity, resilience, and scalability in a high-growth environment.
Into the Box Keynote Day 2: Unveiling amazing updates and announcements for modern CFML developers! Get ready for exciting releases and updates on Ortus tools and products. Stay tuned for cutting-edge innovations designed to boost your productivity.
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
Developing Distributed High-performance Computing Capabilities of an Open Sci...Globus
COVID-19 had an unprecedented impact on scientific collaboration. The pandemic and its broad response from the scientific community has forged new relationships among public health practitioners, mathematical modelers, and scientific computing specialists, while revealing critical gaps in exploiting advanced computing systems to support urgent decision making. Informed by our team’s work in applying high-performance computing in support of public health decision makers during the COVID-19 pandemic, we present how Globus technologies are enabling the development of an open science platform for robust epidemic analysis, with the goal of collaborative, secure, distributed, on-demand, and fast time-to-solution analyses to support public health.
Experience our free, in-depth three-part Tendenci Platform Corporate Membership Management workshop series! In Session 1 on May 14th, 2024, we began with an Introduction and Setup, mastering the configuration of your Corporate Membership Module settings to establish membership types, applications, and more. Then, on May 16th, 2024, in Session 2, we focused on binding individual members to a Corporate Membership and Corporate Reps, teaching you how to add individual members and assign Corporate Representatives to manage dues, renewals, and associated members. Finally, on May 28th, 2024, in Session 3, we covered questions and concerns, addressing any queries or issues you may have.
For more Tendenci AMS events, check out www.tendenci.com/events
5. FizzBuzz
● Write a program that prints the numbers from 1 to 100.
● But for multiples of three print “Fizz” instead of the number and for the
multiples of five print “Buzz”.
● For numbers which are multiples of both three and five print “FizzBuzz”
● Pseudo Code
for i in 1 to 100
if i multiple of 15 print ‘FizzBuzz’
else if i multiple of 3 print ‘Fizz’
else if i multiple of 5 print ‘Buzz’
else print i
print newline
6. Imperative Code – Java
public static void imperative(PrintWriter writer) {
for(int i = 1; i <= 100; i++) {
if (i % 15 == 0) {
writer.println("FizzBuzz");
} else if (i % 3 == 0) {
writer.println("Fizz");
} else if (i % 5 == 0) {
writer.println("Buzz");
} else {
writer.println(i);
}
}
}
7. Imperative Code - Groovy
static imperative(PrintWriter writer) {
for(int i = 1; i <= 100; i++) {
if (i % 15 == 0) {
writer.println("FizzBuzz");
} else if (i % 3 == 0) {
writer.println("Fizz");
} else if (i % 5 == 0) {
writer.println("Buzz");
} else {
writer.println(i);
}
}
}
8. Imperative Code – Kotlin
@JvmStatic fun imperative(printWriter: PrintWriter) {
for (i in 1..100) {
when {
i % 15 == 0 -> printWriter.println("FizzBuzz")
i % 3 == 0 -> printWriter.println("Fizz")
i % 5 == 0 -> printWriter.println("Buzz")
else -> printWriter.println(i)
}
}
}
9. Imperative Code – Scala
def imperative(writer: PrintWriter): Unit = {
for (i <- 1 to 100) {
i match {
case x if x % 15 == 0 => writer.println("FizzBuzz")
case x if x % 5 == 0 => writer.println("Buzz")
case x if x % 3 == 0 => writer.println("Fizz")
case x => writer.println(x)
}
}
}
10. Imperative Performance
Language Ops / second % of best
Java 3470211.76 100.00%
Groovy 3457836.97 99.64%
Kotlin 3405441.23 98.13%
Scala 2444048.87 70.43%
Java Groovy Kotlin Scala
0
500000
1000000
1500000
2000000
2500000
3000000
3500000
4000000
Ops / second
11. Functional Code – Java
MapReduce
static class Replacement {
final Predicate<Integer> when;
final String output;
Replacement(Predicate<Integer> when, String output) {
this.output = output;
this.when = when;
}
}
static List<Replacement> fizzAndOrBuzz =
Collections.unmodifiableList(Arrays.asList(
new Replacement(i -> i % 3 == 0, "Fizz"),
new Replacement(i -> i % 5 == 0, "Buzz")
));
static String replace(final Integer i, final List<Replacement> rules) {
return rules.stream()
.filter(r -> r.when.test(i))
.map(r -> r.output)
.reduce(String::concat)
.orElse(Integer.toString(i));
}
static String fizzBuzz(final Integer i) {
return replace(i, fizzAndOrBuzz);
}
public static void functionalMapReduce(final PrintWriter writer) {
IntStream.range(1, 101)
.mapToObj(FizzBuzzFunctionalMapReduce::fizzBuzz)
.forEach((i) -> writer.println(i));
}
12. Functional Code – Java
static class Replacement {
final String output;
final Predicate<Integer> when;
Replacement(Predicate<Integer> when, String output) {
this.output = output;
this.when = when;
}
}
static final List<Replacement> fizzAndOrBuzz =
Collections.unmodifiableList(Arrays.asList(
new Replacement(i -> i % 15 == 0, "FizzBuzz"),
new Replacement(i -> i % 3 == 0, "Fizz"),
new Replacement(i -> i % 5 == 0, "Buzz")
));
static String replace(final Integer i, final List<Replacement> rules) {
final Optional<Replacement> replacement = rules.stream()
.filter(r -> r.when.test(i)).findFirst();
return replacement.isPresent() ? replacement.get().output : i.toString();
}
public static void functional(final PrintWriter writer) {
for (int i = 1; i <= 100; i++) {
writer.println(replace(i, fizzAndOrBuzz));
}
}
13. Functional Code – Groovy
static class Replacement {
Closure when
String output
Replacement(Closure when, String output) {
this.when = when
this.output = output
}
}
static replacements = [
new Replacement({it % 15 == 0}, "FizzBuzz"),
new Replacement({it % 5 == 0}, "Buzz"),
new Replacement({it % 3 == 0}, "Fizz")
]
static String replace(Integer i, List<Replacement> replacements) {
def replacement = replacements.find{ it.when(i) }
return replacement ? replacement.output : i.toString()
}
static functional(PrintWriter writer) {
for(int i = 1; i <= 100; i++) {
writer.println(replace(i, replacements))
}
}
14. Functional Code – Kotlin
class Replacement(r: (Int) -> Boolean, o: String) {
val rule: (Int) -> Boolean = r
val output: String = o
}
val fizzBuzzRules = listOf(
Replacement({ i -> i % 15 == 0 }, "FizzBuzz"),
Replacement({ i -> i % 3 == 0 }, "Fizz"),
Replacement({ i -> i % 5 == 0 }, "Buzz")
)
fun replace(i: Int, replacements: List<Replacement>): String {
val result: Replacement? = replacements.firstOrNull { r -> r.rule(i) }
return result?.output ?: i.toString()
}
@JvmStatic fun functional(printWriter: PrintWriter) {
for (i in 1..100) {
printWriter.println(replace(i, fizzBuzzRules))
}
}
15. Functional Code – Scala
case class Replacement(when: Int => Boolean, val output: String) {
}
val modulusCheck = (i: Int, div: Int) => i % div == 0
val fizzAndOrBuzz = List(
Replacement(i => i % 15 == 0, "FizzBuzz"),
Replacement(i => i % 3 == 0, "Fizz"),
Replacement(i => i % 5 == 0, "Buzz")
)
private def replace(i: Int, rules: List[Replacement]): String = {
rules.find(r => r.when(i)) match {
case Some(r) => r.output
case None => i.toString
}
}
def functional(writer: PrintWriter): Unit = {
for (i <- 1 to 100) {
writer.println(replace(i, fizzAndOrBuzz))
}
}
17. Functional Code – Scala Streams
val nones = Stream.continually(None)
val fizzes: Stream[Option[String]] = nones.take(2) ++ Some("Fizz") #:: fizzes
val buzzes: Stream[Option[String]] = nones.take(4) ++ Some("Buzz") #:: buzzes
def functional(writer: PrintWriter): Unit = {
for (((fizz, buzz), n) <- fizzes zip buzzes zip (1 to 100)) {
writer.println(fizz.map(_ + buzz.getOrElse("")).orElse(buzz).getOrElse(n))
}
}
18. Functional Performance
Language Ops / second % of Best
ScalaZ 277517.57 100.00%
Scala 276278.53 99.55%
Kotlin 266858.60 96.16%
Java 124968.78 45.03%
Java MapReduce 85608.05 30.85%
ScalaStreams 47997.63 17.30%
Groovy 13135.39 4.73%
ScalaZ
Scala
Kotlin
Java
Java MapReduce
ScalaStreams
Groovy
0
50000
100000
150000
200000
250000
300000
Ops / second
19. Imperative – Java Call
private static String replace(int i) {
if (i % 15 == 0) {
return "FizzBuzz";
} else if (i % 3 == 0) {
return "Fizz";
} else if (i % 5 == 0) {
return "Buzz";
} else {
return Integer.toString(i);
}
}
public static void imperative(PrintWriter writer) {
for(int i = 1; i <= 100; i++) {
writer.println(replace(i));
}
}
20. Imperative – Groovy Call
static String replace(int i) {
if (i % 15 == 0) {
return "FizzBuzz"
} else if (i % 3 == 0) {
return "Fizz"
} else if (i % 5 == 0) {
return "Buzz"
} else {
return Integer.toString(i)
}
}
static imperative(PrintWriter writer) {
for(int i = 1; i <= 100; i++) {
writer.println(replace(i))
}
}
21. Imperative – Kotlin Call
fun replace(i: Int): String {
when {
i % 15 == 0 -> return "FizzBuzz"
i % 3 == 0 -> return "Fizz"
i % 5 == 0 -> return "Buzz"
else -> return i.toString()
}
}
@JvmStatic fun imperative(printWriter: PrintWriter) {
for (i in 1..100) {
printWriter.println(replace(i))
}
}
22. Imperative – Scala Call
def replace(i: Int): String = {
return i match {
case x if x % 15 == 0 => "FizzBuzz"
case x if x % 5 == 0 => "Buzz"
case x if x % 3 == 0 => "Fizz"
case x => x.toString
}
}
def imperativeCall(writer: PrintWriter): Unit = {
for (i <- 1 to 100) {
writer.println(replace(i))
}
}
23. Comparing function optimization
Language Ops / second % of best
Java 667866.64 100.00%
Groovy 641418.92 96.04%
Kotlin 623649.03 93.38%
Scala 498185.74 74.59%
Java Groovy Kotlin Scala
0
100000
200000
300000
400000
500000
600000
700000
800000
Ops / second
25. Summary
● A trivial example doesn’t always tell the whole story.
● Function call overhead cannot be discounted.
● Reducing Code Complexity is sometimes more important than
reducing Runtime Cost.
● Java Closures does not seem to perform as well as Kotlin or
Scala equivalents.
● Kotlin is a an awesome way to reduce complexity and
programmer errors.
● Groovy is a dynamic language.
● Scala was sent by ‘Aliens’.