I was trying to do some C++ coding that can send files from my laptop to my webmail account. It took me about 10 minutes to realize that there is no easy way to do this. Look into these links:
I am trying to understand why PHP or Python or Java support exist but no C++. No flame wars, I love all programming languages and their creators equally but I am curious to understand the logic behind such implementation choices.
-
1If you really see a need for it, why don't you write one?Nathan Osman– Nathan Osman2010年12月27日 00:22:01 +00:00Commented Dec 27, 2010 at 0:22
5 Answers 5
C++ has its strengths and weaknesses. One weakness is that its library is very thin. Email involves a lot of protocols, HTTP/S, SMTP, POP3, IMAP, etc. I don't see how you can support these protocols easily in a standardized way with C++.
-
2Though true (about the thin libraries). This is not the reason why there are no C++ API for these web applications. There are 3rd party libraries for C++ that support all these protocols (you just need curl really). The advantage of C++ is that it is fast, but using it over HTTP nullifies this advantage. So why use a more complex language when a simpler slower one will work. Once you have made this tradeoff they why would you want to support multiple interfaces.Loki Astari– Loki Astari2011年01月11日 18:47:00 +00:00Commented Jan 11, 2011 at 18:47
Hypothesis: because web APIs are primarily used to integrate their respective services with other web applications. Therefore it is logical to conclude those other services are written in some web-relevant languages. C++ is not one of them.
Anyway APIs here do not seem to be language-specific. They're just offering you a bunch of client libraries out of courtesy, not for all possible languages, but for a narrow selection of the most requested ones. If there isn't one for your needs, nothing prevents you from writing your own client library - maybe even publishing it to make people's lives better. Or maybe there is already one - just google for it.
-
2Although C++ is rarely used to directly write web applications, that doesn't mean that it isn't used for interacting with web services.Nathan Osman– Nathan Osman2010年12月27日 00:21:21 +00:00Commented Dec 27, 2010 at 0:21
Why no developer API in C++ for Google or Yahoo mail?
Why no developer API in Haskell, Erlang or Brainfuck for Google or Yahoo mail? Because nobody cared enough or needed it so far. Luckily, this is all just HTTP, XML and JSON, so you can build API bindings for any language/platform you want.
-
2hackage.haskell.org/package/google-search includes the mail api. gist.github.com/tsloughter/588177 erlang access to google mail (though smtp rather than oath)Pete Kirkham– Pete Kirkham2014年07月08日 14:12:34 +00:00Commented Jul 8, 2014 at 14:12
-
@PeteKirkham Cool, however that doesn't invalidate my point in any way, i.e. I could easily mention 5 more languages where this is not available. Also the Haskell binding you mention was created in 2013, while my answer was written in 2010. And the Erlang code you mention seems to be plain SMTP, I don't see anything about OAuth in there so it's not about the Google API.Mauricio Scheffer– Mauricio Scheffer2014年07月08日 16:05:10 +00:00Commented Jul 8, 2014 at 16:05
There are some C++ or C libraries to send email (using SMTP): VMIME, libsmtp, etc. You could also find IMAP libraries
And you could write C++ web applications, e.g. using an HTTP server library like libonion or wt, or making it a FastCGI client. You can do HTTP client processing using libcurl
However, most people prefer coding web app in e.g. PHP. But you could use Ocaml with ocsigen, or opa or Hop
But your question is probably off-topic here.
This is really a summing up of Developer Art's Point:
Nobody (with few exceptions) should write web applications in C++!
-
6-1 Completely disagree. Certain web applications would be much better designed in a language like C++.Nathan Osman– Nathan Osman2010年12月27日 07:20:40 +00:00Commented Dec 27, 2010 at 7:20
-
Name one that doesn't have a medium-large company behind it (which would make it infeasible to write their own interface).dan_waterworth– dan_waterworth2010年12月27日 08:12:56 +00:00Commented Dec 27, 2010 at 8:12
-
1-1 See for example the Wt framework: webtoolkit.eu/wtMauricio Scheffer– Mauricio Scheffer2011年05月01日 22:58:28 +00:00Commented May 1, 2011 at 22:58
-
2@Mauricio, the existence of a framework does not make it a good idea.dan_waterworth– dan_waterworth2011年05月02日 05:22:50 +00:00Commented May 2, 2011 at 5:22