Introduction to JVM languages Java, Scala, Clojure, Kotlin, and Groovy
Explore the Java Virtual Machine with modern programming languages About This Book This guide provides in-depth coverage of the Java Virtual Machine and its features Filled with practical examples, this book will help you understand the core concepts of Java, Scala, Clojure, Kotlin, and Groovy Work...
Otros Autores: | |
---|---|
Formato: | Libro electrónico |
Idioma: | Inglés |
Publicado: |
Birmingham, [England] :
Packt Publishing
2017.
|
Edición: | 1st edition |
Materias: | |
Ver en Biblioteca Universitat Ramon Llull: | https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009630103406719 |
Tabla de Contenidos:
- Intro
- Cover
- Copyright
- Credits
- About the Author
- About the Reviewer
- www.PacktPub.com
- Customer Feedback
- Table of Contents
- Preface
- Chapter 1: Java Virtual Machine
- JVM implementations
- Why develop on JVM?
- JVM adapts to market changes
- Java Class Library
- Ecosystem
- Scenario 1 - Using a JVM application server
- Scenario 2 - Using a general high-level web application framework
- Scenario 3 - Using a microservice framework
- Popular use cases
- Web applications
- Big data
- IoT
- JVM concepts
- Virtual machine
- The JIT compiler
- Primitive datatypes
- Classes
- Reference types
- References and null references
- Garbage collector
- Example
- Backward compatibility
- Build tools
- Java editions
- Java SE
- Java EE
- Example - Java Persistence API as implemented by two application servers
- Java ME
- Other languages on JVM
- Why choose a language other than Java?
- Java is a very verbose language
- Java is not ideal for everything or everyone
- Missing classes in Java Class Library
- Mixing JVM languages in a project
- Increasing build process complexity
- Language runtime libraries
- Writing unit tests in a different language
- Summary
- Chapter 2: Developing on the Java Virtual Machine
- JDK
- Installing JDK
- Downloading JDK
- Installing JDK on Windows
- Installing JDK on macOS
- Installing JDK on Linux
- Downloading API documentation
- Exploring JDK
- The directory structure
- JDK commands
- GUI monitoring tools
- Java VisualVM
- Oracle Mission Control
- JConsole
- JRE
- Class organization with packages
- What are packages?
- Choosing a package name
- Package name examples
- Fully qualified class name
- Java Class Library
- Java Class Library organization
- Package overview
- Fundamental classes of the java.lang package.
- The Object class (java.lang.Object)
- Important object methods
- The String class (java.lang.String)
- Primitive wrapper classes (Integer, Long, Short, Char, Float, Double in java.lang)
- Autoboxing examples
- Exceptions and errors (java.lang.Exception and java.lang.Error)
- The Collections API - java.util.ArrayList and java.util.HashMap
- ArrayList (java.util.ArrayList)
- Commonly used methods of the ArrayList class
- ArrayList usage example
- HashMap (java.util.HashMap)
- Commonly used methods of the HashMap class
- HashMap usage example
- Preparing your classes for the Collections API
- About hashCode()
- About equals ()
- The hashing mechanism
- Running JVM applications on the command line
- At least one class must have a static main() method
- Required directory structure for class files
- Setting ClassPath for a JVM instance
- Placing class files inside a JAR archive
- Runnable JAR file
- Running a program with the java command
- Run a project consisting of separate class files
- Running a project that is placed inside a runnable JAR file
- Other useful parameters of the java command
- -D to pass properties and values
- -ea to enable assertions
- A hands-on example project to run on JVM
- A ClassPath example
- Eclipse IDE
- Downloading Eclipse IDE
- Installing Eclipse IDE
- Summary
- Chapter 3: Java
- OOP in Java
- Defining classes
- Class access modifiers
- Final class modifier - locking a class
- Defining packages
- Importing classes
- Adding class members - variables and methods
- Instance variables
- Methods
- Modifiers
- Protecting class members with access modifiers
- Access modifier example
- Static modifier - instance variables and class variables
- Final modifier - locking a class member
- Overloading methods
- Constructors and finalizers
- Constructors
- Finalizers.
- Extending a class
- Overriding methods
- Calling constructors of a parent class
- Abstract classes
- Interfaces
- Upcasting and downcasting
- Writing Java code
- Operators
- Conditional checks
- The if...else statement
- The switch...case statement
- POJO
- Arrays
- Generics and Collections
- Loops
- The for loop
- The normal for loop
- The enhanced for loop
- The while loop
- The do...while loop
- Exceptions
- Runtime exceptions
- Threads
- Lambdas
- Style guide
- Quiz
- Summary
- Chapter 4: Java Programming
- Configuring Eclipse IDE
- Creating a web service in Java
- Creating a new Gradle project in Eclipse IDE
- Exploring the generated project
- Modifying the Gradle build file
- Building the project
- Coding the backend class
- Backend class business rules
- Creating a dummy implementation of the method
- Creating the test case class and writing its first unit test
- Implementing an input validation check
- Writing the second unit test
- Implementing the business logic
- Creating an executable application task
- Creating a web service
- Running the web service
- Creating Javadoc documentation
- Summary
- Chapter 5: Scala
- Installing Scala
- Scala's Read-Eval-Print-Loop shell
- Functional versus imperative programming
- Scala language syntax and rules
- Statically typed language
- Mutable and immutable variables
- Common Scala types
- Any class
- AnyRef class - reference classes
- AnyVal class - value classes
- Strings
- OOP in Scala
- Defining packages and subpackages
- Importing members
- Defining classes
- Instance variables and methods
- Instance variables
- Instance methods
- Access modifiers for class instance members
- Constructors
- Extending a class
- Overriding methods
- Overloading methods
- Abstract classes
- Traits
- Singleton objects
- Operator overloading.
- Case classes
- Scala's standard library
- Generics
- Collections
- Immutable list
- Mutable list
- Immutable map
- Mutable map
- XML processing
- Functional programming in Scala
- Iterating through collections using functions
- The map, filter, and reduce design pattern
- Map - transform data
- Filter - filter items from a collection or array
- Reduce - for performing calculations
- Currying
- Quiz
- Summary
- Chapter 6: Scala Programming
- Scala IDE for the Eclipse plugin
- Installing Scala IDE for Eclipse
- Switching to the Scala IDE perspective
- SBT
- Installing SBT
- Creating an SBT-based Eclipse IDE project
- Creating a new SBT project
- Loading the SBTEclipse plugin
- Generating a new Eclipse IDE project with SBTEclipse
- Importing the generated project in Eclipse IDE
- The Scala compiler (scalac)
- Creating a singleton object with the main() method
- Creating a singleton object that extends the App trait
- Creating an Akka project
- Adding an Akka dependency to the SBT build file
- Updating the Scala IDE project
- Akka concepts
- Actors
- Actor references (ActorRef)
- Messages
- Dispatchers
- Creating our first Akka actor - QuotesHandlerActor
- Creating messages
- Writing a ScalaTest-based unit test
- Implementing a message handler
- Creating QuotePrinterActor
- The main application
- Summary
- Chapter 7: Clojure
- Installing Clojure
- Creating a start script
- Creating a start script on Windows
- Creating a start script on macOS and Linux
- Clojure's interactive shell (REPL)
- Clojure language
- Syntax
- Expressions
- Defining variables
- Defining functions
- Data structures
- Numeric types
- Strings and characters
- Collections
- Lists
- Vectors
- Sets
- Hash-maps
- Iteration over arrays and loops
- Conditions
- Working with Java classes.
- Creating simple Java classes with deftype and defrecord
- Managing states with agents
- Agent example
- Style guide
- Quiz
- Summary
- Chapter 8: Clojure Programming
- The Counterclockwise plugin for Eclipse IDE
- Installing the Counterclockwise plugin
- Switching to the Java perspective
- Leiningen's build tool
- Installing Leiningen
- Creating executable programs in Clojure
- Compiling to class files without Leiningen
- Compiling projects with Leiningen
- Creating a new Counterclockwise project
- Clojure REPL in Eclipse IDE
- Updating the project's Clojure version
- Adding a dependency
- Exploring monads by applying test-driven development
- The Luminus web framework
- Creating a Luminus project
- Importing the project in Counterclockwise
- Exploring the Luminus project
- Adding a page to the web application
- Summary
- Chapter 9: Kotlin
- Installing Kotlin
- Launch scripts
- Kotlin's REPL interactive shell
- Kotlin language fundamentals
- Defining local variables
- Defining a function
- Kotlin's types
- Kotlin basic types
- Strings
- Null safety handling
- Option 1 - Adding a conditional check
- Option 2 - Using the safe call operator ?.
- Option 3 - Using the Elvis operator ?:
- Option 4 - Using the !! operator
- Conversions
- Collections and generics
- Loops
- OOP in Kotlin
- Defining packages
- Importing members
- Defining classes and constructors
- Adding members to classes
- Adding functions
- The main entry function
- Adding properties
- Inheritance
- Interfaces
- Visibility modifiers
- Singleton and companion objects
- Data classes
- Lambdas and inline functions
- Procedural programming in Kotlin
- Style guide
- Quiz
- Summary
- Chapter 10: Kotlin Programming
- Kotlin for the Eclipse IDE plugin
- Installing the Kotlin plugin for the Eclipse IDE.
- Switching to Kotlin perspective.