Why make it complicated?
-
People really overstate it, it's not that hard. It has a reputation of being difficult because people use it for difficult, low-level tasks, OS stuff, parsers, cryptography, highly optimised serialisation, but those things would be hard in any language. For a newcomer it's, IMO, way easier than say C++, because it doesn't have a mindbogglingly huge std lib with decades of changing best practices to try to figure out. To do simpler things in it is really pretty straightforward, especially if you're already comfortable with a robust type system.
wrote on last edited by [email protected]This contradicts what I've heard others say about it. I have a feeling it is quite subjective, and this might just be an anecdotal recommendation because you have an easy time with it. Maybe I will too! But maybe I won't.
Either way, one part of me really wants to try it, but one part has very little time in life. π₯²
Also comparing it to C++ might not be the flex we think it is.
-
This contradicts what I've heard others say about it. I have a feeling it is quite subjective, and this might just be an anecdotal recommendation because you have an easy time with it. Maybe I will too! But maybe I won't.
Either way, one part of me really wants to try it, but one part has very little time in life. π₯²
Also comparing it to C++ might not be the flex we think it is.
Well sure, I guess you're right, it's definitely a bit subjective and some people have an easier time with some languages and ways of thinking than others for sure. And I didn't really mean to say that it was totally super easy, but... no kind of programming is really super easy. It is quite different and that in itself has a learning curve.
My recommendation is for sure anecdotal, but I think the point about it seeming more difficult than it really is because people often use it for difficult stuff is actually true.
-
i mean, i'm all for rejiggering the internals. i've personally written at least two libraries that uses type annotations in reverse to force arguments into the correct type, and i feel like that should probably be a separate mechanism to "just call the annotation"
dataclasses do this for you at the class level. They enforce type annotations at instantiation.
-
Yeah, it's in my edit I realized the same thing. I'm thinking it doesn't actually really make sense and the real reason is more "the specific way C does it causes a lot of problems so we're not poking syntax like that with a 10 foot pole" + "it makes writing the parser easier" + maybe a bit of "it makes grepping easier"
wrote on last edited by [email protected]One thing that annoyed me about C# as a Java guy is that it really wants you to use camel case for function and property names, even private ones. I don't like it specifically because it's hard to differentiate between a function/property and a type.
But C# has quite a few keywords and seem to like adding them more than Java.
Maybe that's their way of ensuring keywords don't clash with stuff?
-
Well sure, I guess you're right, it's definitely a bit subjective and some people have an easier time with some languages and ways of thinking than others for sure. And I didn't really mean to say that it was totally super easy, but... no kind of programming is really super easy. It is quite different and that in itself has a learning curve.
My recommendation is for sure anecdotal, but I think the point about it seeming more difficult than it really is because people often use it for difficult stuff is actually true.
Take my up vote. I agree with everything in that comment.
-
dataclasses do this for you at the class level. They enforce type annotations at instantiation.
wrote on last edited by [email protected]i think we're talking about different things. you use enforce to mean "validate", i used it to mean "coerce". one of the cases was a command line argument parser that consisted of a single decorator, so you could write
@command def foo(bar: int, baz: float): print(baz * 2 + bar * 3)
and call it with
$ myfile.py foo --bar 3 --baz 2.2
and it would print 13.4another was about creating working protocol buffers from an excel sheet, nested types and enums and oneofs and everything. we used it to parameterize tests of our bluetooth protocol.
-
You're encoding more information in the typescript one. You're saying it's a string that will get updated.
Meanwhile if it's rust it's the opposite. (Variables that can change must specify that they are mutable)
-
That's just a comment
Looks like a snippet of C with two labels that will be referenced by a goto instruction. Very bad code tbh.
-
And bow to the compilerβs whims? I think not!
This shouldnβt compile, because .into needs the type from the left side and let needs the type from the right side.
If type constraints later in the function let the compiler infer the type, this syntax totally works.
-
If type constraints later in the function let the compiler infer the type, this syntax totally works.
Like if the variable is then used in a function that only takes one type? Huh.