What is stream?

9

In both PHP and C #, languages that I have lately used in my day to day, I have come across a common term: Stream.

Whenever I hear the word Stream , the first thing that comes to mind is YouTube, among other sites, which are often called "streaming video sites". >

But in the above-mentioned languages, the term is usually related to reading and writing data in memory or in a file.

For example, in PHP we have a function called stream_get_contents which is responsible for getting the contents of a resource opened by a fopen function in a string .

In C # I ended up running into this term when I needed to use the class FileStream and MemoryStream , which reminded me a little of the wrappers that PHP uses to read the output buffer, files, or even the memory itself (through the php://output , php://memory and the like).

Summarizing my question:

  • What does Stream mean after all?

  • I was wondering if this stream of PHP and Csharp has anything to do with "streaming videos" from sites like Youtube.

  • All languages that work with data manipulation, such as files, temporary files, memory or output buffer, also use this Stream ?

    >
asked by anonymous 08.08.2017 / 14:10

2 answers

9

Almost everything has already been answered in How to really understand Streams? .

Nothing to do with streaming video directly, though the technique is the same. You access a feature that will give you the information you want as you are requesting, the exact way this occurs does not matter.

In general languages do not have streams , libraries do, so any one can have. The most modern ones have the standard library. You can create your streams .

Java 8 invented such a Stream that is no longer a mechanism like this we are talking about, but is used in another context, it is almost the same as LINQ from C #, it is a form of manipulating enumerable on demand

    
08.08.2017 / 14:17
2

I will try to respond generically, without direct link to a specific language. I do not understand Stream as a specific feature of a language, but rather a technique / algorithm.

  

What does Stream mean after all?

As the free translation itself explains, Stream is a stream, it is a data stream, in programming languages it is generally a matter of transferring a content / bytes of known size or not from one "local" to another, local in this case it is always related to hardware (ram, hdd, flash, usb, ethernet, etc.) even if it is virtualized internally this communication is usually done via OS.

  

I was wondering if this stream of PHP and Csharp has anything to do with "streaming videos" from sites like Youtube.

As clarified with the answer to your previous question, yes, because it is about transferring contents / bytes from one point to the other.

  

Do all languages that work with data manipulation, such as files, temporary files, memory or output buffer, also use this Stream?

In this case we need to clarify that there are Streams that you already know the size, a file on disk for example, and there are streams like those of sound and image that are coming to the step that are made available by a server. So in my opinion yes, although not all languages are for the web, or allow the transfer of contents of dynamic sizes, or that they do not even have a class called Stream, in this case it is only a name given to this technique. >     

10.08.2017 / 20:48