Earlier quoted context omitted.
Maybe this is cute monady stuff, but there isn't an equivalent to Optional > with only null/None. You usually don't directly write that, but you might incidentally instantiate that type when composing generic code, or a container/function won't allow nulls.
In what context would you not want to treat Optional.of(null) and null as the same? It shouldn't be a big deal.
Traps to Developers
81–90 of 113 posts
Re: Traps to Developers
#82Re: Traps to Developers
#83> If you already use locking, no volatile needed. Kinda misleading. volatile is for memory mapped I/O and such. volatile means the memory access really happens
Re: Traps to Developers
#84> Some routers and firewall silently kill idle TCP connections without telling application. Some code (like HTTP client libraries, database clients) keep a pool of TCP connections for reuse, which can be silently invalidated. To solve it you can configure system TCP keepalive. For HTTP you can use Connection: keep-alive Keep-Alive: timeout=30, max=1000 header. Once a TCP connection has been established there is no st…
Re: Traps to Developers
#85> Golang use UTF-8 for in-memory string. Nope. It’s just bytes with no encoding. https://go.dev/blog/strings
Re: Traps to Developers
#86"Associativity law and distribution law doesn't strictly hold because of inaccuracy." should be due to precision loss not inaccuracy (they are different).
Re: Traps to Developers
#87LF vs CRLF
Re: Traps to Developers
#88> A method that returns Optional may return null. projects that do this drive me bananas If I had the emotional energy, I'd open a JEP for a new @java.lang.NonNullReference and any type annotated with it would be a compiler error to assign null to it public interface Alpha {} @java.lang.NonNullReference public interface Beta {} Alpha a = null; // ok Beta b = null; // compiler error javac will tolerate this Beta b; if…
I question the wisdom of even having Optional in a language with nulls. It would raise some eyebrows if a function in Python returned an Optional type object rather than T | None. You have to do a check either way unless you're doing some cute monad-y stuff.
Java really suffers with optional because the language has such love for backwards compatibility that it's extremely unlikely that nulls would even be removed from the standard library in the first place. The fact that the ecosystem relies on ugly auto wiring hacks instead of mandating explicit constructors doesn't help either.
Re: Traps to Developers
#89yaml: https://www.bram.us/2022/01/11/yaml-the-norway-problem/ bash: errexit depends on caller's context, will utterly fail you one day: https://lists.gnu.org/archive/html/bug-bash/2012-12/msg00093...