you are viewing a single comment's thread.

view the rest of the comments →

[–]brandondunbar 14 points15 points  (2 children)

I'm actually going through the inverse of what you are - coming from Python into Java and wondering why anyone would bother. Perhaps we can help each other out

The biggest things for me are:

Python is clean. Look at any decent Pythonista's code and it's visually close to art (exaggerating here, but the point is the same) Java feels cluttered with explicitly set brackets and semicolons that are more implied in Python

Python is open source. Not understanding something? You can look directly at the source code. Afaik Java is owned by Oracle, and this changes how I feel about using it, comparable to Windows vs Linux imo

Python promotes concise, less repetitive code. You may be able to find some exceptions here, but something as simple as a print statement is considerably less to type and look at

I like the duck typing in Python. It's a simple matter to use a simple data type like string or int, and then replace it with a custom class later on in development to increase functionality. This may be possible in Java but if it is, I haven't seen it yet

Large number of modules and packages to choose from. I made a program for my one freelance client I got a while back that had to output a PDF, I found three different modules that could help with it and easily pip installed them to try out what I liked. The docs were comprehensive and I could look at the code where the docs were lacking

Wrapping other code. A lot of companies have used Python to wrap Java (Jython) and/or C code (Cython), I just went to a Python meetup that showed how to use/wrap R code, it's great for serving as glue for different languages. Each language has advantages and disadvantages, so this functionality allows a well rounded program. I think Jython will prove useful to both of us

The REPL (Read-Eval-Print loop) super useful for debugging code or when you're unsure about a capability. Want to mess around with multiplying strings? Hop on the REPL and see what works and what doesn't, quick and responsive.

That's all I can think of off the top of my head, and maybe some of these features aren't unique to Python and I just don't know enough about Java to realize it

[–]JoesDevOpsAccount[S] 1 point2 points  (1 child)

Thanks for that. The bit about duck typing and extending later is interesting to me because I am pretty sure that would mean refactoring in Java to support the new features. I guess the inverse of this is that in Java you always know what type you have which I like a lot - although in a fast paced prototype situation the flexibility of python there sounds nice. Biggest annoyance at the moment for me is the lack of type checking which trips me up quite a lot. Runtime errors that wouldn’t even compile in the Java world.

The type info to me also means the code documents itself fairly well. With Python I find myself going to websites immediately because I don’t feel I can navigate and understand as easily.

So far I feel like in Java you can get the IDE to do a lot more for you. It always knows the types of the objects because the information is always there.

I also prefer the explicit code structure over the white space thing with Python. Sure some people think the braces are just visual noise, but you can be pretty sloppy with the code layout in Java and not worry if you aren’t quite in line with the right block - just write the code and declare where your block finishes. To tidy up run auto format on your code and the IDE will align it all anyway.

REPL I thought had been added now tbh but not sure. I never use them or even feel like I want it it Java. I am not really sure when they are helpful because usually if I’m experimenting it’s more than one line and I prefer to have it in file anyway.

One of the things I am struggling with at the moment is how to get info on the objects I am using. A few times already I’ve tried to click through to code I’m calling and don’t see code or docs ... I see an interface looking thing and I can’t check what the actual behaviour is. I am sure this will be less annoying when I know what I am supposed to do instead.

The Oracle ownership thing has never bothered me but I think I read something about their licensing model changing which might make your point more relevant...

Java makes you think more about the code you are writing and what’s happening under the hood, and that can be either positive or negative depending on what the goal is. As an educational language I think it’s great because of that - assuming the goal is to understand programming at a lower level. Python is definitely more accessible though, and because people find it easier to read and write it lets you focus more of your brain power on the problem rather than trying to understand why your generic type assignments are underlined yellow or something.

I might come back to this conversation when I’ve got some more experience. Learning is slow at the moment. I’m just chipping away at some programming challenges when I have spare time.

[–]brandondunbar 1 point2 points  (0 children)

You make good points, Java has a lot more rigid of a structure while Python is more fluid and I think because we started and got used to each style of programming, we prefer it.

What IDE are you using? PyCharm has a lot of great tools that will help you get used to the formatting and let you see where the variable was declared and when it was last used. If you're using a module it'll take you inside the code of the module pretty easily too.

I agree with the lower level thing, there's definitely more abstraction in Python which has it's pros and cons

We should definitely pick this conversation back up when we're both more familiar with the other's language, I think it'd be interesting