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:

  1. GMAIL: http://code.google.com/apis/gmail/oauth/code.html
  2. YAHOO: http://developer.yahoo.com/mail/

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.

  • 1
    If you really see a need for it, why don't you write one? – Nathan Osman Dec 27 '10 at 0:22

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++.

  • 2
    Though 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. – Martin York Jan 11 '11 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.

  • 2
    Although 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 Dec 27 '10 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.

  • 2
    hackage.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 Jul 8 '14 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 Jul 8 '14 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++!

  • 5
    -1 Completely disagree. Certain web applications would be much better designed in a language like C++. – Nathan Osman Dec 27 '10 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 Dec 27 '10 at 8:12
  • 1
    -1 See for example the Wt framework: webtoolkit.eu/wt – Mauricio Scheffer May 1 '11 at 22:58
  • 2
    @Mauricio, the existence of a framework does not make it a good idea. – dan_waterworth May 2 '11 at 5:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.