> but the amount of needless bashing it gets here is astonishing
I don't think it's needless. I'll bash Java as long as it's the language for AP computer science. Imagine a budding young programmer, bright eyed and bushy tailed, eager to get into computer science. They get to class and greet the teacher "Welcome class, let's learn about Java. There's a wide world of computers out there, but your perception of computing will be that Computing <-> Java until maybe the sophomore year of college. Have fun!"
Students come to me their sophomore year of college completely awestruck. "I had not idea! I thought programming was all Java!" they tell me. Imagine that. Close your eyes and picture a world where all of programming is Java programming. How quick did you open them and splash water on your face to wake rid yourself from that nightmare?
Java is singlehandedly responsible for snuffing the dream of so many young programmers. I've seen it in my own research, where kids in elemntary and middle school describe programming as fun, interesting, and challenging. That's because at this age they're using fun languages like Blockly, and they spend their time programming making and playing games.
Then they get to AP computer science and they are introduced to Java. Perceptions of programming fall through the floor, with more students calling it difficult, frustrating, and scary. It's tragic what Java is doing to young people.
Like, I understand we want students to have skills they will use in business, but we can't present programming to them as if all of programming is OOP enterprise development in Java. It's a crying shame.
Teaching Java in abstract, useless lessons about OOP and inheritance is definitely bad.
But I would say Java is as good a first language as python is.
The purpose of first programming language is teaching concepts - functions, structs / classes, abstraction, data structures (importantly lists and maps); And how to solve problems using that.
Python does well in intuitive syntax for lists/maps, handy standard library functions, and having an REPL; But it gives an illusion that types are redundant. The programmer picking up C++ or Java after python sees only ceremony.
You can also learn the modern java without all the OOP shoved in: Basic programs, functions, data types, arrays, using classes to create custom types, using HashMap, ArrayList, HashSet from standard library; then interfaces, inheritance / subtyping, lambda functions. Use jshell to try small snippets;
The problem with teachers teaching java is that they focus too much on inheritance, with mostly superficial examples like "dog extends animal" instead of something in real world. Inheritance is mostly about subtyping, and any CS student with enough math background should not struggle to understand that.
If students get this preconception, I think it's more an issue how they are taught, not an issue with Java itself. I mean the first language I learned and most of my classes were in Java, but that didn't prevent me from knowing there other existing languages and learning about them.
There are books like "Java in Two Semesters: Featuring JavaFX" [0], which appears in the series "Texts in Computer Science"! Now, that series used to be called "Graduate Texts in Computer Science", until they dropped the Graduate to allow for books like these, I guess. And even "Undergraduate" would have been an oversell. Actually, "Computer Science" still is.
That's not the fault of the language, though I'd say maybe Kotlin is a considerably better choice nowadays. If by blockly you mean the visual interface, what you said is going to be true for any language. If by blockly you mean javascript, maybe, but honestly if it's an exercise to build foundations (and not just for personal gratification), javascript (or python) isn't much easier for kids than Java, because it has more footguns. And if there's any fault in the language chosen for AP computer science, the blame should go to the designer of the curriculum.
> And if there's any fault in the language chosen for AP computer science, the blame should go to the designer of the curriculum.
Java was recommended for AP CS 22 years ago. At this point I lay less fault at their feet and I'm more interested in why it's still there at long last.
> If by blockly you mean the visual interface, what you said is going to be true for any language.
My research isn't published yet but I've found this is not necessarily true. This is a product of taking a thing not built for kids but rather professional programmers, and then forcing kids to use it. The problem with Java is that it's the kind of system where you need to know everything about it to use it all. Going from 0 to "hello world" requires over a dozen distinct Java concepts explained.
public class MyFirstJavaProgram {
public static void main(String []args) {
System.out.println("Hello World");
}
}
We've got access modifiers, classes, scopes, lifetimes, variable types, void variables, methods and in particular the main method, String types, arrays of strings, input arguments to main method, the System class, output streams, function calls, string literals, and to top it all off a good old fashioned statement terminator as the cherry on top of that feature sundae. The great irony is that the AP Computer Science Ad Hoc Committee call this behemoth "simple".
That's lesson one, and all it gets you is "Hello World". Most instructors handle this as "Ignore all the things you're writing down, we'll talk about them over the course of the next 3 months." Because that's how long it really takes.
This leaves students in a perpetual state of confusion, where they feel like they never really understand what's going on. Everything is a mysterious incantation and nothing really makes sense. Do wrong thing and it tells you it's wrong, but you won't understand why.
Students spend a lot of time memorizing "static void pub main()"... or was it public void static main? Or static public void class? I dunno, let's consult the spellbook. Because on day one their instructor said "ignore all of that, it's too complicated for you." Well students do ignore all of that, and it teaches exactly the wrong lesson -- they don't learn Java or programming, they learn that programming is hard and not for them yet. It's beyond them, but they're going to do it, and maybe one day they will understand, but not today. Today just write the code and run it.
At this point, most students give up. And I will say that yes, this is Java's fault. Not all programming languages require you to learn a dozen very deep and nuanced concepts to get to "Hello World".
Here's the ideal Hello World program for students and honestly for me too:
"Hello World"
That's it. That's the ideal. You get that in languages like Matlab, and I've had great success teaching robotics using Matlab. With Matlab, students are writing real robot programs within a few hours, whereas with Java students are still raising their hand asking "Wait, so what's the difference between an object and a class? What's a method versus a function? What's static mean? What does void mean? What does []args mean?"
It's my contention that the design of the Java language frequently turns away all but the most technically minded students at precisely the time when they are the most impressionable when it comes to their perceptions of computing, and we're all worse off for it.
Well said! Java is the exact opposite of sane defaults: the programmer must explicitly choose defaults at every turn.
Furthermore, it constantly feels like the arcane minutiae required in Java is Java-specific, in a way that other languages (C-based, functional) aren't.
In Java, if I memorize an incantation, most of the information I've just learned is Java-specific.
In C or C++, it's more computing specific. Other languages will use different syntax, but I will be doing the same thing.
But I guess that's one of the weaknesses of reimplementing a computer in the JVM, and then writing a high-performance language to target that abstracted machine.
> In C or C++, it's more computing specific. Other languages will use different syntax, but I will be doing the same thing.
I think you’ve just internalised C-isms. The core Java language is as close to conventional OOP as it gets, and the model is not that different from most OOP languages. It certainly isn’t alien. We ended up conflating C and computing, but it is more an accident of history and because so many languages borrowed so heavily from it.
Both languages are strictly pass by value. Java pretty much uses pointers (references in name only) and primitives only, and both languages copies these all by value. For actual reference you have to go to c++.
For intro computer science students, pointers-as-explicit-references are far easier to comprehend than Java's esoterica.
Said as someone who took intro computer science at 2 universities across 3 courses (C/C++, Python, Java), due engineering to art to computer science major switching.
I understand why Java did what they did, from a performance standpoint, but that's a poor highest value to hold for education use.
And in retrospect, was batshit user-hostile. F.ex. with a few more keywords and rules, C# smoothed off so many rough edges.
> pointers-as-explicit-references are far easier to comprehend than Java's esoterica.
What is esoteric about Java’s references? They are basically equivalent to C pointers without arithmetics and marketed as references. It is pretty much the same for most high level languages.
Yes, int vs Integer. It does make sense that those would function differently. /s ;)
And C definitely has some inscrutable errors, but to me once I understood them, they always made sense in computer terms. Whereas Java errors and oddities only make sense in Java terms.
For just a lesson of writing code to achieve a specific functionality, you can streamline the process a lot by just starting with a template and let students fill in the gaps. So you don't necessarily make them spend time on "public static final void main", but setup a project in which students can type code, build and see results. To teach them to write robotics code, you can create a Robot class for them to play with, and then gradually
move into the more lower level details. That's certainly how it's done in many college courses too, where templates are setup and students are expected to incrementally add things to address the specific concepts they need to learn, but without worrying too much about details that don't relate to the fundamental concepts. Sure it requires some investment on your side, but your students benefit from being able to start picking up a more marketable skill. This also helps them see your code organization and existing implementation, which they can mimic if they want to extend beyond what's taught.
Matlab is really not a good example imo because if you start wanting to do a bit more, even if it's just to organize the code in better logical blocks, it bad design and lack of OOP gets in the way and makes further progress slower especially for the more talented students.
And finally, while I agree Java might not be the most optimal to teach at the AP level, what you said isn't worth bashing the language for in general terms. It's still sqaurely the AP curriculum's fault that it chooses Java and at the same time requires it to be taught in a way that's not fun or efficient, and not have updated it in 2 decades (while Java had many iterations)
Matlab has a had OOP for a long time now. It's actually the language where first learned about classes and it provided a fine foundation to later learn more conventional OOP languages like python and c++. I'd say it's a fine language for exploring robotics or anything science related. Compared to pretty much all the competition, it just gets out of your way in anything math-adjecent.
Somewhat ironically, matlab the application is written in Java.
> you can streamline the process a lot by just starting with a template and let students fill in the gaps. So you don't necessarily make them spend time on "public static final void main", but setup a project in which students can type code, build and see results.
By all means, if you think you can come up with a way to teach Java to children that's fun and efficient be my guest. We've been trying for decades and haven't cracked the code, so to speak. A lot of professional developers who have no interactions with children have "thoughts" about teaching programming to children, and when those thoughts meet reality, they often find out its not so easy as just writing a little class wrapper and that's all it's going to take. The abstractions of your template designed to hide all of the complexity are going to leak very quickly, I think you will find.
> Matlab is really not a good example imo because if you start wanting to do a bit more, even if it's just to organize the code in better logical blocks, it bad design and lack of OOP gets in the way and makes further progress slower especially for the more talented students.
I've gotta ask if you've actually taught any students using Matlab (or Java for that matter). By what metric do you say it's a bad design? Are you speaking from the perspective of a professional programmer who uses tools to write professional software? Or are you speaking from the perspective of someone who teaches children regularly and are critiquing its design from that perspective?
Because in my experience Matlab has a great design for teaching. It has a ubiquitous data structure, a table, which can store any kind of datatype without having to specify it. You don't have to know about ints, longs, floats, shorts and chars -- all you need to know are there are numbers, and sometimes strings, but mostly just numbers. And the tables/arrays start at index 1. That's a huge deal for teaching students but programmers hate it. They call starting at 1 bad design, but starting at index 0 is definitely an example of something that gets in the way and makes further progress slower for children. But I've gotta say your statements about "especially for the most talented students" rings especially untrue to me because the most talented students are really never slowed down IMO.
Moreover the REPL interface of Matlab allows them to play with their code as they develop it. JAVA doesn't have a REPL and the write-compile-run loops is too long that students lose interest in the coding and debugging phase. Kids love to pair program with a REPL. They are engaged as the interactivity gives them constant incremental feedback. The write-compile-test loop of Java is long enough that pair programming isn't fun for kids. I'll put it this way: for kids, pair programming in a REPL is like playing a game, pair programming in an IDE has all the fun and excitement of writing a book report. Exploratory programming is a sad story in Java, but it's Matlab's raison d'etre.
> Sure it requires some investment on your side, but your students benefit from being able to start picking up a more marketable skill.
Here's the thing, and this is the big problem with AP CS, and why I believe that Java is still taught in this class. People think that teaching kids Java is doing them a favor because they're "giving them a marketable skill" meaning that they will be able to apply to work at Java shops after high school. From my experience they still need a good 2+ semesters with programming before anything they learn is marketable. But developing marketable skills is not really what AP CS is about anyway. All AP classes are really about getting college credit and getting a 5.0 GPA for top colleges. So the skills kids learn there are not being marketed toward companies looking for OOP programmers, they're being marketed toward colleges looking for students. And from our perspective, the perspective of college admissions boards and professors, we don't care about what language they're learning or what "paradigm" they're using whether that's OOP or what have you.
> lack of OOP gets in the way
It floors me that you say a lack of OOP gets in the way, because from my experience it just doesn't. That's completely not what I have found. OOP concepts get in the way far more than anything else. Children just do not organize the world in their brains using class hierarchies (even though that's how their social world is arranged). The original conception of OOP as message passing is far more understandable to children. Like I said my research is still ongoing, but I've gotten middle school children writing more sophisticated asynchronous and parallel code than professional developers with years of experience just through smart language design. When the language gets out of the way and kids are just allowed to think, then they can do pretty amazing stuff. Seymour Papert had kids doing advanced physics with LOGO just by framing the program from the perspective of the turtle.
> what you said isn't worth bashing the language for in general terms.
I don't think I bashed it in general terms (although you won't catch me using it, I'll bash it for other reasons in general terms that are far beyond the scope of teaching children), I am bashing it in the context of teaching children. Sorry if I offended!
I helped training for programming competitions at junior high to high school levels. I also TAed for CS students at a university level.
Admittedly both of these contexts correlate to more maturity and stronger motivation in the students, especially when CS wasn't so hot.
It's still hard for me to believe there's no way one can make a novice productive with templated Java compared to blank-slate Matlab. It's easy to get people off the ground with dynamic typing, I agree. But novices easily drown in the complexity they create, if they're ever allowed to go far without discipline, at which point it's also harder to grade and help them debug when things go wrong.
Templated exercises also provide more structure and predictability, and allow teachers to do more with the same amount of resources. That said, it wasn't necessarily my intention to advocate for using Java for pedagogy (I'd prefer something that's less verbose and has more novice-friendly I/O and GUI libraries), so I'll stop here.
> It's still hard for me to believe there's no way one can make a novice productive with templated Java compared to blank-slate Matlab.
I don't meant to imply you can't make any novices productive with Java, because obviously that's not true. People go from novice to writing Java all the time, and not just a few. But I want more.
My essential point is that while this will work for some people, it's turning off a great deal many more at a time when they are especially impressionable. For example, a student I taught wanted to go to school to be an accountant. But after learning a bit about robots he fell in love with them and now he's going to be building planetary robots next year with the hope of sending them to Mars. Now, I have nothing against accountants, but I'm not trying to make accountants. I want to make programmers, and to do that I need passionate young people willing to give it a try.
There's a huge contingent of students who have fun playing with Logo, Blockly, Scratch et al. and then just nope out when they get to Java. You wouldn't believe how many students tell me they were inspired to code by Logo. Or maybe you would believe it because that's exactly what it was designed to do! But AP CS with Java is a filter, whereas I believe it should be a springboard. These are the students I'm worried about. These are students who were told they are bad at math at a very young age by parents, teachers, media, etc. ("You're not a math person you are a sports person. Or an art person. Or a music person"), so they have very low self esteem when it comes to their potential in this area. Our society is very anti-math, to the point that we create a perception that math isn't even used in every-day life. And maybe that's the root cause of this issue, but I can't solve that one. But I can ameliorate its effects with better language design.
When these students experience Scratch et al., they believe there is a glimmer of hope for them. It doesn't feel like math. It's technical but it's also fun and kind of like a game. And they can get it. They can make programs and games.
Then they get to Java and all they see is math, which they are sure that they're bad at. And it's a huge step backwards for them too, because it takes forever to get them as proficient with Java as they were with Scratch. Going from Scratch to Java is like being blasted back to the stone age for these students.
Programmers looooove the programming as mathematics metaphor. I think a lot of programmers have mathematician envy, and so the programming languages we create for one another drip with the trappings of mathematics.
So I want to reach the students who fell in love with programming early on, have a perception of themselves that they are bad at math, and then are scared away in AP CS. These students are disproportionately girls, not because girls are bad at math but because they are told they are bad at math more than boys. If anyone is here who wants to hire more women but says "I wish we could but they just aren't applying! It's up to the teachers to train more that we can hire!" well this is part of your problem right here.
Java has a shell by default since forever now. You can start it by issuing jshell of any semi-modern JDK.
Also, are you sure matlab is a good language for learning? I only have experience with learning this language not teaching but to me it was a giant oddball compared to many many languages I have learnt.
> Java has a shell by default since forever now. You can start it by issuing jshell of any semi-modern JDK.
Yes, I'm aware of Jshell. Jshell is what you get when you take a static strongly typed compiled language and you give it an interactive shell. It's not exactly coherent, and still doesn't solve the most salient issues. Using JShell is better than an IDE IMO, but if we're going that direction then why are we still using Java? There are far better interactive languages out there.
> to me it was a giant oddball
It is an oddball language, because most languages are written by developers for developers to do the things developers do. Matlab was written for scientists to do science, and because scientists are not developers, Matlab is designed in a way that is more friendly to them. Sure, learning Matlab is not going to help you in a job interview at an OOP shop, if only just because the interviewers there have an opinion about Matlab being an oddball language (although I've managed to get an interviewer to call in his colleagues to see my one liner Matlab solution to a whiteboard coding question, "We've certainly never gotten that answer before" they said). But the things that make it odd to professional programmers make it more understandable to children, I have found. 1 indexing is the best example. People here will complain about it endlessly, but children will consider it obvious and won't think twice about indexing an array with 1 as the first element.
Here's the difference.
Matlab: To access the first element, do x(1).
Student: okay.
And then we move on to the next topic or the activity at hand.
All other languages: To access the first element, do x[0].
Student: Wait, why? Why is the first thing 0? What can't the first thing be 1? That makes no sense whatsoever.
And then we spend the next amount of time talking about indexing, not doing fun things like the activity at hand. The difference between 1 indexing and 0 indexing is trivial in the grand scheme of things. But it's and example of something where just a slight change is the difference between understanding and confusion.
> Also, are you sure matlab is a good language for learning?
I am not sure, that's why I'm doing research on it. But the reason I'm doing research here is because I saw a dramatic result from an experiment, and I want to pull on that thread. The experiment was teaching robotics to middle school students (11-13) using C++ and Matlab. Both groups with little to no computing experience. One was taught C++ in the context of making a robot do a task. The other was taught Matlab. The Matlab group finished the task with ample time to spare, while the C++ had barely gotten past the C++ preliminaries and needed extra time to finish the task. There's got to be something here, it's not like we were trying to make Matlab win. We thought maybe it would have a slight edge but it was just a blowout.
Good luck with your research, but how are you going to discern the difference between high and low level languages? I really do believe that you would have found very similar results for C++/Rust/C vs Python/matlab/java/javascript, etc. given similar quality of third party libraries that the project depends on.
> I really do believe that you would have found very similar results for C++/Rust/C vs Python/matlab/java/javascript
Yes I believe you are on to something here.
> Good luck with your research, but how are you going to discern the difference between high and low level languages?
Thanks! I'll share my findings on HN when I get them, maybe they'll make it to the front page who knows. My research is focused on what features or design elements exactly made Matlab so much more understandable than C++. I think it comes down to
- single data structure that you can put anything in. The table is a very good general structure. Excel echoes this, as people find excel very approachable.
- single numerical type. Everything is basically a float, so you don't have to think about all the numerical nuance involved in choosing between ints, floats, doubles, longs etc.
- 1 indexing, because that's always such a sticking point to brand new programmers
- interactive IDE that allows you to see all of the variables and click into them to see their values. The Matlab REPL isn't great but it's a huge step up from the write-compile-run loop in C++.
Honestly I'd like to try Lua. It has a lot of these properties, so I think it could maybe have good success. But you're right, I'd like to rerun the experiment with all of the languages you listed.
Java is a good intermediate step as a first serious programming language - it has good compile time messages, and even more importantly, it has pretty much full runtime safety, which is absent from python, c, javascript et alia. With these languages students will struggle with code that seem to work, yet are faulty - it is better to fail with an “ugly” but readable exceptions during development, than to not do anything just get wrong results (either type errors, non-intuitive conversions, or straight up memory corruption)
Also, java is a tiny language, I really don’t get your point. Sure, hello world requires 3 lines of boilerplate, but other than that you have pretty much listed every single java feature there is. How many languages’ feature list can you enumerate in a rant?
> Also, java is a tiny language, I really don’t get your point. Sure, hello world requires 3 lines of boilerplate, but other than that you have pretty much listed every single java feature there is. How many languages’ feature list can you enumerate in a rant?
I wasn't enumerating all of the features of the language, but by saying so you basically proved my point. I was enumerating all of the features of the language present in the very first "Hello World" program. It's not about 3 lines, it's about the density of over a dozen concepts packed into those three lines. That's what people mean when they say to do anything in Java you have to know everything about Java.
> Write LOGO first, or scratch then.
Logo and scratch are great first languages, and they spark joy and imagination in children. Then they move to Java and it sucks the inspiration right out of them. Honestly I think students, teachers, and everyone except Java shops would be better off if students started with Logo turtle graphics in elementary school and used it throughout middle and high school as the capable Lisp that it is. Yes we won't graduate as many object oriented Java programmers, but... well I guess there is no but, I really can't see the downside in what I just said.
Java ain’t having many more features. Besides primitives, everything is a class with fields and methods. The static keyword decides whether the field/method is per-class or per-instance, and you can create instances with the new keyword. Sure, there is some play here with OOP-features, but java is a really concise language. Feel free to compare it to C#, Python for example. Good luck explaining why an empty list as a default argument is problematic in the latter’s case. Let alone OOP features in Python.
Java, the language is on the order of complexity of C.
> Besides primitives, everything is a class with fields and methods. The static keyword decides whether the field/method is per-class or per-instance, and you can create instances with the new keyword.
Are you a professional programmer or a teacher?
The perspective you are sharing with me tells me you're a professional programmer who already understands all of this and finds it obvious and easy. The quoted sentence would be absolute gibberish to students.
> Everything is a fleeb with blips and blops. The slorp rump decides whether the blip/blop is per-fleeb or per-glorm, and you can create glorms with the klob rump.
Simple right? How obvious! You say it as if it's all so easy, but it takes a long time to explain all of these concepts. Students are usually very confused about the difference between a field/variable and object and a class, a function versus a method versus a static method... these concepts are quite nuanced and the differences are subtle to students, yet you are breezing past them like they are nothing or obvious.
> Java is a really concise language.
Concise: giving a lot of information clearly and in a few words. Maybe not clearly, but a lot of information in a few words is accurate. And that's the problem. Kids need a little information followed by a lot of examples and explanation. Giving kids subtle nuanced concepts and expecting them to recognize the depth of those concepts without articulating it is a recipe for disaster.
Python is definitely simpler to start with but it doesn't expose the beginners to some concepts directly - interfaces are implicit because of duck typing (unless you use the ABC module), everything is public (underscores are just a convention), there is no method overloading etc.
I think it might be more valuable to expose beginners to static typing because it's much easier to transition from "objects have distinct types" to "pretty much everything is just a hashmap" than the other way around.
The thing about C as a first language is that you need to not only learn what programming is but you also need to learn manual memory management which raises the bar significantly and it's pretty easy to write code that fails for reasons which are difficult for a beginner to figure out (like segfaults).
I don't think it's needless. I'll bash Java as long as it's the language for AP computer science. Imagine a budding young programmer, bright eyed and bushy tailed, eager to get into computer science. They get to class and greet the teacher "Welcome class, let's learn about Java. There's a wide world of computers out there, but your perception of computing will be that Computing <-> Java until maybe the sophomore year of college. Have fun!"
Students come to me their sophomore year of college completely awestruck. "I had not idea! I thought programming was all Java!" they tell me. Imagine that. Close your eyes and picture a world where all of programming is Java programming. How quick did you open them and splash water on your face to wake rid yourself from that nightmare?
Java is singlehandedly responsible for snuffing the dream of so many young programmers. I've seen it in my own research, where kids in elemntary and middle school describe programming as fun, interesting, and challenging. That's because at this age they're using fun languages like Blockly, and they spend their time programming making and playing games.
Then they get to AP computer science and they are introduced to Java. Perceptions of programming fall through the floor, with more students calling it difficult, frustrating, and scary. It's tragic what Java is doing to young people.
Like, I understand we want students to have skills they will use in business, but we can't present programming to them as if all of programming is OOP enterprise development in Java. It's a crying shame.