News for hackers. Stuff that matters.
Re:Writing Python like it's Rust by tejinderss on Sunday May 21, 2023 @05:32AM (#36019252)
> I can do almost all the dynamics things that I can do in Python with C#, but in a type safe way.

If you like flexibility with a good type system, give Typescript a try, its miles ahead of mypy and its designed by same person who’s behind C#.

Re:Writing Python like it's Rust by AlexSW on Sunday May 21, 2023 @05:50AM (#36019347)
I don't think this is a completely accurate comparison, as TypeScript is transpiled to JavaScript and this provides restrictions to the expressibility and usability of types at runtime, which I've sometimes hit my head against. C# has much more type information available at run time, as does Python.
Re:Writing Python like it's Rust by rtpg on Sunday May 21, 2023 @06:03AM (#36019416)
Typescript is of course nice and is a great type system but can’t totally paper over the absolutely impoverished base language that is JS. When you use Python and things like equality do what almost anyone wants instead of checking object identity, it’s real annoying to futz around in TS
Re:Writing Python like it's Rust by influxmoment on Sunday May 21, 2023 @06:36AM (#36019581)
[1, 3, 12].sort() == [1, 12, 3]

5 in [5] == false

Re:Writing Python like it's Rust by ptx on Sunday May 21, 2023 @09:14AM (#36020547)
Even setting the sort order aside, just the fact that it both returns the sorted array and also sorts it in-place is not great. I prefer Python's distinction between sorted (returning a sorted copy) and list.sort (sorting in place and returning nothing).
Re:Writing Python like it's Rust by grumpyprole on Sunday May 21, 2023 @09:41AM (#36020757)
Even better would be to try F#, it will be able to use all the .NET libraries, has Python's succinctness, but with a strong type system (and inference).
Re:Writing Python like it's Rust by hakanderyal on Sunday May 21, 2023 @04:39PM (#36024499)
I may switch to it eventually, but at this point in my career 16 years in, I try to avoid seemingly niche things when I just want to get stuff done. "Boring" is good. I know it's the same platform under the hood but I decided to spend my "innovation tokens"[0] on the stuff I'm buildin.

[0]: https://mcfunley.com/choose-boring-technology

Re:Writing Python like it's Rust by grumpyprole on Sunday May 21, 2023 @04:56PM (#36024612)
I call it "novelty budget" and I completely agree.
Re:Writing Python like it's Rust by hakanderyal on Sunday May 21, 2023 @04:31PM (#36024433)
I'm a full stack dev so I'm also using TS at the same time. While the flexibility is nice, it's too flexible for my taste. To give a one basic example, I want to go to the definition of a symbol with a single action. Not possible with the current TS tooling and all the crazy things you can do with it's type system.

I want the type system to be predictable, so it can support whatever I want to build on top of.

There are features I'm missing with C#, but still I'll choose it over TS any day.