Live data from Hacker News

Python has brought computer programming to a vast new audience

economist.com

11–20 of 268 posts

Re: Python has brought computer programming to a vast new audience

#12
For me it's somewhat strange that it is universally presented as a beginner's language. Python would be hugely confusing to me if I didn't keep the underlying C model -- dynamically allocated objects with reference counts -- in mind at all time. Together with a lot of protocol that is largely arbitrary.

Re: Python has brought computer programming to a vast new audience

#13
post #6

Earlier quoted context omitted.

True, but for me that python was my 4th CL (after fortran, c, c++), there were lots of gotchas, specially with implicit type conversions, mutable classes, and passing by value / reference which all seemed quite arbitrary in my first steps. Maybe for a complete beginner these are no-issues.

Can you explain implicit type conversions problems in python?

It is not a problem, it was just non expected behavior for someone trained in strong typed languages.

For example, you want to calculate the performance of your ML algorithm by counting the correct predictions / total. My expectation was that the result of a division of integers, would be a float, specially if the modulo is not 0.

Re: Python has brought computer programming to a vast new audience

#15
Python is a great language to start programming in. My biggest frustration with traditional programming languages (well, C/Java mostly) was just how much upfront effort and understand is required to do useful stuff. Whereas with python it is pretty easy to whip up a script, read input and transform it into output in real time etc.

That said, I think its also important for Python programmers to dabble at least a little bit with Java to really understand how OOP works. Python does have OOP but it has certain quirks which can confuse newcomers. Java helped to clarify my understanding of OOP a lot, even though I've only used it marginally.

Re: Python has brought computer programming to a vast new audience

#16
post #6

Earlier quoted context omitted.

True, but for me that python was my 4th CL (after fortran, c, c++), there were lots of gotchas, specially with implicit type conversions, mutable classes, and passing by value / reference which all seemed quite arbitrary in my first steps. Maybe for a complete beginner these are no-issues.

Can you explain implicit type conversions problems in python?

bools can be silently converted to int. 1 + true is ok, but 1 + "true" throws.

Sometimes you do want to do math on bools, but it would avoid a class of errors if they would make you wrap them in 'int(the_boolean_variable)'.

Re: Python has brought computer programming to a vast new audience

#17

For me it's somewhat strange that it is universally presented as a beginner's language. Python would be hugely confusing to me if I didn't keep the underlying C model -- dynamically allocated objects with reference counts -- in mind at all time. Together with a lot of protocol that is largely arbitrary.

I've met a lot of people who have programmed simple things in python without understanding the memory model at all so for most people it doesn't seem to be a large impediment.

Re: Python has brought computer programming to a vast new audience

#18
post #6

Earlier quoted context omitted.

True, but for me that python was my 4th CL (after fortran, c, c++), there were lots of gotchas, specially with implicit type conversions, mutable classes, and passing by value / reference which all seemed quite arbitrary in my first steps. Maybe for a complete beginner these are no-issues.

Can you explain implicit type conversions problems in python?

Implicit string and unicode conversions were confusing in Python 2.

True + True evaluates to 2, although that is technically not a type conversion.

Re: Python has brought computer programming to a vast new audience

#19
post #6

Earlier quoted context omitted.

Can you explain implicit type conversions problems in python?

It is not a problem, it was just non expected behavior for someone trained in strong typed languages. For example, you want to calculate the performance of your ML algorithm by counting the correct predictions / total. My expectation was that the result of a division of integers, would be a float, specially if the modulo is not 0.

The division operator was one of the things that changed in Python3. In Python2 the (/) with integer arguments is integer division, rounded down. Python3 introduced (//) for integer division and now (/) always does floating-point division.

Re: Python has brought computer programming to a vast new audience

#20
post #6

Earlier quoted context omitted.

Can you explain implicit type conversions problems in python?

It is not a problem, it was just non expected behavior for someone trained in strong typed languages. For example, you want to calculate the performance of your ML algorithm by counting the correct predictions / total. My expectation was that the result of a division of integers, would be a float, specially if the modulo is not 0.

That's how it is in python 3.
Post reply on HN