Hi! I'm a webdev newbie and I'm currently looking for a good framework to try out. I'd like to know, regardless of my expertise and learning curve of either language, which would be a better choice for building a fast and reliable website? Java(SpringBoot) or Python(Flask/Django)? And can you give some examples of websites made with either language? If anybody has any other suggestions(like JS) besides these two languages/frameworks, feel free to tell me as well. Thanks in advance!! :D
Videos
The issues with Java threads in the question are addressed by the project Loom, which is now included in Jdk21. It is very well explained here https://www.baeldung.com/openjdk-project-loom :
Presently, Java relies on OS implementations for both the continuation [of threads] and the scheduler [for threads].
Now, in order to suspend a continuation, it's required to store the entire call-stack. And similarly, retrieve the call-stack on resumption. Since the OS implementation of continuations includes the native call stack along with Java's call stack, it results in a heavy footprint.
A bigger problem, though, is the use of OS scheduler. Since the scheduler runs in kernel mode, there's no differentiation between threads. And it treats every CPU request in the same manner. (...) For example, consider an application thread which performs some action on the requests and then passes on the data to another thread for further processing. Here, it would be better to schedule both these threads on the same CPU. But since the [OS] scheduler is agnostic to the thread requesting the CPU, this is impossible to guarantee.
The question really boils down to Why are OS threads considered expensive?
FastAPI is a fast framework, and you can quickly (and easily) create API backends in it. To be honest, if you are a Java developer, I would recommend Quarkus or something for building a REST API, not FastAPI. FastAPI is a fantastic tool, absolutely great if you are already in the Python ecosystem.
When it goes about multithreading; Java is 'real' multithreading where as Python is very much not. Java threads will run concurrently; two tasks can and will be executed at the same time. In Python, within one Python process, this is (nearly) impossible. The reason for this is GIL (google it, there is ton's of stuff out there on how it works). The result is; even if you use 'real' threads in Python, code is still not executed concurrently but rather serially, where the interpreter (big difference to Java) is jumping from one call stack to another constantly.
As to what you refer to as 'logical threads', I think you mean the asynchronous capability of Python. This is basically the same as using threads (not really, but on an abstract level they are very similar); tasks are not run concurrently. There is just one thread that constantly switches between tasks. Tasks will yield back control to the event loop (the object that coordinates tasks and decides what is executed in which order), and another task is further executed until that task yields control, etc. It is basically the same kind of execution pattern as with threads within Python.
Comparing a Python framework to a Java framework is just weird in my opinion. They are both useful and cool, but not really competitors.
Honestly, in a perfect world, Python would just do everything for me. It's just such a pleasant language to work with. But we don't live in a perfect world. Still, I want to believe that Python offers at least a solid foundation for backend development in Germany, with well-paid jobs.
How does Python really stack up against Java + SpringBoot?
On LinkedIn, there seem to be about the same number of jobs for both stacks in Germany, but I'm curious about the experiences of other developers here.
Hello,
When you want to get a good job it is best to focus on a particular framework within a programming language such as Java, Python, Javascript, PHP and the most used framework for that particular language. Java+Spring, Python+Flask/Django, etc. I am making some decisions based on stability, tutorials online, what the market is offering in jobs and so on. Personally, I think Java and Python are better for me because they offer great OOP and architectural designs. I just need to decide between these two. I think Java+Spring sounds more robust but I don't know wheater more "fun" jobs will appear in Python. I think python is a little more flexible as it can be just a script but at the same time a large project with OOP. Looking at tutorials online, python offers more it seems and they include fun images etc. On the other hand, Java seems a little more stable. What are your opinions on this and what are you personally working with?
I am working in a big MNC as a Java developer where I am responsible for building the backend APIs using spring Boot. What If someone asks me why are you using spring Boot to build your backend services and not django. Well I know you can't say because I know java. What should be a good answer to such a question ?
Hello all,
I come from the Java world, where the norm for deploying applications to Kubernetes (K8s) is to use the Spring Boot framework.
What is the equivalent framework or standard in the Python world, if any?
Thanks