Better HN
topnewbestaskshowjobs
Log inSign up

shortrounddev2

2,427 karma · joined Jun 15, 2023 (3y ago) · 1,641 submissions

Submissions

comment 3y ago · link · parent

> You appear to think that there is One Way to write applications and that anyone who disagrees with you doesn't know what they are talking about or has never had any experience with them.

You are wrong in your perception

comment 3y ago · link · parent

> For one it means you can never hire people who have newly graduated.

Not necessarily. I wouldn't hire a new grad without an internship or without even some personal project experience. If I were to hire someone out of college, I would expect them to have made a website at some point before and to be able to explain to me how it works. I would also expect them to be able to make the same website in different frameworks if asked to change their tech stack.

> I can understand that you are defensive if you have spent years making this investment and someone suggests you have made a poor choice. But I think it would be time well spent to try to understand why many companies are moving away from the "big framework" approach.

It's quite to opposite: I would expect anybody working with me to be flexible enough to learn different ways of expressing themselves in code, and I would expect them to not take several months to learn something as simple as a web framework.

comment 3y ago · link · parent

Yeah I use nestjs for my backend at my company and it also has a good DI framework, but it depends on typescript interfaces to work well

comment 3y ago · link · parent

I can understand that view, but I like to have the controller class files themselves represent the site hierarchy. Rather than looking in a file for the appropriate route, I look through the filesystem to understand the routing. I expect FooController to map to /foo (or /api/foo or whatever). I worked on a django project which did all the routing in a single location and it frequently resulted in merge conflicts between multiple developers committing changes to the file about the same time

comment 3y ago · link · parent

Yes, obviously the people who offer the virtualized infrastructure are going to need the sysadmins. I'm talking about the majority of businesses and engineers which aren't cloud service providers, but rather customers of those providers.

comment 3y ago · link · parent

Try actually reading this time. I never said that middleware didn't exist in other frameworks, I said you can control that middleware using attributes. Do not accuse other people of being disingenuous because you didn't read something right

comment 3y ago · link · parent

> You've never taken a job working in a language you don't know yet? Anecdotally this is a common thing. In fact, my most recent job hired me to write C# with nothing but prior Go/Python experience.

So then it shouldn't be a problem for you to learn a new skill based on a very common pattern with many examples in different languages

> This comes across to me as needlessly bitter to folks with less experience than you.

If those folks are forcing the business to make tech decisions based on their lack of experience, it makes life harder for others. If you are going to choose between "should we write our backend in C# or javascript", and the decision comes down to "well our bootcamp grads don't know C# and they don't have a background in software engineering, so getting them up to speed on C# will take months", then you're willingly choosing inferior tech to make up for subpar employees

comment 3y ago · link · parent

I might consider this for a very small service, but not for anything with a lot of controllers or services. When you get to the point where your backend is managing several workflows with dozens of views, dozens of models, and each with its own service, it becomes nice to be able to put these things in classes.

I also dislike functions and controllers without explicitly defined return types.

comment 3y ago · link · parent

> No, having to spend months learning how web frameworks are going to deal with that piece of code is not a good thing

Are you in the habit of hiring people without experience? Developers had to spend months (years) learning javascript before they learned any frameworks. Would you rather switch to point and click programming so that your developers don't need to actually learn to code?

> It means that the code is readable only to those who have spent a lot of time working with that framework

Knowing the framework (or being able to learn) that the business is based on should be a requirement for working there. You should not hire people who are incapable of learning things, or who can only do things in one particular way

> And he does have a point about vendor lock-in. I tend to classify these kinds of frameworks as "cancerous" - as they metastasize and define how you can express yourself, and paint you into a corner where it gets really hard to rid your codebase of the framework should that be necessary.

All frameworks will place limitations on how you express yourself. Compared to javascript, C# (and .net) offer far more flexibility and metaprogramming abilities. Try declaratively validating user input in Javascript or Typescript without having to rely on some kind of runtime hack or re-writing the same code over and over.

If you were to decide to ditch express and move to a different framework, then the way you have written your express handlers would also have to be totally discarded. By choosing any language or framework, you are tying yourself to the technology decision and labor pool associated

> Part of my job in the past has to be technical due dil for M&A. This kind of design approach usually results in a red flag if a major part of the valuation is the codebase.

I question your judgment if using a well documented and not at all obscure framework based on some of the most popular frameworks out there (MVC style, bootstrap, etc.) raises a red flag. It would indicate, to me, your lack of experience in writing or reading code rather than anything about the framework itself. If having a javascript backend isn't a red flag in itself to you, then I would pretty much just discard any feedback you would have about a web backend

comment 3y ago · link · parent

> Most web frameworks avoid this

I don't know if that's true, but I doubt it.

> My complaint is that I don't want things in my code affecting my code that aren't code

Many things affect your code under the hood that you don't see. There is no difference between using a decorator/attribute and having a config.json file for other things.

> while the more enterprise stuff like Spring, Dotnet, et. al seem to lean into it.

Because they are responsible for larger services which need to be more maintainable and stable.

> But if I can't compile something in my head at a glance, it shouldn't be a part of the codebase IMO.

This would preclude ever using a programming language or framework which you don't already know. You have been taught to write web services in one particular way; the fact that you don't know other ways doesn't make them "unreadable", it just means you don't know how to read it

comment 3y ago · link · parent

> You can still do service injection in JavaScript

I know that angular is really good at this, but I'm not sure what pure js frameworks would allow a service to be defined as an interface first, and then injected into the constructor of a controller (or even a handler function) based on the implementation method selected somewhere else. I just haven't seen it happen.

comment 3y ago · link · parent

> The second example has poor readability

Only if you don't know C# or asp.net (or bootstrap). In which case: why would you be working for an organization which does?

> And that's even before we get to the issue that this approach has fallen out of favor exactly because it result in code that can be a pain in the neck to figure out.

This kind of structured approach has fallen out of favor because it's become more popular to hire javascript and react developers straight out of boot camp who have only been taught how to code one or two things.

The argument that code needs to be inherently readable to someone with 3 weeks of experience is how you get hundreds of poorly written spaghetti code microservices written in node or typescript and not a language better suited for backend development. If you want your code base to constantly look like it was written by someone following their first javascript tutorial, then by all means continue using this top-level express JS crap

> Please don't do this. This is the kind of legacy approach that I try to teach people working for me NOT to follow.

You are setting yourself up for some bad tech debt in the future

comment 3y ago · link · parent

> Which unfortunately is a problem in itself. A lot of core knowledge is lost and many people running infrastructure don't know how to read actual logs and debug outside of what the GUI shows. Just like you mention it's not even VPS these days it's a Dockerfile pushed to some cloud.

Plenty of k8s users are accessing their services and logs through CLI. It's just that the relevant logs are from the application and not whatever the underlying infrastructure is. It makes it way easier to have amazon deal with the underlying server and just let me focus on the actual application. Saves labor costs (in theory) by not having to hire an IT guy, and you can put more faith in the security practices of the cloud providers than in your own organization.

Your criticism reads like old school developers complaining about new devs learning Javascript without learning C or Assembly. Technology progresses, the set of baseline skills required to do your job changes. Few software engineers know anything about hardware or electrical engineering, but that used to be a requirement many decades ago.

> Copy/paste a Dockerfile, edit some yaml for the CI and claim you know DevOps. It's a shame really. I don't mind a nice minimal GUI when it makes sense, but it's important to understand the pieces below it.

What you've described is a way to make it dead simple for engineers to develop code without having to interface with a human being (a sysadmin) in between. It makes deployments consistent and easy. When you add CI/CD into the mix, you don't even need to run the command anymore, you just merge the master and swap your staging and production instances. Amazon can hire the sysadmins, the client can hire engineers.

comment 3y ago · link · parent

Your complaint is that you have to understand your web framework before writing a program in it? Is that not the case with ALL web frameworks?

> And you're now also stuck with vendor lockin to whatever framework/compiler was using them

I don't understand. If you choose a web framework, you are locked in to developing things in that framework from now on. In what world do companies try to change web frameworks without having to change any of the underlying code? In what world would they want to do so?

comment 3y ago · link · parent

Yes

comment 3y ago · link · parent

The 2nd example:

1. Uses declarative routing, which looks better and makes more sense than running a function to handle routing (e.g, you read it as "There is a handler named GetFoo living within the Foo controller that exists at the base route"). Declaration is more important to the end user than implementation when creating an interface. It also allows you to export these classes to a different Main method which can generate documentation for you without having to even run the HTTP server (the declarations can be picked up using RTTI and not actually having the runtime server activated). You can also add named parameters to the routes and then add them to the body of the handler with their proper types, e.g:

    [HttpGet("/{id}")]
    public ActionResult GetFoo(int id)
And that input validation is handled automatically. Named parameters exist on a lot of these frameworks as well, but Javascript doesn't provide static typing so it's not a good language for writing a backend in

2. Handles input validation under the hood or through middleware so you don't have to manage it in the controller body

3. Can also handle user auth under the hood using attributes so you don't have to handle it in the controller body

4. Uses middleware to handle routing in a predictable way (e.g: the name of the controller is the name of the route by default)

5. Uses class-based controllers to encapsulate the services available to the controller through the constructor, and also helps pair a single model to a single controller for making really simple RESTful interfaces

You can also define a custom controller interface or abstract class which provides a bunch of default functionality that you commonly re-use (e.g: ApiController with some built in response wrappers/handlers for error codes, etc.)

comment 3y ago · link · parent

There's nothing "black magic" about them; they're very well documented features in Java, C#, and Python. They're officially experimental in Typescript but they're so heavily relied upon I can't imagine them getting deprecated

comment 3y ago · link · parent

How did this kind of syntax become so popular? I think express is the first to do the scheme of:

    app.handleGet("/route/goes/here", (req, res) => {

    });
Which seems like it's useful for making really quick and dirty micro-services (nano-services, even), but I still vastly prefer the more declarative and modular schemes of bootstrap or asp.net:

    // Middleware automatically routes "/Foo" to FooController
    [Controller]
    public class FooController : Controller
    {
        private IMyService _service { get; init; }
        
        // Declarative dependency injection
        FooController(IMyService service)
        {
            this._service = service;
        }

        // HTTP Method and Route are declarative
        [HttpGet("/")]
        public ActionResult GetBar([FromBody] Model myModel)
                                 // ^ automatic user input validation using reflection
        {
            this._service.create(myModel); // or whatever you need to do
            return Ok();
        }
    }
This has always seemed way more maintainable to me. Even microsoft has added the ability to do these quick and dirty HTTP routing methods along with top level statements.

comment 3y ago · link · parent

Being a somewhat C/C# inspired bracket syntax, Powershell's syntax is easily better than bash's schizophrenic usage of brackets and semi-colons. Somehow it seems that the people who measure their self worth and identity based on their proclivity for typing in a terminal are also the ones who bitch the most about how long cmdlet names are. I didn't realize Linux users were so allergic to typing (not to mentions aliases and auto-complete)

comment 3y ago · link · parent

Having to type the URL manually is very poor discoverability. Most people don't use the internet this way

comment 3y ago · link · parent

> I am comfortable with the latter type of people administrating my servers. I am not comfortable about the former.

idk what kind of legacy orgs people in this thread work for where there are Linux sysadmins working for their companies which directly manage server configs and security settings. "Administering my servers" is an interesting phrase in 2023, because there often aren't any servers to directly administer (even a VPS is hard to find). The last few companies I worked for all used some kind of virtualized infrastructure and usually through some kind of declarative interface (Docker, Kubernetes, or some terraform-style tool). Certainly, the people who OWN the servers have sysadmins managing these things, but such things are an abstraction these days, where many organizations don't have to deal with CLI configuration and bash, and just leave infrastructure to devops or even the developers themselves

comment 3y ago · link · parent

I think there's an elitism within the Linux world to being a totally CLI user

comment 3y ago · link · parent

What if they CAN do a bash for/while loop, but they prefer not to because bash is the ugliest effing language they've ever seen

comment 3y ago · link · parent

Most end users don't care about privacy

comment 3y ago · link · parent

I think books and magazines serve different demands. Books are infinitely re-readable and the reader has to really engage the content to enjoy it. Physical paper helps with that engagement.

Magazines are mostly short form, cheap content (excluding periodical literary magazines, indie 'zines, etc.) that are usually meant to share the latest news on some subject. Paper is an unnecessary medium with magazines, whose point is to convey contemporary information very quickly, so that people can gossip about it later and then forget about it when the next issue comes out.

In short: It's very difficult to replicate the experience of a book using technology (somehow books have survived the rise of e-readers), but social media optimized magazines down to their most fundamental elements

comment 3y ago · link · parent

OpenGL straight up sucks to work with. DirectX 11 is a much nicer API that doesn't require you to write your own allocator for views in the GPU like the lower level APIs. Linux isn't a major platform I personally care about so I use DirectX 11

comment 3y ago · link · parent

Yes, vbscript is the default scripting language for windows. Many viruses have been spread because .vbs files were set to auto-run: https://en.m.wikipedia.org/wiki/ILOVEYOU

comment 3y ago · link · parent

So supply must match demand

comment 3y ago · link · parent

Investment properties aren't the problem, supply is

comment 3y ago · link · parent

The samples are just hideous. Platform selection #if preprocessors every 5 lines. I would never want to maintain code like this
1
363738
55