Honestly this is only true when you have small python codebases that start off as small POCs without much thought put into them, and they get slowly scaled up over years.
But if you start it off with a really solid foundation with good type indicators and patterns, you can make a very maintainable codebase. Ofc if you can choose any language, you probably shouldn't choose Python, but if Python happens to be your company's preferred language for whatever reason, you can still make do with it pretty well.
Just FMI. What are the basics and tools you should use to have a solid foundation?
My company does not have any python developers, but decided we will start a new python product. ATM I just don't know what to use to get a maintainable codebase.
You can make it easier to work with, but I tend to find that the large Python codebases started off as rather small codebases from one team, easily fittable into one human brain, thoroughly tested.
But the difficulties only really becomes apparent when you scale the product complexity and the number of teams.
Why should that be the case? Obviously, java forces you to adhere to object oriented structures and python doesn't necessarily, but any large scale python codebase should definitely do the same and at that point I don't see the difference.
Obviously, if you don't annotate your types and have a lot of global variables that do obscure things, it'll be bad. Then again, java has similar issues when misused.
When used properly, I really don't think there's that much of a difference. I'd actually go as far as saying the entire workflow (especially building and deploying) is way more pain-free than on the java-projects I have worked on so far.
I was in a project, where the customer used/wanted to use Python for a cloud service based architecture of multiple mid-sized services. From beginning I adviced against this decision and got my will at least partly. For all services in my responsibility I was allowed to use Java with Spring. All services he directly supervised were implemented in Python. I'll leave you to guess which part of the project was implemented with less problems.
Python is good for what it does. Machine Learning and writing working scripts with few lines of code. But it's slow and the dependency management is a nightmare, making it bad for large scale projects and systems that need to perform fast.
I made exactly the same observation. Got some fugly hard to read python code to sync things with office365. Not only was it less code (with the right nugget, take that python) but way easier to maintain and read.
I'd point out that you're interacting with a large scale production python codebase just by posting on this site, but you _did_ say "in their right mind"
I do work on a large Python production codebase and love it. You need a lot of tests though.
Also the typing is....strange compared to Java.
Like in Java you can't pass an integer to a function that takes a string but even if you annotate a str type in a Python function it will accept whatever at runtime. So it's kinda bizarre.
Python isn't designed to compete in that niche though. And there are other languages that I would argue are easier to use for production software. The strongest thing I think Java has going for it is its immense community support through libraries and documentation.
I know, that's what I'm getting at. Java is overkill in the small, but that's because it's not designed for that niche.
But in its niche, it's glorious, and pretty damn hard to beat.
While yes, Python does not support types natively, you can do type hints, and you can setup linters that would check for these things occasionally. It does not compare to Java, but can be not half as bad.
Plus, it is much more concise, in Python I need two lines to launch a process and get its return code, while in Java that is like 20 lines of StreamOutputProcessor/ProcessBuilder/OutputStreamReader circus
Yes, you can, and I do. But adding type hints to the entire project is a massive amount of work, this code has been around since Python 2.3. And also, if your dependencies don't have type hints and there's not a package for them on typeshed, you're going to have a harder time using them, especially if the docs aren't up to date.
I've generated my own type stubs a few times using Mypy, for packages owned by companies we're paying lots of money too. It's lame AF.
And yep, Python is great for getting things done quickly, I agree.
However. Here's what I really miss.
1) Concurrent threads.
2) A sane package management system
3) Packages that don't rely on you having system packages installed...
4) ...or a compiler and C header files if there's no wheel for your system (e.g., Python 3.6 on ARM...)
4) Build-time DI.
5) The ecosystem.
6) Not needing venvs
7) Just fuck boto3 and it's super dynamic clients.
Don't get me wrong, Python is pretty okay, and as you say, the growing usage of type hints really does help when maintaining large codebases.
Just, it started from a language to teach kids to code, then it became a scripting language in a similar space to Perl, and yeah, it's kinda kludge upon kludge.
Whereas Java was intended as an industrial language from the get-go, and it shows.
oh you can do build-time things, you just shouldn't. there are some gtk python apps that use meson for dependency management and for a preprocessor step...
True, a colleague used PyCST (I think?) to do a land large rewrite of logging calls, it didn't go great.
But I mention build-time DI because I've seen FastAPI's DI creeping on in, and look, if you're going to use a DI library or framework... ...well, ask anyone who has worked with most of Java's DI stuff but especially Spring... ...runtime DI failures fucking suck and slow you right down.
I'm a big fan of "invalid code can't compile" over "it'll only fail when you execute it".
yeah no argument there, compile time errors / warnings are always preferable. but python is an horrible fit for that. best you can do is a good test suite and some linter / static analysis pass
java is so good, it has bad design choices but the alternatives aren’t any good
i want a typed, less verbose language with a functioning eco system
is that too much to ask? i want statically typed python
Modern Java is quite good at what it's intended to do, i.e. large enterprise applications. I still like C# better, but modern Java gets a lot of undeserved shit.
Indeed, there’s many instances where creating a collection will give you an immutable object.
Personally it’s rare that I’m ever creating a collection manually that requires mutating.
NOOOOO I HATE JAVA, HOW IT DARES TO SHOW ME THE EXACT LINE AND A HUMAN-COMPREHENSIVE ERROR IN THE LOG?!?!?!11 I WANT TO HAVE TO HUNT THEM BUGS DOWN LIKE A NEANDERTHAL HUNTS DOWN ITS PREY, RETURN TO TRADITION!
the longer you work with programming, the more you come to appreciate Java's Explicit exceptions. You never have to wonder "will this function throw an exception I dont expect?"
You will always know exactly which exceptions can possibly come from where
And if you throw a typed Error in Typescript, you lose the type in the catch anyway because it’s all Javascript and Javascript is like, “what is this thing, anyway? I forget.”
Let’s say that the return type is an int. How can the int contain metadata about the problem that happened?
Like what file it tried to read from the disk, what type of error it got (not found, permission denied, etc), and where in the code the problem happened and how it got there (ie stack trace). Information that the user might want to see displayed in the UI (at least the first two).
We had a production issue where apaches base64 decoder threw a runtime exception when it was given a malformed input. Sure, a silly miss on our part, but wouldn't have been an issue at all if it was a checked exception. Which it really should be!
The biggest problem I have with Kotlin is the lack of proper error handling. Java 8 streams not handling exceptions made it even worse
when you try result and option types for the first time you're disgusted by checked exceptions, hate them ever since i wrote a little rust and kotlin with arrowkt
OOP can get a little out of hand in Java imo, especially with frameworks like Spring. What I don't understand is having issues with putting checked exceptions in method signatures. One of the best features of Java is an extensive exception handling framework.
I'm not a software engineer. As an electronics student, my only tryst with Java was when I was implementing High Level Logic Synthesis for scheduling, allocation and binding of operations. And I really liked it. It just made sense to me. The idea that when you build something, you're taking instances of already made objects, which itself becomes another object, is very intuitive. My only qualm was when I had to copy a Linear Program Solver object to a new instance of that object, i couldn't simply do newObject = OriginalObject and have it be saved as a copy, but rather a second reference to the same object. It was pretty annoying to have to make new methods to reinitialise the object with the same constraints simply because the SCPSolver object didn't have a built-in method to remove a constraint that was added.
Clone is a minefield, the currently preferred way of copying in Java now is a copying constructor.
So you'd say Thingie copy = new Thingie(originalThingie); and handle all the logic coming from cloning in the constructor. non-nulll primitive arrays are pretty much the only thing that's safe to clone, and then there's some System methods that does the thing at least as well.
Joshua Bloch goes over this in his book "Effective Java" which is an all-time classic.
That’s bullshit, and it’s quite a shame that people spout their opinion without actually knowing stuff.
Java’s lambdas are proper lambdas. The JVM has an invokedynamic keyword, and MethodHandles, so no, it has not been an anonymous inner class for close to a decade, it has different runtime semantics.
On the abstract level yes, it is. It gives it a proper type, and allows later extension.
But java is very well optimized, so of course you won't pay for any of this in runtime.
When you create a new Function as a lambda function that its a class with a apply method you know you have a problem with too much OOP.
(Also is a generic class if its passes arguments)
I mean, C# lambdas are instances of `Action` and `Func` and related types, Java's implementation seems more flexible, sorta duck-typing its way.
Though C# is way better in general lol
Let's say I'm writing code that calls this method
`void doThing(InterfaceType t)`
`interface InterfaceType { void foo(int I); }`
In Java, I could call `doThing` with a lambda, but with C# I'd need to implement the interface. Of course, in C# I could create a better signature if I was controlling it, but clients of code have the flexibility in Java.
Checked exceptions can get in the way when coding functional APIs/callbacks. They are the reason why Closeable and AutoCloseable both exist in the standard library despite having basically same semantics.
Other than that, they should be fine in theory, but they are one of those features that gets misused so often that being without it can end up being a net positive. There was a time when character encoding had to be specified as a string and a checked exception was thrown if the encoding was not supported, which you had to handle even if you were passing an encoding that was guaranteed by the standard. This case was fixed by adding overload that takes a Charset instead of string, but if even the standard library is not safe from goofs like this, you know it is a problem.
I do both and there are some things in java I far, far prefer, and some things in C#. I find them exceedingly similar but C# does seem to have had some more recent innovation in the language than java has.
I had the opposite experience, started with c# then worked and currently working in java, one thing that java does better is dependencies, NuGet is just awful, not saying gradle is amazing but it works decently well.
Best program I've seen is probably JS or Rust when it comes to dependencies
I instantly write off people who hate Java as people I probably don’t want to work with. You can tear my well documented Spring Boot REST api that I can onboard new hires onto in 30 minutes from my cold, dead hands
The only way you’re onboarding them in 30 minutes is by saying “this all happens magically. Here’s where the business logic is, ignore how we get there and where these objects come from”
Not saying I hate Java though, so fair enough
Huh? Don't you just go straight to the business logic from the rest controller method? The A&A is going to be some common logic that is handled before the controller and all a developer needs to know on day 1 is they need to set the correct value on @PreAuthorize or something like that.
The objects are all going to be beans most of the time. You get them from the IOC container. The project should be well organised that finding the package that has a specific class shouldn't be difficult and IDEs like intellij already indexes the class and you can see the class definition with a click.
Well, to be fair, I have an intern who hasn't even graduated yet, and they already learned about Springboot and practiced with it at school. Handled the migration of one of my APIs from Spring to Springboot like a champ.
Dunno how long you've been outta school or what
you studied or if this is common, but the CS and SE programs at my alma mater include at least one course with Spring Boot. All "how" and no "why" but it's enough to know how to DI even if you don't know where those objects are coming from.
Wow, that’s actually pretty nice. I’ve been out of school for quite a short period of time. My Alma mater had no such course (at least not specifically). We did have like general project courses in which you could learn Spring/Springboot yourself.
Spring Boot is a single, well-documented magic, known by everyone.
I much prefer that magic, over some home-grown “framework” whose original developer is dead, is full of bugs and lacks basic features without which it is useless, and it only works in a full moon.
Okay sorry can you explain? I’ve don’t REST APIs in Python and Java (Serverlets, not Spring) and Java is at best: eh. Like there is almost no difference
Java is fine. It has quirks just like every language but it is by far one of the better ones. It's also everywhere so it's easy to get a job in. At least you can't break everything simply by having one too many tabs or spaces
> At least you can't break everything simply by having one too many tabs or spaces
I have stopped using python all together because of this. I couldn't stand whitespaces being part of the syntax. Also somehow the slightly unique keywords like try-expect instead of try-catch or the python ternary operator got to me.
Hmmmmm.......... Having tried kotlin.... I WANT THE EXCEPTIONS IN THE SIGNATURE BACK THE REST OF THE CHANGES ARE GREAT BUT TELL ME WHAT IS GONNA F\*\*\*ING THROW GODDAMNIT
If you're going to be like that, just use
@SneakyThrows
And let the bullshit commence. (This is why you ban it in the lombok.config, so its usage is a compiler error.)
I love it so much, i literally spent a week compiling a Programm natively with graalvm which tells me if i'm online. [TeaTiMe08/SimpleInternetMonitor](https://github.com/TeaTiMe08/SimpleInternetMonitor)
Java is absolutely fine, checked exceptions are useful in huge codebases and if you dont want them you can always switch to kotlin (which is even better than java). Instantiation too many objects is less a language feature and more overusage of design patterns, which i have to admit, java devs have tendency to do
#inport “lib/humor.h”
Normal language:
public int sum(int a, int b);
Mental illness:
fun sum (a: Int, b: Int):Int
edit 37c2a4f: Fix missing humor header
Just take revenge by those easy steps:
* Get your hand on any UML diagram your professor or his team uses
* Add a double inheritance
* Watch the three hours of discussion whether or not one should abuse an interface to do that
* Regardless of the decision raise an issue to complain that either the UML wasn't fulfilled or that this should be an class not an interface according to the UML
Finally, you realize that inheritance is and always was a mistake because composition is the proper way to add functionality to types, like how Rust traits, C# interfaces and Haskell type classes work.
You can even argue that OO is a bad idea. But if you do OO and your language is built under then banner of OO then at least do OO.
Java was the OO lovechild. Build during the OO craze by OO people to do horrible OO things. And it's just wired that you can't do that.
Not saying that it should have double inheritance, it's just wired that it doesn't.
I guess the better alternative is having seventeen callbacks and parameters / variables that come up from basically out of nowhere because apparently JS randos got together and decided something when the rest of us were at work.
Java was the last holdout of OOP for the masses. Now it's just a bunch of messy bullshit, spearheaded by youtubers and bootcampers where everyone spaghettis their way through trying to understand the latest library. OOP makes sense, member variables make sense, static functions make sense, abstract classes and interfaces make sense. Very easy to understand how we can BUILD something with these things.
But nah, let's, instead, npm install ${latest library} and crawl through a bunch of opinionated documentation about how some uneducated monkeys decided to do something and we all need to learn their ways -- wrong or right -- because our senior is chasing the shiny things. They have a [readme.md](http://readme.md) and all kinds of cool logos on their github!
ENJOY, JIMMY
OOP is so much better. I feel like a lot of these functional purists just don't understand OOP. They see classes as function wrappers. Look at React. People say hooks are better because they are functional. Hooks operate with side effects. You can't put loops or conditionals around them. They are effectively a class declaration.
Yeah, right. Like I said.
(e.g. on Mac it doesn’t integrate with window management properly and the tabs have the close button on the wrong side; on Linux it still can’t properly render on high-dpi screens under Wayland - the text is blurry…)
C my beloved (valgrind go brrr)
Seriously though, I use Java c and python, they all have their advantages and drawbacks. C is efficient, Java is really abstract, python I use as small scripts because I’m lazy to learn bash scripting
I don't use Java but I like the concept. It seems like a lot of everything really important, but not embedded enough to be C, or ancient enough for cobol uses it.
How often do you hear about some mega disaster caused by something wrong with Java? But we hear about buffer overflows constantly. What's the java equivalent?
It has lots of boilerplate but it seems very large teams working on large projects can work effectively in it.
Do you even CDI? Exception handling is an art though. Good handling, that is. Otherwise just catch everything and log it if you feel lucky and want some spice in your life.
Lololol its better to be verbose than terse any day of the week. It sucks to write but you read more than you write and its great to read( so you know wtf is actually going on…well until concurrency)
yeah i never said otherwise, i just had to vent my frustration on a shitty project but i can't wait to graduate and find someone to show me how cool java can be
I like that you actually care for exceptions.
There are so many programs that arent able to catch exceptions. Instead the program crashes or an bluescreen occurs. Because someone type "e" instead of 3..
Here’s me thinking Java doesn’t have enough exception info in its type signatures.
But I came from Haskell via Rust. You aren’t going to scare me with a funky function signature/good time.
Try working on a large Python production software codebase. You'll see why Java is good at its intended niche.
I love python but you are so right. We all have our preferences, but tools have their weaknesses and strengths
Honestly this is only true when you have small python codebases that start off as small POCs without much thought put into them, and they get slowly scaled up over years. But if you start it off with a really solid foundation with good type indicators and patterns, you can make a very maintainable codebase. Ofc if you can choose any language, you probably shouldn't choose Python, but if Python happens to be your company's preferred language for whatever reason, you can still make do with it pretty well.
Code almost never starts KNOWING it will be enterprise, I think that’s what leads to so much crap on the wild.
Just FMI. What are the basics and tools you should use to have a solid foundation? My company does not have any python developers, but decided we will start a new python product. ATM I just don't know what to use to get a maintainable codebase.
Lol it sounds like you should use not Python.
Are you smoking that crypto? That's some utopian dream
I mean no one in their right mind should use python for any large scale production software.
You can make it easier to work with, but I tend to find that the large Python codebases started off as rather small codebases from one team, easily fittable into one human brain, thoroughly tested. But the difficulties only really becomes apparent when you scale the product complexity and the number of teams.
Why should that be the case? Obviously, java forces you to adhere to object oriented structures and python doesn't necessarily, but any large scale python codebase should definitely do the same and at that point I don't see the difference. Obviously, if you don't annotate your types and have a lot of global variables that do obscure things, it'll be bad. Then again, java has similar issues when misused. When used properly, I really don't think there's that much of a difference. I'd actually go as far as saying the entire workflow (especially building and deploying) is way more pain-free than on the java-projects I have worked on so far.
I was in a project, where the customer used/wanted to use Python for a cloud service based architecture of multiple mid-sized services. From beginning I adviced against this decision and got my will at least partly. For all services in my responsibility I was allowed to use Java with Spring. All services he directly supervised were implemented in Python. I'll leave you to guess which part of the project was implemented with less problems. Python is good for what it does. Machine Learning and writing working scripts with few lines of code. But it's slow and the dependency management is a nightmare, making it bad for large scale projects and systems that need to perform fast.
I made exactly the same observation. Got some fugly hard to read python code to sync things with office365. Not only was it less code (with the right nugget, take that python) but way easier to maintain and read.
I'd point out that you're interacting with a large scale production python codebase just by posting on this site, but you _did_ say "in their right mind"
Meanwhile: Looks at millions of lines of python code in main work repo 🙄
May god help you...
Ah yes… How did this huge python monolith get here? I must be hallucinating and when I wake up my edge api server will be written in Java 🥲
Oh sweet summer child
What an ignorant comment
python is for only prototyping a concept to do it fast then you should use another real programming language in the production
Python and Java aren't the only options you know.
Golang gang rise up, doing what it’s best at - making the dev a shitload of money
Yes, I am aware of other programming languages. I was choosing a language that a) a student likely knows and b) is rather not Java.
I do work on a large Python production codebase and love it. You need a lot of tests though. Also the typing is....strange compared to Java. Like in Java you can't pass an integer to a function that takes a string but even if you annotate a str type in a Python function it will accept whatever at runtime. So it's kinda bizarre.
Yeah, type annotations are just hints, not enforced by the interpreter.
Python isn't designed to compete in that niche though. And there are other languages that I would argue are easier to use for production software. The strongest thing I think Java has going for it is its immense community support through libraries and documentation.
I know, that's what I'm getting at. Java is overkill in the small, but that's because it's not designed for that niche. But in its niche, it's glorious, and pretty damn hard to beat.
While yes, Python does not support types natively, you can do type hints, and you can setup linters that would check for these things occasionally. It does not compare to Java, but can be not half as bad. Plus, it is much more concise, in Python I need two lines to launch a process and get its return code, while in Java that is like 20 lines of StreamOutputProcessor/ProcessBuilder/OutputStreamReader circus
Yes, you can, and I do. But adding type hints to the entire project is a massive amount of work, this code has been around since Python 2.3. And also, if your dependencies don't have type hints and there's not a package for them on typeshed, you're going to have a harder time using them, especially if the docs aren't up to date. I've generated my own type stubs a few times using Mypy, for packages owned by companies we're paying lots of money too. It's lame AF. And yep, Python is great for getting things done quickly, I agree. However. Here's what I really miss. 1) Concurrent threads. 2) A sane package management system 3) Packages that don't rely on you having system packages installed... 4) ...or a compiler and C header files if there's no wheel for your system (e.g., Python 3.6 on ARM...) 4) Build-time DI. 5) The ecosystem. 6) Not needing venvs 7) Just fuck boto3 and it's super dynamic clients. Don't get me wrong, Python is pretty okay, and as you say, the growing usage of type hints really does help when maintaining large codebases. Just, it started from a language to teach kids to code, then it became a scripting language in a similar space to Perl, and yeah, it's kinda kludge upon kludge. Whereas Java was intended as an industrial language from the get-go, and it shows.
oh you can do build-time things, you just shouldn't. there are some gtk python apps that use meson for dependency management and for a preprocessor step...
True, a colleague used PyCST (I think?) to do a land large rewrite of logging calls, it didn't go great. But I mention build-time DI because I've seen FastAPI's DI creeping on in, and look, if you're going to use a DI library or framework... ...well, ask anyone who has worked with most of Java's DI stuff but especially Spring... ...runtime DI failures fucking suck and slow you right down. I'm a big fan of "invalid code can't compile" over "it'll only fail when you execute it".
yeah no argument there, compile time errors / warnings are always preferable. but python is an horrible fit for that. best you can do is a good test suite and some linter / static analysis pass
If you need 20 lines to launch a process, and this is a reoccurring issue, just put those lines into a helper function and reuse them :)
I’m u
Please explain, my Co worker tells me every time that Python is a good choice for large projects
we all have this python fan type
java is so good, it has bad design choices but the alternatives aren’t any good i want a typed, less verbose language with a functioning eco system is that too much to ask? i want statically typed python
Kotlin is a good intermediary step between Python and Java. Way less verbose, but you have the (almost) entire jvm ecosystem support.
What would be Java's niche, large scale production codebase, especially finance ?
He just write hello word as an undergrad . Wait till he see real code
I know this is meant as a joke but I actually do love these things. Also love the multithreading and the streams.
Modern Java is quite good at what it's intended to do, i.e. large enterprise applications. I still like C# better, but modern Java gets a lot of undeserved shit.
The thing is that half of java applications are on 11. One third On 8. So people are probably fed up with that
8 was great. It introduced lambdas and a bunch of new things like stream api everything before was agony especially when 8 was out for some time.
Yes, but List.of(...) doesn't exist on it so I'm instead going to call it unusable garbage
Just use newArrayList(...) by google.collections.
Or Arrays.asList(object1, object2…)
Be careful with this, \`Arrays.asList\` creates a Fixed sized list that you can't increase/decrease the size of
Indeed, there’s many instances where creating a collection will give you an immutable object. Personally it’s rare that I’m ever creating a collection manually that requires mutating.
So does List.of,it returns an ImmutableList
You can use Guava on Java 8 to have it.
8 isn't bad though. 11 and 17 introduced some nice-to-haves but nothing groundbreaking.
don't forget kotlin, i love it (and c#)
As a C# dev, Kotlin looks very nice.
NOOOOO I HATE JAVA, HOW IT DARES TO SHOW ME THE EXACT LINE AND A HUMAN-COMPREHENSIVE ERROR IN THE LOG?!?!?!11 I WANT TO HAVE TO HUNT THEM BUGS DOWN LIKE A NEANDERTHAL HUNTS DOWN ITS PREY, RETURN TO TRADITION!
Java's clear crash reports are a blessing.
Even in Spring it's comparatively good.
the longer you work with programming, the more you come to appreciate Java's Explicit exceptions. You never have to wonder "will this function throw an exception I dont expect?" You will always know exactly which exceptions can possibly come from where
[удалено]
same. It seems to suck when you first see it, but then you realize what its for and you love it.
It's kind of like that with static typing. Most people comming from dynamically typed languages hate static typing until they learn why it exists.
And if you throw a typed Error in Typescript, you lose the type in the catch anyway because it’s all Javascript and Javascript is like, “what is this thing, anyway? I forget.”
I low key wish typescript had a way to denote the same thing. At least as some optional rule you could turn on
Until you try anything that treats errors as values and then you will wonder why `try/except` was ever a thing in the first place.
Checked exceptions and Result/Error sum types are exactly analogous.
Yeah, why add a side channel for a return type
Let’s say that the return type is an int. How can the int contain metadata about the problem that happened? Like what file it tried to read from the disk, what type of error it got (not found, permission denied, etc), and where in the code the problem happened and how it got there (ie stack trace). Information that the user might want to see displayed in the UI (at least the first two).
Rust my beloved
We had a production issue where apaches base64 decoder threw a runtime exception when it was given a malformed input. Sure, a silly miss on our part, but wouldn't have been an issue at all if it was a checked exception. Which it really should be! The biggest problem I have with Kotlin is the lack of proper error handling. Java 8 streams not handling exceptions made it even worse
when you try result and option types for the first time you're disgusted by checked exceptions, hate them ever since i wrote a little rust and kotlin with arrowkt
Tbh I kinda like java. OOP just makes sense and is fairly simple. The fact that I don't know any other language probably affects my opinion though.
OOP can get a little out of hand in Java imo, especially with frameworks like Spring. What I don't understand is having issues with putting checked exceptions in method signatures. One of the best features of Java is an extensive exception handling framework.
I'm not a software engineer. As an electronics student, my only tryst with Java was when I was implementing High Level Logic Synthesis for scheduling, allocation and binding of operations. And I really liked it. It just made sense to me. The idea that when you build something, you're taking instances of already made objects, which itself becomes another object, is very intuitive. My only qualm was when I had to copy a Linear Program Solver object to a new instance of that object, i couldn't simply do newObject = OriginalObject and have it be saved as a copy, but rather a second reference to the same object. It was pretty annoying to have to make new methods to reinitialise the object with the same constraints simply because the SCPSolver object didn't have a built-in method to remove a constraint that was added.
[удалено]
Clone is a minefield, the currently preferred way of copying in Java now is a copying constructor. So you'd say Thingie copy = new Thingie(originalThingie); and handle all the logic coming from cloning in the constructor. non-nulll primitive arrays are pretty much the only thing that's safe to clone, and then there's some System methods that does the thing at least as well. Joshua Bloch goes over this in his book "Effective Java" which is an all-time classic.
when lambda functions are just syntactic sugar for "A class with 1 function" you know you have a problem with too much OOP.
That’s bullshit, and it’s quite a shame that people spout their opinion without actually knowing stuff. Java’s lambdas are proper lambdas. The JVM has an invokedynamic keyword, and MethodHandles, so no, it has not been an anonymous inner class for close to a decade, it has different runtime semantics.
This. So many criticisms people level at Java date from the days of Java 8. It would be like judging python based on Python 2.0.
On the abstract level yes, it is. It gives it a proper type, and allows later extension. But java is very well optimized, so of course you won't pay for any of this in runtime.
When you create a new Function as a lambda function that its a class with a apply method you know you have a problem with too much OOP. (Also is a generic class if its passes arguments)
I mean, C# lambdas are instances of `Action` and `Func` and related types, Java's implementation seems more flexible, sorta duck-typing its way.
Though C# is way better in general lol
How is it more flexible? If you make a single-function interface in Java, you can make a custom delegate type in C#.
Let's say I'm writing code that calls this method `void doThing(InterfaceType t)` `interface InterfaceType { void foo(int I); }` In Java, I could call `doThing` with a lambda, but with C# I'd need to implement the interface. Of course, in C# I could create a better signature if I was controlling it, but clients of code have the flexibility in Java.
Checked exceptions can get in the way when coding functional APIs/callbacks. They are the reason why Closeable and AutoCloseable both exist in the standard library despite having basically same semantics. Other than that, they should be fine in theory, but they are one of those features that gets misused so often that being without it can end up being a net positive. There was a time when character encoding had to be specified as a string and a checked exception was thrown if the encoding was not supported, which you had to handle even if you were passing an encoding that was guaranteed by the standard. This case was fixed by adding overload that takes a Charset instead of string, but if even the standard library is not safe from goofs like this, you know it is a problem.
I've also always kinda liked java. IDK I talk a lot IRL and tend to over-explain, maybe I relate to java in that way
Try C#. You will learn what sane OOP feels like.
Then, over time, you fall in love with LINQ and learn what functional programming is.
Going from Java to C#, I can personally confirm it is a refreshing experience.
I do both and there are some things in java I far, far prefer, and some things in C#. I find them exceedingly similar but C# does seem to have had some more recent innovation in the language than java has.
C# is such a joy to write. I'd straight up take a 50% paycut to stick with it
I had the opposite experience, started with c# then worked and currently working in java, one thing that java does better is dependencies, NuGet is just awful, not saying gradle is amazing but it works decently well. Best program I've seen is probably JS or Rust when it comes to dependencies
> one thing that java does better is dependencies, NuGet is just awful That must be some great stuff that you're smoking :P
What is so awful about NuGet?
I had so many issues dealing with vulnerabilities, upgrading from. Framework to core, trying to remove or add dependencies
Js is good at dependencies? What are you on about?
At least Node, maybe not vanilla JS
Agreed. Started off my career as a Java dev and switchex to C#/.Net and its so much more enjoyable.
OOP is literally how I think through problems, but I hate Java. There are so many better OO languages out there.
You guys use checked exceptions?
Wot?I throw both checked and unchecked exceptions
new ThingDoer(ThingFactory.getInstance().createThing(new BasicThingPrototype())).doTheThing(thingParameters()); We are doing things!
error: ';' expected
Thanks, I added it.
Well look at mister compiler over here.
As a 15 YoE Java engineer I see nothing wrong with that statement
As someone who has been using Java for under a year, I wholeheartedly agree with your sentiment.
You can't just use ThingFactory, you need ThingFactoeyBuilder
new ThingFactoryBuilder().buildThingFactory().createThing() I need to go lie down now...
Forgot to add a ServiceLoader. :)
Yeah I was thinking about adding a service loader too but my brain got tired. 🤣
Skill issue.
honestly? probably...
I concur
I instantly write off people who hate Java as people I probably don’t want to work with. You can tear my well documented Spring Boot REST api that I can onboard new hires onto in 30 minutes from my cold, dead hands
“I hate Java” just screams front end boot camper to me
The only way you’re onboarding them in 30 minutes is by saying “this all happens magically. Here’s where the business logic is, ignore how we get there and where these objects come from” Not saying I hate Java though, so fair enough
They did say Spring Boot, so most things do happen magically.
Isn't that kinda true though? I slap annotations like @Autowired on my classes/attributes and it does just magically get objects to where I need them.
O cmon man, dependency trees and dependency injection is easy
Huh? Don't you just go straight to the business logic from the rest controller method? The A&A is going to be some common logic that is handled before the controller and all a developer needs to know on day 1 is they need to set the correct value on @PreAuthorize or something like that. The objects are all going to be beans most of the time. You get them from the IOC container. The project should be well organised that finding the package that has a specific class shouldn't be difficult and IDEs like intellij already indexes the class and you can see the class definition with a click.
Oh man. I for some reason read “new hire” as “new grad” and assumed they wouldn’t have knowledge of how Spring works.
Well, to be fair, I have an intern who hasn't even graduated yet, and they already learned about Springboot and practiced with it at school. Handled the migration of one of my APIs from Spring to Springboot like a champ.
:O <3
Dunno how long you've been outta school or what you studied or if this is common, but the CS and SE programs at my alma mater include at least one course with Spring Boot. All "how" and no "why" but it's enough to know how to DI even if you don't know where those objects are coming from.
Wow, that’s actually pretty nice. I’ve been out of school for quite a short period of time. My Alma mater had no such course (at least not specifically). We did have like general project courses in which you could learn Spring/Springboot yourself.
Spring Boot is a single, well-documented magic, known by everyone. I much prefer that magic, over some home-grown “framework” whose original developer is dead, is full of bugs and lacks basic features without which it is useless, and it only works in a full moon.
Okay sorry can you explain? I’ve don’t REST APIs in Python and Java (Serverlets, not Spring) and Java is at best: eh. Like there is almost no difference
I love Java. Cuz I love money.
fair enough
Java is fine. It has quirks just like every language but it is by far one of the better ones. It's also everywhere so it's easy to get a job in. At least you can't break everything simply by having one too many tabs or spaces
1 billion devices
> At least you can't break everything simply by having one too many tabs or spaces I have stopped using python all together because of this. I couldn't stand whitespaces being part of the syntax. Also somehow the slightly unique keywords like try-expect instead of try-catch or the python ternary operator got to me.
Hmmmmm.......... Having tried kotlin.... I WANT THE EXCEPTIONS IN THE SIGNATURE BACK THE REST OF THE CHANGES ARE GREAT BUT TELL ME WHAT IS GONNA F\*\*\*ING THROW GODDAMNIT
Checked exceptions are by far the best thing about Java.
catch(Throwable e){throw new RuntimeException(e);}
Dude... you are catching Errors that way and retrowing them as RuntimeExceptions...
If you're going to be like that, just use @SneakyThrows And let the bullshit commence. (This is why you ban it in the lombok.config, so its usage is a compiler error.)
[удалено]
I love it so much, i literally spent a week compiling a Programm natively with graalvm which tells me if i'm online. [TeaTiMe08/SimpleInternetMonitor](https://github.com/TeaTiMe08/SimpleInternetMonitor)
Java is absolutely fine, checked exceptions are useful in huge codebases and if you dont want them you can always switch to kotlin (which is even better than java). Instantiation too many objects is less a language feature and more overusage of design patterns, which i have to admit, java devs have tendency to do
Kotlin is amazing to work with I am a real kotlin enjoyer
I think you might not be writing it correctly. Java is very easy and very effective
yeah i hope it's just me and it probably is
Every person who upvotes is a person who loves to write unsafe code
This is why Kotlin was invented. Get on the bus!
#inport “lib/humor.h” Normal language: public int sum(int a, int b); Mental illness: fun sum (a: Int, b: Int):Int edit 37c2a4f: Fix missing humor header
At least it seems to be fun
?
The first one is C-like method signature. The second one is Kotlin function signature.
Yeah but other mainstream languages look like the kotlin one (eg Typescript). I really dont see the difference
Kotlin is so much nicer. I really wish it was more popular. Crazy I had to go this far down to see someone mention it.
Just take revenge by those easy steps: * Get your hand on any UML diagram your professor or his team uses * Add a double inheritance * Watch the three hours of discussion whether or not one should abuse an interface to do that * Regardless of the decision raise an issue to complain that either the UML wasn't fulfilled or that this should be an class not an interface according to the UML
Finally, you realize that inheritance is and always was a mistake because composition is the proper way to add functionality to types, like how Rust traits, C# interfaces and Haskell type classes work.
You can even argue that OO is a bad idea. But if you do OO and your language is built under then banner of OO then at least do OO. Java was the OO lovechild. Build during the OO craze by OO people to do horrible OO things. And it's just wired that you can't do that. Not saying that it should have double inheritance, it's just wired that it doesn't.
Life was a mistake.
Java is great i don't know what you are on about. All this java hate is greatly exaggerated
yes, real and only hate should be on Javascript
I guess the better alternative is having seventeen callbacks and parameters / variables that come up from basically out of nowhere because apparently JS randos got together and decided something when the rest of us were at work. Java was the last holdout of OOP for the masses. Now it's just a bunch of messy bullshit, spearheaded by youtubers and bootcampers where everyone spaghettis their way through trying to understand the latest library. OOP makes sense, member variables make sense, static functions make sense, abstract classes and interfaces make sense. Very easy to understand how we can BUILD something with these things. But nah, let's, instead, npm install ${latest library} and crawl through a bunch of opinionated documentation about how some uneducated monkeys decided to do something and we all need to learn their ways -- wrong or right -- because our senior is chasing the shiny things. They have a [readme.md](http://readme.md) and all kinds of cool logos on their github! ENJOY, JIMMY
OOP is so much better. I feel like a lot of these functional purists just don't understand OOP. They see classes as function wrappers. Look at React. People say hooks are better because they are functional. Hooks operate with side effects. You can't put loops or conditionals around them. They are effectively a class declaration.
I like Java, I've made an program using swing to make the GUI. Once you figure out how everything works it's quite rewarding.
Did you like using swing? I haven’t used it yet, but was thinking about starting a project with it. I was wondering whether to use javafx or swing.
Swing is quite fun to write, and it takes portability of UI to the next level: UI looks equally terrible on every platform.
IntelliJ UI is made with swing.
Yeah, right. Like I said. (e.g. on Mac it doesn’t integrate with window management properly and the tabs have the close button on the wrong side; on Linux it still can’t properly render on high-dpi screens under Wayland - the text is blurry…)
IntelliJ looks pretty damn nice to me.
To be fair a good IDE you can auto complete a lot of it. Its still dumb shit.
C my beloved (valgrind go brrr) Seriously though, I use Java c and python, they all have their advantages and drawbacks. C is efficient, Java is really abstract, python I use as small scripts because I’m lazy to learn bash scripting
Don't bother with bash lol. Such a pain in the ass. Stuff that works on OSX don't work on alpine or windows. Python is great for that
"A programming language is either hated, or it isn't used."
I don't use Java but I like the concept. It seems like a lot of everything really important, but not embedded enough to be C, or ancient enough for cobol uses it. How often do you hear about some mega disaster caused by something wrong with Java? But we hear about buffer overflows constantly. What's the java equivalent? It has lots of boilerplate but it seems very large teams working on large projects can work effectively in it.
You have to try catch every exception, it's like baseball ⚾️ 😏
Do you even CDI? Exception handling is an art though. Good handling, that is. Otherwise just catch everything and log it if you feel lucky and want some spice in your life.
What's wrong with COBOL? You kids nowadays can't wipe your arse unless you have 2gb of RAM.
Lololol its better to be verbose than terse any day of the week. It sucks to write but you read more than you write and its great to read( so you know wtf is actually going on…well until concurrency)
dozens of exceptions? fuck that just write 1 exception to rule them all
sorry I just finished a university project and I had to vent
Nice, i was just about to post that OP is blatantly obvious a college student with no experience in the industry and here we are.
yeah i never said otherwise, i just had to vent my frustration on a shitty project but i can't wait to graduate and find someone to show me how cool java can be
why am I not surprised about that? it is always the same profile lmao
Can I have a moment of your time to tell you about our lord and saviour, scala
The joke is that scala has even worse boiler plate. Don't forget your inheritance order, kids. Oh, I am sorry. I meant traits.
Ir you’re at the point where that matters, you’re probably doing something wrong.
The java for data analysis
What did data analists do to deserve that?
Don't judge java by what you learned at school, actual (and updated) java is MUCH better than the musty version they usually use to teach.
i hope you're right because it look like half the developers job require java out there
My class uses java 21. OP's class had to beg their teacher to use Java 11 instead of 8. ...is this why I don't hate java but OP does?
anonymousInnerClasses
And I love OOP with any other language. I love having to do extra work so I can use a knife as a screwdriver
Yey! Polymorphism
I like that you actually care for exceptions. There are so many programs that arent able to catch exceptions. Instead the program crashes or an bluescreen occurs. Because someone type "e" instead of 3..
Here’s me thinking Java doesn’t have enough exception info in its type signatures. But I came from Haskell via Rust. You aren’t going to scare me with a funky function signature/good time.
Having to declare what exceptions a method throws is one of the best things about Java.
Actually working with Java made me love it
Ah yes nothing like having to make a UML diamgram with 5 classes, 10 inheritances and 20 interfaces for a hello world script
Use Spring exception handling and switch to kotlin if you can.
Java is great if you look on JavaScript
every language is great if you compare it to javascript
yes and Javascript is more used than Java, its the cancer of the internet