The next class was assembly programming, where the teacher didn't bother to show for 4 months and then resumed the class as if we "self-taught up until this point". We were utterly lost in that one.
I imagine things have changed greatly today but back then it was a complete roller coaster.
I wasn't good at getting educated, but I ended up at a community college to "get my generals" - my first class of the day was computer something or other, and the class was led by a man in extremely thick glasses who said that our general approach in the course was going to be:
* perform actions with the computer
* take a screenshot
* paste the screenshot into mspaint
* print out the screenshot as proof that we had completed the thing
* put that in a folder
* he would review the folder for completion
(for anyone paying attention, anyone could just print out multiple copies)While it was a significantly younger and less experienced me who quit this bullshit in an absolute huff, I don't know if I could go through it today.
Fast forward a few years later, and I was training folks on tech support(a random reversal) and I had a lady who should have taken his class... every time I told them to click on something she asked "is that right click or a left click?" and each time I would respond "its a left click unless I tell you otherwise" (she didn't last long.)
But what does this code even mean..? Isn't Java's whole simplifying model that everything lives in "Objects"? This seems to break that fundamental paradigm and makes the language more complicated. If you needed something like global functions then in vanilla Java as I remember you'd stick it into static final Objects that acts as a namespace of sorts. So you don't need to worry about functions floating around in a global namespace soup.
If you're gunna just have free floating functions in your file.. then why not just cut to the chase and have a
println("Hello world");
floating in your file..? (I mean... you don't have REPL so maybe that wouldn't be too meaningful...) > you don't have REPL
(ahem) https://docs.oracle.com/en/java/javase/23/jshell/introductio...You don't sound like you work with Java. I know for a fact that even some FANGs, with their army of software engineers, still use Java8 for most of their Java projects.
From what I can tell, there are 4 main reasons why some don't upgrade.
1. They have legacy software and are afraid of breaking it, sometimes with good reasons.
2. The devs don't know or care enough about the new versions to bother with it. Noone is promoted because of an upgrade. Work to live, and don't live to work
3. The ones who don't have buy in from management to spend time fixing something that works
4. They are using version 11+ that should be much safer to upgrade than earlier versions, but they are still in the mindset of 1 or 2 above
There have been huge improvements not only in the language itself, but also performance and memory use. They could save money if they upgrade, but in some cases this is acceptable because they can make more money by spending time on a new feature, than an upgrade.
In my last 3 workplaces, they usually tried to use the latest LTS versions. But to be honest, some of the services were in maintenance mode and we didn't get enough benefits to upgrade, so we were sometimes falling behind. Today we have a mix of v17 and v21. Anyone can upgrade anytime they want but noone cares about a service that you seldom work with. I feel kind of bad for that, but not enough to bother. I focus mainly on the services that I work with daily, and make sure they are using the latest versions
You missed the most obvious reason to not upgrade: there is no good reason to do it.
> There have been huge improvements not only in the language itself, but also performance and memory use.
That's debatable, and even if we blindly assume that then it's debatable whether the upgrade justifies the gains.
More often than not, it doesn't.
This is not debatable. It’s a factual truth. Every single actual performance review concludes that modern Java vastly out performs the decade old Java 8 runtime.
For an example here is a quote from Hazelcast when comparing performance of modern Java on data heavy workloads [0]:
> JDK 8 is an antiquated runtime. The default Parallel collector enters huge Full GC pauses and the G1, although having less frequent Full GCs, is stuck in an old version that uses just one thread to perform it, resulting in even longer pauses. Even on a moderate heap of 12 GB, the pauses were exceeding 20 seconds for Parallel and a full minute for G1. The ConcurrentMarkSweep collector is strictly worse than G1 in all scenarios, and its failure mode are multi-minute Full GC pauses.
This is from 2020 and the gap has only gotten wider.
[0] https://hazelcast.com/blog/performance-of-modern-java-on-dat...
I don't think you even bothered to read the sources you're quoting, and you're just trying to make baseless assertions.
The very first question on JetBrain's survey is "Which versions of Java do you regularly use?", and 50% answered Java 8 with around 2% mentioning Java 7 and 1% answering Java 6. On top of that, Java11 alone comprised around 38%.
And you're talking about Java21? It doesn't even register in the survey at all.
The data there clearly shows that the ecosystem has as many users running a modern version. Which directly counters your assertion that everyone is just running 8.
I don't think people realize Java8 was until very recently the dominant java version in production software, and currently close to 90% of all java projects still run on java11 and earlier.
Edit: after checking New Relic's 2024 report on the java ecosystem, it sounds like java11 and earlier is now at slightly over 60%, with java17 being used in around 35% of the projects.
But, yes, with static imports, you can just write "println" like that and have it work.
did you know that every function in a python script is actually an attribute of that module (which is basically a class). so my point is: who cares.
You still need to know what a main class is, so that you can reference it in your build.gradle file.
But it's useful for little one-off scripts, where you just go `$ java foo.java` from the command line.
(My guess: It is.)
> So you don't need to worry about functions floating around in a global namespace soup.
Because having classes floating around in a global namespace soup is fundamentally different and should give no worries to anyone. Yet this was argument made in earnest back when arguments about Java's strengths and weaknesses were much more popular.
Basically, imagine a `class Temporary4738 {` and `}` written above and below the .java file's content, that's roughly how it will behave.
It not having a fixed name is deliberate, so if you decide to build a bigger system you won't use this mechanism in a hard to maintain way, and also it needed a good semantic model for "top-level" variables/fields.
But with this implicit class model, top-level definitions are just fields of the class.
The same strategy is also followed by C# with their top-level statements. And yes, it's syntactic sugar.
https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals...
Welcome to the last 10+ years of Java. They're trying to play catch-up to other languages that made fundamentally different and better choices, making Java more and more complicated in the process. They are so deeply entrenched in the enterprise back end space that programmers put up with it, nay, even feel grateful for it. People who are stuck using Java for the rest of their careers are happy to see it grow to accommodate 21st century programming techniques, even if it means that it becomes so complicated and crufty that no beginner will touch it ever again.
eg want to run code for 6 months at a go managing hundreds of gigs of data, tens of thousands of threads, at high load, with sustained gigs a second of garbage generation? the jvm will just silently tick away doing just that while being nearly bulletproof. As much as I love ruby and python, you ain't doing that with them.
With hot code loading, introspection, etc. All the stuff that makes developing super-robust long-lived systems way easier.
And the flip side of the clunky language is your code from 20 years ago still works.
Scala mainstreamed a bunch of concepts that java was slow to adopt, but the end result was java only took the good ideas and didn't take the bad ideas.
10+ years ago I considered myself proficient at C++. It made sense, I didn't mind the pointers, and while the std library still felt clunky, it was fine. But I tabled these skills, and they indeed rusted a bit, but surely I could bring them out when needed again, right?
Smart pointers with multiple variants, judicious use of macros, rampant use of double colons to ensure proper namespace resolution (which IMHO makes the code an absolute eyesore), to name a few. I won't argue these changes aren't necessary, but it isn't pretty.
Packages still exist.
It’s just not necessary to add an additional level of namespacing.
Statics never were some pure OOP anyway.
SEMICOLON!!!
As the adage goes - Java programmers can write Java in any language.
Seems 'Java programmers' were already writing Java before Java's release ;)
from __past__ import JavaProgrammer
/usr/bin/python: error: line 0: not a chanceThe massive amounts of indirection which the IDE wouldn’t help you understand was the difficult thing. What encoding you use for that is pretty irrelevant. JSON would have been worse.
The problem with xml was that IDEs were unable to help you.
It’s the Python if __name__ == __main__ trash that was the worst. You’ll never understand it and it doesn’t fit in the language.
I use python a lot these days, and like it, but it's pretty funny seeing stuff like the above and type hints.
I hate not knowing what types a function takes and returns.
This seems true to me too. Examples:
* if __name__ == "__main__": main()
* Private members being marked by convention with leading underscore (e.g. def _foo()) instead of being a language feature
* @staticmethod as a decorator instead of being a language feature
* Duck typing vs. abstract base classes
* Static type hints got retrofitted to the language gradually, one feature at a time
* Reference-counted garbage collection seems to be more deterministic than tracing garbage collection and ensures that unreachable resources have their finalizers run as soon as possible... except it's not true
* Having a GIL instead of being truly multi-threaded from day one
* Various OOP concepts that are much better explained in Java than Python: __eq__(), __hash__(), monitor wait() and notify(), object finalizers, thread safety, weak references
* Distinction between str and bytes. This is the biggest change from Python 2 to 3 and caused a lot of incompatibilities. Java separated String and byte[] from the start (though the use of UTF-16 is unfortunate).
(I do realize that there was opposition on this, but that the Clearly Wrong side won out is baffling.)
> * * if __name__ == "__main__": main()
So, don't use it. Python is frequently run as a scripting language (something Java is fundamentally bad at) and this stems from that. All it does is box logic off when a file is being run directly vs imported. It's a user convention and not a language one....ignore it if you hate it so.
> * Private members being marked by convention with leading underscore (e.g. def _foo()) instead of being a language feature
This is all very well explained in the PEP. The quick run down, Python doesn't do anything to hide logic from users. Contracts are just conventions and python treats it that way; so the developer can say "you shouldn't use this directly, here's a notation to let you know", but nothing will stop a developer from doing what they want. In Java they'll just write a wrapper class, inherit the base class, and expose that logic. Or worse, fork the library just to edit the class' functionality in some minor way. In Python they'll just call it directly.
> * @staticmethod as a decorator instead of being a language feature
@staticmethod is a built-in, it is a language feature. It just doesn't follow your preferred syntax.
> * Duck typing vs. abstract base classes
You can do both in Python:
https://docs.python.org/3/library/abc.html
The concepts aren't mutually exclusive or even directly related. Java just happens to be bad at one of them, due to it's weirdly non-effective (for a VM'd language, at least) reflection system; so you think it's bad.
> * Static type hints
You're complaining about reflective programming and then complaining about a feature that essentially exists because you can't reflect. It's circular.
> * Reference-counted garbage collection seems to be more deterministic than tracing garbage collection and ensures that unreachable resources have their finalizers run as soon as possible... except it's not true.
GC arguments have run for decades and everyone has their opinions.
> * Having a GIL instead of being truly multi-threaded from day one
Python was created in 1989. Java was created in 1996. Can you guess what major change in computer history was happening around the latter's time?
Everything was GIANT-locked when Python was designed, unless it was specifically intended for SMP mainframes. The entirety of the FreeBSD operating system had a GIANT lock on it at the time, for instance. Linux didn't even exist. Mac OS and Windows both were fundamentally single threaded and cooperatively multitasked. Commercial Unices that supported SMP were only ~4-5 years old and a very small niche.
You might as well be complaining about "why didn't the x86 architecture just have 64-bit capabilities from the outset?"
> * Various OOP concepts that are much better explained in Java than Python: __eq__(), __hash__(), monitor wait() and notify(), object finalizers, thread safety, weak references.
In other words: "it's not Java, so it's bad".
Java is a pure-OO language; Python is a procedural language with OO as an optional feature. To that end, it exposes OO-features in an optional manner versus forcing you to use them against your will.
So if the basis of all your arguments is "OO is better in Java", well the the response is "yeah I'd hope so, since you have no other choice as it's the fundamental paradigm". Guess what? Haskell is much better at functional programming than Java; that also doesn't make a valid argument about whether either is good or bad.
> * Distinction between str and bytes. This is the biggest change from Python 2 to 3 and caused a lot of incompatibilities. Java separated String and byte[] from the start (though the use of UTF-16 is unfortunate).
Java was developed 7 years later and during a time that Unicode was becoming the standard over ASCII. Python was designed when everything was still ASCII and Unicode a mere glint to the general computer science realm.
As you pointed out, even Java made a bad decision here due to their premature adoption of the standards (as any modern designed language is quick to point out).
> Duck typing vs. abstract base classes / You can do both in Python
I'm saying that the original intent of Python was duck typing, but then people realized that abstract base classes play an important role - e.g. isinstance() testing, static type annotations. So they still ended up where Java started.
> Static type hints / I don't even know what that means.
I'm saying that Python was designed with no type annotations on variables (though values did have types), and then they realized that people wanted this feature... and ended up where C/C++/Java/C# have been all along. Python became "enterprisey".
And then, Python implemented type hints rather badly from 3.0 through 3.10 and beyond. It doesn't include types in the official documentation, so now you have to guess what open() returns (it's typing.BinaryIO/typing.TextIO). It doesn't have an official type checker, instead relying on third-party tools like mypy. It moved items between typing and collections.abc. It requires `from future import __annotations__` for non-trivial programs. It changed typing.List to just list in 3.9. It introduced the | (union) operator in 3.10. And a bunch more little things I can't recall; it just had a bad out-of-the-box experience and kept tweaking things over the decade. Documenting generics and especially protocols in Python takes effort.
> Python was created in 1989. Java was created in 1996
Wrong. Java was created in 1991, and the first version released in 1996. https://en.wikipedia.org/wiki/Java_(programming_language)
Python 1 was released in 1994, and 2 in 2000. They had their chance to make breaking changes. https://en.wikipedia.org/wiki/History_of_Python
While you're right that Python predates Java, it's not by as many years as claimed.
> Various OOP concepts that are much better explained in Java than Python
To exemplify, here is how you figure out how to override `==`: https://docs.python.org/3/library/stdtypes.html#comparisons , https://docs.python.org/3/reference/expressions.html#express... . Notably, there is no documentation for object.__eq__().
Here is the Java version: https://docs.oracle.com/en/java/javase/23/docs/api/java.base...
Now for __hash__() / hashCode(), the Java version is clearer: https://docs.python.org/3/reference/datamodel.html#object.__... , https://docs.oracle.com/en/java/javase/23/docs/api/java.base...
Python __del__ is buried in the "Data model" page: https://docs.python.org/3/reference/datamodel.html#object.__... . Java's finalize() is easily found on Object: https://docs.oracle.com/en/java/javase/23/docs/api/java.base... . Furthermore, Joshua Bloch's book "Effective Java" has a chapter titled "Avoid finalizers and cleaners" that explains in detail why finalizers are problematic.
Python explains a lot less about weakref than Java: https://docs.python.org/3/library/weakref.html , https://docs.oracle.com/javase/8/docs/api/java/lang/ref/pack...
> Java is a pure-OO language
Extremely wrong. Java has primitive numeric types, which do not have methods or fields, and undergo painful boxing/unboxing conversions to interoperate with the OO world. Whether the performance benefits are worth it or not is debatable, but what's not debatable is that Java is not pure OOP. Some say that Java is a bad copy of Smalltalk, which I heard is fully object-oriented.
> Python is a procedural language with OO as an optional feature
Wrong. Every Python value is an object that can be inspected (dir(), .__dict__, etc.). And in the CPython API, every Python value is a PyObject*. I have ample grounds to believe that Python is more OO than Java.
Gosling and others started working on it in 1991, but does it really matter? First public release is when you can learn about it and borrow ideas. It doesn’t make your point less valid, of course - Java made a lot of hype back then.
You're purposefully fudging dates to make the argument more favorable to your point. If you want to argue initial source release, then you can maybe make the point for 0.9:
> In February 1991, Van Rossum published the code (labeled version 0.9.0) to alt.sources
And say that Python had it's initial release just slightly before Java had begun design specs. But Python was in use before that and Rossum had developed the initial version well before that (again, 1989):
> The programming language Python was conceived in the late 1980s,[1] and its implementation was started in December 1989[2] by Guido van Rossum
It's ironic that you're trying to make that same argument for Java and dismissing it for Python, when Python was very much in public use pre-1.0 and Java was not (outside of internal teams).
> Wrong. Every Python value is an object that can be inspected (dir(), .__dict__, etc.). And in the CPython API, every Python value is a PyObject*. I have ample grounds to believe that Python is more OO than Java.
I feel like, just based on this point, you've done nothing more than open the CPython source code and searched for "object". This naming was in place well before Python even had any of the OO-functionality that exists today (new-style classes derived from the Object type). If you're going to argue for "old-style" classes being OO in any way but name, you're probably going to fundamentally disagree with any OO fundamentalists, the designers of Python itself, and the Java community/designers. You might as well argue that structs with function pointers in C make it an OO-language, as that's functionally all they are.
PyObject doesn't correlate to a Python class/Object. It's a container data structure to allow for their duck/dynamic typing. Object is a type of PyObject; but it contains an additional layer of functionality to make it a Python Object (specifically PyMethodObject and PyTypeObject, and their correlative functionality). Again, to allow for the reflection/introspection and GC that you so bemoan; and due to the lack of C generics at the time (or really, even today). Being able to introspect a type has nothing to do with it's "OO-ness", although it can be very useful in such languages (such as C#).
As to your other point, sure...using "pure" was probably going too far. But by that same argument, even Haskell isn't pure-functional (nor do any really exist) due to it's need to interface with IO. But Java is about 90% there and strives for it. Python most definitely isn't nor does it make any intentions to do so.
Again, fudging the history/facts/topics to try and make your point. It's not worth discussing with someone who so fundamentally converses in bad faith. Especially since I'm making no claims to which is better, just outlining the flaws in your complaints. I really don't care about "better" languages.
hello world in python is literally just print("hello world!")
Arguably you could be a happy Python programmer without this capability.
>>> 'hello world'
'hello world'The point was that by including that print(), people already do say yes to including "like you'd do in a real program" ceremony in their supposedly minimal examples.
you forgot surrounding class definition.
Java is designed with OOP in mind and it kind of makes sense to have the user to think in terms of lego blocks of interfaces. Every method or class needs to have clear understanding of its users.
public - software handle is for all users
protected - software handle for current and extending classes
default - software is exposed to current package
private - software is restricted to be used in current class alone and nowhere else
So, the beginning of java programming starts with interface exposed to the user or other programmers. Is it weird and extreme. Yes. At least, it is consistent.
I somewhat agree, but it was kind of exciting to learn what each of those previously meaningless words meant.
Kind of a sneak preview... Tune in for next week when we learn what static means!!
Goals:
Offer a smooth on-ramp to Java programming so that instructors can introduce concepts in a gradual manner.
Help students to write basic programs in a concise manner and grow their code gracefully as their skills grow.
Reduce the ceremony of writing simple programs such as scripts and command-line utilities.
Do not introduce a separate beginners' dialect of the Java language.
Do not introduce a separate beginners' toolchain; student programs should be compiled and run with the same tools that compile and run any Java program.
In collage, CS101 and 102 required me to learn and use JAVA, which I felt was a huge step backwards in usability and a lot of excess typing.
But as I reflect on it now, I think my feeling were because I came from knowing how to do some things and therefore not requiring the framework that JAVA offed to first time programmers.
1. The obvious excess incidental complexity
2. and more important, the enterprisey culture that's much less compatible with the intellectual curiosity, looking under the hood, etc attitude that's needed to become a decent programmer.
Although my high school programming class was c++, which is even worse as a first language.
It makes it far far closer to the python experience.
void main() {
println("Hello world");
}
should work just as well. #! /usr/bin/env kotlin
println("Hello world")
You have to brew install kotlin for this to work of course. But it's a great way for using a lot of Java stuff as well. Kotlin's Java interoperability is excellent if you are using Java from Kotlin.IMHO Kotlin is underused as an alternative to python currently for data science stuff. It's surprisingly capable out of the box even with just the standard library and there are a lot of nice data science libraries that make it more useful. Not for everyone; but fairly easy to get started with.
Kotlin scripting is unfortunately not necessarily very user friendly (e.g. imports can be a bit tedious and IDE support is a bit meh). But it can be a nice way to embed some kotlin stuff in a script. Generally, Jetbrains could give this topic a lot more love and attention and it wouldn't even take that much to level up the experience.
KTS works in jupyter as well (there is a kotlin engine for that). And that of course is nice if you want to use Java libraries in jupyter. And developing kotlin DSLs for stuff and then using them in a script is kind of a power move.
Kotlin has been pretty bad at scripting and REPL, and unfortunately the team decided to drop both:
https://blog.jetbrains.com/kotlin/2024/11/state-of-kotlin-sc...
What really threw me for a loop is the article author mentions: "I knew plenty of professors who were bothered by [the public static void main thing]." I could have sworn that OOP die-hards in academia _wanted_ the formal class boilerplate in the original design. Maybe they aged out? Perhaps, times are changing.
void main(String[] args) {
println("Hello world");
}
and the previous one ...
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
And that is SO MUCH less? Are you being ironic?Should we allow somebody who cannot handle the second one, go on and programming because of the first one?