Coding Journey from Java to C
I have been a Java developer who has shifted to C coding for the past 3 years. Here are a few things that I find different while coding in C.
Pointers and garbage collection
In the programs that I do, there are pointers everywhere. I am still getting used to allocation of pointers, allocating memory for them and cleaning up the space occupied by them. It has made me careful of what space is occupied by pointers and after that whether I am cleaning the space occupied by them. If not, it can always create errors because of memory leak issues.
Procedural vs object oriented
C banks upon being procedural language. It never really sank in but after I started to use C, the differences cropped up. There is no object and I can have fun by creating functions, routines and calling them. Understanding the structure was initially a bit difficult but hey, it is all in the game
Memory allocation
The one surprising thing that I faced was allocation of memory which I never had to do in Java. For every new array or pointer or any variable, memory had to be allocated and after its use, it had to be cleaned. Java used to take care of it, so when I was new in C, I ran into lot of memory leak issues and memory allocation issues till I got a hang of it.
These are the four major differences that I found while transitioning from Java to C. But few things did not change. They are:
Logic
The logic behind any code remains the same. I just had to find out and check out the syntax and the workings of any language in order to implement of my end result goal
Documentation
I make it a point to document my findings and create a ReadMe for my own use so that I can troubleshoot if I run into the same issues. That has not changed. I find documenting helps me in keeping track of what I have been doing and what I have been running into. It is like a tracksheet of my own journey which helps me rollback code or understand a problem relatively easily.
Making it play
I tend to zone out if things are not interesting or if I consider anything as work. So, I usually try out fun stuff before I actually go ahead for the project. It might not be even related to the project per se but I will be trying out new things in that language, make errors, do small codes, laugh and then get back. That gives me a sense of joy and happiness.
That's all for today. I will see you later in the next post.