Coding - the most basic action needed to write a software, which basically is just typing symbols in the editor without a purpose and much thinking
Hacking - process of thinking with purpose to find a weak part of the system. When the weak parts found, a person might break the system, steal some information, affect the availability or integrity of the system. Many security engineers and testers also have to hack their own systems with the purpose to prevent evil hacking.
Hacking is also an international criminal offense (cybercrime).
It depends when you were born - when I got my first computer, hacking meant circumventing security for the fun of it (or very rarely by criminals for financial gain) to gain access to things on a server / website (or to change things on a website / server) whereas cracking meant circumventing security in software you had access to (example, decompiling an EXE file to assembler and changing the assembler in order to get rid of the message that says your trial period has ended). People who exploited vulnerabilities in websites by using scripts they found on the internet were called script kiddies and the hacker community used to hate these people since they would typically deface websites or do some sort of damage which placed the hacking community in a negative light.
One of the banned books of the time included the little black book of computer viruses and the big black book of computer viruses which contained the source code for all the deadly computer virus ever made. You couldn't open this book or the included zip file on 'n windows PC as it would either infect your PC or make your antivirus go ballistic. Keven Mitnick also wrote a book which was considered a good book by the hacking community, The Art Of Deception (which went into a lot of detail on how a secure system can be compromised simply by exploiting the weakest link, typically the people who has access to it). For some of his new books, see: mitnicksecurity.com/S=0/shopping/books-by-kevin-m…
These days, hacking has been hijacked to mean creating something in a clever way, so even if you modify your Roomba vacuum cleaner or your drone to bring you coffee or find a way to fold your laundry in clever way, it's considered hacking. If you are coding something in a clever way, it would be considered hacking under the newly hijacked definition of hacking - creating something in a clever way.
Coding is merely that: The act of writing code. It can be with any purpose.
According to Eric Raymond, a hacker is anyone wanting to create and/or subvert how things are usually done in their field or whatever they're doing right now, in ways that improve the process for everyone. This means that not every coder is a hacker and viceversa.
As for the media, a hacker is anyone violating the security measures put in place in any software system. They can be hackers, such as the guys who did it to improve the security settings in ten thousand routers; but, more often than not, they are to be called crackers (according to ESR anyway).
Tommy Hodgins
CSS & Element Queries
The way I see it, hacking refers to the ingenuity of coming up with a clever, self-made solution to a problem. It doesnt have to be computer related. A hack might be constructing the perfect-sized coffee scoop for your kitchen by designing the right spoon to meet your needs. Or a hack might involve making something from improvised materials. The reason so much hacking happens on computers is that the resources are free, and infinitely malleable. If you were creating art you would need art supplies, but on a computer your words build amazing structures for free.
Coding on the other hand, is simply the act of breaking apart human thought and encoding it into a format that is machine readable. Just because you are coding does not mean you are hacking.