Hacker News new | past | comments | ask | show | jobs | submit login

Well, again I'd say that's just like the above examples. The exponential of a (square) matrix is indeed a very well defined object [1] with semantics perfectly consistent with the exponential of a scalar. On the other hand, broadcasting exp over a matrix is a very different operation, which doesn't really have any meaning in a linear algebra sense.

I understand it's an easy mistake to make when you're used to R or Numpy, but I'd say it's their fault you're making this mistake, not Julia's.

[1] https://en.wikipedia.org/wiki/Matrix_exponential




If you re-read my comment you will see I am not criticizing the language, it makes mathematical sense.

I was pointing out one downside of the broadcast syntax, is that a typo can lead to non-obvious errors in calculations. R avoids this with a expm() function.

Don't get me wrong, I love using Julia, it makes turning maths into code easy, and this is not even close to a deal breaker.


Sure, but my point is that this cuts both ways.

E.g. I could just as easily write

"one downside of autovectorization, is that a typo can lead to non-obvious errors in calculations. When I want the exponential of a matrix, I might accidentally write exp(M) and get unwanted vectorization. This is a typo that can lead to non-obvious errors in calculations. Julia avoids this with a exp.(M) syntax."

I think the potential for typos is symmetric here between julia and R. I think what's asymmetric though is that Julia's broadcasting is more extensible, less and hoc and more general than R's auto-vectorization since it can be done over arbitrary containers and you can control precisely what calls broadcast.

______________________________

Sorry if this comes off as confrontational, that's not my intention. I just think this is a very interesting and fruitful corner of language design.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: