Programming thread

  • Want to keep track of this thread?
    Accounts can bookmark posts, watch threads for updates, and jump back to where you stopped reading.
    Create account
im not using LISP
Still worth reading. There’s also the Art of Computer Programming (not free but still good). Crafting Interpreters is one I really like since being able to make your own programming language feels like a superpower. The first half tells you how to make a language in Java, the second half in C, I only did the second half. I thought it was enjoyable and I got exposed to all kinds of theory and interesting programming constructs.
 
The Pragmatic Programmer & The Mythical Man-Month are both very good reads. They are rooted in the "old" ways ('70s & '80s) of doing things so it will raise your expectations of the software engineering process if you take it to heart, reader beware.
 
I own a copy. It is a pretty good book. I read it after already having some programming experience so I don't know how well it will work for absolute beginners if that is your situation. But overall I would rate it positively for a book on C.
I remember TCPL carefully defining its examples and exercises so that error handling and common edge cases end up out of scope. Assuming that lines are never longer than 80 characters is sensible for a book that teaches C, but you probably don't want to teach this to beginners as if it was good practice, especially since most of the "danger" of C comes from the handling of such edge cases.
 
you can use winapi itself
you can use nuklear.h (kinda like imgui)
you can use microui (recommended)
you can use raygui (i dont really recommend it but its an option)

if you want a big boy library theres also gtk
You can get very far with plain winapi, describe how you want your GUI to look to Claude and it will generate very good C code implementing the GUI, alternatively you can use dialog windows, with dialog resources with what-you-see-is-what-you-get resource editors.

Forget binaries being several megabytes or larger, you can squeeze them below 100 KB and still have real useful programs, its good fun too!
 
asking your favorite LLM
describe how you want your GUI to look to Claude
heartattack.png
 
tbf llms should be good at winapi stuff due to it being ancient and having a lot of example code to read from
I am not taking the Null stance of "OPUS IS AMAZING, DO ALL THE THINGS FOR ME!" :lol: but they are unironically good at getting the fiddly GUI code correct, write everything else yourself, don't get sloppy.

Edit: blame microsoft for letting the LLMs train on 30+ years of winapi code. :lol:
 
I am not taking the Null stance of "OPUS IS AMAZING, DO ALL THE THINGS FOR ME!" :lol: but they are unironically good at getting the fiddly GUI code correct, write everything else yourself, don't get sloppy.

Edit: blame microsoft for letting the LLMs train on 30+ years of winapi code. :lol:
If only there was a gui library that didn’t suck incredible amounts of dick to write things by hand.
 
tbf llms should be good at winapi stuff due to it being ancient and having a lot of example code to read from
ive tried making some gui with gemini in pro mode (im a college student so i got it for free) as a test
1774381984750.png
thats my drawing
and this is the first thing it spat out
1774382022958.png (i use arch btw)
i wanted the slider to be between 5 and 10 but it went a bit too literal i guess
also interesting how it did "textbox" and "Text box" right after

also im attaching the code
The prompt was
make this gui in pure C99 and winapi, dont implement any logic, the text between stars should be italic if possible

C:
#define UNICODE
#define _UNICODE
#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <commctrl.h>

// Enable visual styles (modern UI look instead of Windows 98 look) for MSVC compilers
#if defined(_MSC_VER)
#pragma comment(linker,"\"/manifestdependency:type='win32' \
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#pragma comment(lib, "comctl32.lib")
#endif

// Global font handles
HFONT hFontRegular = NULL;
HFONT hFontItalic = NULL;

// Callback to apply the default font to all child controls easily
BOOL CALLBACK SetFontEnumProc(HWND hwnd, LPARAM lParam) {
    SendMessage(hwnd, WM_SETFONT, (WPARAM)lParam, TRUE);
    return TRUE;
}

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    switch (uMsg) {
        case WM_CREATE: {
            HINSTANCE hInstance = ((LPCREATESTRUCT)lParam)->hInstance;

            // Create fonts (Segoe UI is the standard modern Windows font)
            hFontRegular = CreateFontW(-15, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
                                       DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
                                       CLEARTYPE_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Segoe UI");
         
            hFontItalic = CreateFontW(-15, 0, 0, 0, FW_NORMAL, TRUE, FALSE, FALSE,
                                      DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
                                      CLEARTYPE_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Segoe UI");

            // --- LEFT COLUMN ---

            CreateWindowExW(0, L"STATIC", L"Some Text",
                WS_CHILD | WS_VISIBLE | SS_LEFT,
                20, 20, 200, 20, hwnd, NULL, hInstance, NULL);

            HWND hCheck = CreateWindowExW(0, L"BUTTON", L"is this GUI epic?",
                WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
                20, 50, 200, 20, hwnd, NULL, hInstance, NULL);
            SendMessage(hCheck, BM_SETCHECK, BST_CHECKED, 0); // Checked by default

            CreateWindowExW(0, L"STATIC", L"How much epic is it?",
                WS_CHILD | WS_VISIBLE | SS_LEFT,
                20, 85, 200, 20, hwnd, NULL, hInstance, NULL);

            HWND hRadio1 = CreateWindowExW(0, L"BUTTON", L"a little",
                WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON | WS_GROUP,
                20, 110, 200, 20, hwnd, NULL, hInstance, NULL);
            SendMessage(hRadio1, BM_SETCHECK, BST_CHECKED, 0); // Selected by default

            CreateWindowExW(0, L"BUTTON", L"very",
                WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
                20, 135, 200, 20, hwnd, NULL, hInstance, NULL);

            CreateWindowExW(0, L"BUTTON", L"a lot",
                WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
                20, 160, 200, 20, hwnd, NULL, hInstance, NULL);

            // Split label to support inline italics for *much*
            CreateWindowExW(0, L"STATIC", L"How",
                WS_CHILD | WS_VISIBLE | SS_LEFT,
                20, 200, 32, 20, hwnd, NULL, hInstance, NULL);
         
            HWND hItalicWord = CreateWindowExW(0, L"STATIC", L"much",
                WS_CHILD | WS_VISIBLE | SS_LEFT,
                52, 200, 40, 20, hwnd, NULL, hInstance, NULL);
         
            CreateWindowExW(0, L"STATIC", L"epic is it?",
                WS_CHILD | WS_VISIBLE | SS_LEFT,
                92, 200, 100, 20, hwnd, NULL, hInstance, NULL);

            CreateWindowExW(0, L"STATIC", L"Between\n5 and 10",
                WS_CHILD | WS_VISIBLE | SS_LEFT,
                20, 230, 60, 40, hwnd, NULL, hInstance, NULL);

            // Slider (Trackbar)
            HWND hSlider = CreateWindowExW(0, TRACKBAR_CLASSW, L"",
                WS_CHILD | WS_VISIBLE | TBS_HORZ | WS_TABSTOP,
                80, 235, 200, 30, hwnd, NULL, hInstance, NULL);
            // Values mapped as integers (50 to 100 represents 5.0 to 10.0)
            SendMessage(hSlider, TBM_SETRANGE, TRUE, MAKELONG(50, 100));
            SendMessage(hSlider, TBM_SETPOS, TRUE, 67);

            CreateWindowExW(0, L"STATIC", L"6.7",
                WS_CHILD | WS_VISIBLE | SS_LEFT,
                290, 235, 30, 20, hwnd, NULL, hInstance, NULL);

            CreateWindowExW(0, L"BUTTON", L"calculate epicness",
                WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP,
                150, 350, 150, 35, hwnd, NULL, hInstance, NULL);

            // --- RIGHT COLUMN ---

            CreateWindowExW(0, L"STATIC", L"Little textbox",
                WS_CHILD | WS_VISIBLE | SS_LEFT,
                400, 20, 200, 20, hwnd, NULL, hInstance, NULL);

            CreateWindowExW(WS_EX_CLIENTEDGE, L"EDIT", L"Foo",
                WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | WS_TABSTOP,
                400, 45, 200, 25, hwnd, NULL, hInstance, NULL);

            CreateWindowExW(0, L"STATIC", L"BIG Text box",
                WS_CHILD | WS_VISIBLE | SS_LEFT,
                400, 85, 200, 20, hwnd, NULL, hInstance, NULL);

            CreateWindowExW(WS_EX_CLIENTEDGE, L"EDIT", L"",
                WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL | ES_WANTRETURN | WS_TABSTOP,
                400, 110, 350, 275, hwnd, NULL, hInstance, NULL);

            // Apply regular font to ALL controls
            EnumChildWindows(hwnd, SetFontEnumProc, (LPARAM)hFontRegular);
         
            // Override the one word with the italic font
            SendMessage(hItalicWord, WM_SETFONT, (WPARAM)hFontItalic, TRUE);
         
            return 0;
        }

        // Make static controls have transparent backgrounds to blend with window perfectly
        case WM_CTLCOLORSTATIC: {
            HDC hdcStatic = (HDC)wParam;
            SetBkMode(hdcStatic, TRANSPARENT);
            return (LRESULT)GetSysColorBrush(COLOR_BTNFACE);
        }

        case WM_DESTROY: {
            if (hFontRegular) DeleteObject(hFontRegular);
            if (hFontItalic) DeleteObject(hFontItalic);
            PostQuitMessage(0);
            return 0;
        }
    }
    return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
    // Required to use the Trackbar (Slider) class
    INITCOMMONCONTROLSEX icex;
    icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
    icex.dwICC = ICC_WIN95_CLASSES | ICC_BAR_CLASSES;
    InitCommonControlsEx(&icex);

    const wchar_t CLASS_NAME[] = L"EpicGuiClass";

    WNDCLASSW wc = { 0 };
    wc.lpfnWndProc   = WindowProc;
    wc.hInstance     = hInstance;
    wc.lpszClassName = CLASS_NAME;
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); // Standard gray window background

    RegisterClassW(&wc);

    HWND hwnd = CreateWindowExW(
        0,
        CLASS_NAME,
        L"My epic GUI",
        WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
        CW_USEDEFAULT, CW_USEDEFAULT, 800, 450,
        NULL, NULL, hInstance, NULL
    );

    if (hwnd == NULL) {
        return 0;
    }

    ShowWindow(hwnd, nCmdShow);

    MSG msg = { 0 };
    while (GetMessage(&msg, NULL, 0, 0)) {
        // IsDialogMessage allows using TAB to switch between textboxes/buttons
        if (!IsDialogMessage(hwnd, &msg)) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return (int)msg.wParam;
}

so i think if you dont care that much about how the gui itself is implemented you can delegate it to an llm and treat it like an npm package ("i dont know how it works nor do i care")
which is niggerlicious but it is what it is
 
Last edited:
I'm almost two years late to the news, but better late than never since there was no mention of it here. Jason Knight, the guy who ran cutcodedown.com, died (A) in the summer of 2024. I tried going to his website today and found the domain parked. If you've been around 8/tech/, you've probably seen people link his site. He was a web developer that hated modern webshit, including HTML5. He also developed his own library, elementalsjs, that does polyfills and DOM helpers at 9KB gzipped and minified. Fairly rare to see software near anything Web that has a final, complete release. That website is also now dead and only available through archives. Now for some choice quotes.

From ARIA Roles - Why do these exist?
I ended up reading everything MDN had on the subject, since as always the actual specification from the W3C is written in the same gibberish legalese they always use; reeking of being created in Finnish, translated to Japanese by a Russian, then Google translated to an "Engrish moist goodry" so bad I can almost hear a Vietnamese hooker saying "Me love you long time" as I try to work my way through it...

From What's wrong with YOUR website - Part 4, CSS
Zero improvement or change, to the point if you are going to write HTML and CSS that way, you might as well just go back to writing HTML 3.2 like it's 1997. Of course, that's actually what most people are STILL doing, hence the reason so many developers never pulled their heads out of 1997's arse and deployed as "transitional" -- now instead of slapping a tranny doctype on it they slap HTML 5's lip-service on there, while still practicing decade or more out of date building practices.

He was even early to the goyslop trend, in The /FAIL/ Of Tailwind, The Go-To For The Ignorant
Which is why if you put ten of them on a page, his entire page would be 16k, where my approach wouldn’t even break 7k. But tell me again how much more efficient, or easy to work with, or better halfwitted chazerei like failwind is.

Rest in peace, based HTML4 Strict man.
 
im not using LISP
do try lisp once, its a different programming paradigm to C which forces you to think differently, making you a better problem solver in the process
I've somehow never had any interaction with lisp. Why is it good/bad?
The Pragmatic Programmer & The Mythical Man-Month are both very good reads
These are good, but I would only read them if you are working in a team and/or in a company. Not very useful for solo developers.
Crafting Interpreters is one I really like since being able to make your own programming language feels like a superpower
But then you get an interpreted faggot language. Why would you want to create such niggertrash? Just read this:
1774793079021.jpeg

Actually, on the topic of this book, and other old programming (and mathematics) books, why are all of them so jewishly expensive? It surely can't cost that much to print it?
 
Back
Top Bottom