Most active commenters
  • amazingamazing(9)
  • CharlieDigital(6)
  • bdhcuidbebe(3)

←back to thread

257 points pmig | 21 comments | | HN request time: 0.001s | source | bottom
1. rvz ◴[] No.43096400[source]
Agree. Go is a joy to use. Java is okay but struggles with scaling unless you have the money to burn for this.

To scale up servers in Java requires spinning up highly priced servers with lots of RAM, which that is a lot of money. Using a low spec server is cheaper but you will get more JVM crashes and have to waste time doing more JVM tuning to prevent them. This is not even talking about having lots of 'microservices' to scale which that also means more money spent per month.

Using Go just reduces all of that and saves lots of money and is extremely efficient enough to rely on and it directly compiles to a single binary for deployment.

From a cost and efficiency perspective, Java is just not the answer even though it is a sound language, unlike JavaScript or TypeScript. Given a choice I'd rather use Java or even Kotlin or JS/TS. But the cost reduction, performance gains and onboarding experience with Golang is hard to beat for backend.

Would stay really far away from JavaScript or TypeScript for anything backend.

replies(1): >>43096458 #
2. amazingamazing ◴[] No.43096458[source]
> Would stay really far away from JavaScript or TypeScript for anything backend.

IDK, TypeScript types are extremely ergonomic, and if you're not overzealous makes everything very readable, and given many things are I/O bound anyway, it doesn't matter much.

replies(2): >>43096723 #>>43097320 #
3. CharlieDigital ◴[] No.43096723[source]
Big problems for APIs though because TS types disappear at runtime.

So now you need to add in Zod or Valibot as well to validate your types. If you have view models and DTOs, then you add more Zod. Might as well use a statically typed language?

Working with OpenAPI is much easier when you already have a static type system.

How about database transactions? Ran into an interesting issue this week. In a .NET world, every ORM can participate in an ambient transaction because everyone uses System.Transactions. Not the case in Node because there's no such thing.

Would not build backends in TS except for true microservices. The ergonomics of a Nest.js vs .NET Web API are night and day.

replies(1): >>43096793 #
4. amazingamazing ◴[] No.43096793{3}[source]
> How about database transactions? Ran into an interesting issue this week. In a .NET world, every ORM can participate in an ambient transaction because everyone uses System.Transactions. Not the case in Node because there's no such thing.

I mean you could say the same thing about TypeScript - if your entire stack is TypeScript then there's no need for the type validation either.

replies(1): >>43096840 #
5. CharlieDigital ◴[] No.43096840{4}[source]
Even if your entire stack is TS, you still need validation because the submitted data from an external interface (API call) might not be valid.

You can't just accept any JSON payload and expect it to be valid.

In Java or .NET, it will fail at serialization when the runtime tries to map it to a static type (automatic). This is not the case at runtime with JS (because at runtime, it's no longer TS). Thus you need a Zod or a Valibot to ensure the incoming payload is actually valid by describing the valid types (even if your whole stack is TS at dev time because schema mismatches are a runtime problem).

.NETs System.Text.Json does the mapping and validation using either reflection or AOT generated serializers transparently and automatically because it has static types.

replies(2): >>43096876 #>>43098447 #
6. amazingamazing ◴[] No.43096876{5}[source]
Yes .NET's built in SDK is larger than Node.JS's. I'm not sure what your point is exactly. As you stated just use a validation library if that's necessary. It generally is not though, you can cast the entire output to a type in TypeScript, of course this isn't validation, but it's generally good enough.

Of course if you’re writing a full stack app you can share everything, validating the front and backend with the same code. Clearly that would be a strange thing to hold against .net, similar to the lack of built in validation in typescript.

replies(1): >>43096938 #
7. CharlieDigital ◴[] No.43096938{6}[source]
You double up your work. What you really wanted all along are static types.
replies(1): >>43096964 #
8. amazingamazing ◴[] No.43096964{7}[source]
not necessarily, and in plenty of programming languages static types do not give you validation for free, and in the case of .net you still have to call something else. it's no different than just using zod, other than the fact that it's built in.

if you're using typescript in the front end, seems double to even bother to introduce .net, when typescript and node is fine for the backend too.

replies(1): >>43097042 #
9. CharlieDigital ◴[] No.43097042{8}[source]

    > [amazingamazing 31 minutes ago] I mean you could say the same thing about TypeScript - if your entire stack is TypeScript then there's no need for the type validation either.
I think that if you're here trying to make the case that if your whole stack is TS, you don't need to validate your incoming data, then you probably haven't built a system of consequence where the data actually matters and none of this discussion really matters; you have no context. Go ahead and try to `curl` some nonsense data to any of your TS endpoints and see what happens at runtime without validation.
replies(1): >>43097081 #
10. amazingamazing ◴[] No.43097081{9}[source]
I'm not really sure what your point is. you can add validation in node.js, just like you can with .net.

also, with curl you'd use isomorphic type safety, or just know what you're expecting and hard code the types per inputs, trivial with typescript.

anyway, I'm done here since this conversation is going in circles.

11. bdhcuidbebe ◴[] No.43097320[source]
I guess you just dont know the domain well enough to understand the kind of issues strong typing and compiled software is solving.
replies(1): >>43097529 #
12. amazingamazing ◴[] No.43097529{3}[source]
Please do tell, what typescript, node and a few dependencies cannot do here.
replies(1): >>43101612 #
13. jbhoot ◴[] No.43098447{5}[source]
I think CharlieDigital's point is that a bad payload will fail right at the serialisation boundary in case of .NET. We know the problem right there. Now we only need to fix the bad payload.

For TypeScript with only types and without validation, a bad payload gets through, and there is no telling where in the workflow it will explode. This could waste more time and developer resources in debugging.

replies(1): >>43098495 #
14. amazingamazing ◴[] No.43098495{6}[source]
Again this isn’t an inherent property of .net, you have to add validation. There are plenty of ways to do this in node so the point is moot.
replies(2): >>43098562 #>>43102001 #
15. CharlieDigital ◴[] No.43098562{7}[source]
Here is a .NET web API

    var builder = WebApplication.CreateBuilder(args);
    var app = builder.Build();

    app.MapGet("/{userId}", (int userId) => userId);
    app.Run();
See `int userId`? If I call this API with `http://localhost:5123/asdf`, I will get an error because the types don't match. If I call this with `http://localhost:5123/1234` it will work fine. The same would be true if I required a class `User` here. The router is able to introspect the type at runtime to determine if the types match; both basic types like this as well as complex types using the built-in serializer. It is built in.

I've put it into a short clip for you: https://imgur.com/a/WNbGUQD

replies(1): >>43098599 #
16. amazingamazing ◴[] No.43098599{8}[source]
I’m not sure why you’re so obsessed with this. You can do the same thing with any validation library in nodejs. Your exact example is possible by integrating any validation library of your choosing into a nest js route pipe. In particular primitive type validation is built into nestjs anyway

The fact that it’s built in is neat but not really important. Most people are not making thousands of toy apps. If the necessary they will integrate and move on.

There are more compelling reasons to use .net than this.

17. bdhcuidbebe ◴[] No.43101612{4}[source]
Provide strong typing, low memory footprint and good performance at scale. See the topic of discussion for more details.
replies(1): >>43102593 #
18. mattgreenrocks ◴[] No.43102001{7}[source]
The issue is that this sort of validation boilerplate shouldn't have to be written. The framework should be able to figure it out from the HTTP handler declaration. I suspect this is why FastAPI got so popular in the Python world.

IMO, a lot of the JS world seems mentally fixated on express.js-levels of abstraction still. Anything more is viewed as "magic" and viewed as suspect because it requires learning.

replies(1): >>43103655 #
19. amazingamazing ◴[] No.43102593{5}[source]
Yes, I agree, but what you're saying isn't really relevant in an I/O bound scenario. In any case, I wouldn't write a K8s operator in node.js, yes. Go is the best for that.
replies(1): >>43103464 #
20. bdhcuidbebe ◴[] No.43103464{6}[source]
Sorry, but what IO bound scenario?
21. CharlieDigital ◴[] No.43103655{8}[source]
The irony is that the "learning" just gets applied elsewhere; there are certain foundational building blocks that I think every language and platform needs once you start building "serious" applications.