
Python vs Julia Observations - Jcol1
https://medium.com/@Jernfrost/python-vs-julia-observations-e61ee667fa95#.1et1xs4dr
======
dalke
Many of the comments concern bpython. I believe may more people work with
IPython/Jupyter for this sort of thing. I wonder if this would have improved
things for the author.

> I have to know empty collections in python are false: ... That fits poorly
> Zen of Python:

I disagree. I found that code to be completely Pythonic.

> In Julia you can write e.g.: joinpath(homedir(), "bar", "foo") ; But there
> is no such natural extension in python

It's in Python 3.5:

    
    
      >>> from pathlib import Path
      >>> Path.home()
      PosixPath('/Users/dalke')
      >>> Path.home().joinpath("bar", "foo")
      PosixPath('/Users/dalke/bar/foo')
    

Yes, I quite dislike the location of "shutil.rmtree".

The author writes "I can run call command but that will not print result to
console." The subprocess.call() prints its results to my console, so I don't
know what is going on.

------
viraptor
Many of the points are based on personal taste. But others are just wrong /
misunderstood. Specifically:

> See how when you assign to a variable you don’t get to see the result.

Yes. Because assignment doesn't return any value in Python.

> Instead I have to know empty collections in python are false

No. There's always `len(collection) == 0` available.

> import os / Python had no idea what os was.

That's just some mistake the author made. Importing modules works just fine
and in many style guides it's preferred over importing specific
functions/classes.

> Instead we have to look at an entirely different module named shutil with
> the function rmtree.

This is exactly because of being explicit, like the author wanted Python to be
a few lines above. The `os` module maps pretty much exactly onto basic OS
operations. There's no rmtree, because it's not a basic mapping. It's a
complex procedure, so it's somewhere else (with other complex functions).

> Shell commands like cat are in my fingertips for such things.

This is not a feature of bpython as far as I understand. It's a feature of
ipython though. Just choose your repl.

> I run it like this: run(`codesign --verify $app`)

Whatever the language, this is a bad way to run external applications. What if
the `$app` contains spaces? Or hyphens? Or semicolons? Again, author approved
of the explicit approach in the same article, so they should just pass an
array of command and arguments instead.

> In contrast Python distinguishes the two with: ["codesign", "\--verify",
> app] "codesign --verify {}".format(app)

They're different things, and that's a good thing. If you want to print out a
list as if it was a single command, you can do `' '.join(the_list)`, but
without proper escaping, it's not always going to be correct.

> Here are some examples of what I do in Julia which does not require
> extensive libraries:

And I call BS at this point. If the author can do "Modifying and resigning iOS
apps." in Julia without extensive libraries, they should show that. Calling an
external command does not count.

~~~
dalke
> What if the `$app` contains spaces?

The author writes "Whether dealing with string literals or back-ticks for
expressing a command line, you can refer to a variable foo as $foo and it will
be escaped properly."

[http://docs.julialang.org/en/release-0.4/manual/running-
exte...](http://docs.julialang.org/en/release-0.4/manual/running-external-
programs/) confirms that `` has special escaping rules designed to prevent the
problems you pointed out.

> Or hyphens?

The interpretation of hyphens depends on the program being called, not the
shell. There is no automated way to escape them.

I agree with everything else you wrote.

~~~
viraptor
Ok, I'm impressed. That's actually a pretty cool solution that's missing in
every other backtick-enabled language I know.

------
trextrex
I haven't heard of bpython before, but I believe Jupyter/IPython is quite
popular, and now supports syntax highlighting too [1].

[1]
[http://blog.jupyter.org/2016/07/08/ipython-5-0-released/](http://blog.jupyter.org/2016/07/08/ipython-5-0-released/)

------
anst
As someone using (and loving) both Python and Julia, I found the title
overpromises and the content underdelivers. More accurate header would be
"Personal take on REPL/shell interactions in bpython and Julia".

~~~
whyrt12
What is your opinion on both languages?

~~~
anst
My take is from scientific computing perspective. But as my opinion isn't that
interesting, I take this opportunity to cite some julia-python-language-
relatedtopics on HN.

I'm still betting on Julia
[https://news.ycombinator.com/item?id=11516374](https://news.ycombinator.com/item?id=11516374)
and, since I do not use it for "production", I'm not giving up
[https://news.ycombinator.com/item?id=11692155](https://news.ycombinator.com/item?id=11692155)

That said, if it's all about speed, then Python can be, well, faster:
[https://news.ycombinator.com/item?id=10735840](https://news.ycombinator.com/item?id=10735840)
(especially so if you need BigInt, these still suck in Julia.)

Recently, discovered Go(language). Clean design rules!
[https://news.ycombinator.com/item?id=4158865](https://news.ycombinator.com/item?id=4158865),
(but you shouldn't take it for what it is not
[https://news.ycombinator.com/item?id=12330573](https://news.ycombinator.com/item?id=12330573))

------
kahrkunne
Wow, nice opinions!

