←back to thread

311 points melodyogonna | 10 comments | | HN request time: 0.074s | source | bottom
Show context
postflopclarity ◴[] No.45138679[source]
Julia could be a great language for ML. It needs more mindshare and developer attention though
replies(4): >>45138887 #>>45138911 #>>45139421 #>>45140214 #
1. mdaniel ◴[] No.45139421[source]
I don't understand why in the world someone would go from one dynamically typed language to another. Even the kernels example cited below is "eh, the types are whatever you want them to be" https://cuda.juliagpu.org/stable/tutorials/introduction/#Wri...

Then again, I am also open to the fact that I'm jammed up by the production use of dynamically typed languages, and maybe the "for ML" part means "I code in Jupyter notebooks" and thus give no shits about whether person #2 can understand what's happening

replies(1): >>45139719 #
2. postflopclarity ◴[] No.45139719[source]
It's very important that readers, writers, maintainers, etc. of code are able to easily understand what that code is doing.

explicit and strict types on arguments to functions is one way, but certainly not the only way, nor probably the best way to effect that

replies(1): >>45139888 #
3. mdaniel ◴[] No.45139888[source]
I would actually be curious to hear your perspective on the "best way" that isn't typechecking. I literally cannot comprehend why someone would write such a thing

I readily admit that I am biased in that I believe that having a computer check that every reference to every relationship does what it promises, all the time

replies(1): >>45140099 #
4. postflopclarity ◴[] No.45140099{3}[source]
first and foremost great documentation & design docs cannot be surpassed as a tool to explain and understand code. and that is entirely language agnostic.

more generally, the most important bits of a particular function to understand is

* what should it be called with

* what should it return

* what side effects might it have

and the "what" here refers to properties in a general sense. types are a good shortcut to signify certain named collections of properties (e.g., the `Int` type has arithmetic properties). but there are other ways to express traits, preconditions, postconditions, etc. besides types

replies(2): >>45140351 #>>45143339 #
5. lgas ◴[] No.45140351{4}[source]
I mean documentation can be wrong whereas types can't, so it seems like it's strictly a worse tool if your goal is to understand what's actually going on and not what someone said was going on at some point in the past.
replies(1): >>45140463 #
6. postflopclarity ◴[] No.45140463{5}[source]
> whereas types can't

they sure can...

replies(1): >>45142118 #
7. olddustytrail ◴[] No.45142118{6}[source]
Can they? How does that work?
replies(1): >>45142854 #
8. adgjlsfhk1 ◴[] No.45142854{7}[source]
types can be (and almost always are) overly restrictive, preventing otherwise valid code from running. they can also be under powered, and not expressing necessary invariants for the algorithm.
replies(1): >>45145006 #
9. const_cast ◴[] No.45143339{4}[source]

  but there are other ways to express traits, preconditions, postconditions, etc. besides types
You can also put that in the type system, and expressive languages do. Its just a compiler limitations when we can't.

I mean, even in C++ with concepts we can do most of that. And C++ doesn't have the most expressive type system.

10. lgas ◴[] No.45145006{8}[source]
I didn't make any claims about that, just that they can't be wrong. And by that, I didn't mean you can't choose the wrong types, just that once you've chosen types that compile they can't be incompatible or other than what they are.

That being said, I've always found the argument that types can be overly restrictive and prevent otherwise valid code from running unconvincing. I've yet to see dynamic code that benefits from this alleged advantage.

Nearly universally the properly typed code for the same thing is better, more reliable and easier for new people to understand and modify. So sure, you can avoid all of this if the types are really what bother you, but it feels a bit like saying "there are stunts I can pull off if I'm not wearing a seatbelt that I just can't physically manage if I am."

If doing stunts is your thing, knock yourself out, but I'd rather wear a seatbelt and be more confident I'm going to get to my destination in one piece.