Having used PHP and Java extensively in my career, it’s always entertaining to read what people think about these languages.
Having used PHP and Java extensively in my career, it’s always entertaining to read what people think about these languages.
Based on some places I used to work, upper management seemed convinced that the “idea” stage was the hardest and most important part of any project, and that the easy part is planning, gathering requirements, building, testing, changing, and maintaining custom business applications for needlessly complex and ever changing requirements.
Absolutely.
I’ve seen so many projects hindered by bad decisions around performance. Big things like shoehorning yourself into an architecture, language, or particular tool, but even small things like assuming the naive approach is unacceptably slow. If you never actually measure anything though, your assumptions are just assumptions.
Null is terrible.
A lot of languages have it available as a valid return value for most things, implicitly. This also means you have to do extra checking or something like this will blow up with an exception:
// java example
// can throw exception
String address = person.getAddress().toUpperCase();
// safe
String address = "";
if (person.getAddress() != null) {
person.getAddress().toUpperCase();
}
There are a ton of solutions out there. Many languages have added null-coalescing and null-conditional operators – which are a shorthand for things like the above solutions. Some languages have removed the implicit nulls (like Kotlin), requiring them to be explicitly marked in their type. Some languages have a wrapper around nullable values, an Option type. Some languages remove null entirely from the language (I believe Rust falls into this, using an option type in place of).
Not having null isn’t particularly common yet, and isn’t something languages can just change due to breaking backwards compatibility. However, languages have been adding features over time to make nulls less painful, and most have some subset of the above as options to help.
I do think Option types are fantastic solutions, making you deal with the issue that a none/empty type can exist in a particular place. Java has had them for basically 10 years now (since Java 8).
// optional example
Class Person {
private String address;
//prefer this if a null could ever be returned
public Optional<String> getAddress() {
return Optional.ofNullable(address);
}
// not this
public String getAddress() {
return address;
}
When consuming, it makes you have to handle the null case, which you can do a variety of ways.
// set a default
String address = person.getAddress().orElse("default value");
// explicitly throw an exception instead of an implicit NullPointerException as before
String address = person.getAddress().orElseThrow(SomeException::new);
// use in a closure only if it exists
person.getAddress().ifPresent(addr -> logger.debug("Address {}", addr));
// first example, map to modify, and returning default if no value
String address = person.getAddress().map(String::toUpperCase).orElse("");
Bill is a liability.
This is probably going to be similar to Apple’s find system, which is a low powered Bluetooth based system. Apple Airtags and powered-off phones just broadcast a “I am here” signal once in a while that other devices can receive and report back to Apple.