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

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

    +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
    https://benchmarksgame-team.pages.debian.net/benchmarksgame/performance/pidigits.html
    
    1.0 	C gcc #6	0.59 	2,444 	1090 	2.37 	100% 100% 100% 98%
    1.1 	C++ g++ #6	0.66 	5,152 	986 	2.63 	100% 100% 100% 100%
    1.2 	Rust #4	 	0.71 	2,672 	799 	0.73 	3% 0% 0% 100% 
    1.2 	Free Pascal #3	0.73 	2,268 	530 	0.73 	0% 0% 100% 0%
    1.4 	F# .NET #6	0.82 	34,428 	905 	0.83 	1% 2% 96% 1%
    1.4 	Haskell GHC #5	0.83 	6,056 	928 	0.84 	0% 99% 1% 1%
    1.5 	Ada 2012 GNAT   0.88 	4,704 	1130 	0.89 	0% 0% 100% 1%
    1.5 	Rust #2	 	0.88 	2,800 	1306 	0.89 	0% 1% 100% 0%
    1.5 	C++ g++ #4	0.89 	4,280 	513 	0.92 	0% 2% 1% 100%
    1.5 	OCaml #7	0.89 	5,968 	593 	0.90 	0% 0% 1% 100%
    1.5 	Swift #2	0.89 	9,256 	600 	0.91 	3% 0% 0% 99%
    1.5 	PHP #5	  	0.91 	13,196 	399 	0.96 	2% 0% 3% 100%
    1.5 	C# .NET #5	0.92 	35,404 	977 	0.96 	98% 3% 2% 1%
    1.6 	Java  #3	0.93 	36,552 	764 	0.98 	2% 3% 1% 99%

    However, Java is one of the fastest and most energy-efficient object-oriented language. Interpreted languages like Perl, Python, and Ruby were among the least energy efficient

    Using the Computer Benchmarks Game, the team of researchers tested these languages by compiling/executing such programs using the state-of-the-art compilers, virtual machines, interpreters, and libraries.

    They then analyzed the performance of the different implementation considering three variables: execution time, memory consumption and energy consumption.

    https://jaxenter.com/energy-efficient-programming-languages-137264.html

    https://jaxenter.com/wp-content/uploads/2017/09/energy-efficient-languages-768x689.png

    https://jaxenter.com/wp-content/uploads/2017/09/energy-efficient-languages-2-768x368.png

    3.14159265, 31 Августа 2021

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function display(id:number, name:string)
    {
        print("Id = " + id + ", Name = " + name);
    }
    
    function main() {                                                 
    	display(1, "asd");
    }

    А ваш говно компайлер умеет так делать?

    >> Output:
    Id = 1., Name = asd

    ASD_77, 07 Мая 2021

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

    −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
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    // https://github.com/dotnet/coreclr/blob/a9f3fc16483eecfc47fb79c362811d870be02249/src/vm/i386/cgenx86.cpp#L1613
    
    PCODE DynamicHelpers::CreateHelperWithTwoArgs(LoaderAllocator * pAllocator, TADDR arg, TADDR arg2, PCODE target)
    {
    #ifdef UNIX_X86_ABI
        BEGIN_DYNAMIC_HELPER_EMIT(23);
    #else
        BEGIN_DYNAMIC_HELPER_EMIT(17);
    #endif
    
    #ifdef UNIX_X86_ABI
    	// sub esp, 4
    	*p++ = 0x83;
    	*p++ = 0xec;
    	*p++ = 0x4;
    #else
        // pop eax
        *p++ = 0x58;
    #endif
    
        // push arg
        *p++ = 0x68;
        *(INT32 *)p = arg;
        p += 4;
    
        // push arg2
        *p++ = 0x68;
        *(INT32 *)p = arg2;
        p += 4;
    
    #ifdef UNIX_X86_ABI
        // mov eax, target
        *p++ = 0xB8;
        *(INT32 *)p = target;
        p += 4;
    #else
        // push eax
        *p++ = 0x50;
    #endif
    
        *p++ = X86_INSTR_JMP_REL32; // jmp rel32
    #ifdef UNIX_X86_ABI
        *(INT32 *)p = rel32UsingJumpStub((INT32 *)p, (PCODE)DynamicHelperArgsStub);
    #else
        *(INT32 *)p = rel32UsingJumpStub((INT32 *)p, target);
    #endif
        p += 4;
    
        END_DYNAMIC_HELPER_EMIT();
    }

    Функция из дотнеткора, которая нахерачивает опкодов куда-то.

    j123123, 28 Октября 2020

    Комментарии (43)
  5. 1C / Говнокод #26813

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    ГрИнвС = ?(ГрИнвЧ=1, "Первая", ?(ГрИнвЧ=2, "Вторая", ?(ГрИнвЧ=3, "Третья", 
             ?(ГрИнвЧ=4, "Четвертая", ?(ГрИнвЧ=5, "Пятая", ?(ГрИнвЧ=6, "Шестая",
    	 ?(ГрИнвЧ=7, "Седьмая", ?(ГрИнвЧ=8, "Восьмая", ?(ГрИнвЧ=9, "Девятая", 
    	   Строка(ГрИнвЧ))))))))));

    Определение группы инвалидности из числового значения. Возможно, код писал обладатель неизвестной медицине 9-й группы инвалидности.

    maalssy, 23 Июля 2020

    Комментарии (43)
  6. Python / Говнокод #26751

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    import traceback
    
    a = (1,2,[3,4])
    try:
        a[2] += [4,5]
    except:
        traceback.print_exc()
    print(a)

    Traceback (most recent call last):
    File "prog.py", line 5, in <module>
    a[2] += [4,5]
    TypeError: 'tuple' object does not support item assignment

    (1, 2, [3, 4, 4, 5])


    Какой бароп )))

    https://m.habr.com/ru/company/domclick/blog/506138/

    3_dar, 13 Июня 2020

    Комментарии (43)
  7. C++ / Говнокод #26598

    +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
    char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size )
    {
    	char *dst = dst_buffer;
    	for ( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- )
    	{
    		if ( *src == '#' )
    		{
    			// cut msg name out of string
    			static char word_buf[255];
    			char *wdst = word_buf, *word_start = src;
    			for ( ++src ; *src >= 'A' && *src <= 'z'; wdst++, src++ )
    			{
    				*wdst = *src;
    			}
    			*wdst = 0;

    Тут недавно слили исходники «Team Fortress 2» и «Counter Strike: Global Offense» — и в соответствующих местах начался вой игроков: кошмар, мы все умрём, нас всех взломают!

    gost, 23 Апреля 2020

    Комментарии (43)
  8. Куча / Говнокод #26447

    +2

    1. 1
    2. 2
    3. 3
    «Ростелеком», а с ним и кучка проводных операторов поменьше,
    внаглую редиректит *.js запросы на скрипты рекламной говноконторки,
    принадлежащей сыну министра МВД.

    https://habr.com/ru/post/489528/

    gost, 24 Февраля 2020

    Комментарии (43)
  9. Perl / Говнокод #26003

    +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
    #!/usr/bin/perl
    
    # Fetch all JS from govno
    use strict;
    use warnings FATAL => 'all';
    use LWP;
    
    my $res = LWP::UserAgent->new->request(HTTP::Request->new("GET" => "http://govnokod.xyz/"));
    die "Failed: " . $res->code unless $res->is_success;
    
    for (split /\n/, $res->content) {
        print if /<script/ ... /script>/ and !m/[<>]/;
    }

    кууик.

    Официальный тред для ржания над пятым перлом

    MAKAKA, 29 Октября 2019

    Комментарии (43)
  10. JavaScript / Говнокод #25988

    0

    1. 1
    2. 2
    var q = jQuery('#expand-trigger').text().replace('Привет, ', '').replace('!', '');
    console.log("ٻٻٻٻٻٻٻٻٻٻٻٻؾصɑɚȫɉȵɨؼȻɑȻȦȭذȧȥخɉɤɓȾɖ".split("").map((c, i) => String.fromCharCode(c.charCodeAt() ^ q.charCodeAt(i % q.length) ^ 1659)).join(""));

    3_dar, 23 Октября 2019

    Комментарии (43)
  11. C++ / Говнокод #25924

    +4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    // File.cpp
    QString File::size() const
    {
        return QString::number(QFileInfo(m_path).size());
    }
    
    // ... somewhere in the code...
    
    File* message = ...
    ...
    if (message->size() == "0")
            return;

    Commit b1aef142 "Refactoring"
    Р - Рефакторинг

    salamon_style, 10 Октября 2019

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