Live data from Hacker News

Python, as Reviewed by a C++ Programmer

sgh1.net

41–50 of 79 posts

Re: Python, as Reviewed by a C++ Programmer

#42

What is a "C++ programmer?" On any given day, I poop you not, I'm writing either c#, java, c++ or any number of scrpting languages (perl, bash, python, JavaScript). Do people seriously only use a single language these days!?

Why do you jump between multiple languages all the time?

Re: Python, as Reviewed by a C++ Programmer

#43
post #32

Earlier quoted context omitted.

Python is "pass reference by value", in C++ semantics.

Of course, because that is the only way to implement call by reference, i.e. to pass the reference as a value.

It's possible to pass a reference by reference.

Re: Python, as Reviewed by a C++ Programmer

#44
post #13

Earlier quoted context omitted.

No, no, no there is no "call by object." It is precisely this mistaken idea which muddies the waters, as you put it. Virtually all modern processors are stack-based architectures. All arguments to functions are passed on the stack or in registers. The only thing that can be placed onto the stack or into a register are numbers. Those numbers can represent either an actual value or an address in memory. The former is c…

In Java, this code will print the string representation of Lassie: Dog toby = new Dog("Toby"); public static void replaceDogWithToby ( Dog d ) { d = toby; } public static void main ( String[] args ) { Dog d = new Dog("Lassie"); replaceDogWithToby(d); System.out.println(d); } In Pascal, this will print Toby: var toby:tDog; procedure replaceDogWithToby ( var d:tDog ); begin d := toby; end; var lassie:tDog; begin {code…

I haven't done java in a long time so I won't try to debate the specific language level semantics with you (the same is true of pascal though it has been even longer), however assuming that your examples run and behave as you describe then what is going on in the java example is that 'Dog d' is passed as a reference to a reference, and then the value pointed to by the argument, i.e. the address of "toby," is replaced with the address of "lassie."

Re: Python, as Reviewed by a C++ Programmer

#45
post #42

What is a "C++ programmer?" On any given day, I poop you not, I'm writing either c#, java, c++ or any number of scrpting languages (perl, bash, python, JavaScript). Do people seriously only use a single language these days!?

Why do you jump between multiple languages all the time?

Not, OP, but I've worked for an ad-agency in a software-dev role.

Their primary code base is written in Java, monitoring scripts in Python/Ruby, and tracking pixel code in JavaScript, so I would have days in which I coded in all 3, albeit for separate use-cases.

Re: Python, as Reviewed by a C++ Programmer

#46

Earlier quoted context omitted.

There's a lot of people passionate about it because it's the first low-level language that's reasonably approachable to people who mostly code in Python/Ruby/etc - you rarely ever have to pull out a debugger, for example.

Haha, oh you definitely have to pull out the debugger. Rust doesn't save you from logic errors, control flow issues and ffi gone wrong. That said I get your point about using the debugger less .

Honestly, my programs tend to be simple enough that logic errors are reasonably rare, and the ones that do pop up can be resolved by println debugging. :)

Re: Python, as Reviewed by a C++ Programmer

#47
post #38
post #31

Earlier quoted context omitted.

In what way are they different?

In a classic call-by-reference, changes you make to the passed parameter are seen by the caller when the function returns. That doesn't happen consistently with Python.

I think you're just using "classic" to mean the behavior of languages like C++. Under the hood there are only two ways this mechanism can function, and I don't think it helps to mix high level language semantics in when trying to explain it, as those semantics are always expressed in one of those two ways.

Re: Python, as Reviewed by a C++ Programmer

#48
post #32

Earlier quoted context omitted.

Of course, because that is the only way to implement call by reference, i.e. to pass the reference as a value.

It's possible to pass a reference by reference.

In which case the argument is still a value, containing a pointer to a value, which is a pointer to the object.

Re: Python, as Reviewed by a C++ Programmer

#49
For what it's worth, python has been making inroads in the HPC world as well. In that context it seems like python is being used as the glue to tie highly optimized, custom written, C/C++ libraries together. http://lorenabarba.com/publications/ http://dl.acm.org/citation.cfm?id=3019084&CFID=927535872&CFT... http://dl.acm.org/citation.cfm?id=2830170&CFID=927535872&CFT...

It's happening enough that there has been a series of popular conferences for it, PyHPC http://www.dlr.de/sc/desktopdefault.aspx/tabid-11992/21071_r...

Re: Python, as Reviewed by a C++ Programmer

#50

What is a "C++ programmer?" On any given day, I poop you not, I'm writing either c#, java, c++ or any number of scrpting languages (perl, bash, python, JavaScript). Do people seriously only use a single language these days!?

Some people are far more specialized in what they work on.

- Apple's Swift codebase is 54.8% c++ [0]

- Microsoft's CNTK codebase is 57.6% c++ [1]

- Bitcoin's codebase is 68.6% c++[2]

- XBMC's codebase is 84.7% c++[3]

If you work on certain or specific types of projects, like ones making the tools that others use do their projects, then you are typically working more in only 1-2 languages at a time.

[0] https://github.com/apple/swift

[1] https://github.com/Microsoft/CNTK

[2] https://github.com/bitcoin/bitcoin

[3] https://github.com/xbmc/xbmc

Post reply on HN