News for hackers. Stuff that matters.
Re:Why People Should Learn Python by hacker_9 on Wednesday August 24, 2016 @05:11AM (#12350697)
Why you shouldn't learn Python:

1. In-consistant syntax.

2. The language uses exceptions to control flow of logic.

3. Divided community, since Python 3+ included breaking changes to the standard.

4. Un-discoverable APIs. You better hope the documentation is bulletproof else the API could change in any which way during runtime.

5. Poor error messages. If an import goes wrong you are not told why, and so on.

6. Ultimately slow performance for anything marginally complex.

7. Poor tooling.

Re:Why People Should Learn Python by wiz21c on Wednesday August 24, 2016 @05:47AM (#12350798)
1. a matter of tast

2. care to elaborate ?

3. it's not divided, it's evolving from 2 to 3. Java's community is under Oracle's grip, don't know if it's any better...

4. it's not because you can do it that it's worth to do it, so in practice API are just not changing at runtime

5. I can say the same of my industrial strength Java environment...

6. Not a problem since what you do doesn't require speed

7. Ever used PyCharm ? I wouldn't say it's poor tooling. The debugger is fine. What I miss is something like a good profiler to look at running code.

But I'd say :

8. Optional typing should've been there from day one, it'd made code editor, tooling better

9. The date/time handling is not good

10. SOA support is weak (and in the kind of setting I am, we use tons of XSD, WSDL, XML, security, signature you name it)

Re:Why People Should Learn Python by mertd on Wednesday August 24, 2016 @07:02AM (#12351091)
#2 is because it is more "pythonic" to ask for forgiveness than permission (EAFP).

For example, rather than checking if a dictionary has an element before accessing it, you just try to access it and handle the KeyError if it doesn't. The code reads easier and the normal flow would be faster in this case.

When used in EAFP context only, I think it is fine to use exceptions as part of logic in Python. They are relatively less costly compared to C.

Re:Why People Should Learn Python by kirkdouglas on Wednesday August 24, 2016 @05:59AM (#12350847)
> What I miss is something like a good profiler to look at running code.

vprof is quite nice: https://github.com/nvdv/vprof

Re:Why People Should Learn Python by nhumrich on Wednesday August 24, 2016 @09:32AM (#12351844)
PyCharm comes with cProfile and let's you "run with Profiler". But maybe that's only the paid version.
Re:Why People Should Learn Python by dagw on Wednesday August 24, 2016 @09:34AM (#12351861)
Yup. The integrated profiler is only in the paid version
Re:Why People Should Learn Python by typon on Wednesday August 24, 2016 @08:10AM (#12351400)
Reasons to learn Python:

Sklearn, tensorflow, pandas, Sqlalchemy, requests, Beautifulsoup, numpy, scipy, pulp.

If you have a language that had equivalent libraries that cover all these domains I'd love to hear it. Until then I can build really cool stuff in Python very easily thanks to the amazing hardwork and generosity of these library creators.

Re:Why People Should Learn Python by gone35 on Wednesday August 24, 2016 @10:36AM (#12352344)
If you have a language that had equivalent libraries that cover all these domains I'd love to hear it.

R[1].

[1] https://cran.r-project.org/

Re:Why People Should Learn Python by 0xCMP on Wednesday August 24, 2016 @12:06PM (#12353010)
Okay, but I'm not sure they wanted to go from python to R. The issues listed in the original post are definitely not fixed in R. And you lose out on python's ability to also be used for other things.
Re:Why People Should Learn Python by typon on Wednesday August 24, 2016 @02:10PM (#12354007)
The problems people have with Python are magnified at least 10x on R.
Re:Why People Should Learn Python by omginternets on Thursday August 25, 2016 @12:12PM (#12360197)
You can't possibly claim that the R language is better-designed that python...
Re:Why People Should Learn Python by neurostimulant on Wednesday August 24, 2016 @09:58AM (#12352034)
Yup. For engineering and data science Python seems to be the best choice right now.
Re:Why People Should Learn Python by foxylad on Wednesday August 24, 2016 @06:25AM (#12350955)
> 4. Un-discoverable APIs...

One of the main reasons I like python is that it is the most self-documenting language I've come across. Say what you like about significant whitespace, but in my last job I used to show salespeople snippets of code and they understood them - with no knowledge of the language.

Re:Why People Should Learn Python by icc97 on Wednesday August 24, 2016 @07:02AM (#12351090)
I agree that the code does document itself well. The biggest problem I have is the docstrings [1] which I find quite weird and find the Javadoc style comments much more readable.

  [1]: https://www.python.org/dev/peps/pep-0257/
Re:Why People Should Learn Python by Rotareti on Wednesday August 24, 2016 @06:15AM (#12350922)
>3. Divided community, since Python 3+ included breaking changes to the standard.

I'm using Python since about half a year and for all I did this wasn't an issue. I just started with 3 and had the feeling everything around me was 3 as well. 3 was released in '08.

Re:Why People Should Learn Python by yoz-y on Wednesday August 24, 2016 @08:36AM (#12351532)
We are hitting the 2/3 divide constantly. In our software we try to support both (for plugins). But it is a mess especially if you want to load interpreters to both at the same time. It is also near impossible to make somebody update from 2 to 3 in the scientific community.
Re:Why People Should Learn Python by freehunter on Wednesday August 24, 2016 @07:32AM (#12351233)
Unless you want to follow a tutorial or use a library. Most are up to 3 now, but not all. And especially with tutorials, the older ones don't always say.
Re:Why People Should Learn Python by lcnmrn on Wednesday August 24, 2016 @05:22AM (#12350735)
Name a single language that covers all those things and has a pretty syntax.
Re:Why People Should Learn Python by lmm on Wednesday August 24, 2016 @10:37AM (#12352353)
Scala. (Which is why I use it)
Re:Why People Should Learn Python by ben_jones on Wednesday August 24, 2016 @05:32AM (#12350762)
01000010 01101001 01101110 01100001 01110010 01111001 00111111 00001101 00001010?
Re:Why People Should Learn Python by jeffwass on Wednesday August 24, 2016 @05:57AM (#12350833)
You had me until the CR LF, but clearly the true hacker's choice is just the LF. <ducks>
Re:Why People Should Learn Python by dpatru on Wednesday August 24, 2016 @05:51AM (#12350812)
Binary?
Re:Why People Should Learn Python by omginternets on Thursday August 25, 2016 @12:13PM (#12360209)
1
Re:Why People Should Learn Python by dalke on Wednesday August 24, 2016 @06:55AM (#12351060)
10010 10202 11020 11002 10121 11020 11111 01020 00101
Re:Why People Should Learn Python by enrmarc on Wednesday August 24, 2016 @07:36AM (#12351249)
IMHO Ruby is a good candidate.
Re:Why People Should Learn Python by pthreadses on Wednesday August 24, 2016 @08:18AM (#12351442)
Weird, I actually consider Pythons consistency in syntax to be a positive. And it's continually becoming more so.
Re:Why People Should Learn Python by sedeki on Wednesday August 24, 2016 @06:00AM (#12350851)
What do you mean by inconsistent syntax?
Re:Why People Should Learn Python by enrmarc on Wednesday August 24, 2016 @07:37AM (#12351257)
Why does Python use methods for some functionality (e.g. list.index()) but functions for other (e.g. len(list))?

http://effbot.org/pyfaq/why-does-python-use-methods-for-some...

I guess is that.

Re:Why People Should Learn Python by curiousssly on Wednesday August 24, 2016 @06:46AM (#12351028)
Collection library has:

  deque

  defaultdict

  Counter
After many years I often write DefaultDict myself.

Edit: formatting

Re:Why People Should Learn Python by pjc50 on Wednesday August 24, 2016 @05:35AM (#12350767)
8. Significant whitespace. Not only is it a constant minor inconvenience when editing the program, it makes it very hard to cut-and-paste code fragments on the web.
Re:Why People Should Learn Python by rglullis on Wednesday August 24, 2016 @05:45AM (#12350794)
"Making it hard to copy-paste code from the web" is something that I would consider a feature, to be honest.
Re:Why People Should Learn Python by dalke on Wednesday August 24, 2016 @07:00AM (#12351082)
Some similar failure cases are: 1) when I make a presentation using Keynote, it drops the leading spaces when it exports to PDF, so my students can't simply copy/paste my example code. 2) the interpretation of blank lines with no indentation on the repl means "end of current code", which is different than in a .py file. This means if I copy&paste from my in-development code to the repl, I can get syntax error unless I carefully ensure that all blank lines inside of indented code blocks are also indented.
Re:Why People Should Learn Python by rglullis on Wednesday August 24, 2016 @07:06AM (#12351108)
For (2), ipython and %cpaste are your friends.
Re:Why People Should Learn Python by dTal on Wednesday August 24, 2016 @08:18AM (#12351440)
I've never understood this complaint. Whitespace is included when you copy something. What's the problem?

Admittedly it is mildly annoying when someone decides to use some random number of spaces for indentation, and you have to fix it to make it match the rest of your code (my preferred editor, Geany, has a feature for this). We should all just use tabs. But "very hard"?

Re:Why People Should Learn Python by yoz-y on Wednesday August 24, 2016 @08:34AM (#12351519)
The web collapses whitespace so if the code is not in <pre> tags you are stuck. This is quite often a case where comment systems were not intended to share code.
Re:Why People Should Learn Python by dTal on Wednesday August 24, 2016 @09:12AM (#12351727)
You're right, of course, this does often happen. Seems to me, though, the issue isn't cutting and pasting something on the web - it's getting it losslessly onto the web in the first place. It's the responsibility of the person posting the snippet to ensure it shows up correctly, and if their chosen platform doesn't support that they should use a better one.

This probably reads pedantically, but I do think there's a distinction. By analogy, if someone tried to post APL on a site that didn't support Unicode, you wouldn't say the issue is it's "hard to cut and paste APL".

Re:Why People Should Learn Python by pjc50 on Wednesday August 24, 2016 @09:15AM (#12351742)
Yes I would. Requiring a character set outside of ASCII is what I'd call a high-risk design decision, that could easily become a misfeature of a language. Windows "smart quotes" are bad enough and that's not even a programming language. This is why people invented J as an alternative to APL.
Re:Why People Should Learn Python by dTal on Wednesday August 24, 2016 @10:48AM (#12352410)
Would you say it's "hard to copy and paste Unicode"?
Re:Why People Should Learn Python by pjc50 on Wednesday August 24, 2016 @11:46AM (#12352858)
Most systems support UTF-8, so most of the problems have been solved by now. There's still a lot of scope for malicious or very surprising unicode; invisible characters or modifiers, font problems, RTL/LTR, characters which have different code points but cannot necessarily be visually distinguished ("ı = 1" etc), good old Zalgo, and so on.
Re:Why People Should Learn Python by ramblenode on Wednesday August 24, 2016 @09:37AM (#12351879)
It's Python's fault for not retrofitting its syntax to satisfy a markup language invented years later?
Re:Why People Should Learn Python by yoz-y on Wednesday August 24, 2016 @10:59AM (#12352501)
No, but it is a problem that people encounter nevertheless.
Re:Why People Should Learn Python by runako on Wednesday August 24, 2016 @09:45AM (#12351918)
> Whitespace is included when you copy something. What's the problem?

In addition to the points posted in a parallel thread, selecting and copying leading whitespace reliably is more difficult than just getting the printable characters. Also: it's not something that anyone has any cause to do outside of copying Python text.

Re:Why People Should Learn Python by tummybug on Wednesday August 24, 2016 @05:57PM (#12355586)
Any editor with multiline support makes this problem go away (vim, sublime)
Re:Why People Should Learn Python by didymospl on Wednesday August 24, 2016 @06:47AM (#12351032)
8. Global Interpreter Lock in CPython
Re:Why People Should Learn Python by verbatim on Wednesday August 24, 2016 @07:26AM (#12351205)
This isn't an issue with the language, it's an issue with the common implementation of the language. It will be remedied by either fixing CPython, or by switching to a different implementation.

(If neither happens, then I guess it isn't really a problem.)

Re:Why People Should Learn Python by didymospl on Wednesday August 24, 2016 @01:09PM (#12353520)
I wrote explicitly that this is a problem with CPython. I totally agree that this is not the problem of the language itself. Neither are the most of the points from the parent post(tooling, community, performance, error messages). Yet all that still greatly affects your experience with the language. Same applies to the default implementation. I think you would agree if I said that Sun(Oracle) JVM played an important role in Java adoption, wouldn't you? Unfortunately, it's not so easy to just switch to some other implementation of Python: PyPy uses GIL as well, IronPython and Jython don't but they are years behind the current version of the language. GIL is not a problem when you use libraries that handle concurrency natively(e.g. NumPy) but when you try to parallelize some computationally intensive algorithm written in Python you're probably going to hit the wall. I love Python but it's really not a one-size-fits-all tool.
Re:Why People Should Learn Python by whyever on Wednesday August 24, 2016 @08:34AM (#12351525)
> This isn't an issue with the language, it's an issue with the common implementation of the language.

There is no formal definition of the language. It is defined by the C implementation. So I'm not sure how meaningful that distinction is.

> If neither happens, then I guess it isn't really a problem.

Or people give up on Python and use another language.

Re:Why People Should Learn Python by dalke on Wednesday August 24, 2016 @11:11AM (#12352598)
Python is not defined by its C implementation. For example, Python-the-language does not require reference counting even though CPython uses that.

The real-world distinction between the Python specification and its implementation started in the late 1990s, with JPython (now Jython).