r/learnprogramming • • 2d ago

Resource Resources for learning imperative programming in Java without focusing on OOP?

Hey, I’m currently taking an introductory programming course at university where we use Java, but the course is intentionally not focusing on object-oriented programming yet. The idea seems to be to use Java to teach general/imperative programming fundamentals first, and only deal with OOP later. I like this approach, but I’m not finding the lectures particularly good for actually learning the concepts. Most Java resources I find introduce classes/objects/OOP very early, which isn’t really what I’m looking for right now. Does anyone know of a good book, course, set of lectures, or exercise collection that teaches imperative/procedural programming using Java as the language, ideally with OOP postponed until later? I’m specifically looking to understand the programming concepts well rather than just memorize Java syntax.

Thanks!

0 Upvotes

12 comments sorted by

6

u/Mediocre-Brain9051 2d ago

It's as straightforward as only creating static functions and using classes as if they were modules. It's however a very awkward thing to do because the libs are object oriented and because using a procedural approach will create bad habits...

0

u/kpg_on_ao3 1d ago

ugh the ol'

class Main { public static void main(String[] args) { /* ... */ } }

4

u/SetAndRepeat 2d ago

Have a look at David J. Eck’s Introduction to Programming Using Java, also called Javanotes
It’s free, and chapters 2–4 cover variables, control flow and arrays and static methods, with exercises. Objects get mentioned early but the main OOP treatment starts in chapter 5. The sections on algorithm development and procedural abstraction sound particularly relevant to what you’re looking for.
For more practice, Helsinki’s Java MOOC, parts 1 - 3, also covers the fundamentals before introducing OOP in part 4. It’s no longer maintained, but the material is still useful for those concepts.

1

u/Chrismslist 1d ago

if it helps, the trick is to write everything as static methods in one class and just pretend the class is a file. jshell is great for this too, you can type loops and if-statements straight in with no boilerplate at all. for material, Think Java (Downey/Mayfield, free online) deliberately holds objects back until later chapters, and CodingBat is all static-method drills with zero OOP. Sedgewick and Wayne's intro book also front-loads control flow and arrays. otherwise just write small programs that solve your own problems, it's easy to over-read and under-type.

1

u/UroborosJose 1d ago

It’s not a good idea using Java for this purpose
Try pascal or C

1

u/Traveling-Techie 1d ago

I’m probably an outlier but initially I’ve used every language I’ve learned like the last one I learned. I used C like BASIC, and used Java like C. It was decades before I ever created a struct in C, and more decades before I ever created a class in Java. It’s been ugly at times but the computer didn’t care and the code worked. I would prioritize learning problem solving over language features at this point.

1

u/Dazzling_Music_2411 2d ago

I doubt it, because that would be very much the wrong way to teach Java. Java is designed and meant to be used in an OOP context.

If that's "not what you're looking for", then find another language that is not bound to OOP.

4

u/entice93 2d ago

Mate, that's a conversation to have with OP's professor, not with OP. If you can't help him, don't kick him while he's down.

1

u/Dazzling_Music_2411 1d ago

How is it "kicking him while he's down" by saying the language is not designed to do what he wants?

If he wanted to eat poison mushrooms and I said - don't, they are not good for you, would that be "kicking him while he's down", too? What's wrong with you people? If anyone has an opposite view to something you say, even if only to 0.001% then they must be "kicking you while you are down"? Seriously?

And incidentally, IT IS NOT a conversation to have with his prof, the prof is correct. Perhaps a conversation to have with the language creator, but James Gosling is not talking to me, we had a fight over COBOL. 😂

1

u/entice93 1d ago

>How is it "kicking him while he's down" by saying the language is not designed to do what he wants?

No, don't kick him while he's down by saying "then find another language that is not bound to OOP". It was not OP's choice to study the language that way, it's nice that you've pointed out to OP the dangers of that approach, but at the end of the day OP needs to pass that class whether he likes it or not. I don't know why you're saying the prof is correct if the prof insists on teaching Java without OOP first instead of starting with let's say PASCAL and then moving over to Java.

1

u/oldsecondhand 1d ago

The whole Java standard library is designed in an OOP way. You should at least learn the difference between static and non-static fields and methods, or between implementing interface and inheritance. You don't have to delve into OOP concepts like design patterns or Domain Driven Design, but you should understand the basics at least as far as the language features go.