|
|
Subscribe / Log in / New account

An introduction to the Julia language, part 1

An introduction to the Julia language, part 1

Posted Aug 29, 2018 12:44 UTC (Wed) by milesrout (subscriber, #126894)
Parent article: An introduction to the Julia language, part 1

Pity to see so many comments focusing on trivial syntactic issues like the indexes. I'm only surprised there aren't twice as many focusing on the syntax of the comments as per Wadler's law. From what I have seen, Julia's standard library (and the major libraries) are all written to be indexing-agnostic.


to post comments

An introduction to the Julia language, part 1

Posted Aug 29, 2018 13:17 UTC (Wed) by Paf (subscriber, #91811) [Link] (4 responses)

I really, really don’t think it’s practical long term to have switchable indexing. Not everything will work with it, especially outside of the standard libraries. However careful they are, others will not even bother.

But that’s not fatal or anything - it’ll just end up as a 1 based language with a few angry holdouts switching it to 0 and struggling with non standard library code (of which one hopes there will be a lot, if the language is to really succeed), It’s just I think the switching ability isn’t a good idea, it’s a mild misfeature - it largely opens the possibility of frustration rather than benefit.

An introduction to the Julia language, part 1

Posted Aug 29, 2018 15:28 UTC (Wed) by leephillips (subscriber, #100450) [Link] (3 responses)

Well, Fortran has been considered practical long term, and there you can index arrays any way you want - even with negative indices.

An introduction to the Julia language, part 1

Posted Aug 29, 2018 17:11 UTC (Wed) by Paf (subscriber, #91811) [Link]

Good point.

Looking at Julia, it appears roughly that the alternately indexed arrays are an explicitly different kind of object from regular arrays...? That seems much better than what it seemed others were describing.

An introduction to the Julia language, part 1

Posted Aug 31, 2018 4:25 UTC (Fri) by cry_regarder (subscriber, #50545) [Link]

By the way, I have found arbitrary indexing to be handy for naturally expressing dynamic programming tableaus and pre-built recursive bases. The code naturally matches the math.

I've worked around it in fixed index languages by having a constant holding the offset:

o = 3
i[0 +o] = i[-3 +o] + i[-1 +o]

ugly but readable against the maths.

An introduction to the Julia language, part 1

Posted Sep 6, 2018 6:52 UTC (Thu) by Wol (subscriber, #4433) [Link]

> Fortran has been considered practical long term, and there you can index arrays any way you want - even with negative indices

And FORTRAN is 1-based and you can't change the index. They were prepared to change and break things when they went from FORTRAN to Fortran, yet this is something they extended rather than broke.

(Don't feed a FORTRAN loop into a Fortran compiler and expect it to work! Incidentally this is 1 or 0 based - a FORTRAN loop is 1-based while a Fortran loop is 0-based :-)

Cheers,
Wol

An introduction to the Julia language, part 1

Posted Aug 29, 2018 21:40 UTC (Wed) by k8to (guest, #15413) [Link]

For my part it was just an idle comment about the indexing. I don't think 1-based indexing is important in terms of a detriment.

I'm not a big fan of having there be multiple indexing conventions though. Just seems like more cognitive load. But maybe it isn't in its targetted domain.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds