Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
masklinn
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
41 ms
·
871.
▲
by
masklinn
1y ago
3dB is “twice as loud” in that it’s twice (or half) as much power . Part of the reason why the bel is used is that human perception is closer to logarithmic than linear (weber-fechner law), so a logarithmic scale is a better approximation
872.
▲
by
masklinn
1y ago
Unless you know the concrete reader types and they expose their underlying reader or concrete type, short of unsafe yes. And as the essay points out, neither bytes.Reader nor bufio.Reader expose the underlying type.
873.
▲
by
masklinn
1y ago
1. Like read(2), io.Reader.Read takes a slice parameter to which it writes, it doesn't return one. This is better for a "legitimate" read stream as the caller can amortise allocations. 2. And Read takes the slice by value,
874.
▲
by
masklinn
1y ago
byte[] is a bytes buffer, a sequence of bytes. io.Reader is an abstraction around a read stream. You can adapt a byte[] to a Reader by wrapping it in a bytes.Reader, that way if a function needs a reader and you have bytes, you can give the
875.
▲
by
masklinn
1y ago
They mean const in the sense of readonly guarantees. In java types are generally shared and mutable so let's say you want a list input, you generally don't store it as is because the caller could modify it at any point, so if you
876.
▲
by
masklinn
1y ago
> Why didn't they go with `defer` which is the more ergonomic and established pattern? Neither statement is true. > `defer` also doesn't need to change the API of thousands of objects to use it Callbacks can trivially be bri
877.
▲
by
masklinn
1y ago
[Symbol.dispose] is a way of creating an entry whose key is the value of the expression Symbol.dispose in the same way obj[Symbol.dispose] is a way of accessing it. The parens are just the method definition shorthand, so it’s a shorter way
878.
▲
by
masklinn
1y ago
Right, so instead of just grabbing a property by its well know unique name aka the entire point of symbols you need to first resolve the property descriptor, check a new completely unnecessary flag, and only then can you call the method. An
879.
▲
by
masklinn
1y ago
(const local should be using local in the snippets).
880.
▲
by
masklinn
1y ago
> Probably would be easier to pass DisposableStack as an argument to stack all .defer() callbacks in the caller's context? The problem in that case if if the current function can acquire disposables then error: function thing(
881.
▲
by
masklinn
1y ago
> Unsure if this is inspired from C++ RAII. Not really. Both are ways to perform deterministic resource management, but RAII is a branch of deterministic resource management which most GC'd languages can not use as they don't h
882.
▲
by
masklinn
1y ago
Note that depending on use case, it may be preferrable to use `DisposableStack` and `AsyncDisposableStack` which are part of the `using` proposal and have built-in support for callback registration. This is notably necessary for scope-bridg
883.
▲
by
masklinn
1y ago
They're basically dual of one another. `using` is mostly more convenient, because it registers cleanup without needing extra calls, unlike `defer`. And of course you can trivially bridge callbacks, either by wrapping a function in a di
884.
▲
by
masklinn
1y ago
> This looks most similar to golang’s defer. It runs cleanup code when leaving the current scope. It's nothing like go's defer: Go's defer is function-scoped and registers a callback, using is block-scoped and registers an
885.
▲
by
masklinn
1y ago
The error was probably trying to write a generic `using`. In my experience languages which use higher order functions or macros for scope cleanup tend to build high-level utilities directly onto the lowest level features, it can be a bit re
886.
▲
by
masklinn
1y ago
Yes? Congratulation you know what a finalizer is? I was replying to this: > would very explicitly cause the GC to have semantic effects, and I think that goes strongly against the JS philosophy. Do you disagree that a finalizer provides
887.
▲
by
masklinn
1y ago
higher order function, function taking an other function (/ block). E.g. in Ruby you can lock/unlock a mutex, but the normal way to do it would be to pass a block to `Mutex#synchronize` which is essentially just def synchroniz
888.
▲
by
masklinn
1y ago
> To make a "resource", you'll tack on a new magical method to your POJO, identified not with a standard name [...] nothing to do with Symbol's core purpose of creating unique identifiers. The core purpose and origina
889.
▲
by
masklinn
1y ago
It's basically lifted from C#'s, the original proposal makes no secret of it and cites all of Python's context managers, Java's try with resources, C#'s using statements, and C#'s using declarations. And `using
890.
▲
by
masklinn
1y ago
It's similar, but more inspired by C#'s "using declaration", an evolution of the using blocks, which are the C# version of try-with-resource: `using` declarations don't introduce their own block / scope. The or
891.
▲
by
masklinn
1y ago
> JS: drop but we couldn't occupy a possibly taken name, Symbol for the win! You're about a decade late to the party? That is the entire point of symbols and "well known symbols", and why they were introduced back in
892.
▲
by
masklinn
1y ago
FinalizationRegistry was added, like, 5 years ago.
893.
▲
by
masklinn
1y ago
> Anyway, I didn't say it was "inferior to defer", I said that it seemed more error-prone than RAII in languages like Rust and C++. It is, but RAII really isn't an option if you have an advanced GC, as it is lifetime-
894.
▲
by
masklinn
1y ago
Destructors require deterministic cleanup, which advanced GCs can't do (and really don't want to either from an efficiency perspective). Languages with advanced GCs have "finalizers" called during collection which are th
895.
▲
by
masklinn
1y ago
If you mention the product, even if it’s an absolutely perfect fit, you should definitely disclose the conflict of interest upfront. This is not about overly promoting the product, it’s about making clear that you are promoting your produ
896.
▲
by
masklinn
1y ago
The sys.monitoring and import optimisation suggestions apply as-is. If you use standard unittest discovery the third item might apply as well, though probably not to the same degree. I don’t think unittest has any support for distribution s
897.
▲
by
masklinn
1y ago
> This trend of overengineering I'd dispute it being over -engineering: media keys tend to control a mix of hardware and software (OS) features (looking at asus keyboards on the internet I see audio volume, mic mute, fan speed 
898.
▲
by
masklinn
1y ago
> Interesting to see astral come out with this right around facebook’s release Astral announced they were building a typechecker back in January: https://x.com/charliermarsh/status/1884651482009477368
899.
▲
by
masklinn
1y ago
> Rust, in many ways, is a terrible first systems programming language. Contrariwise, Rust in, in many way, an awesome first systems programming language. Because it tells you and forces you to consider all the issues upfront. For instan
900.
▲
by
masklinn
1y ago
Literally nothing in your comment is correct. In the Rust snippet vector is moved into the loop, and thus freed. There are situations where you hit the limits of the borrow checker, plenty of them. This is not one of them. Again, the borrow
More ›