diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2020-06-07 14:14:41 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2020-06-07 14:14:41 +0200 |
commit | a19d98ce7e590e6c7f82aa08f7e9791a72e2e8bc (patch) | |
tree | 3420ab92e02e3b1e2994be7198a83c667118ffe1 /content/blog/2015-12-16-java-as-afirst-language/index.md | |
parent | 043710894c648f91a3c9acd11800d67f3b872670 (diff) | |
download | rabalderz-a19d98ce7e590e6c7f82aa08f7e9791a72e2e8bc.tar.gz rabalderz-a19d98ce7e590e6c7f82aa08f7e9791a72e2e8bc.tar.bz2 rabalderz-a19d98ce7e590e6c7f82aa08f7e9791a72e2e8bc.zip |
Split english and norwegian posts.
This turned out a bit different than I initially though. The english and
norwegian sections will essentially be separate. Afaict there's no
direct way to make a "combined view" listing both english and norwegian
posts. However, I think that's fine. Let's roll with this for now.
Diffstat (limited to 'content/blog/2015-12-16-java-as-afirst-language/index.md')
-rw-r--r-- | content/blog/2015-12-16-java-as-afirst-language/index.md | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/content/blog/2015-12-16-java-as-afirst-language/index.md b/content/blog/2015-12-16-java-as-afirst-language/index.md deleted file mode 100644 index a6c4cca..0000000 --- a/content/blog/2015-12-16-java-as-afirst-language/index.md +++ /dev/null @@ -1,110 +0,0 @@ -+++ -title = "Why Java is not good as a first language" -lang = "en" - -[taxonomies] -tags = ["programming", "java", "learning"] - -[extra] -author = "harald" -+++ - -During the spring semester of the last year, a friend of mine was trying to -learn Java as part of her studies. I think it's great when anybody shows an -interest in programming so I of course volunteered to help her out a bit. That -was an interesting experience in many ways. - -<!-- more --> - -On the one hand I found it very difficult to find ways to explain in plain and -simple terms concepts that after decades of programming feel like second nature -to me. Another challenge was of course to guide her towards understanding -without giving her the answer to her excercises, especially when the email -exchanges got rapid and I sensed the frustration rise at the other end. - -On the other hand though, the language itself also created some obstacles to -learning in my opinion. To understand why, let's look at the seminal "Hello, -World"-sample program: - -```java -import java.lang.*; - -public class Hello -{ - public static void main(String[] args) - { - System.out.println("Hello, world!"); - } -} -``` - -There's not many lines of code here, and the gist of it is not hard to -comprehend even for a beginning programmer. But there's a lot going on here -that unnecessarily obstructs the understanding of the code. - -To fully understand this code, you need to be familiar with _classes_, -_objects_, _methods_, _accessibillity_, _arrays_, _packages_ and _streams_. -That's a very tall order for the first day of class. So what the teacher does -is to teach the students to ignore the stuff they haven't learned yet: - -* Why do you have to write `public class Hello`? Don't worry about that, just - copy it for now. -* What's the `public static void main`-thing? It's where you should write your - program, just ignore it for now. -* What about the `args`? ... - -And they have to. There's no way you can get around this code without ignoring -pretty much everything in it. That's bad for many reasons. - -Programming is about paying attention to details, not ignoring them. So this -very way of introducing someone to programming encourages habits you have to -unlearn again as you advance. Another reason this is bad is that since the -students won't understand it, they will not be able to write it from scratch -either. This again encourages them to use crutches like editor macros for -generating code templates, or simply by copying something that works from -somewhere else. - -Now contrast this to a programming language that was designed for learning: - -```pascal -program Hello; - -begin - writeln('Hello, World!'); -end. -``` - -This is the same program written in Pascal[^1]. There's essentially nothing -that even the novice programmer can not grasp here. You declare the name of the -program, and write the code of your program between the `begin` and -`end.`-statements. Output to the terminal is handled by a simple call to -`writeln`, there's no need to know about streams, functions or anything else. - -Now it's easy to expand by introducing variables, loops, conditionals, -functions etc. Along each step the students should be able to follow without -having to repeat, memorize or copy incantations of unintelligible code that -just has to be there. Once the basic concepts are learned properly it should be -much easier to move to new languages, as it will now mostly amount to mapping -the same concepts to a different syntax. - -It can of course be argued that "Hello world" is not a realistic example of -programs that you will write as a student. You will quickly move beyond this, -but to learn the basics the extra stuff still gets in the way. By removing the -cruft and allowing the students to build understanding one concept at the time, -they have a far better chance of learning anything at all. And there will be -less bad habits to unlearn afterwards. - -Neither is it my intention to single out [Pascal] as the perfect teaching -language here. [Ruby], [Python] and perhaps even [JavaScript] are also good -candidates, as are numerous other modern languages. In fact I don't think the -language itself is all that important. The important thing is that the student -can understand the code she writes even from the very beginning. And that you -can progress from there without having to bite over too many concepts at the -time. - -[^1]: This is quite likely the first Pascal code I've written in 25 years! - -[Pascal]: http://freepascal.org/ -[Ruby]: http://ruby-lang.org -[Python]: https://www.python.org/ -[JavaScript]: http://prog21.dadgum.com/203.html |