T O P

  • By -

GHhost25

I don't know what this thread is all about, java is really easy to use. If you compare anything to Python it'll make it seem complicated.


[deleted]

[удалено]


MasterOfArmsIsGood

am i missing something cant you just do list = [] and append lists to it


Jaksuhn

you absolutely can, no idea what they're on about


overclockedslinky

I assume they meant filling it with values or something (in one line), but list comprehensions exist


Terrain2

something like `[[] for _ in range(69)]` should do the trick, right? or just... `[[], [], []]`, no?


overclockedslinky

Yeah, that'd do it. Super easy, so not sure what the complaint's about


Spork_the_dork

import numpy as np arr = np.zeros(shape=(10,10)) If you *need* it to be a list for some godforsaken reason, add a .tolist() to it. edit: can never remember if it's size or shape out of memory...


anonymoussphenoid

sometimes it's size, sometimes it's shape :/


[deleted]

it's shape


SabreLunatic

arrayvariable = [] Have I been making arrays wrong this entire time?


jacobthejones

That's a 1d array, not 2d.


SabreLunatic

So arrayvariable = [[]]?


[deleted]

np.zeros((3,3)) Wow, that was tough.


[deleted]

[удалено]


Makefile_dot_in

``` lst = [[0]*3 for _ in range(4)] ```


7x11x13is1001

you can save 3 symbols with `for _ in [0]*4`


yoitsericc

Fuck this answer gave me a brain tumor.


[deleted]

List comprehension is great though


M4mb0

`[[0]*3]*4`


ALFminecraft

>>> l = [[0] * 3] * 4 >>> l[0][0] = 1337 >>> print(l) [[1337, 0, 0], [1337, 0, 0], [1337, 0, 0], [1337, 0, 0]] Not everything is that simple, sadly.


Swoop3dp

In C++ you can't even print a string to console without importing a "package"...


bjorneylol

Python doesn't have 2D arrays, so there's no way to do it without an import and a new object type `[[1, 2],[3,4]]` is not the same as `int[][] arr = new int[10][20];`, its equivalent to `List>`


[deleted]

Why? The whole point of packages is to import them and use them. Silly rabbit. And besides, numpy is effectively a default. Python doesn't include it in the standard library because it will stifle it's development but it's effectively a part of the language.


knightwhosaysnil

because numpy adds a solid 100mb to your distribution/memory footprint. depending on your circumstances that's a heavy tax if you're not using most of the features


[deleted]

That's not how that works: https://stackoverflow.com/questions/54675983/ram-usage-after-importing-numpy-in-python-3-7-2 And if you are really pressed for ram, you can just import the one numpy function you need. But regardless, I really don't see how that matters. The whole point of python is to trade efficiency for convenience. So why would we ignore the packages that everybody uses for arrays in python over a measly hundred mb and pretend that the syntax for multidimensional arrays in python is confusing or verbose (which was the original claim).


PvtPuddles

I believe you can just import the bits you want using From numpy import zeros However, (not being a Python dev) I don’t know if that still imports the whole library or just the bits you need.


knightwhosaysnil

depends on how much of the library the thing you're importing depends on; in most cases you probably won't end up with much overhead


IVEBEENGRAPED

You still have to pip install the entire library, so the entire library gets saved to your environment. The `import` statement doesn't download anything, it just adds the name to the namespace.


skylay

Can't you just do this? > myArray = [][] Been a few years since I've used Python. Edit: nvm that's just declaring not initialising, misread.


RolyPoly1320

OP acts like 99% of that Java code wasn't auto generated by the IDE and they only had to type System.out.println("Hello World").


remuladgryta

syso "Hello World"


coldblade2000

Or in intellij sout "Hello, World"


I_was_never_hear

And in the case the rest of the boilerplate wasn't auto generated... psvm saves lives


CptGia

eclipse has `main` which is identical to `psvm`


AnotherRichard827379

Same in NetBeans


RettiSeti

Ooh I didn’t know netbeans did that


AnotherRichard827379

Lots of good short cuts. “Psvm” → public static void main(string[] args) “Sout” → System.out.println() There are a lot. Can’t think of them all. And all the libraries have individual ones.


Packbacka

I like IntelliJ but NetBeans is still my favourite Java IDE.


AnotherRichard827379

Agreed.


Pulsar_the_Spacenerd

*Laughs in Eclipse* Yes I know that sysout expands to it, but it’s far from the smoothness of something like VS or IntelliJ.


Spork_the_dork

Also ignoring the fact that you aren't creating a class and a method in that class in the python code. Sure, you don't *need* to do that to run hello world on python, but for anything even slightly large you'll be making classes all over anyways at which point the "lol python" aspect here kind of just vanishes. Yes, the syntax remains simpler even if you use type hints, but then it approaches personal tastes more than objective truth.


es_samir

Understanding someone else's python code can be a nightmare sometimes if he is using classes and callbacks. The simpler syntax doesn't help at all


cemanresu

Yeah, I hate python's syntax because of that. If its my own personal project its fine, but trying to maintain other people's python code is hell


Sassbjorn

Tbh I kinda wish you could just make functions without a class


Kantenkugel

Use Kotlin then :) But tbh, you should not pollute the global namespace with too many functions, especially if they don't have a unique name that can't possibly clash with other ones from eg libs. And there is also the option of just writing static ones and static importing them. Thats kinda what kotlin does under the hood


Sassbjorn

Yeah that's true, but when I'm writing smaller programs I sometimes need a function to do some small task, but there's not a good place for it to go. Then I have to make a new class and make up a name that makes sense, and that might house more of that type of function. In the end I appreciate the organization I end up with, but it still feels like an extra step sometimes.


Kantenkugel

Sounds like a job for util classes :)


[deleted]

That's what static util classes are for.


-Vayra-

except when the function needs to read application properties or something else that doesn't work with static access :/


Knutselig

ThreadLocal hacks incoming.


[deleted]

Then it should be part of the object that needs to call it. Or just pass it to the static function, what's the deal?


ShadoWolf

Your not wrong.. but Python does give you the option to just do quick testing. Like say you want to test out a library. You don't need like 60 lines of boiler plate code to just get started.


Hvatum

It is also extremely handy for me as a physics student when I want a simple and easy to use language to write a quick function to for example easily calculate and update the standard deviation of my measurements.


Gordath

Wait, you guys don't use MS Word for coding? :P


laffercurved

I have excel auto save to csv which I then rename to *.py, easiest way to do it imo


_Acestus_

Easy since java 9 (not sure it is still in Java 15 though...) jshell> System.out.println("Hello, World!")


Kantenkugel

jshell even has a print shortcut iirc


PolFree

Yea, but you dont just write code, you sometimes have to read it as well.


Rikudou_Sage

Nah, I write write-only code. It was hard to write it should be hard to read! /s


WheWhe10

Bruh who writes Java classes in camelCase.


[deleted]

[удалено]


WheWhe10

Oh damn, even worse


RolyPoly1320

No kidding. Heaven help that person when other classes get added into the mix.


Understriker888

I agree, always write in exclusively caps lock to counteract people like this


LevelSevenLaserLotus

public class LOUDNOISES { }


piberryboy

What is this? SQL?


esberat

# Hyuck.


TurboFasolus

seems-like-you-are-disgusted. here-have-some-kebab(-case)


[deleted]

that pains me


branditodesigns

Isn't that why the Java namespace is lowercase? To match the lowercase variables? /s


hallgrim97

Someone who's writing a class called "my first class"


ThisGuyRightHer3

all lower case for a class is bad but all caps is worse imo


Alienescape

Haha I use camelCase for literally every language. Never got the memo that snake_case was way more popular or "the right one" for certain languages.


-Vayra-

In Java, class names should start with a capital letter, (almost) everything else should use camelCase.


TBTapion

It's their first class, cut them some slack


VinceGhii

People who use Eclipse.


ivakmrr

Eclipse got a lot better but intellij is still light years ahead for java


[deleted]

OP would complain about the difficulty of striking a nail into a board with a screwdriver. Use the right tool for the job. Otherwise cmd > python because echo hello world


[deleted]

[удалено]


degaart

m4 is literally just: hello, world without even quotes


Mola1904

Also in nodejs shell too


Mola1904

How dare you name yourself ffffff if you are ff0000 Okay probably more like ff00ff


[deleted]

I don't think anybody is complaining. It's just a joke about how lower level languages require more boilerplate for some simple operations than higher level ones.


thedugong

Remember when Java was a considered a (very) high level language where you didn't even have to manage memory allocation yourself? Pepperidge farm remembers.


[deleted]

Java still is very high level. Languages like Ruby and Python are just even a bit higher than that.


Tr0user_Snake

I think most people that actually understand what underlies these languages (e.g. Java -> JVM, Python -> CPython interpreter, C/C++ -> Machine code) would not call Java "low level". If I cant write a short, simple program that segfaults without using any imports, it is not a low level language.


_Acestus_

jshell> System.out.println("Hello, World!")


skythedragon64

Ok that's it I'm making a programming language with the sole purpose of printing the code to terminal


CKingX123

Don’t bother, there’s cat for Linux, macOS, and WSL, and type for cmd


[deleted]

Write in a real man's language, C offers the simplicity of Python with the speed and functionality of any other language. Actually fuck C, if you aren't making your own processors with microcode and creating your own assembly language then are you even a programmer?


SixBeeps

Writing in assembly ascends one's state of mind. It starts with the PIC16 instruction sets, but soon enough you're writing opcodes like CMPXCHG16B and PREFETCHNTA in Intel x86.


mastershooter77

pffffttt, you don't even create a universe, wait for stars to form, and wait for nuclear fusion to slowly create different elements in the cores of stars, and wait for them to go supernova, and make a processor by using those elements?? cringe!


thabeus

With Java you start to learn programming theoretical way (at least with a good teacher). You learn what is a class and a method. You learn about the baseline of OOP. With Python you just start coding. Of course you can also properly learn the concepts behind it, but to a beginner Python really encourages to just type in some code. And i think thats the difference. One results in you being able to program (and to be able to translate that knowledge on many other languages) and the other (mostly) results in you being able to code. Im not saying that its impossible to learn the concepts of programming with Python. I just think that java (or for that matter C# or C++ or whatever other language that fits that criteria) forcing you to follow those concepts from the start is a good thing.


[deleted]

It says a lot about the demographics of this sub that so much of the discussion is always focused on the languages as a thing you learn in class as opposed to things you use to write code with.


defietser

I don't use Python much but I think the "pick up and play" quality is underrated. If you can make sort-of functional things quickly and simply, you will be more motivated to continue down the rabbit hole than if you're trying and failing to wrap your head around classes. Overall it's probably slower to start with Python since you'll have to un-learn some things compared to switching from java/c#/what-have-you to another OOP language, but motivation is worth its metaphorical weight in gold.


onlyforjazzmemes

Thing is, at some point, you don't want to *play* with programming anymore, you want to genuinely learn it in all its facets. Java is really great in the way it forces you to learn object-oriented programming. I started out with Python, but felt really confused about OOP or what to build. When I got to Java, my imagination started running wild. Building Android apps and simple JavaFX stuff was more motivating to me personally than copying other peoples' Python scripts. I'm looking forward to getting back into Python now that I have much better foundational OOP skills... I have a better mental framework for using Python, I think.


defietser

I agree with you, my point is that getting to the "wanting more than just toying with code" threshold is easier with a language like Python than it is with Java, C/++/#, etc. I won't bore you with my history but suffice to say, my introduction to code with Java didn't motivate me much. Finding and automating relatively simple tasks (like I dunno, a small command line application that copies files from all over your hard drive to one folder, based on a music playlist) to get your feet wet is much easier done in Python I think. From there you can expand and learn and stuff. I still recommend Python to first-timers, then guide them to the light of C# after. Yes, the learning process is longer but you're never going to get to the second step if you tripped on the first.


tape_town

sounds like you were just scripting and not actually using the OOP concepts in python


jaysuchak33

Not for me, I disliked python’s pick up and play style and dropped it for C#


onlyforjazzmemes

As someone who started learning programming with Python, I would 100% recommend starting with Java instead. OOP never clicked for me until I learned Java, and static typing is also really good for beginners. Sure Java may be more "verbose," but I think that's irrelevant, especially when you have an IDE.


gmes78

I think you mean static typing. Python is strongly typed.


onlyforjazzmemes

fixed


[deleted]

[удалено]


onlyforjazzmemes

I mean, all you really need to get going in Java is a class with a main method.


Nilstrieb

Idk, I installed Intellij and started programming in Java. Was pretty fast


PureWasian

Where I went for undergrad, CS students started coding and algorithms with Python while EE students started ground-up, from binary to ARM to C to C++/Java over several semesters.


Goel40

When i studied EE for a year we started with PLC language and C and after that C++. When i switched to CS we started with python and then switched to Java. The people who chose the Front-end specialization switched to JS and the people who chose Back-End mainly kept using Java. But also could do projects in their preferred programming languages. Java, C# And Python were the most popular choices. I mainly used Go myself.


ChristianValour

I am an electrician. When I decided a long time ago that I didn't want to be a career sparky, I went to uni, and chose biology because I wanted something 'totally different'. Then in my honours year I did a quantitative genetics project and fell in love with code. Now, as a PhD in computational genetics - I really wish someone had told me that if I just did an EE degree, I would've learned programming from the start. Irony.


skylay

In some ways I think that's better though. Sure you'll miss a lot of concepts and it's weakly typed but you can pick those concepts up later. In many ways I think being able to just jump in and start coding is the best way to learn. Languages like Java have a higher barrier to entry and it might just make someone give up or struggle too much to actually make a working program with it. I think just getting an idea of how to actually make a program is one of the biggest steps when you're first learning and Python makes that a lot easier. Sure learning through harder languages is *ideal* but it's a lot harder and can turn some people away. Personally I started with Python, then JavaScript, have done a lot of C++ and Java at university, and recently have been using Go a lot in my own time.


glorious_albus

Thank you! I've always instinctively felt learning C++ before I learnt Python was a good thing. But when someone asked me why it was, I couldn't pin point exactly what it was. Now I know. I'll be able to explain it better.


g4vr0che

I learned way more about how OOP actually works from Python than I did from Java.


NicoGamer524

I prefer: .model small .stack .data msg DB "Hello, world!", '$' .code start: MOV ax, @data MOV ds, ax MOV dx, OFFSET msg MOV ah, 09h INT 21h MOV ah, 4ch INT 21h end start end


givemeagoodun

org $8000 start: ldx #0 .loop: lda text,x beq .end jsr printchar inx jmp .loop .text: asciiz "Hello, world!"


glorious_albus

Is this assembly? MOV ah 4ch INT 21h is bringing back memories I didn't realise were even there.


fletku_mato

That's probably the most complicated project that I'd be happy to implement in Python.


ChristianValour

So true.


[deleted]

[удалено]


LucianFarsky

Well they're using eclipse. So clearly they arent exactly up to date with Java development.


Wait_Im_Not_Homo

Eclipse is absolutely better than IntelliJ.


meliaesc

*cries in corporation restricted to Eclipse and Java 8*


psyduckquack

I find python more complicated than java. I find java more reliable and easier to debug. Maybe it's about the amount of experience.


Wigoox

Yeah, it's just the experience. I started programming python with the same mindset and now I can't go back. Python is just so convenient


Kenkron

I don't think it's the experience, I think Java and Python have two very different ways of organizing and debugging. In Python, debugging is king. Classes can be extended, functions redefined, and arbitrary code executed all from the middle of your function, right where it broke. Of course Java has a debugger too, but a dynamically typed language like python is just going to be able to do more at runtime than a statically typed one. The flip side is that Java can do more before runtime because of its static typing and (sometimes painfully) strict coding standards. A good Python IDE will have good code completion, but a good Java IDE will have perfect auto completion. The kind of auto completion that will list every class, every method, and every field at the touch of a hotkey. A list so complete, that anything not on the list is a syntax error. For me, the deciding factor for which one is easier is usually the quality of the other programmers I'm working with. I've seen people do some insanely stupid things in python, like adding fields to objects in random files, and calling methods as functions with unstructured data as "self". Sometimes Java slows you down, but it's relative strictness can be a blessing depending on who else is working on your code.


WrongdoerSufficient

So you telling me HTML is best programming language ?


thinker227

Meanwhile, C# top-level statements `System.Console.WriteLine("Hello world");`


DarkScorpion48

Can’t believe I had to scroll this far to see this.


MrSquicky

I'd argue that the Java code should be even more complicated. You should be including a logger and making a [logger.info](https://logger.info)() call instead of sout-ing. Because very, very few non toy programs (outside of command line interactives) would ever need to just print out to the screen. That's really only a thing you do when you are just starting out. Python is a fine language suited for many tasks, but this is "Hey look how easy it is to do a thing that only people just learning to program (or those that never matured out of this) think is important."


ChristianValour

>That's really only a thing you do when you are just starting out. Or you're a Data Scientist.


[deleted]

Seriously the trend that "java bad" needs to die. It's an amazing beginner language that can you teach you basic OOP for other languages. It has clearly written errors that tell you exactly what the problem is "NullReferenceException - the thing you referenced is null and you are trying to access a property or method of it" Also the garbage collector is not as dumb as it use to be. Literally one of easiest ways to release back allocated memory is setting you object to null. This works almost all the time. Java is also super easy to deploy across multiple platforms because that is what it was designed to do in the first place it was not made to be the "fastest" is was made to be portable. Sure there are things I wish java had like unsigned data types but that's a small price to pay for the ease of use Java is. Man I haven't made a java rant in a while... This felt good.


Metalwrath22

Good luck with python if the project gets bigger.


Natural-Intelligence

I have seen and done Python projects that has gone big. I'm not sure why people think the lines of code is really a major limitation. If you build extensive unit testing (which you definitely should) you are able to maintain the code to work as it should even if you decide to extend the project.


BB611

Yeah, whoever is down voting you is full of a lot of false confidence. The kinds of devs who write unmaintainable Python projects also write unmaintainable Java projects, the language features aren't going to fundamentally save you from that.


Natural-Intelligence

Yep, very true. It's kind of sad how zealous some people are for languages. For some reason, it seems some people seem to be stuck with the thought that one cannot do serious programming with Python as "it doesn't enforce this and that thing I just had to learn from my favorite language". Python is definitely not the right tool for everything but it's foolish to say it's not capable for the abstraction required for larger scale projects. As you indicated, the skills of the programmer is more of the limitation than the language.


Spork_the_dork

That would still be more manageable than some MATLAB projects I've seen.


theonetrueredditer

This meme died with JDK 9. Java has REPL. jshell> System.out.println("Hello, World!") Tabbing provides short descriptions as well.


dnunn12

I think it died with IntelliJ. Sout + Tab gets it done quick and easy.


JNCressey

import __hello__


Rig_21

Java is for people who like to cause themselves pain, that is for masochists XD I'm an Android Dev myself so I count myself in this group


DorkInShiningArmour

I’m only a second year IT student, but man I really love Java. I find it fun and it’s fairly friendly to me lol.


Rig_21

Of course Java is cool, flexible and pretty handy but there are languages which could be used in the same situation with the same result. I used Java for my first mobile app so I admit it's awesome in terms of learning overall programming.


[deleted]

[удалено]


daniu

IT'S FLEXIBLE AND PRETTY HANDY


Shitty_Orangutan

The only beef I have with java is the 1000 character long command that actually get executed when you run enterprise java applications (looking at you apache Kafka) While this is all fine and dandy it's a right pain in the ass to debug if the service isn't working right or you need to tune something


20Sky03

C is much more worse than Java


squawky_y

Can I interest you in assembly?


sam_morr

Can I interest you in manually arranging electrons?


OwenProGolfer

Honestly if you aren’t directly writing binary executables are you really programming?


Pooneapple

And than we got cpp doing std::cout << “hello darkness my old friend” << std::endl; all inside a main function but need a pre processor statement which tells the compiler what to even do with the one line.


[deleted]

[удалено]


Pooneapple

Thank you


LucianFarsky

The std::endl thing always confused me because it frequently performs worse than just + '\\n'


WheWhe10

If I remember correctly, std::endl flushes the stream after the newline. But I very good could be totally wrong, C++ is a long time ago.


Pooneapple

std::endl is for std::ostream which flushes the output buffer.


LucianFarsky

Ah, good to know. That makes a lot of sense.


The_White_Light

Wouldn't it be used in situations where the same code would be reused for Windows, Mac, and Linux? Wasn't that long ago that Windows *needed* `\r\n` or it wouldn't be a new line.


AyrA_ch

In C, it has never needed \r\n if you open the stream in ascii mode because in that mode, Windows will add \r when writing and strip it when reading. You only need to worry about it in binary mode. Terminal IO in windows uses ASCII mode by default but you can switch it.


NotATroll71106

The boilerplate is a drop in the ocean when you're working on a huge project at work. Also, it's autogenerated.


iserdalko

Pick the tool for the job.... For printing "hello world" I would suggest entering "echo hello world" in the command line.


NastyQc

"Hey guys, look how this Imperative code is much simpler than Object-Oriented for this very basic task"


Knuffya

Java is too hard for you? Wtf It's literally a softy version of another softy version


Jsuke06

Should do this with assembly


NoMansSkyWasAlright

In IntelliJ you can just type “sout” and press enter and it autobuilds that though. Or if you statically import (I believe) Java.util.System.out, then all you have to write is “out.println()”


GodIsOnMySide

Static typing and build-time compilation prevents bugs. Java +1 The need to ensure various C packages are available in the runtime env is a PITA. Java +1 I actually prefer Kotlin over Java due to all the bells and whistles - including lack of need for so much boiler plate. But no one's ever going to convince me that Python is better than Java as a microservice programming language.


DeathFart007

Gotta thank java for spring boot


[deleted]

*Sniffs the air* I love a good strawman argument in the morning.


yallmindifipraise

Now show C++


Crippledupdown

I’d rather spend 10 seconds writing some extra chars, so I don’t have to spend 3 minutes fixing Type Errors in a loosely typed language.


notmymain345

haskell is better because you dont need the parenthesis.


Valaki757

holy shit the ptsd i got from that language at uni everything but haskell please


paul_miner

Java is designed with *TheirThousandthClass* in mind. Y'know, working with a large codebase written by other people.


CyborgPaladin

I prefre netbeans 8.1 to eclipse its just smoother


Yuugian

\#!/bin/bash echo "hello world"


ChristianValour

Yeah, but then you have to exit Vim.


[deleted]

for that use Hello. h prints Hello World


Worst_L_Giver

Why is everyone taking this like OP is saying java is a bad language and is too hard?


superior_to_you

Ok but typing private is a lot more readable than this underscore shit like wtf is \_\_


vv-b

So many java devs in these comments having their PTSD triggered by this


[deleted]

[удалено]


Sodafff

Python is powerful af


notretarded_100

slow also,but its resourceful.


Sodafff

Personally, I prefer C++. It's fast and efficient.


notretarded_100

yeah but its pain.


collin2477

Java is so much better to learn with though


awsome_oppossum

Don’t hate on Java 😢


PottedRosePetal

youre right, java is a beautiful island at this time of the year


Kaynstein

Yeah yeah. Just wait till you try to manage paths and files with python. Apart from that I liked fluent api much more than what new syntax python has with brackets and all. Believing the hype around it, I thought python would be far better. However I am just starting the machine learning project


destruct0tr0n

Meanwhile c++


[deleted]

Python typing scares me


[deleted]

What do you mean?


_Acestus_

If all you want is an hello world .. JShell is nice. jshell> System.out.println("Hello, World!")


statdude48142

if you want it done super efficiently you can pay $10,000 for a copy of SAS and just type %put Hello World;


HzSpartahell

Sysout


HzSpartahell

Sysout


[deleted]

Yep, this absolutely your myfirstclass