null
void
Object
[a] -> (a -> b) -> [b]
[a] -> (a -> Bool) -> Bool
Ord a => [a] -> [a]
class $Class$ {
public static int $method$(String $string$,
int $def$)
}
core.typed
- an optional type system for Clojure
String uuid;
String website;
String email;
String firstName, lastName;
String clientXml;
int birthYear;
long registrationDate;
int min, max;
boolean registered;
int priority;
UUID uuid;
URL website;
Email email;
Name name;
Optional<Document> client;
Year birthYear;
Instant registration;
Range<Integer> range;
Status status;
Priority priority;
Try<InputStream> tryOpen(File f) {
return Try.ofFailable(
() -> new FileInputStream(f));
}
github.com/jasongoodwin/better-java-monads
CompletableFuture<String> callWebService() {
//...
}
null
"[null
] led to innumerable errors, vulnerabilities, and system crashes,
which have probably caused a billion dollars of pain and damage [...]"
- [...]
NullPointerException
is by far the most common exception in Java.- [...] worsens readability by [filling] your code with often deeply nested null checks.
- [...] It doesn’t have any semantic meaning [...]
- [...] Java always hides pointers from developers except in one case: the null pointer.
- [...] It creates a hole in the type system. [...] it can be assigned to any reference type
org.apache.catalina.connector.CoyoteAdapter
Option(al)
?
Optional<String> opt = null; //YOLO
scala> Some(null) == None
res1: Boolean = false
Demo
val s: String = "abc"
val x = s.length()
val s: String? = null
val x = s.length()
val s: String? = "abc"
val x: Int? = s?.length()
if (s != null) {
val x2: Int = s.length()
}
A flyweight [...] minimizes memory use by sharing as much data as possible with other similar objects;
[...] simple repeated representation would use an unacceptable amount of memory.
[...] Flyweight objects must be immutable.
[...] model using Value Objects instead of Entities wherever possible.
[...] Entity’s design should be biased toward serving as a Value container
[...] Value types that measure, quantify, or describe things are easier to create, test, use, optimize, and maintain.
[...] performance almost always matters.
And I absolutely detest the fact that people [...] dismiss performance concerns so readily.
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point
// bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
//y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
return y;
}
wikipedia.org/wiki/Fast_inverse_square_root
null
void
Object