You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the source of the http://docs.javaslang.io/[Javaslang documentation].
3
+
This is the source of the http://docs.vavr.io/[Vavr documentation].
4
4
5
5
=== Performing Updates
6
6
@@ -10,5 +10,5 @@ This is the source of the http://docs.javaslang.io/[Javaslang documentation].
10
10
githubPassword=<GitHub password>
11
11
12
12
* Update the version in `gradle.properties`. Please note that the version in the Maven section of `getting_started.adoc` currently has to be updated manually.
13
-
* Write documentation and test results with `./gradlew asciidoc`. If the Javaslang API has changed, some code example tests might fail.
13
+
* Write documentation and test results with `./gradlew asciidoc`. If the Vavr API has changed, some code example tests might fail.
14
14
* Then `git commit`, `git push` and `./gradlew publishGhPages`
Copy file name to clipboardExpand all lines: src/docs/asciidoc/introduction.adoc
+20-20Lines changed: 20 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,20 @@
1
1
== Introduction
2
2
3
-
Javaslang is a functional library for Java 8+ that provides persistent data types and functional control structures.
3
+
Vavr is a functional library for Java 8+ that provides persistent data types and functional control structures.
4
4
5
-
=== Functional Data Structures in Java 8 with Javaslang
5
+
=== Functional Data Structures in Java 8 with Vavr
6
6
7
7
Java 8’s https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html[lambdas (λ)] empower us to create wonderful API’s. They incredibly increase the expressiveness of the language.
8
8
9
-
http://javaslang.io/[Javaslang] leveraged lambdas to create various new features based on functional patterns. One of them is a functional collection library that is intended to be a replacement for Java’s standard collections.
9
+
http://vavr.io/[Vavr] leveraged lambdas to create various new features based on functional patterns. One of them is a functional collection library that is intended to be a replacement for Java’s standard collections.
__(This is just a bird’s view, you will find a human-readable version below.)__
14
14
15
15
=== Functional Programming
16
16
17
-
Before we deep-dive into the details about the data structures I want to talk about some basics. This will make it clear why I created Javaslang and specifically new Java collections.
17
+
Before we deep-dive into the details about the data structures I want to talk about some basics. This will make it clear why I created Vavr and specifically new Java collections.
18
18
19
19
==== Side-Effects
20
20
@@ -70,11 +70,11 @@ Rich Hickey, the creator of Clojure, gave a great talk about https://www.youtube
70
70
* behave type-safe when used in unchecked covariant casts (Java-specific)
71
71
The key to a better Java is to use __immutable values__ paired with __referentially transparent functions__.
72
72
73
-
Javaslang provides the necessary http://static.javadoc.io/io.javaslang/javaslang/2.0.0/javaslang/control/package-summary.html[controls] and http://static.javadoc.io/io.javaslang/javaslang/2.0.0/javaslang/collection/package-summary.html[collections] to accomplish this goal in every-day Java programming.
73
+
Vavr provides the necessary http://static.javadoc.io/io.vavr/vavr/0.9.0/io/vavr/control/package-summary.html[controls] and https://static.javadoc.io/io.vavr/vavr/0.9.0/io/vavr/collection/package-summary.html[collections] to accomplish this goal in every-day Java programming.
74
74
75
75
=== Data Structures in a Nutshell
76
76
77
-
Javaslang’s collection library comprises of a rich set of functional data structures built on top of lambdas. The only interface they share with Java’s original collections is Iterable. The main reason is that the mutator methods of Java’s collection interfaces do not return an object of the underlying collection type.
77
+
Vavr’s collection library comprises of a rich set of functional data structures built on top of lambdas. The only interface they share with Java’s original collections is Iterable. The main reason is that the mutator methods of Java’s collection interfaces do not return an object of the underlying collection type.
78
78
79
79
We will see why this is so essential by taking a look at the different types of data structures.
80
80
@@ -120,13 +120,13 @@ This model does not impose any implementation details. Here come functional data
120
120
121
121
Also known as https://en.wikipedia.org/wiki/Purely_functional[__purely__ functional data structures], these are __immutable__ and __persistent__. The methods of functional data structures are __referentially transparent__.
122
122
123
-
Javaslang features a wide range of the most-commonly used functional data structures. The following examples are explained in-depth.
123
+
Vavr features a wide range of the most-commonly used functional data structures. The following examples are explained in-depth.
124
124
125
125
==== Linked List
126
126
127
127
One of the most popular and also simplest functional data structures is the https://en.wikipedia.org/wiki/Linked_list[(singly) linked List]. It has a __head__ element and a __tail__ List. A linked List behaves like a Stack which follows the https://en.wikipedia.org/wiki/Stack_(abstract_data_type)[last in, first out (LIFO)] method.
128
128
129
-
In http://javaslang.io/[Javaslang] we instantiate a List like this:
129
+
In http://vavr.io/[Vavr] we instantiate a List like this:
130
130
131
131
[source,java]
132
132
----
@@ -150,9 +150,9 @@ The new head element 0 is __linked__ to the tail of the original List. The origi
150
150
151
151
image::images/list2.png?w=660[List 2]
152
152
153
-
These operations take place in constant time, in other words they are independent of the List size. Most of the other operations take linear time. In Javaslang this is expressed by the interface LinearSeq, which we may already know from Scala.
153
+
These operations take place in constant time, in other words they are independent of the List size. Most of the other operations take linear time. In Vavr this is expressed by the interface LinearSeq, which we may already know from Scala.
154
154
155
-
If we need data structures that are queryable in constant time, Javaslang offers Array and Vector. Both have https://en.wikipedia.org/wiki/Random_access[random access] capabilities.
155
+
If we need data structures that are queryable in constant time, Vavr offers Array and Vector. Both have https://en.wikipedia.org/wiki/Random_access[random access] capabilities.
156
156
157
157
The Array type is backed by a Java array of objects. Insert and remove operations take linear time. Vector is in-between Array and List. It performs well in both areas, random access and modification.
158
158
@@ -256,7 +256,7 @@ image::images/binarytree2.png?w=660[Binary Tree 2]
256
256
257
257
In order to maintain the performance characteristics of a binary search tree it needs to be kept balanced. All paths from the root to a leaf need to have roughly the same length.
258
258
259
-
In Javaslang we implemented a binary search tree based on a https://en.wikipedia.org/wiki/Red%E2%80%93black_tree[Red/Black Tree]. It uses a specific coloring strategy to keep the tree balanced on inserts and deletes. To read more about this topic please refer to the book http://www.amazon.com/Purely-Functional-Structures-Chris-Okasaki/dp/0521663504[Purely Functional Data Structures] by Chris Okasaki.
259
+
In Vavr we implemented a binary search tree based on a https://en.wikipedia.org/wiki/Red%E2%80%93black_tree[Red/Black Tree]. It uses a specific coloring strategy to keep the tree balanced on inserts and deletes. To read more about this topic please refer to the book http://www.amazon.com/Purely-Functional-Structures-Chris-Okasaki/dp/0521663504[Purely Functional Data Structures] by Chris Okasaki.
260
260
261
261
=== State of the Collections
262
262
@@ -285,15 +285,15 @@ Arrays.asList(1, 2, 3)
285
285
.collect(Collectors.toList())
286
286
----
287
287
288
-
Javaslang is greatly inspired by Scala. This is how the above example should have been in Java 8.
288
+
Vavr is greatly inspired by Scala. This is how the above example should have been in Java 8.
289
289
290
290
[source,java]
291
291
----
292
-
// = Stream("1", "2", "3") in Javaslang
292
+
// = Stream("1", "2", "3") in Vavr
293
293
Stream.of(1, 2, 3).map(Object::toString)
294
294
----
295
295
296
-
Within the last year we put much effort into implementing the Javaslang collection library. It comprises the most widely used collection types.
296
+
Within the last year we put much effort into implementing the Vavr collection library. It comprises the most widely used collection types.
The Javaslang collections provide us with many functions to operate on the underlying elements. This allows us to express things in a very concise way.
338
+
The Vavr collections provide us with many functions to operate on the underlying elements. This allows us to express things in a very concise way.
Most goals can be accomplished in various ways using Javaslang. Here we reduced the whole method body to fluent function calls on a List instance. We could even remove the whole method and directly use our List to obtain the computation result.
349
+
Most goals can be accomplished in various ways using Vavr. Here we reduced the whole method body to fluent function calls on a List instance. We could even remove the whole method and directly use our List to obtain the computation result.
350
350
351
351
[source,java]
352
352
----
@@ -365,7 +365,7 @@ We described how to model sorted Sets with binary tree structures. A sorted Map
365
365
366
366
The HashMap implementation is backed by a http://lampwww.epfl.ch/papers/idealhashtrees.pdf[Hash Array Mapped Trie (HAMT)]. Accordingly the HashSet is backed by a HAMT containing key-key pairs.
367
367
368
-
Our Map does __not__ have a special Entry type to represent key-value pairs. Instead we use Tuple2 which is already part of Javaslang. The fields of a Tuple are enumerated.
368
+
Our Map does __not__ have a special Entry type to represent key-value pairs. Instead we use Tuple2 which is already part of Vavr. The fields of a Tuple are enumerated.
369
369
370
370
[source,java]
371
371
----
@@ -376,7 +376,7 @@ Integer key = entry._1;
376
376
String value = entry._2;
377
377
----
378
378
379
-
Maps and Tuples are used throughout Javaslang. Tuples are inevitable to handle multi-valued return types in a general way.
379
+
Maps and Tuples are used throughout Vavr. Tuples are inevitable to handle multi-valued return types in a general way.
At Javaslang, we explore and test our library by implementing the https://projecteuler.net/archives[99 Euler Problems]. It is a great proof of concept. Please don’t hesitate to send pull requests.
390
+
At Vavr, we explore and test our library by implementing the https://projecteuler.net/archives[99 Euler Problems]. It is a great proof of concept. Please don’t hesitate to send pull requests.
0 commit comments