I'm on board with Java not being a great first language but I'm pretty tired of posts constantly citing ancient unidiomatic Java to prove how bad of a language it is. Their file i/o example could just as easily be
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
public class fileIO {
public static void main(String[] args) throws IOException {
Files.copy(Paths.get("test.txt"), System.out);
}
}
Granted that Files utility was added in 2011. Even in 2010 there were plenty of better ways to write that example.
Nothing kills a beginner's interest more than "you need to have a class and a main method, always, and I can't explain why, just trust me, you'll understand later."
Java was my first language. No one explained any of that stuff to me. And for whatever reason I lacked the agency to go figure it out for myself although I had internet access. Probably because I assumed paying attention in class and doing my homework was enough.
I agree. I don't believe Java is a good first programming language. I'm just tired of posts bashing Java by citing code that doesn't take advantage of any of the improvements in the language since 1.4.
I think that says more about your teacher (and maybe about you) than it does about Java as a first language. Bad teachers will teach poorly no matter which language they're teaching.
Again, I don't think Java is a good beginner programming language, but this version:
1. Avoids try/catch syntax, and in fact can defer mentioning exceptions entirely (at the cost of the "throws" declaration being a mystery, which the main function already is to a beginner)
2. Does not require understanding of loops. In fact their example loop is particular egregious in its use of assignment in the loop condition which is especially likely to confuse beginners who are still learning the difference between "=" and "=="
3. Does not require introduction to Java's Reader I/O abstraction
4. Does not require familiarity with null references
I'm not saying my version wouldn't be confusing for beginners, but it would be hard to write a worse version than the one they give.
I would partially agree with this even though Java is a great language.
I can firmly recall in my CS 101 class where they were teaching basic programming using Java, and the teacher seriously told us "just put static in all of your method declarations, don't worry about why yet otherwise you won't be able to use them in your main".
...didn't fully learn what static meant until over a year in my programming career.
In my CS101 class I asked what the "public static void main(String[] args)" meant at the beginning of the java code we kept getting and got the response: "It's some magic, don't worry about it."
But that's already the problem: You start by ignoring instead of explaining things.
If you start with
print("Hello world!")
you can already start explaining your subjects everything they've just written and build from there.
So, you'll get around faster to teaching the mindset of programming instead of explaining access modifiers. Those are not needed for that.
Also, if you would start an explanation of anything new to me now with "oh, that's magic, just ignore it.", I still would walk away from your course if you can't explain that within a week.
I think you're being a little bit aggressive about the when's and the how's. I think there's nothing wrong with saying "Don't worry about that until next week, we'll be discussing that in another lecture" as long as it does in fact get explained. I don't think the statement should be "it's magic, ignore it," ever.
At most universities I've seen, CS101 assumes no programming experience, so if you want to show a real Java code block there's going to be a lot of stuff a student's never seen before.
I also think this is why languages with REPLs and relatively few syntax modifiers (like Python) are good for intro courses. You can fire up a REPL and type `print "Hello World"` and it'll do just that. The students don't have to see any "don't worry about it" type stuff.
edit We may have been agreeing about the "print Hello World" part and the Python part. The problem is that some universities (like my Alma Mater) had the hard requirement of all CS and IT students started with Java.
Yeah, that's exactly my point (I'm not sure if we're misreading each other here?). If you want to teach someone how to program, there is much to be had if you start with simplicity and consistency. Algol-derived languages pretty much all struggle with this, whereas Python, Javascript etc. have a much more sane base to learn from.
(NOTE: Only a base. Both Python and JS get very complicated and magic-y if it comes to details. But those are not what you'll want to teach. You'll want to explain scopes, variables, functions, objects etc.)
In both, the basic file is a scope. In both, you can write "Hello World" without fluff, because that scope is executed. It is consistent on a starter level. Then you move to variables. Then to loops. Then to functions showing how you can modularize code. And you didn't have to write `public`, `static`, `class` or whatever. Your students don't even need type theory beyond "that's a string" and "that's a number".
> The problem is that some universities (like my Alma Mater) had the hard requirement of all CS and IT students started with Java.
Mine did too (still does, AFAIK). Incidently, they also did also basically nothing to guarantee any didactic quality in any of their courses. Go figure ;-)
I still maintain the opinion that people defining rules like this overestimate the effort that comes with switching languages. If you're teaching solid fundamentals instead of "Language X", you shouldn't have too much of a problem teaching the same students something like Java at a later point. But the way to get the basic understanding will be much smoother.
As an anecdote: Shortly before I finished my masters I would help out a bachelor student on his first project. He had the problem that they only had started out in Java a semester before, but he had to use Python (because of the tooling and libraries involved). He asked me a couple of questions that mostly equated to "how do I best do X in Python" (the hardest being non-performance critical parallel tasks - simple threading stuff). A couple lines of code later, his reaction basically was "Really? That's it?!". His impression seemed to be that most tasks must* be very difficult and complicated, since they were presented this way in his Java class...
It was even worse starting in C++. Almost half the code in any project was opaque black magic. What is char and why do I need it? Why do I need `using namespace std`? Why do I need to create a Pair in order to insert into a Map?
I don't think it's worse in C++. You can make purely imperative C-like programs in C++ with essentially no boilerplate (with the exception of maybe needing io from the standard library), and build things up as they go.
While I still am a big fan of C++, I'd attest to the fact that is a worse language to teach beginners. Funnily enough, that's not so much because of the language, but because of its legacy.
I learned programming with Borland Turbo Pascal and later Delphi and have to admit I struggled with the OOP mindset at first. The according chapters of the book I used were filled with contrived examples that left me saying "I can also do this the old way!". Apart from this, I found the book to be very well written, though.
Then, I tried learning C++ (using a Book frome the same series) with Borland C++ Builder. Boy, was that a mistake. I didn't get around to understand why I had to keep using -> instead of . everywhere (before, I almost never used a pointer anywhere), the whole delete-dance was a nightmare and the Borland tooling was so filled with magical clicks that generated event handlers that I never understood how the whole thing really worked (you never got to see the whole code). Headers vs. .cpps was a similar disaster, and compiler errors could only be met with comparing your code with the example on a symbol by symbol basis[1].
So, while C++ is a nice language (far better than Java IMO), starting in it was a nightmare. The problem here is that you have to explain way too many concepts at the beginning (which still holds true even with C++17), and since APIs like the Borland GUI libraries or win32 are based on so much cruft and ages old crap, you'll never get to the point where a beginner can say "Look, I've drawn a circle!".
Honestly, if you ask me, programming courses should best just start with a modern version of Python. But even then you'll have trouble setting up on Windows and getting over the whole UI frameworks disaster.
[1]: This kills experimentation. That's the absolutely last thing you want to do if you're trying to teach a motivated kid how to program.
Edit:
Also note: Often, the mindset seems to be that "beginner" means someone at a university. In my opinion, that's a fallacy too. I started out when I was 11 - I'd never even had any decent english course in school back then. Think of that, and you'll start to see the flaws in starting out with some way too complicated concepts. We should get rid of the notion that a learner has to "push through" things (especially at the start!). It will be to the benefit of society.
The problem there seems to be that you were learning an IDE/Gui builder and c++ at the same time. I still think I language that exposes pointers directly (c, c++, others?) are far better than something like python. Pointers force you to understand memory, allocations, the heap and stack, etc. There are way too many professional programmers that don't understand them.
The problem there seems to be that you were learning an IDE/Gui builder and c++ at the same time.
Even from a modern persective, I'd disagree with that. Yes, the IDE was a pain point, but it existed because the alternative is much worse. You don't want to start out explaining Makefiles to anyone (even if you start with VS you'll be spending an hour setting up instead of programming).
Pointers force you to understand memory, allocations, the heap and stack, etc.
Yeah, and we'll both agree that this is crucial knowledge for any professional programmer. But if you're starting out (we're talking first language here), it's in the way. You don't even know what a loop is yet. You're at least years away from professional.
Also, not everyone who programs wants to become a software developer. Sysadmins don't need pointers, but a readable alternative to shell scripts is nice (I know such people, they exist). A journalist who wants to make a flashy chart on the internet doesn't need to know pointers. A biologist also doesn't - but (s)he can certainly benefit from programming. Have you seen what Jupyter can be used for?
Edit:
As a side note, I also see much value in starting with a more functional language than C++.
Lexical scope really affects your thinking. If you can get to that at the end of the first course, you'll have taught something tremendously useful. I've been working at a local university of applied sciences until last year, and you really don't want to know how many students there struggle with a C++ lambda expression.
Again, to reiterate: I'm a fan of C++. I still cringe at most other imperative languages. But I see its weaknesses (especially in teaching).
> Also, not everyone who programs wants to become a software developer. Sysadmins don't need pointers, but a readable alternative to shell scripts is nice (I know such people, they exist). A journalist who wants to make a flashy chart on the internet doesn't need to know pointers. A biologist also doesn't - but (s)he can certainly benefit from programming. Have you seen what Jupyter can be used for?
In context, this is about CS classes, while the others might do some programming they shouldn't need to do computer science. Also, although being easier, is jupyter doing anything not being done in emacs years ago?
>You don't want to start out explaining Makefiles to anyone (even if you start with VS you'll be spending an hour setting up instead of programming)
To anyone on the path of becoming a professional programmer, yes, it's worth a few minutes to write a trivial makefile. It's worth teaching how to compile from the command line and how to batch those commands with a DSL is really simple. Again, there are way to many programmers who have no idea what their IDE is doing, which really isn't that much.
> Yeah, and we'll both agree that this is crucial knowledge for any professional programmer. But if you're starting out, it's in the way. You don't even know what a loop is yet. You're at least years away from professional.
c/c++ don't force this straight away though, you can easily do for loops before you begin managing memory. In any language memory should be understood before arrays are.
> Also, although being easier, is jupyter doing anything not being done in emacs years ago?
While I already think it's worthwhile that you can sidestep emacs' setup and learning curve for uninterested students, you might be interested in how it is already used for collaboration and teaching.
If you're teaching math or physics to a bunch of students who know Python and SciPy, I would assume Jupyter notebooks are an amazing way to distribute course material.
Clicking on a few random ones seemed to be broken in the web view, which doesn't bode well ;)
I'm sold on the idea though. 20 years ago all our math books came with basic programs in each section, I can't help but think maths and physics would have been much more fun if we'd been able to run them or had something like jupyter. I've been told textbooks don't come with this any more, which seems like a shame now that computing devices are so ubiquitous.
> In context, this is about CS classes, while the others might do some programming they shouldn't need to do computer science.
We seem to read the same statement differently. I actually had a CS101 class in highschool (also in Pascal, I didn't learn much there
;-) ). While all students there wanted to go in the engineering/science direction, I think only a hand full of us ended up in CS. Granted, this might be due to terminology.
On the other hand, I work with people who studied "business informatics", which at a bachelor's degree has the same base classes. I can guarantee you none of them use a pointer in their daily work (again, they do more in the sysadmin direction).
> To anyone on the path of becoming a professional programmer, ...
Yes, but not in the first lecture. Not before they know what a loop is. Many don't even know the command line (yes, I was also stunned to see that).
On the other point, I entirely agree :). I could make a huge list of frustrations I have with professionals not being willing or able to introspect how things work.
> c/c++ don't force this straight away though, [...]
As I said, it's not so much of the language anymore, more its legacy. C++ has stuck around quite a while, and this results in an abundance of old and bad APIs.
And with the better ones, you'll be able to leave pointers aside, but end up ignoring templates instead... Also, already the output operator on STL streams means you'll have a lot of explaining (or ignoring) to do.
Additionally, if you really are already teaching computer science students, I'd say you'll give them a better time explaining pointers and so on to them after they already know a language they can certainly use in the industry - in which case the idea of using Java to start out still has a point...
Edit:
This basically leads back to the original argument of the article: If you change the starting language for beginners, do it for their learning progression. If you're changing it to C++ for C++'s sake, you won't be doing your students a favor, stick with Java. If you can tolerate telling your students "hey, look, this magical thing is actually that feature here", you can also tell them later on that C++ is basically much like Java except for some details. I think language switching isn't as hard as it's made out to be if you're teaching the right concepts.
Yeah, I did Pascal in high school too, but I thought x01 were college designations, we don't use them here.
Actually, I've been brushing up on my awk lately and it seems like it might be a good candidate for those not on the CS track.
It teaches/requires the command line. It has a built in loop (great for fast feedback). It's a decent enough language. And I'd argue it and the rest of unix tools are probably more worthwhile than any general purpose language, they're brilliant for data wrangling.
> I thought x01 were college designations, we don't use them here.
As I said, this is properly a terminology question. I can't speak from experience for the american naming scheme, and where I live, much of it has been "rehashed" in different institutions.
Does that mean that you have noone at the beginning of a CS degree that can't program yet? We certainly hat a good bunch of them.
As for UNIX tools: Absolutely. I've never gotten around to learn awk properly (and never had any need to), but having experience in bash (and other shells) in combination with the GNU tools has had countless benefits for me so far.
Do you have any preference for introduction material for awk?
Edit:
When it comes to data processing, I also really like what projects like pandas are doing:
> Does that mean that you have noone at the beginning of a CS degree that can't program yet? We certainly hat a good bunch of them.
I don't think our school was very typical, it was a fairly poor public school, I suspect it was taught because there was a sepecific teacher that wanted to teach it. It was being run from the commerce department at the time, with half the time spent in the graphic design class rooms (they only ones with computers). This was in the late 90's when they were still teaching us touch typing on electronic typewriters. It does seem like a huge waste for students to start a CS degree without experience though, a good portion of them will never have any aptitude for it.
> Do you have any preference for introduction material for awk?
I've been going through O'Reilly's "Sed & Awk" that was sold as part of a unix bundle a while ago. I haven't done much at all, though it has simplified monitoring things at work, like coloring log files reading from log files to tell us how many and how long a particular set of processes are taking.
It would of been better to start you with C then transitioned to C++ later on or skip it all together and go directly to java/ocamel/haskell then come back to C++ at a later date.
What's the point in hiding the fundamentals of OOP, rather than starting with them very quickly? You can't get very far before you're calling methods on the strings you're printing.
I'm genuinely curious, I sat through an intro to programming & follow-up course in PHP and that line of thinking seemed to confuse the students. They weren't sure of what a function was even though they were using functions! The professor never got around to explaining OO or any fundamentals.
> What's the point in hiding the fundamentals of OOP, rather than starting with them very quickly?
Fewer concepts to learn. I've worked with people who have been programming professionally for decades and still don't use OOP well. OOP is hard.
With a novice user, you want to get them making a computer do cool stuff as soon as possible with as few concepts as possible. Everything else runs the risk of scaring them away forever.
It's not about hiding OOP, it's about being overwhelmed with too many new concepts at the same time. Put yourself in the shoes of a beginner: the runtime, the IDE, the language keywords,... everything is new to them. Once you know your way around simple functions you can start adding another layer of abstraction. But slowly. Maybe Ruby would be an easier start for OOP than Java.
Just my opinion, but it seems that starting off all at once with the language runtime, "Hello World", an IDE, and language keywords will cause more confusion than a few extra lines of code.
Java was the first language used when I was in school, and nobody had a problem with the "Hello World" boilerplate. The professor took about 2 minutes explaining it, told us we'd cover it later in the course (and we did), and then we jumped into the main function.
A bad teacher can teach any language poorly.
EDIT: Now that I think about it, the class was something like, "Data Structures in Java," and the main focus of the class was introducing data structures, with Java tacked on because it was popular at the time (right around y2k) and it made grading easier to have everything in the same language. After that, I don't recall there being any classes explicitly about learning particular language. There was an "Advanced Java" class, but it was an elective showing how to create GUIs and a (brief) intro to things like Java Server Pages.
I believe it is to teach the fundamentals of the CPU, Machine code before the student has any knowledge of the abstraction's that currently exist. Then after the fundamentals have been established introduce the abstractions and different approaches to improve productivity.
The reverse is to give people a way to build things. Even simple things. This lights up the brains response every time you get the computer to, as my old lab partner in my first CS class put it 'to do a thing! Automatically!'.
My first real python program made me gush with endorphins. I feel like if I didn't start off on Python first (and, for whats it worth, still heavily use today) I wouldn't have been NEARLY as interested in the mechanics behind it (specifically the C libraries) or generally the things python lets you take advantage of (like manually managing memory. I still have horrid memories learning C and dealing with pointers.) It drove my curiosity to understand all the under the hood aspects.
If I started with Java, I wouldn't have had these wow like moments writing fairly large (at the time, anyway) programs that actually functioned. Like my first simple RSS reader. Or the first time I discovered I could automate my Macs tasks quite easily.
I was HUNGRY for power after that. and i knew, at least, more power, for all python was worth, would likely come from other languages being in the mix. So I learned Java, and C, and opened my eyes to the power of many other languages (I still insist Perl is better at string processing than any other language. Show me that its not! /rant)
I think there is a lot of value is in learning the fundamentals with Python or another interpreted / high-level language first.
I agree with your view point. Although why are you in the CS class? If you're only interested in just getting the job done the fastest?
From a practicality stand point of view using bash, batch files, nodejs, python is going to be faster second to none, I'm not discussing that. The point is using a low level language you have to consider about decoding the jpg, memory allocation or possible streaming issues. Optimal buffer size and command prompt parameters to parse from the command line to resize the image. All tangibly relate to other fields in the curriculum and when you get a job the field.
It's not about getting the job done. It's more about opening ones eyes to the potentials of computer science. Learning Python open the doors to other kings. Not to mention many of the things you are mentioning here are power user features of python as well.
He's deliberately made the java example of file input too busy, it's poorly written. And added multiple exception handling to make it longer than it needs to be (in its context).
I started in BASIC as a kid. The barrier to entry was minimal and fun for a few hundred lines of code.
To manage the complexities of a large code base, you need to have supports and infrastructure and information hiding to structure it neatly. That adds extra code, but contains it in a way to makes sense of it all.
>He's deliberately made the java example of file input too busy, it's poorly written.
Do you have evidence to judge the intention of the author?
The simple truth is that good pedagogical code is hard to write in any language, but Java makes it especially hard since it makes the two most essential things, invocation and I/O, needlessly difficult. Java also makes graphics (AWT and Swing) and even something as simple as Date/Time needlessly difficult. Just about the only thing that's really outstanding in the standard library are the Collection classes (arguably util.concurrent is good too, but a) concurrency isn't for beginners and b) concurrency requires better language and runtime constraints, like those provided by Clojure or Erlang).
Java was invented for embedded devices and was supposed to be C without pointers that could run anywhere. Not quite sure how it ended up as an Enterprise Server platform. marketing, I guess.
Logo[0] was my first programming language on an Apple IIe. I was in 2nd grade and I loved it. You had subroutines, but that's it. Essentially all state was visible (although you could do increasingly more magical-seeming things the more state you hid - a truism that has held since then). It was a lovely way to see the thread of execution.
What an amazing experience to read Papert's[1] Mind Storms[2] as an adult to understand the profound thinking behind Logo.
Why not teach Logo as the first programming language?
We feel the same way! That's why we re-created Apple LOGO with 3D [adding UP / DOWN / R(oll)L(eft) / R(oll)R(ight) commands] support to make it more palatable to modern audiences...
While there is nothing wrong with adding up, down, roll, pitch, and yaw commands (I guess yaw is already provided by RT and LT) it feels like you are missing the point of LOGO when you make statements like these.
The turtle graphics are great at getting you sucked in, but the language is so much more powerful than that. Logo is a lisp and can be used to do many wonderful things in addition to turtle graphics
One thing to consider when picking a language for someone's first programming experience: students like the 'language du jour' - it motivates them.
I like the idea of using Basic/Pascal/Blockly/etc (and students like how easy those are) but about 3-4 weeks in they'll start to ask "Sooooo.... does anyone actually use this for real, in industry?". This tension between wanting something easy enough that students can handle it vs. wanting something that 'real' programmers use is common.
Picking a language like Java (and handing out starter files to overcome the required verbosity) is a nice way to go - it reduces the cognitive load to something they can reasonably handle AND it keeps the motivation of using a "real world language"
Disagree 100% and that's because I've helped and seen many juniors who learn ruby or JavaScript first not actually understand what they're doing. More so ruby, FWIW.
Examples: in junior ruby engineer, even some mid level, the confusion between local variables and attributes causes huge amounts of confusion. I don't know how many times I've asked "why is this an instance variable?" to a response being the sound of crickets.
Things like attr_* in ruby cannot be appreciated until you know why they're there. In more verbose languages like Java you're forced to understand from the beginning. Yes, there's more to learn before you get started but once you've learned it you're capable.
Learning Java was a huge "aha!" moment for me after having spent years with ruby. I've known others who express the same.
I think developers who don't learn a language like Java first hit a very hard and tall walls at some point in their learning and advancement.
Java also is much better, IMHO, language to learn design patterns in, because there is often no shortcuts provided by syntax to "prevent" or circumvent them. Also an added bonus is that the example you're reading is likely to be in Java.
I used to think scripting languages were great for learning to program but my tune has changed as I've progressed over the last decade. I now think they inhibit learning at a certain point because they lack the rigidity needed to demonstrate more advanced techniques to the learner.
I love ruby, it's in my damn username, I just don't like it as a first language these days.
I disagree.
Yes, Java is verbose, but all this verbosity makes sense.
I think it is better to write more code, but be able to understand it and reason about it, than write one line and rely on all magic under the hood (having no idea how it works).
The thing is, a person learning a first programming language doesn't understand it and cannot reason about it. They're more interested in "why do we use a for loop" and "what's an int?" and less interested in "How do these static objects work?".
But I agree with you to an extent. Eventually the hand holding has to stop, we have to take the training wheels off, and they're going to have to fall a few times. But it's easier to get back up after you've had training wheels, because you know what it feels like to ride a bike.
Or for younger programmers (pre-college) a learning oriented language like Processing where you can gently move into java, and get to do graphical and interactive programming quickly seems to be a better option. As a teen, the lack a excitement from learning to write to files and handle text input killed my initial enthusiasm for programming and had me go first into the sciences instead. Whereas, I still find it very satisfying to be able to make interactive graphics in a few lines of code in a way that text output or static webpages never will for me.
For the college level, I agree with the writer's suggestion of Python, not just for its ease of learning, but its breadth of libraries making it useful for many science and engineering courses. However, I think that for getting advanced (fun) features early on by picking and getting the right library (working) may still be a bit too much unnecessary friction to do 'fun' programming to get earlier students engaged. Learning extra tooling and library systems is 'trivial' if you code regularly, but is still a surprising amount of work when you're new to programing and gets in the way of early feedback. (I have had colleagues in the sciences hesitate at the sight of import statements, dealing with multiple libraries, and new IDE's when suggesting using something like sci-py/python over Matlab for projects, for these sorts of reasons.)
The examples the author cites of having to write a great deal of code that one does not understand is the motivation for Racket's language levels [0].
However, it is not just a matter of Java having a syntax that imposes a lot of cognitive load on novices. It is about being able to talk basic programming language features independently from advanced languages features. This is independent of both syntactic and semantic complexity. Python's clean syntax, for example, masks some really complex semantics.
Neither Java and Python are poor programming languages, but their overriding design goals are to be languages that proficient programmers can be very productive in. The pervasive mistake in CS education seems to be that these languages are therefore great choices for teaching programming to non-programmers. They are almost certainly not.
I really hope that the discussion of languages for CS1 can move beyond this. There are many languages whose overriding design goal is to be phenomenal for introductory computing education. They are designed by computer science educators, and are shaped foremost by the observed successes and difficulties of actual students that are learning to program with them. They provide answers for educators beyond just a syntax and semantics; frequently, they come battle-tested textbooks and teaching materials.
This isn't a bad idea (Python not Java for a first language makes sense on a number of levels) but the example is setting up a straw-man. Why is the Java code handling exceptions when the Python code isn't? Why is the Java code reading the file line-by-line and the Python code isn't?
Further, you could easily write a simple file library in almost any language that abstracts over the difficulty of using the full file library if you're looking to ease people into programming.
All that being said, Python is a pretty good first language and there's a reasonable chance that someone who does one course in Python might be able to do simple tasks later on, which is nice. I think first languages should generally either be simple scripting languages or 'hazing' languages (i.e. something weird to put everyone on a more level playing field).
If you're going to take CS AP classes in high school, it's gonna be Java. This probably explains why a lot of people learn Java as a "first" language. (And no, not everybody started programming when they were five.)
At least at my high school, we have two classes teaching Java.
One is AP Computer Science, and the other is IB Computer Science. They're taught by different teachers, and AP CS is almost purely focused on nothing but programming, while IB CS also examines how computers work, ethical issues currently in the field, etc.
However, we also have Programming and Advanced Programming, taught by another different set of teachers, that teach Visual Basic, Gamemaker Studio, and handwriting HTML. Not JS, or CSS, just HTML.
In Europe I'm not aware of any country offering Java classes in high-school. It's typically Python or other languages with a low barrier to entry. Maybe JS today.
Yet most good universities stick to Java for CS101, and for good reasons imho. On the other hand, non-CS majors at my school were sent right away to "useful" languages in their field (C++ at that time, I assume Python is more common nowadays).
Here I'm the UK visual basic is collages and universities language of choice, its out dated and not even used much in the industry.
I finished computing science degree in may last year and every single code example was in visual basic, before that in my HND and HNC both visual basic.
So we should start to teach ppl to fly planes by first teaching them to ride a bike? Riding a bike will not help you fly. Programming isn't hard but if "public static..." melts your mind, software may not be for you.
Also the classic file read idiom (the C one) teaches some of the most basic things every programmer should undertand:
. file encoding (which you ignore)
. buffer sizes
. error handling (likely 80-90% of production code)
Your python example ignores these basic instructive points. Why is there no "String str=String.read(file)"? Because it's seldom useful in production (see points above).
I disagree with this.
The second course most [software] engineering students at my university are exposed to, after basic MATLAB and C programming, is 'Object Oriented Design', which teaches the fundamentals of OOP using Java.
It's very useful to have a consistent mental model of classes, methods, variable lifetimes, etc. early on.
Of course, if you're teaching yourself to program (or recommending a language for self-teaching) then Java probably isn't the way to go. However, with a competent teacher, fundamental Java knowledge can be invaluable.
Currently learning Java in AP Computer Science in highschool.
I have past experience with Java/C/programming, so it's not too difficult, but a lot of my classmates struggle due to the complexity of Java. Thankfully, the AP test is mostly logic focused, but the amount of time we spend going over Java is less time we can talk about problem solving. (And the amount of time we go over topics like what "static" means is substantial)
Seems like if you did spend the time and effort to understand all the parts of the Java example, you'd be well on your way to being a coding badass. But it's important for someone forming their first impressions to be able to have a quick turnaround from having an idea, to telling the computer to do something, to having the computer do it. That's the part that gets 'em hooked!
I teach Java in my "Intro To Programming For NonMajors" class. I get around the problem of "lots of boilerplate code required" by giving them a file with the boilerplate code, and then have them start writing their code in main(). It works well enough (certainly as well as having them write 10 PRINT "Hello, World!") and the students are fine with it.
I think the first language course should not be any single language but a language sampling course. Students learn the concept of variables, switches, loops and subroutines, then they learn how it is used in all common languages. And for homework, they are allowed to pick their favorite.
For starting programmers, language is not important, concepts are. Any specific language will skew the concept.
I started with Visual Basic in high school, it was a great base and kept things interesting. Our teacher did a great job of giving us fun projects to develop and I think that was way more important than the language chosen.
In my high school we learned Pascal first. OOP Pascal Second. C++ third. and C last. I am forever grateful to have learned programming in this order. It has enabled me to jump into any language and just "get things done".
Is great.... except the lack of support for writing your own functions. Except you can simulate it with hacks, which are confusing to kids. My son did SB at school, and the code they produced was a mess because they couldn't structure things well when they needed repeated, but slightly different things to happen, they end up copy pasting, then they have a problem and have to track down all the copy pastes, etc
Apache Groovy meets the one-line criteria but fails the simple syntax rules criteria. In your example, you have to explain that Groovy's println syntax above only works for certain types of arguments. If you want to print a string then
println "Hello World"
is being translated internally to `System.out.println("Hello World")` and therefore works. But if you want to print a list then
println [1, 2, 3]
doesn't work because it's being translated to `println.getAt([1,2,3])`. You need to put parentheses around it, writing
println([1, 2, 3])
to achieve the same effect. Your choice of example obscures this dirty little secret about Apache Groovy. There's many other confusing rules like this in the language, e.g. `myVariable.class` returns the class of myVariable, whereas `myVariable.clazz` returns a property called clazz.
The Java example in the blog post works for all types of arguments, even if it is 5 lines long. I agree with you that Clojure meets both the one-line and simple syntax rules, though.
Java is my favorite language now, but its power comes with a lot of potentially confusing constructs. The sheer complexity of the syntax is bad for beginners as well.
It's harder to create program that compiles and runs, at least until you understand compiler and syntax errors well enough to avoid them.
I learned Java as my second language after Perl and I remember how horrible it was to grok all the concepts at once.
At the same time, like I said, it's my favorite language now. The syntax, constructs, and standard library are built in a very sensible way. There's nothing I can look at in Java and say "wow this really fucking sucks" which is rare among languages. C# is the only language I can think of that definitely has cleaner design.