News for hackers. Stuff that matters.
Re:Python Is Eating the World by sreque on Monday August 12, 2019 @11:36AM (#20676381)
I still don't think you quite understand what's going on here. Python wouldn't create a new variable in this case. I It would re-assign the value represented by the variable you already assigned once. I agree that it would have been better if Python had explicit variable declarations (this is one of the few things I think Perl got right.).

On the other hand, Ruby made this same mistake. If you wrote this code in Javascript you wouldn't get an error, but you would in fact have two different variables.

For instance, this code runs for me using node 8:

  var fun = (bool) => {
    var x = 1;
    if (bool) {
        var x = 2;
        x += 1;
    } else {
       x += 1;
    }
    console.log("x=" + x);
  }

  fun(1);
  fun(0);
Re:Python Is Eating the World by winstonewert on Monday August 12, 2019 @11:43AM (#20676455)
> I still don't think you quite understand what's going on here. Python wouldn't create a new variable in this case. I It would re-assign the value represented by the variable you already assigned once.

Uh. no. he typoed the reassignment, so it wouldn't re-assign the value.

> So, of three of the most popular dynamic languages, Python, Ruby, and Javascript, none of them would have helped you catch this kind of error at script-parsing time. So again, it seems like you have an irrational dislike for Python, all things considered.

Sure, but he's made it clear he likes Java. Fundamentally he's against dynamic typing, so of course he doesn't like any of the dynamic languages.

Re:Python Is Eating the World by sreque on Monday August 12, 2019 @11:51AM (#20676544)
Ah my bad. I think I would have understood it more if he included the typo in his example.
Re:Python Is Eating the World by winstonewert on Monday August 12, 2019 @11:52AM (#20676553)
He did. But that just illustrates why this kind of bug is so annoying, its hard to spot.
Re:Python Is Eating the World by CydeWeys on Monday August 12, 2019 @11:42AM (#20676449)
I don't understand why you're accusing me of being irrational. These seem like very rational problems to have with Python. They literally caused me bugs that cost me time to deal with that I wouldn't have faced in other languages.

You're also assuming that I don't have the same problems with Ruby or JavaScript. I do. The exact same critique could be made of them as well, but they're not the subject of this thread; Python is.

Re:Python Is Eating the World by rohan1024 on Monday August 12, 2019 @12:01PM (#20676656)
You can't argue with someone who has chosen to overlook your viewpoint.

I've ran into the same issues while writing python code. People who are newly picking up python are especially prone to these kind of bugs. Also, with python I have to spend lot of time to figure out what went wrong in my code as compared to other languages.

People who have been using python for long have wired there brain to avoid such pitfalls and now they happily defend it.

Re:Python Is Eating the World by sreque on Monday August 12, 2019 @12:09PM (#20676742)
I don't think what you're saying is true. I already said I think it would have been better if Python and Ruby had explicit variable declarations. But, if this is your biggest issue with a language and it's ecosystem, then IMO that language is doing pretty well. I would rather, for instance, have to deal with implicit variable declarations in Python that the gigantic mess of Java frameworks that have been invented to "reduce boilerplate", such as Spring/Guice, AspectJ, Hibernate, etc.
Re:Python Is Eating the World by sreque on Monday August 12, 2019 @11:50AM (#20676538)
My bad. I didn't realize you were against all dynamic languages in particular. FWIW I prefer Java and static types as well, but as far as scripting languages go, I think Python is pretty great.