4 ms·
One of my main gripes about matlab and that Julia unfortunately adopted is the dot syntax. Any other symbol would have worked, but the dot is just way too easy
by cycomanic 6y ago
One of my main gripes about matlab and that Julia unfortunately adopted is the dot syntax. Any other symbol would have worked, but the dot is just way too easy to overlook.
I think it is because it was initially developed for people primarily working with matrices.
Most of the things I do is actually based around multidimensional arrays so when I do operations I almost always want element-wise operations. Unfortunately you often don't even realise you do the wrong operation, just the result is wrong. So I have spend lots of time debugging, until I realised I had a missing dot somewhere, and then spending again significant time trying to find where the dot is missing.
I therefore always found the complaint about np.dot(x,y) being too verbose interesting, because I like that, it makes it explicit and is difficult to overlook.
- dklend122 6y agoYou can use the @. macro to dot an entire block. I personally like the dot syntax. It's ergonomic, and provides cool stuff like this: https://julialang.org/blog/2017/01/moredots/ https://julialang.org/blog/2017/01/moredots/ I don't know of an equivalent functionality in any other language.
- cycomanic 6y agoThe @. syntax is definetly an improvement. I don't have an issue with the principle of the dot syntax just with the symbol. The examples in your link perfectly illustrate the issue. If this was a line in a long code base maybe even with mixed element-wise and matrix operations it would be very easy to overlook a missing dot. It would be even worse if the constants were floats. It is just such a terrible choice of symbol for this operation, because it is so easy to overlook. Everyone I know always looks for missing dots if they encounter a some nonstraight forward bug in matlab (I don't know any Julia users).
- teleforce 6y agoPerhaps you should look at D language offering, it has awesome UFCS feature [1] that some other languages are copying now and a REPL. For multi-dimensional array matrix it provides the fastest computation as well, even compared to Chapel and Julia [2]. [1]https://tour.dlang.org/tour/en/gems/uniform-function-call-syntax-ufcs https://tour.dlang.org/tour/en/gems/uniform-function-call-sy... [2]https://dlang.org/blog/2020/06/03/a-look-at-chapel-d-and-julia-using-kernel-matrix-calculations/ https://dlang.org/blog/2020/06/03/a-look-at-chapel-d-and-jul...