Stroustrupได้โพสต์เมื่อเร็ว ๆ นี้ชุดของการโพสต์ debunking ตำนานยอดนิยมเกี่ยวกับ C ++ ตำนานที่ห้าคือ:“ C ++ สำหรับโปรแกรมขนาดใหญ่ซับซ้อนเท่านั้น” เพื่อทำการ debunk มันเขาเขียนโปรแกรม C ++ ที่ง่าย ๆ ในการดาวน์โหลดเว็บเพจและแยกลิงค์ออกมา นี่มันคือ:
#include <string>
#include <set>
#include <iostream>
#include <sstream>
#include <regex>
#include <boost/asio.hpp>
using namespace std;
set<string> get_strings(istream& is, regex pat)
{
    set<string> res;
    smatch m;
    for (string s; getline(is, s);)  // read a line
        if (regex_search(s, m, pat))
            res.insert(m[0]);              // save match in set
    return res;
}
void connect_to_file(iostream& s, const string& server, const string& file)
// open a connection to server and open an attach file to s
// skip headers
{
    if (!s)
        throw runtime_error{ "can't connect\n" };
    // Request to read the file from the server:
    s << "GET " << "http://" + server + "/" + file << " HTTP/1.0\r\n";
    s << "Host: " << server << "\r\n";
    s << "Accept: */*\r\n";
    s << "Connection: close\r\n\r\n";
    // Check that the response is OK:
    string http_version;
    unsigned int status_code;
    s >> http_version >> status_code;
    string status_message;
    getline(s, status_message);
    if (!s || http_version.substr(0, 5) != "HTTP/")
        throw runtime_error{ "Invalid response\n" };
    if (status_code != 200)
        throw runtime_error{ "Response returned with status code" };
    // Discard the response headers, which are terminated by a blank line:
    string header;
    while (getline(s, header) && header != "\r")
        ;
}
int main()
{
    try {
        string server = "www.stroustrup.com";
        boost::asio::ip::tcp::iostream s{ server, "http" };  // make a connection
        connect_to_file(s, server, "C++.html");    // check and open file
        regex pat{ R"((http://)?www([./#\+-]\w*)+)" }; // URL
        for (auto x : get_strings(s, pat))    // look for URLs
            cout << x << '\n';
    }
    catch (std::exception& e) {
        std::cout << "Exception: " << e.what() << "\n";
        return 1;
    }
}
มาแสดง Stroustrup ว่าโปรแกรมขนาดเล็กและอ่านง่ายคืออะไร
- ดาวน์โหลด http://www.stroustrup.com/C++.html
- แสดงรายการลิงก์ทั้งหมด: - http://www-h.eng.cam.ac.uk/help/tpl/languages/C++.html http://www.accu.org http://www.artima.co/cppsource http://www.boost.org ...
คุณสามารถใช้ภาษาใดก็ได้ แต่ไม่อนุญาตให้ใช้ห้องสมุดบุคคลที่สาม
ผู้ชนะ
คำตอบ C ++ชนะโดยการโหวต แต่ขึ้นอยู่กับห้องสมุดกึ่งบุคคลที่สาม (ซึ่งไม่ได้รับอนุญาตตามกฎ) และพร้อมกับคู่แข่งที่ใกล้ชิดคนอื่น ๆทุบตีอาศัย HTTP ที่ถูกแฮ็กเข้าด้วยกันไคลเอนต์ HTTP (จะไม่ทำงานกับ HTTPS) gzip, การเปลี่ยนเส้นทางเป็นต้น) ดังนั้นWolframจึงเป็นผู้ชนะที่ชัดเจน อีกวิธีที่ใกล้เคียงกับขนาดและความสามารถในการอ่านคือPowerShell (พร้อมการปรับปรุงจากความคิดเห็น) แต่ก็ไม่ได้รับความสนใจมากนัก ภาษาหลัก ( Python , C # ) ก็เข้ามาใกล้เช่นกัน
Content-Type: text/html; charset=UTF-8... ฉันจะส่งอีเมลถึงเขา
                boost/asioนั้นจะใช้หมดไปซึ่งเป็นห้องสมุดบุคคลที่สาม ฉันหมายถึงภาษาที่จะไม่รวมการดึงข้อมูล url / tcp เป็นส่วนหนึ่งของห้องสมุดมาตรฐานจะแข่งขันกันอย่างไร