{"id":16737318,"url":"https://github.com/dogweather/language-comparison","last_synced_at":"2025-11-11T19:27:15.219Z","repository":{"id":37295419,"uuid":"490017539","full_name":"dogweather/language-comparison","owner":"dogweather","description":"A GraphQL server prototyped in many languages","archived":false,"fork":false,"pushed_at":"2024-04-25T06:25:31.000Z","size":449,"stargazers_count":6,"open_issues_count":6,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-03T01:40:34.762Z","etag":null,"topics":["crystal","elixir","graphql-server","ocaml","python","rust","typescript"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dogweather.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-05-08T17:58:15.000Z","updated_at":"2025-01-02T12:48:44.000Z","dependencies_parsed_at":"2024-04-25T07:43:18.370Z","dependency_job_id":null,"html_url":"https://github.com/dogweather/language-comparison","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogweather%2Flanguage-comparison","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogweather%2Flanguage-comparison/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogweather%2Flanguage-comparison/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dogweather%2Flanguage-comparison/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dogweather","download_url":"https://codeload.github.com/dogweather/language-comparison/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233418665,"owners_count":18673474,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crystal","elixir","graphql-server","ocaml","python","rust","typescript"],"created_at":"2024-10-13T00:25:51.725Z","updated_at":"2025-09-17T19:30:59.693Z","avatar_url":"https://github.com/dogweather.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Logic Server: My own [TodoMVC](https://todomvc.com) of server-side code\n\nComparing languages by re-implementing some typical functions.\n\n- [x] Text Service functions\n- [ ] GraphQL server\n\n\n**Code Samples**\n\nHere are samples of each language. Or browse the folders to also compare the tests and config files.\n\n* [Crystal](#Crystal)\n* [Elixir](#Elixir)\n* [Python](#Python)\n* [Rust](#Rust)\n* [Swift](#Swift)\n\n\n## Crystal\n\n```Crystal\n# Plaintext and HTML manipulation.\nmodule TextService\n  extend self\n\n  #\n  # Return a new string enhanced with typographic characters:\n  #  Single quotes: ’\n  #  Double quotes: “”\n  #\n  def add_typography(text : String) : String\n    text.gsub(/\"([^\"]+)\"/, \"“\\\\1”\")\n        .gsub('\\'', '’')\n  end\n\n\n  #\n  # Add nicer typography that HTML can provide:\n  #  Fractions using superscript and subscript.\n  #\n  def add_html_typography(text : String) : String\n    text.gsub(%r{\\b(\\d+)/(\\d+)\\b}, \"\u003csup\u003e\\\\1\u003c/sup\u003e\u0026frasl;\u003csub\u003e\\\\2\u003c/sub\u003e\")\n  end\nend\n```\n\n## Elixir\n\n```elixir\nimport String\n\n\ndefmodule TextService do\n  @moduledoc \"\"\"\n  Plaintext and HTML manipulation.\n  \"\"\"\n\n  @doc \"\"\"\n  Return a new string enhanced with typographic characters:\n    Single quotes: ’\n    Double quotes: “”\n  \"\"\"\n  @spec add_typography(binary) :: binary\n  def add_typography(text) do\n    text\n    |\u003e replace(~r/\\\"([^\\\"]+)\\\"/, \"“\\\\1”\")\n    |\u003e replace(~r/'/, \"’\")\n  end\n\n\n  @doc \"\"\"\n  Add nicer typography that HTML can provide:\n    Fractions using superscript and subscript.\n  \"\"\"\n  @spec add_html_typography(binary) :: binary\n  def add_html_typography(text) do\n    text\n    |\u003e replace(~r/\\b(\\d+)\\/(\\d+)\\b/, \"\u003csup\u003e\\\\1\u003c/sup\u003e\u0026frasl;\u003csub\u003e\\\\2\u003c/sub\u003e\")\n  end\nend\n```\n\n## Python\n\n```python\n\"\"\"Plaintext and HTML manipulation.\"\"\"\n\nimport re\n\nDOUBLE_QUOTED_TEXT = re.compile(r'\"([^\"]+)\"')       # \"Hello\"\nFRACTION           = re.compile(r'\\b(\\d+)/(\\d+)\\b') # 1/2\n\n\ndef add_typography(text: str) -\u003e str:\n    \"\"\" Return a new string enhanced with typographic characters:\n          Single quotes: ’\n          Double quotes: “”\n    \"\"\"\n    return DOUBLE_QUOTED_TEXT.sub(r'“\\1”', text).replace(\"'\", \"’\")\n\n\ndef add_html_typography(text: str) -\u003e str:\n    \"\"\" Add nicer typography that HTML can provide:\n          Fractions using superscript and subscript.\n    \"\"\"\n    return FRACTION.sub(r'\u003csup\u003e\\1\u003c/sup\u003e\u0026frasl;\u003csub\u003e\\2\u003c/sub\u003e', text)\n```\n\n## Rust\n\n```rust\n/// Plaintext and HTML manipulation.\n\nuse lazy_static::lazy_static;\nuse regex::Regex;\nuse std::borrow::Cow;\n\nlazy_static! {\n    static ref DOUBLE_QUOTED_TEXT: Regex = Regex::new(r#\"\"(?P\u003ccontent\u003e[^\"]+)\"\"#).unwrap();\n    static ref FRACTION:           Regex = Regex::new(r\"\\b(\\d+)/(\\d+)\\b\").unwrap();\n}\n\n/// Return a new string enhanced with typographic characters:\n///     Single quotes: ’\n///     Double quotes: “”\nfn add_typography(text: \u0026str) -\u003e String {\n    DOUBLE_QUOTED_TEXT\n        .replace_all(text, \"“$content”\")\n        .replace(\"'\", \"’\")\n}\n\n/// Add nicer typography that HTML can provide:\n///     Fractions using superscript and subscript.\n///\nfn add_html_typography(text: \u0026str) -\u003e Cow\u003cstr\u003e {\n    FRACTION.replace_all(text, r\"\u003csup\u003e$1\u003c/sup\u003e\u0026frasl;\u003csub\u003e$2\u003c/sub\u003e\")\n}\n```\n\n## Swift\n\n```swift\nimport Foundation\n\nextension String {\n    /// Provide a higher-level API for regexes.\n    func gsub(_ regex: NSRegularExpression, _ replacement: String) -\u003e String {\n        return regex.stringByReplacingMatches(\n            in: self,\n            range: NSRange(location: 0, length: self.utf16.count),\n            withTemplate: replacement\n        )\n    }\n}\n\n\nlet SINGLE_QUOTE =  try! NSRegularExpression(pattern: \"'\")\nlet DOUBLE_QUOTES = try! NSRegularExpression(pattern: #\"\"([^\"]+)\"\"#)\nlet FRACTION =      try! NSRegularExpression(pattern: #\"\\b(\\d+)/(\\d+)\\b\"#)\n\n\n/// Return a new String enhanced with typographic characters:\n///   Single quotes: ’\n///   Double quotes: “ ”\nfunc addTypography(text: String) -\u003e String {\n    return text\n        .gsub(SINGLE_QUOTE,  \"’\")\n        .gsub(DOUBLE_QUOTES, \"“$1”\")\n}\n\n\n/// Add nicer typography that HTML can provide:\n///   Fractions using superscript and subscript.\nfunc addHtmlTypography(text: String) -\u003e String {\n    return text.gsub(FRACTION, #\"\u003csup\u003e\\1\u003c/sup\u003e\u0026frasl;\u003csub\u003e\\2\u003c/sub\u003e\"#)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdogweather%2Flanguage-comparison","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdogweather%2Flanguage-comparison","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdogweather%2Flanguage-comparison/lists"}