4 ms·
Yeah, the worst ones are the stream ones, some what ironic given that he singles one out over Java. The IO one may have `ReadToEnd`, but it's still nowhere near
by mattmanser 14y ago
Yeah, the worst ones are the stream ones, some what ironic given that he singles one out over Java. The IO one may have `ReadToEnd`, but it's still nowhere near as simple as Python or Ruby, it just shouldn't have to take that many lines of code to read a file.
And these days I include RestSharp pretty much straight away if I'm going to be doing any HTTP calls, the native HTTPClient API is horrible. But even that's not got the greatest API, there's absolutely no good reason to have to declare a `RestClient` before doing a `RestRequest`, it's just a waste of lines of code. You always end up just writing a wrapper round it.
- eel 14y agoThere are ways in the .NET framework to read an entire file with one line: File.ReadAllText("file.txt"). And the System.Net.WebClient class provides ways to make simple HTTP calls in much fewer lines than WebRequest does. Likewise, Python has ways for interacting directly with streams.
- emn13 14y agoWebClient's API is essentially buggy; it cannot support encoding properly since the order of operations of the API is different from in HTTP, and further the response headers aren't properly exposed to let you work around the limitation. It's fine for a quick hack, it's useless for a reliable web client.