News for hackers. Stuff that matters.
Re:Deno 1.9 by folkrav on Tuesday April 13, 2021 @10:24PM (#26802267)
> enums [...] everybody but me hates them

Hmm, what did I miss, why do people hate them exactly?

> And sure it’s marked “experimental” but it’s used a lot and almost guaranteed to be a future conflict. Putting that toothpaste back in the tube is gonna make a lot of people feel a lot of pain.

Maybe I'm a bit masochist, but I can't say I feel a lot of compassion for people using experimental features in missing-critical production code.

Re:Deno 1.9 by lobstrosity420 on Tuesday April 13, 2021 @10:42PM (#26802352)
>Maybe I'm a bit masochist, but I can't say I feel a lot of compassion for people using experimental features in missing-critical production code.

To be fair, decorators are an experimental feature in name only at this point. A lot of libraries force you to use it, including Microsoft's own tsyringe and the beyond popular TypeORM. NestJS is a reasonably popular framework that will codegen services with decorators in them. As the OP of this thread said, the toothpaste is out of the tube now.

Re:Deno 1.9 by folkrav on Tuesday April 13, 2021 @10:43PM (#26802365)
Fair point.
Re:Deno 1.9 by lygaret on Wednesday April 14, 2021 @02:18AM (#26803571)
the entire angular2+ ecosystem as well
Re:Deno 1.9 by tengbretson on Wednesday April 14, 2021 @10:50AM (#26807887)
> Hmm, what did I miss, why do people hate them exactly?

They operate in a weird gray-zone between being just compile-time types vs. an actual readonly object in the runtime. I don't think I've seen a use case for them yet that wouldn't have been better accomplished with a union type of string literals and using const string literals in the code.

Re:Deno 1.9 by folkrav on Friday April 16, 2021 @12:05PM (#26835627)
Say all you need is a fixed set of strings that get reused everywhere. What is better accomplished by defining a union type AND consts literals rather vs creating a single string-based enum and using that everywhere? I feel like I'm misunderstanding...
Re:Deno 1.9 by mssundaram on Thursday April 22, 2021 @01:23AM (#26899052)
You don't even need the const literals.

    type Color = "red" | "blue" | "green";
Re:Deno 1.9 by pierreyoda on Wednesday April 14, 2021 @04:19AM (#26804380)
> Hmm, what did I miss, why do people hate them exactly?

In my experience, enums are far less type safe and convenient (usage in switch for instance, combined with a linter) than union types.

Re:Deno 1.9 by flyingchipmann on Wednesday April 14, 2021 @11:26AM (#26808414)
The thing is enum and union type have different use cases. Union type cannot be used to check against incoming data. It's a lightweight type level feature. There is no way for compiler to identify the unknown data object from the network. Enum is essentially an object in memory which can be used in this case.