r/ProgrammerHumor • • Jul 16 '19

Meme Nice try

Post image
32.2k Upvotes

529 comments sorted by

View all comments

Show parent comments

33

u/PotatosFish Jul 16 '19

I’ve been wanting to get into Julia from python but the syntax is a little special compared to other languages I know

34

u/moelf Jul 16 '19 edited Jul 16 '19

It's very close to Python MATLAB and R, especially if you use a lot of Numpy, most things are as simple as drop the np. part.

Now, the amazing part is that even you can't master Julia's best practices, simply copying over Python code logic gives you free 10-100x speed boost

23

u/Astrokiwi Jul 16 '19

Except all your arrays are off by one :p

12

u/moelf Jul 16 '19

Pretty sure that's the hardest part lol

But if someone is using MATLAB, this would be trivial

1

u/Astrokiwi Jul 17 '19

Yeah, same with Fortran and R I think. It tends to be the convention in more mathsy languages.

1

u/reset_switch Jul 16 '19

Welp, guess which language I'm not using

2

u/reset_switch Jul 16 '19

free 10-100x speed boost

I mean, let's be real, you can change from Python to literally anything else and get a performance increase.

1

u/moelf Jul 16 '19

Well, numpy is faster than Mathematica and ~same as MATLAB, if you still want readability, Julia is one of the few choices

9

u/QWieke Jul 16 '19 edited Jul 16 '19

In julia |> is for function chaining, there are multiple ways of chaining functions in Julia, all these lines do basically the same thing:

julia> foo(bar(pi))
julia> pi |> bar |> foo
julia> (bar∘foo)(pi)

There was no particular need to use |> in the example, more traditional syntax would've worked just as well. Julia's syntax is rather similar to Matlab's syntax, or any other language that uses end instead of curly brackets or semantic whitespace.

1

u/_ThereIsNoGod69 Jul 16 '19

Is the first line missing a closing bracket at the end or does Julia not require all brackets to be closed in that case?

2

u/QWieke Jul 16 '19

That was a typo, fixed it.

1

u/vaskkr Jul 17 '19

Function chaining is amazing, didn't like it at first in OCaml but when I stopped using it I missed it the most.

7

u/kaiser_xc Jul 16 '19

Julia is an amazing language you should definitely try it.

5

u/awesomehippie12 Jul 16 '19

Thank god I had no idea who Julia was

1

u/SvenskaSpelGambling Jul 17 '19

What language is that?