Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Learn Java with Math: Is Java really a good beginner language?

 
Ranch Hand
Posts: 71
1
Firefox Browser Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ron,

What's your take on Java as a beginner language? Java was my first programming language in the late 2000s. Looking back, I think Python would have been a better introductory language.

The table of contents of your book look really interesting. I'm looking forward to checking it out.

Thanks!
 
Greenhorn
Posts: 14
Mac OS X Python Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Though Java is a very verbose language, definitely it is a good beginner language. It's strict typed language will give you an opportunity to practice discipline while writing code. And that discipline will lead you to apply to other languages where type is a concern.

While python is a good language to start but the intendation should not be something I should be concerned as a first programmer. So I still prefer Java as a beginner language.
 
Author
Posts: 8
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Carl,
I like Vaseem's reply. One more thing I'd like to emphasize is, if one is serious to learn fundamental programming concepts, Java is a good one to start with.

Thanks
Ron
 
Marshal
Posts: 76492
366
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you seen Joel Spolsky's ideas about teaching programming? He says you should make things difficult so as to weed out the “can't”s from the “can”s. Anybody who can't hack pointer arithmetic (in C) would drop out. He says that universities worry about 40%+ of students changing from CS to something else. I agree with Spolsky there; what is wrong with them deciding they would be happier reading law? And why does Spolsky seem to think law is an easy option?
Eleven years' moderating on this website has taught me something. Java® has a feature just as difficult as pointer arithmetic, which many teachers don't seem to understand themselves.

The number of times I have found myself saying things like, “not an object‑oriented solution.” . . . That has convinced me that it is just as difficult to get one's head round OO (=object‑orientation) as around pointer arithmetic. If Spolsky asked people to write a proper OO app in Java® for an interview exercise, he would find just as many “can't”s as he does by asking about pointer arithmetic. Well, maybe. That is why I asked elsewhere about when you introduce OO concepts in your book.
 
Sheriff
Posts: 17153
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I actually like that Python enforces proper indentation and I think it’s good for new programmers. It’s not just a style thing. I learned how to program in the 80s, when structured programming was The Thing. That meant a language like Pascal or BASIC, which were my two (concurrently learned) first languages.

Indentation was not a big thing in BASIC, at least not in the version of it that I learned. However, one of the first concepts my instructor in Pascal emphasized to us was the importance of proper indentation and alignment so that the structure of the code was clear. I credit my instructor for emphasizing this seemingly “trivial” detail. It’s not trivial. In my opinion, knowing how to properly indent code to clearly show the structure you intend your logic to have is an extremely important fundamental concept to learn, especially if you’re a beginner. I can point to any number of threads around here where that would have made a significant difference in the student being able to understand where they went wrong and why their program wasn’t working the way they thought it should.
 
Junilu Lacar
Sheriff
Posts: 17153
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vaseem Mohammed wrote:intendation should not be something I should be concerned as a first programmer.


Just to drive home the point that I totally disagree with this statement. This is like saying that first-time carpenters shouldn’t worry about things like measuring and making sure that their work is square but instead focus on learning how to cut things with saws and pound things with hammers first. Couldn’t be any further from the truth as I see it.
 
Campbell Ritchie
Marshal
Posts: 76492
366
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:. . . when structured programming was The Thing. . . . like Pascal or BASIC . . . .

I remember writing BASIC before that and it wasn't a structured language then.

. . . any number of threads around here where that (=correct indentation) would have made a significant difference . . .

Text in () is my text.

Agree.
 
Rancher
Posts: 259
13
Eclipse IDE C++ Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
python is fundamentally flawed. i have taken about a half dozen very large python apps and re-wrote them into java. it was a horrible experience. it took weeks of very careful debugging to get the java versions working and almost all of the bugs were due to these 2 little things:

#1 not having braces makes seeing where a code-block begins and ends difficult and causes many mistaken interpretations of the code. i was not using a special python IDE that did anything special to help point out the code blocks. but if you have to rely upon IDE features to make up for a defect in the language that says it all. visual style and program flow should be separate. just as how we have css and xml to separate interface from implementation.

#2 another problem is that the types are not easy to determine either, and they can be changed on a whim. these python apps will change a var's type repeatedly and it can become confusing and lead to errors. a var can bounce back and forth like a ping-pong ball. now it's a string, now it's an int, now it's a double, now it's a string again.

python programs are much shorter, it requires fewer lines of code when you don't have any braces for clearly formatting the code, or any type safety at all, so you can keep reusing variables and changing their types. but it's error prone, hard to maintain, hard to rewrite. these are bad habits to teach a beginner, just like how basic taught spaghetti programming with numerous goto jumps all over the place.

on the other hand, java is too verbose, and some of the style conventions are inconsistent such as needing to put a semicolon after a brace like this:


for a beginner i think the best language would be C, because many languages are C-like. when they go learn a new language after C they won't feel like they're learning it all over from scratch. also you avoid needing to learn OOP right off the bat and can focus on the core concepts. java is a good 2nd language to learn for learning OOP.
 
Campbell Ritchie
Marshal
Posts: 76492
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

S Fox wrote:. . . for a beginner i think the best language would be C . . . you avoid needing to learn OOP right off the bat . . . .

But some people take a very long time to go from procedural programming to OOP (=object‑orietned programming).

I presume you would require your beginners to know about pointer arithmetic.
 
Junilu Lacar
Sheriff
Posts: 17153
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@S Fox: I won’t say you’re wrong because obviously based on your experience, that’s what is right for you. I will say that your view does not align with my experience in learning how to program nor with my experience with Python. I think the problems you describe are not unique to Python nor are they inherent to Python as a language. To me, that sounds more like problems in the way the programs were written, problems that to large extent can also be seen in other languages. Java does not inhibit or discourage writing convoluted spaghetti code. Java does not inhibit or discourage writing code with misleading and confusing structure. That’s all about programmer discipline and to a large extent, skill.

I think what language you use to learn programming isn’t as important as what disciplines you learn about good programming. Certainly, good organization and structure is one thing. The ability to write unit tests is top on my list. I strongly believe that we should be teaching new programmers how to write tests, maybe introduce testing concepts concurrently with basic concepts like loops and conditionals and procedure/function/method calls. Too often in the forums I have complained about how kids are being taught ways of writing programs that I would have to reverse or drastically alter immediately if they ever, by some miracle, made it into one of my teams.
 
Ranch Hand
Posts: 88
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Have you seen Joel Spolsky's ideas about teaching programming? He says you should make things difficult so as to weed out the “can't”s from the “can”s. . . . it is just as difficult to get one's head round OO (=object‑orientation) . . .


Although I think I get the object-oriented idea, I suspect I'd be a bit clueless about making solutions object-oriented, as such (unless there seems to be a need) - can you give a correct-incorrect example for a simple problem or two?
 
Ranch Hand
Posts: 47
1
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Don.  What mathematical skills must I possess to become a successful, EMPLOYABLE programmer?  I'm 51.  School was a long time ago.  Is your book a tool to help me acquire this skill?

"Who This Book Is For
Those new to programming and Java but have some background in mathematics and are at least comfortable with using a computer."


Thanks.
 
Campbell Ritchie
Marshal
Posts: 76492
366
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is usually no need or benefit to quoting the whole of an old post; who want to read my ramblings twice? I have shortened the quote.

Elaine Byrne wrote:. . . Although I think I get the object-oriented idea, . . . can you give a correct-incorrect example . . .

Let's think about it. Let's imagine you are trying to read a text file containing numbers, do some calculations with those numbers and write them to a new file.All the loops will work. The only really bad name for a variable is x. the resources are closed (actually, there is a risk of not closing the resources), and you are handling the exception, which probably won't be thrown in the first place. Actually there is a risk of throwing an exception, because you might have misspelt the name of the input file, so it is a lot better to use a file chooser to find your file.
Apart from that, the above code is pretty bad. It is all crammed into the one method. You might be creating objects to execute the input and output, but you don't have any objects to manipulate your data onc eyou have got them. Nor are you recording your data. This method simply acts as a conduit for data to flow from one file to another. You can tell procedural code because it is full of statements like something = somethingElse;, whereas object‑oriented (=OO) code would contain statements like someObject.doSomething(something);
An OO solution might look like this:-
  • 1: Record the input file as data in the object.
  • 2: Record the results as data in the object.
  • 3: Use a separate object both to record the data and to do the calculations of log and sin.
  • 4: Divide the work between separate methods, some callable from elsewhere.
  • Note:-
  • 1: Create objects to record the numbers and do all the calculations.
  • 2: Create List to store those numbers for as long as ithey are needed.
  • 3: Separate methods for reading and writing.
  • 4: The methods don't do their own exception handling; if calling code supplies a wrong file name, that code will have to correct the problem.
  • 5: The object permits two options for dealing with its data: (i) write to file (ii) return (copy of) the List.
  • 6: This object is immutable: after the constructor completes, there is no way that any of the data can change. That isn't necessary in the procedural solution because no data were stored, but it is very useful for an OO solution.
  • 7: All methods shorter; the longest occupies 12 lines.
  • 8: Validation in first class' constructor; you cannot rely on nice well‑behaved input with positive finite numbers as you would get from a file.
  • You will probably find some spelllling errors in the above code. The OO solution is longer but offers much more versatility.

    Note the following features:-
  • 1: Lots of testing.
  • 2: Use the correct Java7+ way to close resources.
  • 3: Use of String#format instead of the + concatenation operator.
  • 4: Cache the value to be returned by toString(), but that is only a very minor point. Only possibel in immutable objects.
  • 5: Use the Java7+ classes (Path, Paths, Files) instead of File.
  • Those five things are all improvements (well, maybe not No 4) which I should have made to the code and didn't. Maybe you can improve the variables' names, too.
     
    Campbell Ritchie
    Marshal
    Posts: 76492
    366
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Remember the last five features in my previous post are things I didn't do, but probably should have done.

    Edit: I see I have also let some errors slip into my code; I shall leave finding them as an exercise for the reader
     
    Marshal
    Posts: 8436
    606
    Mac OS X VI Editor BSD Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Vaseem Mohammed wrote:... the intendation should not be something I should be concerned as a first programmer.


    I completely disagree with this statement.

    Indentation and code formatting skills are equally important for programmer (regardless of experience) as to be able to logically think and approach problem in disciplined way, so it could be tackled with as least as possible struggle. Especially that's applicable to beginners.

    Having poor indentation and formatting makes code to look messy, simply that's because what it is in such case, which invites all sorts of problems which are opposite to disciplined approach.


    And if I'm not mistaken, we have several tutorials elaborating on this topic in more grained details.
     
    Junilu Lacar
    Sheriff
    Posts: 17153
    298
    Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Dustin Wright wrote:What mathematical skills must I possess to become a successful, EMPLOYABLE programmer?


    That depends on what kind of programs and what parts of it you’ll be writing. For example, programmers who focus mostly on front-end technologies usually don’t deal with complex math often, unless if there’s complex graphics involved, maybe.

    I’ve been a programmer for more than thirty years and I graduated with a degree in engineering. Thinking back over those thirty years, I probably used the kind of math I learned in high school more often than the kind I learned in college. And that wasn’t very often either. However, I think the training I got as an engineer on how to approach problem solving was invaluable.

    In engineering, we have to solve very complex problems and math is only a part of it. The key part to problem solving though that I learned as an engineer is the logic, the ability to break the problem down into component parts and attack those individually while still maintaining the integrity of the big picture and making sure those individual parts came together as a cohesive and coherent whole. The discipline and analytical skills in assessing the problem, coming up with a clean and logical solution, and then executing with precision and organization, that’s what I think was invaluable in helping me become a good developer.

    If I’m not mistaken, the point of the book is to use math problems as a way to learn Java and from what I’ve seen from the book samples available, you’ll at least get to practice some of the problem solving skills I just mentioned.

    As an example, there’s this exercise in the book: Imagine we’re playing a game where I think of a number between 1 to 100. You’re allowed to ask me questions that will help you figure out what that number is but you can’t ask me “What is the number?” What would be your strategy in figuring out the number with the fewest number of questions asked?

    This is a great problem for a few reasons, and it’s much more superior in quality to many of the problems we see given to students who post questions in these forums.

    1. It doesn’t prescribe or even suggest a solution — the student has to figure out the logic on their own.

    2. The problem is simple enough to be able to easily relate to. However, the ideal solution involves a basic algorithm that is often used in programming. If the student is able to come up with the algorithm on their own, then they will already have a leg up when they study that algorithm later.

    3. Having to come up with an algorithm is itself often a difficult task. However, the process is very much the same kind of process engineers use to solve problems: List down what you’re given, identify the boundaries of the problem, know what the end goal is, figure out a systematic way of getting from where you are to where you want to be, then do it.
     
    Junilu Lacar
    Sheriff
    Posts: 17153
    298
    Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Dustin Wright wrote:Is your book a tool to help me acquire this skill?


    Just to reiterate the point in my previous long-winded reply: I think the book will in fact help you acquire or least practice the kind of problem solving skills that good programmers have. The specific maths are not as important as the problem solving strategies, skills, and discipline that you’ll learn and practice, in my opinion.
     
    Elaine Byrne
    Ranch Hand
    Posts: 88
    1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Campbell Ritchie wrote:... Let's imagine you are trying to read a text file containing numbers ....


    Thanks, Campbell
     
    Campbell Ritchie
    Marshal
    Posts: 76492
    366
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Elaine Byrne wrote:. . . Thanks, Campbell

    That's a pleasure
     
    See ya later boys, I think I'm in love. Oh wait, she's just a tiny ad:
    The trailboss has a kickstarter
    https://coderanch.com/t/754577/Garden-Master-kickstarter
    reply
      Bookmark Topic Watch Topic
    • New Topic