1. Лучший говнокод

    В номинации:
    За время:
  2. Куча / Говнокод #27620

    +1

    1. 1
    Питушня #19

    #1: https://govnokod.ru/26692 https://govnokod.xyz/_26692
    #2: https://govnokod.ru/26891 https://govnokod.xyz/_26891
    #3: https://govnokod.ru/26893 https://govnokod.xyz/_26893
    #4: https://govnokod.ru/26935 https://govnokod.xyz/_26935
    #5: (vanished) https://govnokod.xyz/_26954
    #6: (vanished) https://govnokod.xyz/_26956
    #7: https://govnokod.ru/26964 https://govnokod.xyz/_26964
    #8: https://govnokod.ru/26966 https://govnokod.xyz/_26966
    #9: https://govnokod.ru/27017 https://govnokod.xyz/_27017
    #10: https://govnokod.ru/27045 https://govnokod.xyz/_27045
    #11: https://govnokod.ru/27058 https://govnokod.xyz/_27058
    #12: https://govnokod.ru/27182 https://govnokod.xyz/_27182
    #13: https://govnokod.ru/27260 https://govnokod.xyz/_27260
    #14: https://govnokod.ru/27343 https://govnokod.xyz/_27343
    #15: https://govnokod.ru/27353 https://govnokod.xyz/_27353
    #16: https://govnokod.ru/27384 https://govnokod.xyz/_27384
    #17: https://govnokod.ru/27482 https://govnokod.xyz/_27482
    #18: https://govnokod.ru/27514 https://govnokod.xyz/_27514

    nepeKamHblu_nemyx, 27 Августа 2021

    Комментарии (637)
  3. JavaScript / Говнокод #27615

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    function *foo()
    {
       yield 1;
       yield 2;
       yield 3;
    }
    
    function main()
    {
        for (const o of foo())
        {
    	console.log (o);
        }
    
    }
    
    main();

    давайте посмотрим, как TS/JS имплементирует "елды". изначально код выглядит красиво. но заглянем под капот что генерит tsc для выполнение такого кода. мне придется разбить этот ужос

    ASD_77, 24 Августа 2021

    Комментарии (671)
  4. C++ / Говнокод #27614

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    struct file_id
    {
        uint64_t        persistent;
        uint64_t        volatile_;
    
        static const size_t RAW_LENGTH  = 16;
        operator std::string() const
        { return std::string(reinterpret_cast<const char*>(&persistent), RAW_LENGTH); }
    
        // Операторы для использования file_id в качестве ключа map и 
        // unordered_map
        struct hash
        {
            std::size_t operator()(const ntdec_smb2_file_id& file_id) const
            {
                std::string s_file_id = file_id;
                std::hash<std::string> hasher;
                return hasher(s_file_id);
            }
        };
    
        bool operator == (const ntdec_smb2_file_id& other)
        {
            return std::string(*this) == std::string(other);
        }
    
        bool operator < (const ntdec_smb2_file_id& other)
        {
            return std::string(*this) < std::string(other);
        }
    
        bool operator > (const ntdec_smb2_file_id& other)
        {
            return std::string(*this) > std::string(other);
        }
    };

    operator std::string тоже UB?

    YpaHeLI_, 24 Августа 2021

    Комментарии (11)
  5. JavaScript / Говнокод #27606

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    type a = 1;
    type i = a & a;
    type j = a | a;
    
    function main() {
        let v1: i;
        let v2: j;
        assert(sizeof(i) != sizeof(j));
        print("done.");
    }

    ну все я понял вам скучно... как насчет такого примера?

    ASD_77, 23 Августа 2021

    Комментарии (616)
  6. Куча / Говнокод #27601

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    fn main() {
        println!("Hello World!");
    }
    
    rustc --version --verbose:
    
    rustc 1.52.1 (9bc8c42bb 2021-05-09)
    binary: rustc
    commit-hash: 9bc8c42bb2f19e745a63f3445f1ac248fb015e53
    commit-date: 2021-05-09
    host: powerpc-unknown-linux-gnu
    release: 1.52.1
    LLVM version: 12.0.0
    
    Error output
    
    rustc ./hello.rs
    Illegal instruction (core dumped)

    https://github.com/rust-lang/rust/issues/85238

    Open: clienthax opened this issue on May 12 · 6 comments

    3.14159265, 22 Августа 2021

    Комментарии (26)
  7. Куча / Говнокод #27570

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    C	5.2s 	gcc test.c
    C++	1m 25s 	g++ test.cpp
    Zig	10.1s 	zig build-exe test.zig
    Nim	45s 	nim c test.nim
    Rust	Stopped after 30 minutes	rustc test.rs
    Swift	Stopped after 30 minutes 	swiftc test.swift
    D	Segfault after 6 minutes 	dmd test.d
    
    Rust and Swift took too long to compile 400k lines, so I tried smaller numbers: 
    
    # lines	Rust	Swift 	D
    2k	3.4s 	0.8s
    4k	9.0s 	1.0s
    8k	30.8s 	2.3s
    20k	3m 52s 	11.8s 	4.7s
    100k	- 	5m 57s 	segfault

    https://vlang.io/compilation_speed

    3.14159265, 15 Августа 2021

    Комментарии (40)
  8. C++ / Говнокод #27561

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    QSqlQuery& SQLConnect::get()
    {
        if ( makeConnection() ) {
            query = QSqlQuery(mDb);
            return query;
        }
        QSqlQuery empty;
        return empty;
    }
    
    bool SQLConnect::makeConnection()
    {
       mDb = SQLConnectPool::Instance().get();
       return true;
    }

    Раньше компилилось и не замечал, а тут на новом компиляторе начал кидать ошибки и решил посмотреть, что же там напроектировали

    avk17, 14 Августа 2021

    Комментарии (12)
  9. JavaScript / Говнокод #27556

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    function foo(arg: any) {
        if (typeof arg === "string") {
            // We know this is a string now.
            print(<string>arg);
        }
    }
    
    function main() {
        foo("Hello");
        foo(1);    
    
        print("done.");
    }

    я вам новый говнокодец притарабанил.... вот будете как настоящие жабаскриптеры в нативе

    ASD_77, 11 Августа 2021

    Комментарии (162)
  10. Куча / Говнокод #27551

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    10 лет назад читала самоучитель по Паскалю, где были задания: "написать алгоритм для нахождения простых чисел до n", 
    "написать 2D-пушку (на CRT модуле)". 
    Сейчас хочется найти его, вспомнить свое детство (задолго до того, как пошла формошлепить хех). 
    Ничего похожего пока не нашла.

    JaneBurt, 06 Августа 2021

    Комментарии (579)
  11. JavaScript / Говнокод #27550

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function main() {
        let user = {
            firstName: "John",
            sayHi() {
                print(`Hello, ${this.firstName}!`);
            },
        };
    
        user.sayHi();
    
        print("done.");
    }

    как тебе такое Илон Маск?

    ASD_77, 06 Августа 2021

    Комментарии (110)