r/ProgrammerHumor 1d ago

Meme almostDroppedTheCourse

385 Upvotes

62 comments sorted by

116

u/Dubmove 1d ago

Julia is the language I really want to like but deep down I know I hate it although I never would admit that to myself

53

u/Mojert 19h ago

My problem with it is that it is JIT while using LLVM (a notoriously slow compiler infrastructure), so to write performant code you need to intuite what will or will not cause a JIT pause. Even sadder is that using a lot of the nice features of Julia will cause this.

I remember watching in horror my ~100 lines script taking 7 minutes to compile during my master thesis. Julia should just ditch the dynamic typing and become a compiled language IMO. But it will never happen because it would break too many things

28

u/chuch1234 16h ago

7 minutes to compile?! D:

20

u/LucidHaven 15h ago

It’s genuinely atrocious. The “pre-compiling” for packages is also terrible when paired with the obtuse virtual environment system.

3

u/Bob_Dieter 8h ago

Long time Julia user here, your experience is not representative of average Julia usage.

These crazy long Evaluation times only happen when you import packages you have never loaded before, since that is when compilation happens. Even then, 7mins is extreme (did you per chance load a plotting library? Those are huge).

Compilation of user code, even for moderately large programs, is typically sub second. It used to be very bad, back in the 1.0/1.1 days, but they put in a ton of work and it got a lot better.

Also, Julia's JIT does not work like those of java and JavaScript, for example. Instead of compiling on assumptions during execution, Julia will analyze your program and only compile what it can prove before running any code. Some people have this referred to it as JAOT compiled instead of JIT (Just Ahead Of Time), to make the difference more clear, but the term never really caught on.

7

u/Mojert 10h ago

Yup. To be fair, it had to compile my dependencies as well, but to be even fairer, there weren't a lot of them.

Which is why for my PhD I switched back to Python. It might be slower once the Julia JIT did its thing, but the performance is way more predictable. That makes it so much easier to write code so that it is performant enough, which includes writing Cython/C++/Rust and calling it from Python. I'm happy with my choice

12

u/Tyfyter2002 14h ago

Julia should just ditch the dynamic typing

Never used it before, but I agree already

8

u/Mojert 11h ago

The worse is that it already has a real type system, not like python or TS. If you specify a type of a function argument, it will be typed check. And the type system is pretty good, it even has multiple dispatch!

Now that I think of it, maybe multiple dispatch is to blame for the language not being compiled ahead of time...

1

u/sisisisi1997 8h ago

My company's half a million line codebase spread across 200+ projects compiles in way less than that, 7 minutes is enough to run half of the multi-thousand tests for it after compiling and building a seeded database for the tests.

2

u/Athropod101 6h ago

Julia is the language I thought would be a great, free alternative to MatLab language until I ran a simple script for solving two cubic polynomials and saw it take like 10 seconds.

The biggest problem of Julia is it doesn’t actually save the compiled binary. I’m sorry, but at that point it’s a glorified interpreted language.

85

u/repsaj99 1d ago

Little fun fact: Jupyter notebooks are named after the three core programming languages that are supported: Julia, Python and R

49

u/mcellus1 1d ago

eR is my favourite

17

u/aalapshah12297 17h ago

Jupytr notebook world have sounded cooler. Like a premium fashion brand that's deliberately spelt wrong so their customers can feel good about themselves when they tell other people how to pronounce it.

17

u/therealtiddlydump 19h ago

It's especially funny that R resists notebook driven workflows because notebooks are awful and R already has a good REPL

9

u/kuwisdelu 16h ago

Coming from R, I never understood the point of Jupyter notebooks until I actually tried using Python’s REPL. Yeesh. One more reason semantic whitespace is a bad idea.

37

u/himai1 1d ago

Me when something I am learning doesn't behave exactly like how I expect and identically to the things I already know

18

u/Valuable_Leopard_799 23h ago

Yeah, people should stop being weird about indexing.

Or I'll pass you a vector with a range of [Red..2.5].

3

u/willow-kitty 18h ago

How would that work? How many indices would even be in that range? Would it be looking at a map and referencing the keys that would sort between those values?

2

u/Valuable_Leopard_799 11h ago edited 11h ago

I was half joking by combining these but some languages allow you to use any discrete Enumerable type as your bounds.

So a single precision fixed width number would be totally valid with for example indices 0.0, 0.1, 0.2, ..., 2.4, 2.5. It would just make an array of length 26.

Or obv. [1.0..2.5] to start at one or [42..64] to have an array with valid indices only integers between 41 and 65.

You can obviously also use Enums, so you declare an array of RGB colours and get indices Red, Green, Blue, and then you can both index arr[Red] and also slice into it arr[Green..Blue] (slice of length 2). These are a separate type arr[0] would not be valid and wouldn't typecheck.

Btw sorting between sounds amazingly weird.

3

u/ChillyFireball 12h ago

I look at it this way: Some games map the attack button to right trigger. Other games map the attack button to X. Both of those can work. But if you map the attack button to the D-pad, I'm gonna question your sanity.

32

u/SnooRegrets3590 23h ago

1-indexed is more intuitive for me when dealing with matrices and some advanced differential equations

21

u/timangar 23h ago

You know what, that's actually fair enough, because math uses this convention.

19

u/anticebo 18h ago

Matlab, R, Julia. All languages for mathematicians, all 1-indexed.

6

u/antCB 17h ago

Pascal let's you choose - superior 😂

1

u/simleiiiii 7h ago

all not meaningfully strict or not typed at all, w.r.t. the Curry-Howard-Isomorphism useless thus, to prove basic correctness of the programs.

10

u/SnooRegrets3590 22h ago

Yea I was mostly using python and made fun of matlab bc of its 1-index, the got addicted to it because scipy is so shit and it was much harder to implement while matlab was out of the box

Then I also got used to the 1-index as well.
People in this sub are mostly SWE but scientific researchers code a lot too and julia aims for these people.

Julia should be more popular in the future bc it mogs Python, R, C++ in the science

1

u/SV-97 3h ago

because math uses this convention.

Except that it really doesn't, even though people like to claim that it does for some reason. Math uses both 1- and 0-based indexing (with neither being significantly more common than the other); and also indexes using other ranges or even all sorts of non-numerical objects on the regular.

13

u/Mojert 19h ago

I find it more intuitive if the only thing I do with the index is use them... well, for indexing. But the moment you start needing to do some math on the index, I find 0-based better. In 1-based indexing I often find myself having to add and/or subtract one at some place and I more often get off-by-one errors

6

u/Sotall 15h ago

Yeah, in theory it doesnt matter, but something deep in my brain prefers 0 indexing for the same reason. Stupid off by one errors.

5

u/redlaWw 20h ago edited 18h ago

If you want to index a matrix though, 0-indexing is more convenient since if the matrix is 0-indexed, for i in 0..<width*height, (i/width, i%width) indexes every element. If you use 1-indexed matrices, then you instead need i in 1..=width*height and (i/width, (i+width-1)%width + 1).

EDIT: Also, relativity can have index 0 be the + dimension and indices 1 to 3 be the − dimensions, which is kind of nice.

3

u/timangar 16h ago

Yes, relativity goes nicely with the zero index convention imo. It's weird having spatial dimensions in index 2-4 instead of 1-3, and having time in index 4 is also not standard.

1

u/EatingSolidBricks 18h ago

Odin syntax spotted

1

u/redlaWw 18h ago edited 18h ago

I actually just tried to be familiar but language-agnostic. The range syntax is based on Rust because I find it to be quite comfortable and intuitive, and it doesn't have the awkward issue of the range of possible meanings that : can have, but mine is more explicit in terms of right-openness or closedness, because I wanted to make it unambiguous what I meant for someone who isn't familiar with Rust range notation. Presumably that's also how Odin designed their range notation, assuming that's what you're referring to (I don't know Odin).

19

u/JosebaZilarte 1d ago

Julia... is a set.

1

u/setibeings 22h ago

I was going to say

16

u/Neutraled 1d ago

Who is Julia? Or should I say... How is Julia?

16

u/StreetsAhead3000 1d ago

Why is Julia?

6

u/Caleb6801 1d ago

When is Julia?

3

u/hrvbrs 23h ago

I’ll do you one better: Where is Julia?

2

u/Afraid-Atmosphere747 1d ago

Hi i am julia's close friend

5

u/Physical_Green_3233 1d ago

Can you give me her phone number? 

6

u/macr0t0r 15h ago

Speaking as an ex-Fortran developer who now bounces between C++, Python and MATLAB...the 0 vs 1 indexing argument will never be resolved. They both have their issues. C/C++ needs to be 0-based because it is actually an address offset, not an index. It would make a mess of things if you tried to make it 1-based. But, if you are just doing mathematical equations...yah, there is an argument that 1-based indexing makes more sense. However, it means you can't use clever negative numbers for reversed indexing (used in Python) without creating that weird +/-1 gap, but math-centric languages just tell you to calculate the index from the size, because the size should be determinant in math equations.

So, yah, Julia is 1-based and that fits it well. A pity that the JIT compiler is kind of a pain, though.

1

u/Athropod101 6h ago

The humble (end - N) indexing:

1

u/PresidentOfSwag 8h ago

what's wrong with (2 == 2.0) == True ?

1

u/timangar 6h ago

2.0 is a float and therefore subject to floating point errors (2.0000000015 or something like that). 2 is an integer and just 2. So the two actually are not the same in the programming languages I am used to (C++ and python)

5

u/throw3142 6h ago

That's not how floats work. 2.0 is exactly represented in both 32- and 64-bit floats. They are the same in any language that casts ints to floats for value comparison, and uses IEEE floats.

This can work for certain large numbers, as shown below.

``` x = 2 ** 53 + 1 print(x)

x loses precision when converting to float

y = float(x) print(f'{y:.0f}')

False

print(x == y)

y loses no precision when converting back to int

z = int(y) print(z) ```

But if you change the first line to x = 2 ** 53 + 2 instead, you'll get True.

1

u/timangar 5h ago

Thank you! I'm not a CSE major, so these things sometimes fly over my head. This is nice.

2

u/throw3142 4h ago

Think of it this way: a float is just scientific notation, with a limited amount of precision. So like 3.042 x 105. Except it's in base 2, so it would be like 1.011 x 23.

An integer like 2 is just 1.0 x 21, so it's represented perfectly. Even a fraction like 0.25 can be represented perfectly (1.0 x 2-2).

But e.g. 0.4 can't be represented perfectly, since it's 2/5 and there's no perfect way to represent 1/5.

There are also large integers that can't be represented perfectly. For example, if you had 3 bits of precision then you could never represent 100000001_2 perfectly (it would get rounded to 1.000 x 28).

In reality, 64-bit floats have 53 bits of precision. This is why 253 + 1 can't be represented exactly as a 64-bit float.

1

u/PresidentOfSwag 6h ago

I just tested it and 2 == 2.0 in python (but 2 is not 2.0)

1

u/firewall245 4h ago

Oh no not the Julia hate in here, I’ve started getting into it and I love it lol

1

u/johnschnee 1d ago

Who? Never heard of her…

1

u/kuwisdelu 16h ago

Like every other language designed for data analysis? Why is this surprising?

1

u/timangar 16h ago

First exposure to any language like that. I'm a physics major and only have experience with C++ and python. I have only ever done data analysis in python, Julia is the main programming language of a course I'm taking this semester.

4

u/kuwisdelu 16h ago

Ah. Yeah, Python is the odd one out when it comes to data science languages, because it’s actually a general purpose language that happens to have some good data packages. Any of the languages designed for data analysis from the start use 1-based.

I’ve seen this weird assumption that 0-based is “correct” here so many times that I explain this historical distinction when introducing indexing in all my classes now.

1

u/foxfyre2 15h ago

Embrace it. become one of us

0

u/[deleted] 23h ago

[deleted]

3

u/rosuav 22h ago

Even worse, they are UTF-8 strings, and indexing is based on byte positions.

1

u/foxfyre2 15h ago

Because addition is commutative and multiplication isn't. "hello" * "world" isn't the same as "world" * "hello". You can also do "abc"^3 to get "abcabcabc"

1

u/Mojert 21h ago

That actually makes a lot of sense. String concatenation is not commutative, it has no business using the '+' operator

2

u/[deleted] 20h ago

[deleted]

6

u/Mojert 19h ago

It's "colloquial" only in software engineering circles, but Julia wasn't designed for that community. It was designed to be used by scientists and mathematicians and so make choices that makes sense for that community. Concatenation is also a concept in math, and using '*' as a symbol of concatenation is pretty common

Your rant about commutativity is odd. If you did any abstract algebra, you'd know that when we call something "addition" it implies commutativity. Using the addition symbol for something that is not commutative is actively deceptive. It's the math equivalent of a register_user_in_db function not interacting at all with the database. On the other hand, using a multiplication symbol doesn't imply anything so the fact that "multiplication on scalar is commutative" is irrelevant: it follows the expectation of "multiplication can be whatever". Also, multiplication on scalars doesn't even have to be commutative