Yes, PHP is faster than C#

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • .NET Runtime

    .NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.

  • This is addressed in the article:

    > “But Rob,” I hear you say, “they’re not reading it byte-by-byte in the PHP version!” and I’d reply with, “but we’re not reading it byte-by-byte in the C# version either!”

    Links to https://github.com/dotnet/runtime/blob/1ba0394d71a4ea6bee7f6...

  • C-Sharp

    All algorithms implemented in C#.

  • The previous post on this blog makes another worthless comparison, this time based on lines of code:

    https://withinboredom.info/blog/2022/03/16/my-favorite-langu...

    > Like, look at this Merge Sort in C# [1] (130 lines) and then look at it in PHP (31 lines) [2]. You can’t beat that kind of productivity, not to mention in PHP, you can even mix data types (like ints and floats) where in the C# version, it’d be much more difficult.

    [1] https://github.com/TheAlgorithms/C-Sharp/blob/master/Algorit...

    [2] https://www.w3resource.com/php-exercises/searching-and-sorti...

    The C# version is the first Google result for "c# merge sort". But a later result is from w3resource.com, which where the PHP code came from. That C# code is only 55 lines and could easily be shorter by replacing loops with standard library calls:

    https://www.w3resource.com/csharp-exercises/searching-and-so...

    Also, both versions of the code from w3resources.com are trash -- they use an O(N) step to remove an element from the front of the array (array_slice in PHP and List.Remove in C#), which makes them O(N^2 log N), which is even worse than a naive selection sort or bubble sort.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • PHPT

    The PHP Interpreter

  • Here's the latest optimization to that func: https://github.com/php/php-src/commit/085b360abb622abc18b955...

    In the latest addendum on the blog post, I ended up removing the counting of 1s.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts