Is there any way for the language server to report differently for incomplete arguments instead of throwing an error?

So this is actually a problem for almost all language servers or editor tooling where I am still in the processing of writing a function call and it throws an error about incomplete arguments. I am using TypeScript right now so I thought to try and resolve this issue. I am using VS Code with the TypeScript 7 extension.

Errors with red squiggles are flashy and disturbing. And this problem masks on genuine errors such as I am trying to access a function that doesn't exist.

For incomplete function calls, I would like if the server could delay throwing the error until I leave that line in my editor. If that is not possible, then be notified in some other way or color than red or yellow squiggles.

Have others not cared about this problem?

reddit.com
u/noobdainsane — 4 days ago

Dynamic loading of controllers instead of static definitions in Express.

The usual way is to app.get("/", () => {}); to define an endpoint. I am not going to write the code at one place like a small application, I will define controllers which contain the handler functions to handle the endpoints. So If I create separate files for controllers, I would also have to register their endpoints in the router as shown above. Instead, I am thinking about creating a dynamic loader by which controllers themselves will say "Hey, I am a controller and I handle these endpoints (HTTP methods with URLs)". So this way adding a new endpoint is just creating a new controller and not needing to register it again in the router.

I also want to map the raw HTTP method strings and valid URLs in my project to a type (Object or Map keys) for type safety and being less error prone. Apparently AI tried to do something like -

const router = express.Router();

    const methods = {
        GET: router.get.bind(router)
    };

Because it is not exactly guaranteed that "GET" is equivalent to app[method.toLowerCase()]("/", () => {}); , so you bind the function itself. I think there are many ways to structure it, and AI tried to structure of the first question as parsing all .js files inside the controllers directory, and dynamically joining their functions as app.httpmethod(url, func);. Maybe there is a better way than this, such as through proper types or OOP? I can only use JavaScript right now, not TypeScript.

Do large projects also do something similar to this? I don't know because I feel like if this was common, there would have been already an easier abstraction in Express, unless I am missing that.

reddit.com
u/noobdainsane — 10 days ago
▲ 50 r/Backend

Should I use NGINX? Backend architecture discussion.

I am new to web development and working on a project for college. It's a cloud data storage solution. I spent some time writing a HTTP server in Node, then to realize NGINX exists as a web server. But you need your own logic to perform backend operations.

I can use NGINX as a proxy and reverse proxy. Requests come to NGINX, which forwards it to Node, it does some processing and tells NGINX which files to serve.

But NGINX mainly shines in serving static files directly. In my project, for almost all URLs I need to do some processing before choosing to serve a file. This means NGINX will always have to send requests to my Node backend and so NGINX's advantage of high performance doesn't really apply to me. This creates a bottleneck.

There is also HTTPS to worry about. If I use a proxy like NGINX, I can write my Node backend using HTTP while NGINX uses HTTPS to communicate with clients. Both NGINX and Node would be on the same physical server (I don't know how to feel about that). If not using a proxy, I would have to code with HTTPS.

I am not creating an industry scale and ready platform. Though I am aiming for it. Create such an architecture which is scalable.

I guess most people just use Express and do the web server. For the current project, I am actually aiming to not use Express because my dumb friends need to be able to understand it. Though Express makes it much easier, it adds some learning. Doing it in plain JavaScript also has the benefit of learning how things work at low level. I might create a second version of the project with using much more high level tools and frameworks.

So do I even need NGINX? I probably thought of using NGINX in the first place because I was writing my own web server in Node and realized NGINX can just do the URL routing and serve the pages. But this is probably not what I want directly. Serving the files, at least in a high level language like JavaScript and not worrying about decades of performance engineering, is very easy. I did create it. But I also want easier control over the backend. I guess people could create NGINX modules to move some of the backend in NGINX itself, but it is C and NGINX's architecture.

I absolutely do love C, but not something I will use right now for this project. I could create another version where I do the backend in C.

reddit.com
u/noobdainsane — 13 days ago
▲ 7 r/swaywm

Why does sending to scratchpad resize it to small?

I have set keybinds to send my web browser to the scratchpad and send SIGSTOP to pause it and to send SIGCONT and bring to current workspace. So I can have my browser loaded in memory instead of re-opening it.

Whenever it comes back from the scratchpad, why is it sized like a square? Resizing it, even automatically is an extra step. If it just makes it floating instead of tiling, then my floating size set for that application is bigger than what comes. How can I make it retain the size?

reddit.com
u/noobdainsane — 2 months ago

Something that can auto-insert the correct format specifier in C?

It's annoying when you change a variable to print and you have to fix that format specifier again. It becomes difficult to keep a track of the mapping of format specifiers to the parameters in large function calls and also you need to remember the many format specifiers.

What if there was a tool which could auto-update the format specifier when we change the variable type? Format specifier to data type are mostly logically 1:1 binding so there is always mostly one correct format specifier to use on any data type.

I use Clangd for tooling and it should really be added to do this, or does anything like this already exist?

Stuff like these is why I am not becoming the biggest fan of C even though I still like it. It grows so slowly. I want C++20 modules to be added to C. Wouldn't that heavily decrease compile time? We are still proud of adding something like the auto keyword in C23. That's so late.

reddit.com
u/noobdainsane — 3 months ago

A compilation of many quirks of C?

Every language has tons of "quirks". By quirks, I mean small or hidden unusual behavior or scenarios you don't normally think about. C has lots of such quirks. For example, I just discovered sizeof('a') returns 4 not 1. 'a' defaults to an int. There are so many such quirks I have found but I can't even recall them now. Struct padding, signed overflow UB but unsigned wrap works, string pooling, char array allocates on the stack but char pointer allocates the string in read only memory, and so many more.

I would like a compilation if exists, of all such quirks. This would actually help in MCQ tests.

I have seen that in interviews, they can as the output of - printf("%d", printf("hello"));. Now I know what printf() returns, but most students don't go their way learning this and most institutions don't teach this thoroughly. I don't think this can be classified as a quirk but good to take a look at.

reddit.com
u/noobdainsane — 3 months ago

Is there a well-designed template or config that handles compiler options?

Visual Studio handles compiler flags on its own. It provides a nice UI with lots of flags to tweak the compiler flags. If you are not using an IDE, most people just use some basic and only necessary compiler flags. Not everyone has the deep knowledge to remember and list out all the compiler flags.

Using a build system like CMake, I am looking for if there exists a well laid out config or template that handles lots of compiler flags (and supports different compiler toolchains and target platform) and is easy for me to configure. Something like this should exist.

reddit.com
u/noobdainsane — 3 months ago