Difference between ui and lightning namespace in Salesforce

The original components that were made available when the Lightning Component Framework first came out live in the ui namespace (<ui:button>, <ui:inputText>, and so on).

The new and improved components, also known as the Base Lightning Components, live in the lightning namespace (<lightning:button>, <lightning:input>, and so on).

Whenever possible, use the Base Lightning Components (components in the lightning namespace). Benefits include:

Styles: Base Lightning Components are styled with the native Lightning look and feel.
Performance: Base Lightning Components are already loaded at the client-side and don’t require additional download or processing. Our performance optimization efforts are also focused on components in the lightning namespace.
Innovation: The Lightning namespace is where components are being actively developed. This is where you can expect to see new and improved components moving forward.
Accessibility: Base Lightning Components are built for accessibility.
Client-side validation: Base Lightning Components include client-side validation when applicable.