12 ms·
I recently began learning Julia and initially everything was amazing, except for 1 based indexing but with everything else I could overlook that. Then I attempt
by Datenstrom 8y ago
I recently began learning Julia and initially everything was amazing, except for 1 based indexing but with everything else I could overlook that. Then I attempted building something medium sized and it all fell apart. I feel like it needs some serious work on tooling, the module system, packages, etc.
Has anyone built something medium-large sized in Julia? Maybe I'm missing something. When I was trying to use modules to organize my code the response I got was that modules are more trouble than they are worth so just don't use them. So why do they even exist? That really put me off from Julia despite really liking it otherwise.
I would want to build things with it not just play in a REPL and notebooks.
- walshemj 8y agoout of interest what would you consider medium sized?
- agumonkey 8y agoout of curiosity, could you give more details about modules problems ?
- Datenstrom 8y agoI do not recall the exact issue anymore unfortunately, I abandoned the project because of it, but the general sentiment on the Julia discourse seemed to be just avoid them. This blog post seems to sum up my issues with modules and namespaces pretty well though: http://luthaf.fr/julia-some-criticism.html http://luthaf.fr/julia-some-criticism.html I think that these issues are generally acknowledged although I don't know if they will be addressed. Seems like major pain points for library development should have been addressed before 1.0.
- ChrisRackauckas 8y agoA lot of this blog post is addressed by just using `import` instead of `using`... so it was actually just an issue of not reading the manual. It's like using `from package import *` and then complaining Python doesn't namespace properly.
- masklinn 8y ago> It's like using `from package import <star>` and then complaining Python doesn't namespace properly. It really is not: * `from package import <star>` is more work than `import package`, `using` is shorter than `import` * the official documentation Python documentation starts with qualified imports, then introduces local bindings, and finally unqualified imports, opening a few doc pages imports are either fully qualified or explicitly bound; the first occurrence of using a non-prelude package in Julia's tutorial is `using`[0] and the modules documentation explains `using` first The official Julia documentation very specifically steers the reader towards unqualified imports as the default & proper way to do things, Python's does the opposite. [0] https://docs.julialang.org/en/v1/manual/functions/#Optional-Arguments-1 https://docs.julialang.org/en/v1/manual/functions/#Optional-... edit: oh for fuck's sake I hate hn's shitty brain-dead pseudo-markup.
- ChrisRackauckas 8y agoRight, so this is a documentation thing, and I agree the docs should probably be changed a bit. But it's not a language thing.
- improbable22 8y ago> `using` is shorter than `import` By one letter! And in the right direction: for trying things out interactively, `using ThePackage` and then having everything available is great. Then once you know what you want to do, in more careful code you can switch to `import` and qualify more things, and your future self with thank you. But serving both of these needs seems like a valid design goal. I'm not sure the manual does a great job of explaining this right now, import vs. using also changes the rules around adding methods to functions, and it is perhaps more confusing than it has to be.
- masklinn 8y ago> By one letter! Yes, by one letter. Out of 6. "using" is 16% shorter than "import". And it uses better keyboard alternation (the first 4 letters of `import` are on the right side of a qwerty keyboard, the last 2 on the other, for using the only "i" and "n" are consecutive letters on the same half of the keyboard). So "using" is 1. introduced first 2. the primarily documented import mechanism 3. significantly shorter and 4. significantly more comfortable to type. If Julia's community doesn't want people to use it everywhere, they're doing a very, very good job of fucking with and victimising their users by way over-incentivising the use of `using` over `import`. > And in the right direction: for trying things out interactively, `using ThePackage` and then having everything available is great. And for writing maintainable code it's terrible, despite being by far the easiest and most convenient solution. ChrisRackauckas complains that people use `using` over `import`, literally everything in the language and documentation pushes them towards it. Putting the convenience of interactive sessions way, way over that of proper programs does not seem like "the right direction" to me, especially not when people then jump on their high horses and chide users for doing what the language unambiguously pushes them towards. > But serving both of these needs seems like a valid design goal. Python does that just fine: it provides convenience for interactive use without pushing users towards the least maintainable and desirable option.
- agumonkey 8y agofair enough, the article is from 2015 though; these weren't open research problems, I'd hope they've been fixed since.
- celrod 8y ago> When I was trying to use modules to organize my code the response I got was that modules are more trouble than they are worth so just don't use them. Really? I normally break up my code across modules, but also across libraries. I'd say a few of my projects are at least medium sized. I discuss an example here, where much of the code is split across many separate modules: https://bayeswatch.org/2019/01/29/optimizing-a-gibbs-sampler/ https://bayeswatch.org/2019/01/29/optimizing-a-gibbs-sampler... I achieve roughly 1700x better performance in an example than a JAGS model. A C++ version does a bit better at 2000x when compiled with Clang. Having all these dependencies checked out for development is not best practice, so I wouldn't recommend strictly following my example.
- 4thaccount 8y agoI actually like 1-based for numerical work. A lot of great languages (Smalltalk, APL, Lua...etc) use it too. It makes sense with matrices.
- lloda 8y agoAPL let you choose. It was only trouble and then Iverson made J 0-based.
- 4thaccount 8y agoYeah you can change when needed of course (forgot about that). Iverson's J did a lot of things (chief of them was removing the awesome symbols) to make it more appealing. A lot of folks understand the cause, but also realize it takes away one of the best reasons to use APL. So moving to 0-base wasn't necessarily because he thought it was better.
- ModernMech 8y agoThis is something I don't fundamentally understand. As someone who works a lot with MATLAB I'm very used to and like 1-based indexing. But when I use C or Python, 0-based indexing is not something I complain about or hold against the language. It's just the way things are. Maybe if you don't think of it in terms of a different index basis and instead you think of it as indexing vs. offsets then it becomes easier to switch between the two?
- ssivark 8y agoIf that's someone's biggest complaint against the language, then I'd say the language must be pretty awesome ;-) It's basically bikeshedding. "But I look at the shed all day..." "But I'm used to looking at reddish colors..." "Red is more correct than green because <yadda yadda>..." Let's all move on to more important things :-)
- zimablue 8y agoIt's not bikeshedding because: 1) it is pervasive and fairly importsnt 2) it's kind of a deep indication that something is amiss. It's like a language written in 2019 that has default dynamic not lexical binding, not in terms of importance but in terms of it's an argument that was had and decided 20 years ago. If this is wrong then you can probably assume that lots of other things which are important, decisions which can't be "proven" correct but have both convincing arguments and weighty empirical evidence are wrong (I'm not having that argument here but google why 0-based makes sense by Djikstra). I might have to learn Julia at some point but 1-based indexing was a fairly heavy indicator to me to hold off.
- RivieraKid 8y agoAgreed, that's my experience as well. Julia is amazing for scripts and smaller projects, but I wish there was something like Swift (which I'm increasingly convinced is closest to the ultimate general-purpose language) with all the nice things that Julia has. Specifically, these things make Julia less suitable for larger projects: - Lack of support for OOP. And no, purely functional programming is not the best way to code all projects. - Dynamic typing. - Doesn't compile to native code (there are ways to do it, but too complicated and there are caveats). - Module system doesn't seem to be design well. - You can't use a function before it's defined.
- CyberDildonics 8y ago> - Lack of support for OOP. And no, purely functional programming is not the best way to code all projects. Julia doesn't rely on functional programming and there are also structs and operator overloading. What feature do you think is missing specifically? > Dynamic typing. Julia is not dynamically typed, though if you write a type unstable function, you will get back an Any type. - Module system doesn't seem to be design well. What specifically is problematic?
- StefanKarpinski 8y agoJulia is dynamically typed: https://stackoverflow.com/a/28096079 https://stackoverflow.com/a/28096079.
- RivieraKid 8y ago> Julia doesn't rely on functional programming and there are also structs and operator overloading. What feature do you think is missing specifically? Interfaces, access modifiers, calling methods via object.method() instead of method(object), you can't define methods inside classes (structs) with an implicit "this" parameter. > Module system doesn't seem to be design well. Working with a multiple file project feels weird... I have to first "include()" the source code and then use "import" or "using". The module system in Java, Javascript or Swift seem to be more straightforward and sensible.
- FridgeSeal 8y ago
- dnautics 8y agoYeah, I built several libraries that replace IEEE floating points with alternatives. You should really be using modules to organize your code. I don't know who told you that they are more trouble than they are worth. I would also suggest aggressively unit testing all the parts. Numerical developers are not often in that habit, which is a shame. https://github.com/REX-Computing/unumjl https://github.com/REX-Computing/unumjl https://github.com/interplanetary-robot/SigmoidNumbers https://github.com/interplanetary-robot/SigmoidNumbers
- jhayward 8y ago> Numerical developers are not often in that habit, which is a shame. For certain! I don't know how anyone can do any serious numerical development without a whole lot of test cases, including esoteric PhD-level numerical analysis stuff. I remember working with the IMSL libraries back in the 1970's and being in awe of the huge set of numerical tests they had in the test suite which gave them, from my point of view, an unbeatable lead in development. These were tests that were often about highly esoteric aspects of numerical stability in floating-point algorithms and were written by extremely well educated mathematicians with tons of numerical experience. For those who aren't greybeards IMSL (the International Mathematical Subroutine [now Statistical] Library) was one of the first uses of re-usable software in application programming. It started as decks of punch cards that you would put in a request for and the computing facility would punch a copy of the appropriate routines for you to include in your program deck.
- killaken2000 8y agoYou can change the indexing method if you want but that can introduce its own issues https://docs.julialang.org/en/v1/devdocs/offset-arrays/ https://docs.julialang.org/en/v1/devdocs/offset-arrays/