Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
ackfoobar
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
5 ms
·
31.
▲
by
ackfoobar
1y ago
> I'm not sure why Me neither. > you are entirely correct that sealed types can fully model sum types I want to be wrong, in that case I learn something new.
32.
▲
by
ackfoobar
1y ago
> Substantiate this. You never gave an example how sum types in Java/Kotlin cannot do what "real" sum types can. >> weird name choice but whatever > snarky potshot Sorry that you read snark. What I meant was "
33.
▲
by
ackfoobar
1y ago
You wrote a lot of words to say very little. Anyway, to translate your example: sealed interface Shape permits Point, Bound {} final class Point implements Shape {} sealed interface Bound extends Shape permits Circle, Rectangl
34.
▲
by
ackfoobar
1y ago
Yes https://openjdk.org/jeps/409#Sealed-classes-and-pattern-matc... > with pattern matching for switch (JEP 406)the compiler can confirm that every permitted subclass of Shape is covered, so no default clause or oth
35.
▲
by
ackfoobar
1y ago
> So i am not sure why we are arguing :) I think we agree on a lot of points. The rest is mostly preferences. Some other comments in my thread though...
36.
▲
by
ackfoobar
1y ago
Oh if you use those features to express what "sum type as subtyping" can, it sure gets confusing. But it's not those things that I want to express that are hard to reason about, the confusing part is the additions to the HM t
37.
▲
by
ackfoobar
1y ago
Good point, well there's Ordering type built-in in Haskell (LT | EQ | GT). Ordering -> bool has 2^3=8 values (const true, const false, == LT, == EQ, == GT, is_lte, is_gte, ne) EDIT: now you see why I used the smallest type possible
38.
▲
by
ackfoobar
1y ago
A first-order function type is already exponential. A sum type has as many possible values as the sum of its cases. E.g. `A of bool | B of bool` has 2+2=4 values. Similarly for product types and exponential types. E.g. the type bool -> b
39.
▲
by
ackfoobar
1y ago
> The moment you start ripping cases as distinct types out of the sum-type, you create the ability to side-step exhaustiveness and sum-types become useless in making invalid program states unrepresentable. Quite the opposite, that gives
40.
▲
by
ackfoobar
1y ago
If you don't do inline records you either - create a separate record type, which is no less verbose than Java's approach - use positional destructuring, which is bug prone for business logic. Also it's funny that you think OC
41.
▲
by
ackfoobar
1y ago
> the end result is seriously faster Do you have a ballpark value of how much faster Rust is? Also I wonder if OxCaml will be roughly as fast with less effort.
42.
▲
by
ackfoobar
1y ago
Unless you reach an unsound part of the type system I don't see how. Could you provide an example?
43.
▲
by
ackfoobar
1y ago
> I have no idea I can tell. Thankfully the OCaml textbook has this explicitly called out. https://dev.realworldocaml.org/variants.html#combining-recor... > The main downside is the obvious one, which is that an inlin
44.
▲
by
ackfoobar
1y ago
> Just ugliness and typical boilerplate heavy approach of JVM languages. I have provided a case how using inheritance to express sum types can help in the use site. You attacked without substantiating your claim.
45.
▲
by
ackfoobar
1y ago
> Sum types: For example, Kotlin and Java (and de facto C#) use a construct associated with inheritance relations called sealing. This has the benefit of giving you the ability to refer to a case as its own type. > the expression of s
46.
▲
by
ackfoobar
1y ago
> If you want speed > If you want to be efficient Funny that you assume the best position of the trade off continuum isn't somewhere in the middle for most people. Besides, for developer efficiency, I prefer a language where I do
47.
▲
by
ackfoobar
1y ago
As a Kotlin enjoyer, I find these comments counterproductive. Maybe they like the lack of extension functions?
48.
▲
by
ackfoobar
1y ago
> .NET is now cross platform, but only as long as it doesn't hurt VS sales, with GUI workloads, profilers, still being mostly Windows only, and partially supported on VSCode, which also has the same VS license. On HN I keep hearing
49.
▲
by
ackfoobar
1y ago
> The watch is simply missing the two 5.1k resistors connecting the CC1 and CC2 pins of the USB-C connector to ground that are required to indicate to whatever is plugged in that it wants 5v power. This is so annoying. Back when USB-C wa
50.
▲
by
ackfoobar
1y ago
> Give it a script Ideally the build tool does that for you, e.g. `./gradlew run -t`.
51.
▲
by
ackfoobar
1y ago
> things that are a net improvement do not preclude other things that are net improvements. That's a good framework to think about things. Going all-in on renewables implies keeping fossil fuels around, because storage tech is sever
52.
▲
by
ackfoobar
1y ago
A diesel train releases orders of magnitudes less CO2 than flights though.
53.
▲
by
ackfoobar
1y ago
> dataclasses are, um, classes So is the case when you use `namedtuple`, which creates a new class. This is not an interesting gotcha. Classes (the Python language construct) are how you implement records (the language-neutral concept) i
54.
▲
by
ackfoobar
1y ago
Pydantic is everything I want Python dataclasses to be. While Pydantic `BaseModel`s, like dataclasses, are still "classes", I consider that an implementation detail of how records are implemented in Python - thus not really contra
55.
▲
by
ackfoobar
1y ago
Do you have some examples? I think JDK developers make a lot of effort to make sure users bugs will not corrupt the runtime.
56.
▲
by
ackfoobar
1y ago
I'm shooting for 54C medium rare but I've never left a thermometer to see the temp rise and fall. The steaks taste good is all I can tell you.
57.
▲
by
ackfoobar
1y ago
I agree that his suggestion is more applicable to home cooks than restaurants.
58.
▲
by
ackfoobar
1y ago
Well, a lot earlier. I pull my steak out of the pan when it reaches 45C internally.
59.
▲
by
ackfoobar
1y ago
In Chris Young's video, the suggestion is to stop carry over cooking by slicing the meat when the internal temperature reaches the target temperature. A corollary to that is that if the meat is closer to target temperature when it leav
60.
▲
by
ackfoobar
1y ago
TLDR: Resting is about carry over cooking (which raises the internal temperature more than you expect) than juice retention.
More ›