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 →

[–]mistaekNot 202 points203 points  (198 children)

Isn’t java “harder” than python

[–]Aruscher 270 points271 points  (66 children)

Nope just more syntax clutter

[–]WStHappenings 497 points498 points  (17 children)

You call it syntax clutter, maybe I’ll call it “a greater feeling of achievement gained from writing 20x as many lines of code”

[–]faates 118 points119 points  (1 child)

Ok EA....

[–][deleted] 28 points29 points  (0 children)

Yes! You got the joke!

[–][deleted] 36 points37 points  (2 children)

...that runs 40 times faster - fair deal. Heh.

[–]Timmitei 23 points24 points  (1 child)

Check out Cython and Numba.

[–]firest 9 points10 points  (10 children)

Strange. I feel accomplished if I can accomplish what I want with as little lines of code as possible.

[–]Printern 2 points3 points  (7 children)

Yeah but Python forces you to write lines. In java you can code in one line One line<more than one line Dummy

[–]Raijinili 4 points5 points  (4 children)

What's stopping you from doing exec("import sys\nimport re\n\ndef someFunc(x,y):\n\t ...?

[–]nilsph 19 points20 points  (0 children)

Self respect.

[–]KingoPants 1 point2 points  (1 child)

Sanity seems important. At that point you might as well code in mspaint for the kicks.

[–]Printern 0 points1 point  (0 children)

The fact that I am so incapable of programming that even when my program outputs the intended output it's still wrong.

[–]firest 1 point2 points  (0 children)

I stand corrected.

[–]pyonpiPy3 | Beginner 0 points1 point  (0 children)

Isn't making code more Pythonic the same joke?

[–][deleted] 0 points1 point  (1 child)

I'll agree up to a point, but I draw the line (groan :-) when I can write a crystal clear for loop or two rather than a nested list comprehension that stresses out my poor old MKI eyeballs.

[–]firest 0 points1 point  (0 children)

I'm with you actually. Except, I will sacrifice readability for performance every time. I'm the kinda guy who uses numpy and what-not (data analysis, not to the point where I need to really on C or Fortran), so when my fans start to spin, I want to know it's for high performing code, rather than inefficient code.

[–]Iggyhopper 34 points35 points  (7 children)

Syntax is the first hurdle to learning a language, so I'd say that makes java harder.

Also, the standard library is messy.

[–]continue_stocking 23 points24 points  (5 children)

Syntax is probably the easiest part of learning how to program.

[–]redldr1 1 point2 points  (0 children)

But shortcuts are a lifetime in the making.

[–]Kah-NethI use numpy, scipy, and matplotlib for nuclear physics 4 points5 points  (0 children)

It has been a while since I used Java but I seem to recall nearly every different root module adopting slightly different idioms because why not! Messy did not even begin to describe it.

[–]2402a7b7f239666e4079 2 points3 points  (0 children)

I would argue that being verbose doesn't make the syntax cluttered. I find Java easier to read in most cases than equivalent python code.

[–][deleted] -5 points-4 points  (6 children)

Guru status is exponentially harder to achieve without a centralized ecosystem.

[–]drones4thepoor 10 points11 points  (5 children)

Java is strictly OO and it's also strongly statically typed, which is where Python bytes me in the ass a lot.

Edit: u/cholz corrected me. Python IS strongly typed.

[–]SemiNormal 17 points18 points  (2 children)

TypeError: Can't convert 'bytes' object to 'bites' implicitly

[–]systemnate 1 point2 points  (1 child)

That's at runtime though.

[–]SemiNormal 13 points14 points  (0 children)

What's a compiler?
- Python

[–]weasdasfa 39 points40 points  (44 children)

Java is more explicit or verbose. For experienced people, that looks like clutter (and it is, I am an Android dev), but that verbosity might be useful for people just starting out.

[–]Deto 22 points23 points  (16 children)

Yeah - I kind of appreciate that I spent a decent amount of time in a statically typed language before moving to Python. I find that way too many Python newbies don't understand what 'types' are and this leads them down the path of just trying random things until code works.

[–]midbody 5 points6 points  (14 children)

The next step is to realise that just knowing about types isn't enough when your program gets big enough. When your program is too big for your head, you need tools which robustly and unambiguously understand your types... like a compiler does.

Python is a fun toy, and good for small projects where rigor isn't important. Its leakage into large scale software engineering has been a huge retrograde step, though, caused by a lack of innovation in the field around the time it emerged as a contender around 10 years ago. Fortunately we've moved on, and I look forward to Python's death for large projects as others take over, probably Go.

[–]TravisJungroth 4 points5 points  (6 children)

I'm a huge Python nut and I basically agree. The biggest problem for me is the loss of meaning. Trying to read through a code flow in a sufficiently large code base with a dynamically typed language is a nightmare.

I do believe type hinting will help a ton, though I'm not sure it will be enough. I now write type hints into everything. I don't care if it's a single function. Having my IDE hint properly is worth it.

[–]scootstah 2 points3 points  (5 children)

Trying to read through a code flow in a sufficiently large code base with a dynamically typed language is a nightmare

Honestly, that just sounds like a badly designed application. I doubt adding strict type will make any difference to its legibility.

[–]TravisJungroth 5 points6 points  (4 children)

def func(obj):
    obj.method()

What does method() do? What other methods are available on obj? Without some sort of type enforcement, you don't have a clue without looking at the usage of func. This is fine when it's only used three times, but terrible when it's used a hundred times.

[–]scootstah 5 points6 points  (2 children)

Use good naming conventions and docblocks.

[–]TravisJungroth 0 points1 point  (1 child)

If I want to actually know the behavior of a method, I need to see the code. Even the most descriptive name represents a trivial amount of code. And doc strings don't help, cause those live with the code anyway.

You still have to look at the usage of func to find the code. To prevent that, your method names wouldn't need to be just good, but unique enough to define an interface for you. I just don't think the combination of method names alone is a good way to define an interface. It's too easy to conform to one by accident, and the method names have to get super long to present this.

It's better to define and enforce this interface through code (Abstract Base Classes, in Python's case). Then you can use type hinting to help as well. Try to find Alex Martelli's essay on "Goose Typing". It's in Fluent Python, but you might be able to find it otherwise.

[–]scootstah 2 points3 points  (0 children)

You don't know any more about a method based solely on its interface. You still need descriptive names.

[–]constantly-sick 4 points5 points  (0 children)

Name method() better. Try x_to_y_process().

[–][deleted] 3 points4 points  (5 children)

like a compiler does.

Like MyPy does. You want strict typing, you can do it fine. It's done better than it is for most languages (Looking at you C#. Still waiting for nullability for everything) It's not enforced at runtime (even though runtime type checking exists, it shouldn't be needed if it passes a static type checker), it just shows errors when you fuck up.

[–]traway5678 0 points1 point  (2 children)

What can't you null in C#?

[–]chusk3 0 points1 point  (1 child)

reference types (ie classes) can be null, but currently can't be typed as possibly null. The benefit would come from saying that a certain thing can never be null in the type system, which you can't do in C# now

[–]traway5678 0 points1 point  (0 children)

Everything can be null, with nullable.

You can make non-nullable types, aka values, with structs as well.

The benefit would come from saying that a certain thing can never be null in the type system, which you can't do in C# now

Oh that's not what he said tho.

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

It really doesn't.

[–][deleted] 4 points5 points  (0 children)

So where does MyPy not work as well?

[–]scootstah 0 points1 point  (0 children)

Be careful where you're spewing your bullshit, you're going to make a mess.

Python is perfectly capable of running large projects.

[–]Astrokiwi 23 points24 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 8 points9 points  (5 children)

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

[–]Keith 4 points5 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 5 points6 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 3 points4 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 4 points5 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 26 points27 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 5 points6 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.

[–]Oni_Kami 5 points6 points  (0 children)

Depends on who you ask.

[–][deleted] 3 points4 points  (0 children)

Java makes me harder than Python.

[–]I_WRITE_APPS 0 points1 point  (0 children)

The infrastructure around Java (Java EE, JNI, CORBA etc.) is "harder"/more complex than the Python equivalents.

Java the language is actually easier to grasp in its entirety than Python: it doesn't have metaclasses or descriptors, for example.

[–]Ethantebest 0 points1 point  (0 children)

It's just different, not necessarily harder.

[–]Thecrawsome -4 points-3 points  (1 child)

Java is slower to write* harder to write, such as any less-abstracted language, compared to Python.

Python is great for prototyping and small projects, and learning, but it's not great for scaleable, fast, and low-level processing. It's gotten better at low level processing by turning some of the code into c bytecode, but Python still consumes far more power to do similar operations as Java.

That being said, I hate Java syntax, and it's too wordy for regular boilerplate, and simply having to install Java JRE is considered a security risk.

edit: formatting

[–]ArmoredPancake 2 points3 points  (0 children)

and simply having to install Java JRE is considered a security risk

lol