5 ms·
I am curious about what, specifically, you find easier to do in Java syntax than Python syntax. Seriously, there is a fairly direct translation from any Java y
by btilly 14y ago
I am curious about what, specifically, you find easier to do in Java syntax than Python syntax.
Seriously, there is a fairly direct translation from any Java you might want to write to completely equivalent Python. Sure, Python offers more complex techniques such as list comprehensions and iterators. But you don't need to use them. You can just write Java-like Python.
- mturmon 14y agoAnd, the OP says he wants to move away from Python to a C-like language for better arrays? It's a weird reason given that arrays are not that complex a data structure, plus the option of using numpy arrays, which are quite fast and capable.
- fusiongyro 14y agoInterfaces.
- slurgfest 14y agoThat is a noun. What is the actual use case?
- fusiongyro 14y agoIn context, the noun obviously refers to the Java interface syntax.
- pmiller2 14y agoAbstract base classes. See http://www.doughellmann.com/PyMOTW/abc/ http://www.doughellmann.com/PyMOTW/abc/
- fusiongyro 14y agoAbsent static type checking and manifest typing, abstract base classes do much less than Java interfaces.
- btilly 14y agoAh yes, the age-old static typing vs duck typing argument. Sure, in theory static typing can catch bugs. But doing it like Java does it is a lot of work per real bug actually caught.
- fusiongyro 14y agoWhether 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.)
- 14y ago
- tsahyt 14y agoThere's just no need for Interfaces when you have duck-typing at your disposal.
- fusiongyro 14y agoSee my remark below.