문제

Next semester (starts in just under 5 weeks), I'm taking System Programming and OOD concurrently. Apparently SP centers on working in C on Linux, and I only have Java and Python experience, so I am a little nervous about this.

For those of you who've taken these at an university, what should I look out for?

I've already taken Computer Organization which included an overview of Assembly. With the exception of implementing loops in assembly, I ranged from B+ to A- in the assembly projects. Building circuitry was another story, however.

도움이 되었습니까?

해결책

Well, exactly what you're going to need wil depend on the class, though some generalities will likely hold. I'd suggest getting a C book intended for Java programmers. It's likely to point out the major pitfalls and help you transition.

The biggest items that you're going to worry in C that you don't really worry about in Java are pointers and memory management. Java references are technically pointers, but they're seriously dumbed-down pointers, and from what I've seen, Java programmers don't really see them as the pointers that they are and often have some trouble dealing with pointers initially. Going hand in hand with that is the fact that you won't have a garbage collector, so anything that gets allocated on the heap will not only have to be manually allocated, but you'll have to manually de-allocate it when you're done with it. So, you're going to have to become familiar with malloc and free. You also aren't going to have classes, and structs in C can't have functions in them, so you don't generally program in C in an object-oriented manner. That may or may not be a big deal for you. It does mean, however, that what you'll be learning in your systems programming course and your object-oriented design course are likely to be very different.

OOD should be more of an extension of what you know, teaching you how to better program in an object-oriented manner. Systems programming, on the other hand is much more about getting down and dirty and will be much more low-level in what it deals with. Both are really important to being a good programmer though.

Without knowing your exact skill set and experiences and without knowing the exact courses, giving more detailed advice would be difficult, but primarily, the issue is likely to be in dealing with how C doesn't doesn't manage things for you and doesn't try and keep you safe from yourself. You will have to be more careful programming in C than you would be in Java or Python. There's plenty of stuff that's perfectly legal C which would be illegal many other languages and could surprise you. The main things to be concerned about though are pointers and manual memory management.

다른 팁

Have no fear - it's only code

Java and C have very similar syntax coming from the same family of languages. As others have said, your biggest hurdles will be learning pointers (hint: they're just indirection), and memory management. Suddenly all those arrays you've been declaring in your Java have to be disposed of. Like any subject, once you've twigged what it's all about then it suddenly becomes straightforward.

Overall, it's more about learning the environment you'll be working in rather than some language syntax and constructs. Linux programming is very different to general Java programming. One relies closely on the operating system APIs, all C pointers and structs, and the other is generally much simpler because it's at a higher level of abstraction, there's just a lot more of it.

Developing the mindset

Perhaps the way for you to approach this is to maintain two working environments as virtual machines (Parallels or VMWare come to mind). One is purely for developing C code, the other for Java and no mixing them up. You could use different themes for the desktop to reinforce the different mindset (black for C, blue for Java or whatever). Each time you come to work in one or other environments you have many visual cues to promote the appropriate mindset you need to get the work done.

I always found it difficult to take classes with opposing points in the same semester.

If your systems class is very low level you will likely need to do some very non-OO things.

If you can keep the two straight though it might be a good time to learn the advantages of each approach.

My personal experience with OOD classes were that you needed to go to a nearly theoretical level of abstraction to get full credit and that the systems classes were usually more theory than code because it was not reasonable to build much of an OS feature in a single semester.

If you haven't ever done any C or assembler, be prepared to understand Java and Python at a whole new level. Even though you already have some comp sci survey class that told you how memory and references work you almost certainly do not fully grok it.

Go into to it with an open mind, and an open heart. C is a beautiful thing, but not at all in the same way that Python is beautiful. It is beautiful more in the same way that a trench knife is beautiful.

For Systems you have to go low. You have to understand how fundamental stuff pointers, memory management, registers, system calls, even assembly and system architecture etc work. OOPS is at higher level of abstraction. So you will have to continuously switch your perspective or rather frame of abstraction. As long as you keep this in mind, I don't think it should be that difficult.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 softwareengineering.stackexchange
scroll top