ROS2 is the second-generation Robot Operating System, an upgrade to ROS1 that addresses some of its issues. The first ROS2 version, Arden, was released in 2017. With continuous updates and optimizations, it now has a stable version. As with ROS1, the choice of Linux version is also relevant to the ROS2 version. The corresponding versions are listed below.

2.1. ROS2 Fully Supports Three Platforms
2.2. Implemented a Distributed Architecture
The master node is eliminated, enabling distributed node discovery, publish/subscribe, and request/response communication.
2.3. Real-time Support
2.4. New Programming Language
2.5. Using the new build system Ament (Catkin for ROS)
2.6. ROS1 can communicate with ROS 2 via rosbridge
ROS1 currently only supports Linux, and is commonly built and used in Ubuntu. ROS2, on the other hand, can be built and used in Ubuntu, Windows, and even on embedded development boards, making it a more widely used platform.
ROS1's core is C++03, while ROS2 makes extensive use of C++11.
ROS1 uses Python 2, while ROS2 requires at least Python 3.5. Foxy uses Python 3.8.
ROS 1 requires starting roscore before starting. This master controls all inter-node communication. ROS 2, however, does not have this. Instead, it uses an abstract middleware interface for data transmission. Currently, all implementations of this interface are based on the DDS standard. This enables ROS 2 to provide various high-quality QoS policies, improving communication across different networks.

ROS 1 compiles using the catkin_make command, while ROS 2 compiles using the colcon build command.