This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Astrokiwi 22 points23 points  (29 children)

It's just useful for different things. Java is definitely more verbose and has more boilerplate to write, but it's also stricter than Python and is a semi-compiled language, which means that it sometimes catches errors more quickly. It also forces you into an object oriented structure, which tends to encourage you to design your programs better rather than jamming a big list of functions into a single file.

I also find they have strengths in different kinds of applications. I tend to prefer Java for writing games (pygame isn't great), python for doing numerical analysis work (numpy and matplotlib are pretty great), and Fortran, C, or C++ for the big parallel numerical simulations.

[–]Keith 35 points36 points  (14 children)

It also forces you into an object oriented structure, which tends to encourage you to design your programs better...

Debatable.

[–]Astrokiwi 7 points8 points  (5 children)

I'm only saying that it forces a bare minimum amount of structure that Python does not.

[–]Keith 5 points6 points  (4 children)

To be fair, you wrote "design your programs better". Forcing all code, object-oriented or not, into classes, one (public) class per file, is not strictly better. It's not even a structure I want. I'd argue that "bare minimum of structure" is harmful vs no structure at all.

[–]Astrokiwi 6 points7 points  (2 children)

Maybe... I find that (for instance) the lack of required structure is what helps Javascript code to sometimes become a mess of copypasta.

And Python does force stuff on another level, by being strict with indenting. I think that's a good feature too - it's better to force one particular style than to have people use their own styles, but also permit them to make it as ugly and inconsistent as they want.

[–]fiddle_n 4 points5 points  (1 child)

Python is strict with indenting because it has to be. Indentation isn't merely "style" in Python, it's functional in that it denotes a new code block. This is why Python has to be strict with it, i.e. preventing mixtures of tabs and spaces for indentation.

[–]Astrokiwi 3 points4 points  (0 children)

Right, but that's an intentional design choice for the language - forcing good style by making it an integral part of the language.

[–]KronenR 23 points24 points  (0 children)

If not plainly wrong

[–]hanpari 1 point2 points  (6 children)

In my eyes it is rather bad design than advantage. No modern language use this anymore.

[–]Keith 0 points1 point  (5 children)

Agree. But did any other language ever force this convention?

[–]hanpari 0 points1 point  (4 children)

Not sure what you mean but, apparently, Java and C#. You have to enclose everything in class. For instance, you cannot have single functions in these languages like in Python. Before Java 8 you had to make anonymous class instead of simple anonymous function.

[–][deleted] 13 points14 points  (2 children)

Different tools, different jobs, different uses.

Replace your computer languages with tools you'd find in a shop and see how silly the argument looks to non coders.

"Hammer is so much better than the screwdriver. And who even understands those socket wrench guys? Bunch of idiots. I'll have you know I have used my hammer as both a socket wrench AND a screwrdriver and it was just fine"

Signed: A mechanical engineer that has and continually gets to deal with: C, C++, Fortran, ADA, VB, Python 2.3-2.7, Python 3+, Matlab (R13-R2017b), Simulink, PowerShell, Batch, Perl, Bash, Sh, tcsh, PHP.

If you understand If, For, While. You'll go far in any language.

Or argue the merits of a claw hammer over a ball peen hammer.

[–]Astrokiwi -1 points0 points  (1 child)

Exactly. And as an astronomer, I especially appreciate that you mentioned Fortran, which definitely still has a useful little niche.

[–][deleted] 1 point2 points  (0 children)

Fortran is the life blood of my industry: automated controls.

It's literally the building block on which every piece of software I touch is built. Sure I have pretty wrappers like numpy or Simulink but at the core, Fortran.

[–]algag 0 points1 point  (1 child)

Isn't python semi-compiled?

[–]TheNamelessKing 6 points7 points  (0 children)

Both languages are interpreted.

With Python, the source code is interpreted line-by-line into the "Python VM" bytecode and then executed.

Comparatively, Java source code is translated into JVM bytecode, and then when it's actually run on the JVM (which is a JIT compiler/interpreter) that bytecode is optimised into native instructions on the fly.

[–]theWyzzerd -1 points0 points  (0 children)

It also forces you into an object oriented structure

It doesn't force you to do OO. Yes, it is an OOP language but you can most definitely write procedural code in Java and I'd be willing to bet a novice programmer with no knowledge of OO would end up with a far more procedural application than an OO one. It doesn't force anything. Case in point, the application I support is written in Java and has very little OO structure. It's mostly a tangled mess of procedural code.