3 ms·
Whether or not that's true, it is a concrete difference between Python and Java. Python is not a superset of Java.
by fusiongyro 14y ago
Whether or not that's true, it is a concrete difference between Python and Java. Python is not a superset of Java.
- btilly 14y agoI never claimed that the two were the same language. My claim was that you can take anything written in Java and pretty much directly translate it to Python. The fact that there are things Java will flag as errors that a Python translation does not, does not change this fact.
- fusiongyro 14y agoAs I said, you seem to be claiming that Python is a superset of Java, not equivalent to it, and that claim is manifestly false. Errors that are detected in one place and not in another are a manifest difference. Also, Java threads and anonymous classes do not translate directly to Python.
- btilly 14y agoPython has threads. In Python classes are first class objects, and you can easily do anything you could do with Java anonymous classes on the fly. Furthermore Java anonymous classes are usually used as a verbose replacement for a lack of closures. But in Python you can create closures and pass them around. (You do have to do some juggling to mutate variables, but 1 element arrays are only a slight pain to work with.)
- fusiongyro 14y agoYes, but again, there is no Python syntax for anonymous classes. That you can "easily do" something a different way is not proof that two things are the same, it's proof that they are in fact different. Which again, is my point. That Python has other, different features that can be used for other different effects just makes it that much more different. Python has green threads, but if you want concurrency, you have to resort to the process module. This is not a limitation Java's threading shares. I'm not arguing that Python is bad or inadequate, just that it is a fundamentally different thing and should not be viewed as a superset of Java.
- btilly 14y agoMy claim is that it is fairly easy to translate any Java program into an equivalent Python one. That some things need different constructs is not evidence against this claim.
- fusiongyro 14y agoYour claim is untrue, and that different constructs are needed is evidence. It is often easy, but that isn't guaranteed.
- emidln 14y agoI'm not saying you should do this, but you can have an anonymous class like this: type('', (dict,), {'__init__': lambda self, *args, **kwargs: not super(self.__class__,self).__init__(*args, **kwargs) and setattr(self,'__dict__',self)}) Python easily allows multiple threads to exist at once. The only reason they don't run at the same time is an implementation detail of the most common Python implementation. Python running on the CLR, the JVM, and extensions for both CPython and PyPy show that you can run multiple threads concurrently if you really want to.