Both are Transport-layer protocols, but they make opposite trade-offs. TCP is connection-oriented and reliable — it guarantees that every byte arrives, in order, exactly once. UDP is connectionless and "fire-and-forget" — it just sends packets (datagrams) with no delivery or ordering guarantees. You trade TCP's reliability for UDP's low overhead and speed.
TCP UDP
┌───────────────────────┐ ┌───────────────────────┐
│ connection (handshake)│ │ no connection │
│ reliable (retransmit) │ │ best-effort (no retry)│
│ ordered delivery │ │ unordered │
│ flow + congestion ctrl│ │ none │
│ higher overhead │ │ minimal overhead │
└───────────────────────┘ └───────────────────────┘
