{"id":19789534,"url":"https://github.com/webfreak001/wc_in_dlang","last_synced_at":"2026-03-05T13:05:08.439Z","repository":{"id":146628700,"uuid":"216555989","full_name":"WebFreak001/wc_in_dlang","owner":"WebFreak001","description":"A wc written in dlang","archived":false,"fork":false,"pushed_at":"2019-10-21T11:56:27.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T14:48:04.636Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WebFreak001.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2019-10-21T11:53:55.000Z","updated_at":"2020-01-29T08:44:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"b2a52990-64db-42cf-a601-574df5bd1b20","html_url":"https://github.com/WebFreak001/wc_in_dlang","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/WebFreak001/wc_in_dlang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFreak001%2Fwc_in_dlang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFreak001%2Fwc_in_dlang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFreak001%2Fwc_in_dlang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFreak001%2Fwc_in_dlang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebFreak001","download_url":"https://codeload.github.com/WebFreak001/wc_in_dlang/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFreak001%2Fwc_in_dlang/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30127260,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T12:40:50.676Z","status":"ssl_error","status_checked_at":"2026-03-05T12:39:32.209Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-12T06:33:52.020Z","updated_at":"2026-03-05T13:05:08.421Z","avatar_url":"https://github.com/WebFreak001.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# wc in less than 1000 characters without a single if statement in D\n\n## The Introduction\nAfter reading \"Beating C With 80 Lines Of Haskell: Wc\"\nhttps://chrispenner.ca/posts/wc found on hackernews.\nI thought D could do better.\n\n## The Program\nSo I wrote a wc in D.\nI consists of one file, has 46 lines and 906 characters.\nSure, it is using D's awesome standard library phobos.\nBut then why wouldn't it, its awesome and it comes with every D compiler.\nThe program itself does not contain a single if statement.\nTalking about imperative programming languages;\nthe Haskell wc implementation has several if statements.\nThe D program, apart from the main function, contains three tiny functions.\nI could have easily put all the functionally in one range chain,\nbut then it properly would have exceed 80 chars per line.\nAnd that's a major code-smell.\n\nThe Performance:\nIs the D wc faster than the coreutils wc?\nNo, but it took my 15 minutes to write mine (I had to search for walkLength,\nbecause I forgot its name).\n\nfile      | lines | bytes | coreutils         | haskell             | D                   |\n----------|-------|-------|-------------------|---------------------|---------------------|\napp.d     | 46    | 906   | 3.5 ms +- 1.9 ms  | 39.6 ms +- 7.8 ms   | 8.8 ms +- 2.0 ms    |\nbig.txt   | 862   | 64k   | 4.7 ms +- 2.0 ms  | 39.6 ms +- 7.8 ms   | 9.3 ms +- 1.9 ms    |\nvbig.txt  | 1.7M  | 96M   | 658.6ms +- 24.5ms | 226.4 ms +- 29.5 ms | 716.2 ms +- 30.8 ms |\nvbig2.txt | 12.1M | 671M  | 4.4 s +- 0.058 s  | 1.1 s +- 0.039 s    | 4.8 s +- 0.051 s    |\n\nmemory:\n\nfile      | coreutils | haskell | D     |\n----------|-----------|---------|-------|\napp.d     | 2052K     | 7228K   | 7588K |\nbig.txt   | 2112K     | 7512K   | 7556K |\nvbig.txt  | 2288K     | 42620K  | 7772K |\nvbig2.txt | 2360K     | 50860K  | 7692K |\n\nIs the Haskell wc faster?\nFor big files, absolutely, but then it is using threads.\nFor small files, gnu's coreutils still beats the competition.\nFor very big files the difference between the coreutils and the D program is\nreduced quite a bit to ~10%.\nAt this stage its is very likely IO bound, and its fast enough anyway.\n\n## The conclusion\nI'll not claim that one language is faster than another.\nIf you spend crazy time on a micro-benchmark and optimizing you are going to\nbeat the competition.\nThat's not real life, who cares?\n\n__But I'll claim, that functional programming in D gives functional programming\nin Haskell a run for its money.__\n\n\n### About Kaleidic Associates\nWe are a boutique consultancy that advises a small number of hedge fund clients.\nWe are not accepting new clients currently, but if you are interested in working\neither remotely or locally in London or Hong Kong, and if you are a talented\nhacker with a moral compass who aspires to excellence then feel free to drop me\na line: laeeth at kaleidic.io\n\nWe work with our partner Symmetry Investments, and some background on the firm\ncan be found here:\n\nhttp://symmetryinvestments.com/about-us/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebfreak001%2Fwc_in_dlang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebfreak001%2Fwc_in_dlang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebfreak001%2Fwc_in_dlang/lists"}