Einzelnen Beitrag anzeigen

Robotiker
(Gast)

n/a Beiträge
 
#33

AW: Delphi-Projekt-Argumentesammlung u.Vergleich

  Alt 24. Nov 2012, 10:05
ISO C++, von MS gerne Modern C++ genannt, sieht deutlich anders aus, als alter WinApi-Code.
Ich zitier mich einfach mal selber und zeige ein paar Codeschnippsel aus der Hilo-Beispiel App für Windows 8.

Ist dieses C++ unstrukturierter und schlecher zu lesen als z.B. C# ?
Code:
vector<unsigned int> RandomPhotoSelector::CreateRandomizedVector(unsigned int vectorSize, unsigned int sampleSize)
{
    // Seed the rand() function, which is used by random_shuffle.
    srand(static_cast<unsigned int>(time(nullptr)));

    // The resulting set of random numbers.
    vector<unsigned int> result(vectorSize);

    // Fill with [0..vectorSize).
    iota(begin(result), end(result), 0);

    // Shuffle the elements.
    random_shuffle(begin(result), end(result));

    // Trim the list to the first sampleSize elements if the collection size is greater than the sample size.
    if (vectorSize > sampleSize)
    {
        result.resize(sampleSize);
    }

    return result;
}
oder

Code:
void ImageBrowserViewModel::StartMonthQuery(int queryId, cancellation_token token)
{
    m_runningMonthQuery = true;
    OnPropertyChanged("InProgress");
    m_photoCache->Clear();
    run_async_non_interactive([this, queryId, token]()
    {
        // if query is obsolete, don't run it.
        if (queryId != m_currentQueryId) return;

        m_repository->GetMonthGroupedPhotosWithCacheAsync(m_photoCache, token).then([this, queryId]
        (task<IVectorView<IPhotoGroup^>^> priorTask)
        {
            assert(IsMainThread());
            if (queryId != m_currentQueryId)
            {
                // Query is obsolete. Propagate exception and quit.
                priorTask.get();
                return;
            }

            m_runningMonthQuery = false;
            OnPropertyChanged("InProgress");
            if (!m_runningYearQuery)
            {
                FinishMonthAndYearQueries();
            }
            try
            {     
                // Update display with results.
                m_monthGroups->Clear();                  
                for (auto group : priorTask.get())
                { 
                    m_monthGroups->Append(group);
                }
                OnPropertyChanged("MonthGroups");
            }
            // On exception (including cancellation), remove any partially computed results and rethrow.
            catch (...)
            {
                m_monthGroups = ref new Vector<IPhotoGroup^>();
                throw;
            }
        }, task_continuation_context::use_current()).then(ObserveException<void>(m_exceptionPolicy));
    });
}
Das ist die Sprache, mit der Delphi in Zukunft, auch Mobilbereich, konkurriert. Erst recht, wenn der C++ Builder seinen neuen, auf CLang basierenden, Compiler hat. Nicht irgendwelches Zeug, von vor 20 Jahren.

Argumente wie "Delphi liegt mir einfach besser" oder "Das bin ich so gewohnt", sind doch gute Gründe für Delphi. Aber dieser Thread trägt den Titel "Argumentesammlung und Vergleich". Da muss man schon mit dem richtigen Vergleichen. Und das ist im nativen Bereich der Vergleich Delphi/FireMonkey/Free Pascal mit der ganzen C++11 / Qt / Boost usw. Welt. Ganz ohne Bezug auf MS, Delphi will ja auch Cross Plattform sein.

Geändert von Robotiker (24. Nov 2012 um 11:10 Uhr)
  Mit Zitat antworten Zitat