by javitury · 4y ago · 0 comments
I found that R has the best libraries. It's the easiest language to use but it's also easy to write spaghetti code. Static analysis is a joke.
Writing code in Julia is slower/more tiresome. I have to annotate all structs and function input types. In languages like typescript, I would see this as an investment because tsserver will later use that information for linting and autocompletion, so the net return is clearly positive. In Julia however static analysis is very primitive and limited, you feel like having to write code twice: once for annotations and then again for the implementation, with very limited cross-checking between the two. When writing functions, output types are so hard to annotate that I just skip them completely and only annotate input types. Type errors are usually caught at runtime. The runtime messages are helpful though.
Unfortunately I couldn't even find a reputable Poisson-binomial package for Python so I stopped here. From my limited experience with python in other projects, I think that static analysis using pyright is mature and worth using (nets a positive return, although inferior to tsserver). This experience varies greatly between frameworks and packages, it's only worth to annotate the code if the underlying libraries also provide type hints.
And I definitely don't get what you mean by having to write the code twice: To me the beauty of Julia is exactly that you write it once, then optimise it for speed (or robustness, with gradual typing and all) instead of rewriting it in another language.
Unfortunately, I also don't agree that the runtime error messages are good in Julia. I find them pretty bad :( even if stack traces are good. And also, the lack of automatic type checking in the editor is also a problem for productivity.
That has been my experience as well: among optionally-typed languages, Julia is pretty good at inference, and at telling you why it gave up. This is critical when dealing with a language with a Sufficiently Smart Compiler that takes some convincing to do what you want.
[1]https://docs.scipy.org/doc/scipy/reference/generated/scipy.s...
[2]https://docs.scipy.org/doc/scipy/reference/generated/scipy.s...
[1] https://en.wikipedia.org/wiki/Poisson_binomial_distribution
The attempt to shoehorn in the Python version of the R Fourier variation was closed 18 days ago with a "doesn't quite fit, try again later"
[1]https://en.wikipedia.org/wiki/Poisson_binomial_distribution
[2]https://cran.r-project.org/web/packages/PoissonBinomial/inde...
Looking at some child comments it looks like there have been attempts to get it added to scipy since 2016.
Can you elaborate on that? Argument types in function definitions do not help the compiler infer types - you can leave them completely untyped. It's really only required in struct fields, so that the compiler can know the size of your struct and doesn't have to box everything.
(I don't recommend it though, having some idea of type safety is in general a good idea)
julia> struct Foo
a
end
julia> Foo(17)
Foo(17)
julia> Foo("bar")
Foo("bar")
People should absolutely criticise Julia for its faults, but I would expect them to at least learn and understand the very basics of the language before doing so.Structs and functions do not need to have type annotations. They are completely optional and learning when to annotate is one of the first learning challenges for newcomers to the language.
There are code generation advantages to type annotations for structs, but they are not required. As for functions, this will only ever be the case if type inference fails, which should be so rare that you hardly even need to consider it.
Regardless, that's orthogonal to being type safe.