P4 is a domain-specific (in contrast to general purpose languages such as Python or C) programming language that allows a programmer to arbitrarily decide how the packets traversing programmable dataplane blocks are processed. You can compile the code then inject the configuration into a networking device (e.g. a router, Network Interface Card inserted into the server or software switch). Of course, to enable this you need to have a special chip containing programmable blocks.
Some common networking terms clearly explained