Live data from Hacker News

Some Insights from a Julia Developer

stochasticlifestyle.com

191–200 of 241 posts

Re: Some Insights from a Julia Developer

#191

Earlier quoted context omitted.

Right, so zero-based is wrong unless one is using a language close to assembly.

Which one is "right" and which one is "wrong" (those are strong words I chose somewhat tongue-in-cheek) is a matter of opinion. I have my opinion, and that is that zero is the proper number to start enumerations on, not just in programming, but for everything.

Sure, but why would zero be the proper number to start counting at outside of zero-based programming languages?

Everyone starts counting objects at 1. Zero means an absence of objects to count or list. I count that there are 7 cars in the lot. The first one is 1. If there were 0 cars, I would not have any to enumerate over. If I make a list, I always number the first one as 1 (or A). If there was nothing on my list, I would have nothing (0) to number.

Word processors start list numbering at 1. Printers number the first page as 1. Kids are taught to count starting with one, using one finger. I feel like this is only an argument because we have zero-based indexing in mainstream programming languages, although maybe there are some mathematicians who think otherwise?

Re: Some Insights from a Julia Developer

#192

Earlier quoted context omitted.

Right, so zero-based is wrong unless one is using a language close to assembly.

Which one is "right" and which one is "wrong" (those are strong words I chose somewhat tongue-in-cheek) is a matter of opinion. I have my opinion, and that is that zero is the proper number to start enumerations on, not just in programming, but for everything.

No, zero is the right number to start an offset, not an enumeration. No one starts counting from zero in real life.

Re: Some Insights from a Julia Developer

#193

Earlier quoted context omitted.

Enumeration should generally begin at 1. In common language, you don't say "this person won the 0th place trophy", you say "this person won the 1st place trophy". It's address offsetting that should begin at 0. C strongly encourages you to think of arrays as simply address+offset pointers, so it absolutely should start with 0.

> you don't say "this person won the 0th place trophy" I think it would make sense to say it. The reason I don't is that people around me would misunderstand me if I did. (Around some people, it works, though!)

If some told me they got the "0th place trophy", I would take that to be a colorful way of saying they didn't win anything, as 0 means nothing, or the absence of trophies, in this case.

Re: Some Insights from a Julia Developer

#194

Sometimes, in my darker moments, I have the terrifying thought that one of the reasons that many users like R and made it popular (apart from the historical context of its now many libraries and being the main free version of statistical software), is specifically that it isn't robust and sensibly designed from a programming/analytical perspective. You can download a package, type in a preset command on a preset thin…

Having literally spent all day fighting R, I’m looking forward to getting back on the Julia side of things. Time to port more code.

Re: Some Insights from a Julia Developer

#195

Earlier quoted context omitted.

If that were the case I wouldn't have an adjacent subthread telling me that they are pretty much the same ;). To be clear, I have no beef with Julia, I'm sure it's a fantastic language. I take issue with people thinking they can get the same level of performance without explicitly controlling their memory access patterns/allocations. 98% of developers will never need it in their careers but when you do there is no su…

Why don't you think you can control those things? Make an array, loop through linearly, just like C. Avoid allocations in inner loops, just like C.

I agree, a lot of the performance problems have to with allocation in any language, gc'd or not. I still can't believe people making the same argument against gc'd languages even when highly performant jvm exists.

Re: Some Insights from a Julia Developer

#196

Earlier quoted context omitted.

Which one is "right" and which one is "wrong" (those are strong words I chose somewhat tongue-in-cheek) is a matter of opinion. I have my opinion, and that is that zero is the proper number to start enumerations on, not just in programming, but for everything.

Sure, but why would zero be the proper number to start counting at outside of zero-based programming languages? Everyone starts counting objects at 1. Zero means an absence of objects to count or list. I count that there are 7 cars in the lot. The first one is 1. If there were 0 cars, I would not have any to enumerate over. If I make a list, I always number the first one as 1 (or A). If there was nothing on my list,…

> Sure, but why would zero be the proper number to start counting at outside of zero-based programming languages?

I don't take programming languages as a reference point. It's the other way around. I try to figure out what the most natural, principled, and elegant way would be, and I would base my programming language on that, if I were to design one.

> Zero means an absence of objects to count or list. I count that there are 7 cars in the lot. The first one is 1. If there were 0 cars, I would not have any to enumerate over. If I make a list, I always number the first one as 1 (or A). If there was nothing on my list, I would have nothing (0) to number.

We should distinguish between two uses of the natural numbers, I think:

0. _Ordinal numbers_, for assigning labels to things. "This is car 3." 1. _Cardinal numbers_, for saying how many things there are. "There are 7 cars."

The relationship between the two would be that the number of cars is the number that is next in line when you have called out the indices (0, 1, 2, 3, 4, 5, 6) of all the cars.

> Word processors start list numbering at 1. Printers number the first page as 1. Kids are taught to count starting with one, using one finger. I feel like this is only an argument because we have zero-based indexing in mainstream programming languages

What is the most common isn't what determines, for me, what is the most proper. I will play along and use 1-based indexing when I have too, but in my heart I know how I think it should _really_ be.

> maybe there are some mathematicians who think otherwise?

Yes, though starting numberings on 1 is still common (maybe the most common). Zero is at least recognised as a natural number nowadays. Historically, this wasn't the case. Apparently, Peano started on 1 in his axioms for the natural numbers [0], and zero, as far as I understand, hardly had the status of being a number at all during much of Greek and Roman antiquity [1].

[0] https://en.wikipedia.org/wiki/Peano_axioms#Formulation [1] https://en.wikipedia.org/wiki/0#Classical_antiquity

Re: Some Insights from a Julia Developer

#197
post #192

Earlier quoted context omitted.

Which one is "right" and which one is "wrong" (those are strong words I chose somewhat tongue-in-cheek) is a matter of opinion. I have my opinion, and that is that zero is the proper number to start enumerations on, not just in programming, but for everything.

No, zero is the right number to start an offset, not an enumeration. No one starts counting from zero in real life.

> No one starts counting from zero in real life.

The question for me is what one _should_ do, not what is usually done.

Re: Some Insights from a Julia Developer

#198

Earlier quoted context omitted.

> you don't say "this person won the 0th place trophy" I think it would make sense to say it. The reason I don't is that people around me would misunderstand me if I did. (Around some people, it works, though!)

If some told me they got the "0th place trophy", I would take that to be a colorful way of saying they didn't win anything, as 0 means nothing, or the absence of trophies, in this case.

That's just an artefact of being used to a certain way, isn't it? For me, it's about finding fundamental reasons for one convention or another, not about the practicalities.

Re: Some Insights from a Julia Developer

#199

Whenever I see Julia mentioned, I like to link to this blog post by Graydon Hoare (creator of Rust). https://graydon2.dreamwidth.org/189377.html

That is a great tour of the forces driving the evolution of languages. My reservation with Julia in the past was its widely varying performance. The OP clarifies how this happens and that these cases are not dark mysteries but rather the contrary. Here's a jewel from the Graydon post:

> PHP initially implemented its loops by fseek() in the source code

Re: Some Insights from a Julia Developer

#200
post #38

Earlier quoted context omitted.

Zero based indexing is not a C artifact. Here's Dijkstra writing about it in '82: https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E...

There's the very real possibility that zero based indexing is in fact a Yacht Racing artifact. http://exple.tive.org/blarg/2013/10/22/citation-needed/

> The social reason is that we had to save every cycle we could, because if the job didn’t finish fast it might not finish at all and you never know when you’re getting bumped off the hardware because the President of IBM just called and fuck your thesis, it’s yacht-racing time.

I don't buy it. Wouldn't people want their programs to run fast regardless of this?

Post reply on HN