Salesforce offers two variants of the Streaming API - PushTopic and Generic.
In Summer '17 (v40.0) Platform Events are now also Generally Available (GA).
How do they differ and why would you use one over the other?
Salesforce offers two variants of the Streaming API - PushTopic and Generic.
In Summer '17 (v40.0) Platform Events are now also Generally Available (GA).
How do they differ and why would you use one over the other?
Very generally, the Streaming API was created primarily to update UI components(Source) where as Platform Events are for integrations via a Message Bus.
With a PushTopic from the Streaming API you are limited to receiving events notifications when the configured query and event occur. There is no capacity to manually generate these events beyond causing the criteria required by the query and event.
Generic Streaming via the Streaming API is similar to Push Topics but is not bound to specific changes to Salesforce data. Instead you control when to publish an event. The trade off is that the payload of the event is a 3000 character string rather than a defined structure like that of a PushTopic.
Platform Events provide the defined notification structure of a PushTopic with a more flexible model than Generic Streaming for raising and subscribing to the events. They can be published and subscribed to via Apex in addition to the APIs.
As Mohith commented, there are differences with the limits between Platform Events and the Streaming API.
E.g.
Another interesting difference is that PushTopics are limited to 2,000 clients/subscribers across all topics for Unlimited Edition orgs. Where as for the Generic Streaming that limit is 2,000 clients/subscribers per generic streaming channel.
Platform events have limits on subscribers documented in Platform Event Allocations. They differ based on edition and subscriber type.
From What Is the Difference Between the Salesforce Events?
Platform Events
Platform events enable you to deliver secure, scalable, and customizable event notifications within Salesforce or from external sources. Platform event fields are defined in Salesforce and determine the data that you send and receive. Apps can publish and subscribe to platform events on the Force.com Platform using Apex or in external systems using CometD.
Streaming API Events
Streaming API provides two types of events that you can publish and subscribe to: PushTopic and generic. PushTopic events track field changes in Salesforce records and are tied to Salesforce records. Generic events contain arbitrary payloads. Both event types don’t provide the level of granular customization that platform events offer. You can send a custom payload with a generic event, but you can’t define the data as fields. You can’t define those types of events in Salesforce, and you can’t use them in Apex triggers.
Another significant differences -
In streaming API's we lose the update (event) if the subscriber is offline, however in platform events they will be available in the event bus for a duration of 24 hours. So if a subscriber comes online after sometime, he will still have access to updates happened during outage time.
[Update] Same can be achieved for streaming APIs using Durable push topics.
Platform events are a first class object, that means you can setup multiple fields and can have your own structure to publish events. It wasn't possible on streaming APIs, as you had to rely on object fields which can be part of query.
Well, platform event is part of streaming API. Comparing to push topic and generic event, it is more pub-sub driven and offers more flexibity in terms of payload and handling.
Reference: