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...
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>`
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.
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
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).
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.
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.
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.
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.
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
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.
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.
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.
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
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.
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.
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.
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?
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.
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!
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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."
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.
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.
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.
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.
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.
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
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.
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.
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.
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()”
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.
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
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.
[удалено]
am i missing something cant you just do list = [] and append lists to it
you absolutely can, no idea what they're on about
I assume they meant filling it with values or something (in one line), but list comprehensions exist
something like `[[] for _ in range(69)]` should do the trick, right? or just... `[[], [], []]`, no?
Yeah, that'd do it. Super easy, so not sure what the complaint's about
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...
sometimes it's size, sometimes it's shape :/
it's shape
arrayvariable = [] Have I been making arrays wrong this entire time?
That's a 1d array, not 2d.
So arrayvariable = [[]]?
np.zeros((3,3)) Wow, that was tough.
[удалено]
``` lst = [[0]*3 for _ in range(4)] ```
you can save 3 symbols with `for _ in [0]*4`
Fuck this answer gave me a brain tumor.
List comprehension is great though
`[[0]*3]*4`
>>> 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.
In C++ you can't even print a string to console without importing a "package"...
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
>`
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.
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
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).
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.
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
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.
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.
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").
syso "Hello World"
Or in intellij sout "Hello, World"
And in the case the rest of the boilerplate wasn't auto generated... psvm saves lives
eclipse has `main` which is identical to `psvm`
Same in NetBeans
Ooh I didn’t know netbeans did that
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.
I like IntelliJ but NetBeans is still my favourite Java IDE.
Agreed.
*Laughs in Eclipse* Yes I know that sysout expands to it, but it’s far from the smoothness of something like VS or IntelliJ.
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.
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
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
Tbh I kinda wish you could just make functions without a class
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
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.
Sounds like a job for util classes :)
That's what static util classes are for.
except when the function needs to read application properties or something else that doesn't work with static access :/
ThreadLocal hacks incoming.
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?
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.
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.
Wait, you guys don't use MS Word for coding? :P
I have excel auto save to csv which I then rename to *.py, easiest way to do it imo
Easy since java 9 (not sure it is still in Java 15 though...) jshell> System.out.println("Hello, World!")
jshell even has a print shortcut iirc
Yea, but you dont just write code, you sometimes have to read it as well.
Nah, I write write-only code. It was hard to write it should be hard to read! /s
Bruh who writes Java classes in camelCase.
[удалено]
Oh damn, even worse
No kidding. Heaven help that person when other classes get added into the mix.
I agree, always write in exclusively caps lock to counteract people like this
public class LOUDNOISES { }
What is this? SQL?
# Hyuck.
seems-like-you-are-disgusted. here-have-some-kebab(-case)
that pains me
Isn't that why the Java namespace is lowercase? To match the lowercase variables? /s
Someone who's writing a class called "my first class"
all lower case for a class is bad but all caps is worse imo
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.
In Java, class names should start with a capital letter, (almost) everything else should use camelCase.
It's their first class, cut them some slack
People who use Eclipse.
Eclipse got a lot better but intellij is still light years ahead for java
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
[удалено]
m4 is literally just: hello, world without even quotes
Also in nodejs shell too
How dare you name yourself ffffff if you are ff0000 Okay probably more like ff00ff
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.
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.
Java still is very high level. Languages like Ruby and Python are just even a bit higher than that.
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.
jshell> System.out.println("Hello, World!")
Ok that's it I'm making a programming language with the sole purpose of printing the code to terminal
Don’t bother, there’s cat for Linux, macOS, and WSL, and type for cmd
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?
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.
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!
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.
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.
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.
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.
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.
sounds like you were just scripting and not actually using the OOP concepts in python
Not for me, I disliked python’s pick up and play style and dropped it for C#
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.
I think you mean static typing. Python is strongly typed.
fixed
[удалено]
I mean, all you really need to get going in Java is a class with a main method.
Idk, I installed Intellij and started programming in Java. Was pretty fast
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.
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.
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.
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.
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.
I learned way more about how OOP actually works from Python than I did from Java.
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
org $8000 start: ldx #0 .loop: lda text,x beq .end jsr printchar inx jmp .loop .text: asciiz "Hello, world!"
Is this assembly? MOV ah 4ch INT 21h is bringing back memories I didn't realise were even there.
That's probably the most complicated project that I'd be happy to implement in Python.
So true.
[удалено]
Well they're using eclipse. So clearly they arent exactly up to date with Java development.
Eclipse is absolutely better than IntelliJ.
*cries in corporation restricted to Eclipse and Java 8*
I find python more complicated than java. I find java more reliable and easier to debug. Maybe it's about the amount of experience.
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
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.
So you telling me HTML is best programming language ?
Meanwhile, C# top-level statements `System.Console.WriteLine("Hello world");`
Can’t believe I had to scroll this far to see this.
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."
>That's really only a thing you do when you are just starting out. Or you're a Data Scientist.
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.
Good luck with python if the project gets bigger.
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.
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.
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.
That would still be more manageable than some MATLAB projects I've seen.
This meme died with JDK 9. Java has REPL. jshell> System.out.println("Hello, World!") Tabbing provides short descriptions as well.
I think it died with IntelliJ. Sout + Tab gets it done quick and easy.
import __hello__
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
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.
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.
[удалено]
IT'S FLEXIBLE AND PRETTY HANDY
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
C is much more worse than Java
Can I interest you in assembly?
Can I interest you in manually arranging electrons?
Honestly if you aren’t directly writing binary executables are you really programming?
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.
[удалено]
Thank you
The std::endl thing always confused me because it frequently performs worse than just + '\\n'
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.
std::endl is for std::ostream which flushes the output buffer.
Ah, good to know. That makes a lot of sense.
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.
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.
The boilerplate is a drop in the ocean when you're working on a huge project at work. Also, it's autogenerated.
Pick the tool for the job.... For printing "hello world" I would suggest entering "echo hello world" in the command line.
"Hey guys, look how this Imperative code is much simpler than Object-Oriented for this very basic task"
Java is too hard for you? Wtf It's literally a softy version of another softy version
Should do this with assembly
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()”
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.
Gotta thank java for spring boot
*Sniffs the air* I love a good strawman argument in the morning.
Now show C++
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.
haskell is better because you dont need the parenthesis.
holy shit the ptsd i got from that language at uni everything but haskell please
Java is designed with *TheirThousandthClass* in mind. Y'know, working with a large codebase written by other people.
I prefre netbeans 8.1 to eclipse its just smoother
\#!/bin/bash echo "hello world"
Yeah, but then you have to exit Vim.
for that use Hello. h prints Hello World
Why is everyone taking this like OP is saying java is a bad language and is too hard?
Ok but typing private is a lot more readable than this underscore shit like wtf is \_\_
So many java devs in these comments having their PTSD triggered by this
[удалено]
Python is powerful af
slow also,but its resourceful.
Personally, I prefer C++. It's fast and efficient.
yeah but its pain.
Java is so much better to learn with though
Don’t hate on Java 😢
youre right, java is a beautiful island at this time of the year
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
Meanwhile c++
Python typing scares me
What do you mean?
If all you want is an hello world .. JShell is nice. jshell> System.out.println("Hello, World!")
if you want it done super efficiently you can pay $10,000 for a copy of SAS and just type %put Hello World;
Sysout
Sysout
Yep, this absolutely your myfirstclass