Should you use Go over TypeScript for your Backend? The Perspective of Someone who uses Both.
HTML-код
- Опубликовано: 31 май 2024
- TypeScript or Go. Its a hard question to answer when trying to pick a backend language and the honest answer is: they are both good?
Today I breakdown my thoughts on which language I would use and where. At the end of the day it comes down to your app and how you want to architect things.
twitter: / benjamin41902
insiderviz: www.insiderviz.com
#golang #typescript #programming - Наука
Mate, as a Software Architect of several years, I find your insights and analysis rock solid and spot on. Good job. Consider a Solutions Architecture job, we need more.
Software architects are just programmers that can't code. It's a worthless job, like scrum masters.
Go vs kotlin?
Cool vid, I like how you go into detail about the decision making factors and you're not presuming higher knowledge from your audience while also keeping your video short enough.
Your Frontend and Backend architecture in same freaking language, what else would you want ? Regarding computation and scalability, there are tons of options that can handle those worries. For me, not having to switch between two different programming language paradigms is the key.
TRPC is the one thing that makes letting go of TS for all my backends by far the hardest. The power of having everything in one Next app is absurd and it makes development so easy I find it hard to give up. I think Go is still often better, but it is for sure slower to develop.
What stops me from doing that is that js is a dsl for browsers, but backend doesn't run in a browser. Js people are often amazed that node can manage 400 concurrent connections, but a server in C can manage 400'000. Go is probably not that far off from the C.
Hey, Link listen... I see you are some basic beach, and please don't share your basic beach opinions since we can read them on Js/Ts landing page hero component. Just get lost. You have no idea what the flip you talk about.
I think the programming language you use is not as important as the patterns you use. Some patterns are hard to implement with Typescript because it has too much abstraction around JavaScript.
Then you are better off using Elixir and the phoenix framework. Performance is not as good as go (but almost is) and it scales both horizontally and vertically without you having to configure anything. With Phoenix liveview you get the benefit of using the same programming language in the backend and the frontend. And not to mention that you can have millions of concurrent connections on just 1 server (scalability is great). Only 2 drawbacks, 1: Functional programming language (which isn't a drawback actually but might feel like it if you are used to OOP), 2: No strict typing which typescript and go do offer (but Elixir doesn't have the problems that those languages solve with strict typing so it is also not really a drawback).
Your videos are really helpful, always look forward to them. Thank you
Great video! Your comparison really makes it clear for me
There was a nice conclusion out there @11:58. After that, in knew that I need more of his knowledge and i pressed Sub and wrote this comment. I appreciate your video. Very informative.
Also, that example website is just what I needed to see
Love the video! 😍
So insightful.
I find your insights so useful.
This was great advice and well thought out.
Good video... always love your contents 👍🏿
I would love a course that focuses on the differences between typescript/go while creating a clone of your finance app (or something similar).
I've struggled with this when building side projects (for a portfolio) because using Typescript is usually more ergonomic and just easier, especially when using Vercel, than dealing with another deployment.
btw I think you can also deploy a backend in Go using AWS functions in Vercel if you place it in an 'API' folder. Never tried it with Go, though.
thank you, more other comparisons about the tools you use every day
Buh let me add this... in a comparison video, please do more to tilt to a side, it so common online to see "i leave the decision to you", most people compare to get a vote up or down... and you actually do more than most... so great work again 👍🏿
I agree.
no, that's the opposite of what should be done. There isn't a silver bullet, like "pick this language whenever you can". It always depends on circumstances and the context of your application.
Niceeeee just found you, keep it up, I'm subbed
What kind of projects are you building to get a deep understanding of the quirks of both languages? I find that my personal projects help me understand how to do something in Typescript/Go but nothing deeper.
Why do we need k8s to scale vertically with ts, but we dont need it for go?
Ben, have you tried nestjs ? I was thinking about building a REST API with Go but I think Nest can cover everything I need.
An early version of insiderviz used Nest, its great, very angular like, not my favorite but it works well
How do you combine TS and Go on the backend? Do you proxy requests from browser via Node and then to Go? Or browser goes straight to Go port on the server?
I would just communicate between them using either a queue in Redis/RabbitMQ or via HTTP
Ive been wanting for ever to try and find some next js substitute for golang
With maybe only delegating js/ts for any frontend pages that need it
This way i could just definitively get away from node and npm
you can use reflection to generate ts types from your go backend...
I might be wrong but i dont see Solid Start or Svelte Kit entering the enterprise world. A separate backend is always more flexible and scalable. Im doing my current side project with Next and TRPC but I would totally pick Go on my backend over TS anyday. Performance or not.
You think Solid or Svelte will enter the frontend scene in the job market in the next 2 years or React will stay king ?
Its hard to say, I honestly don't have enough experience to make an informed call. On paper and in simple stuff both are incredible, but idk what its gonna be like at scale. React is battle tested and has absurd library support that they are gonna be hard pressed to match.
Subscribed!
Hope web assembly frameworks will be production ready in coming years
You and me both
I will go for Rust.
Recently, Discord went for rust in one of the modules & they found multi-fold improvement in performance.
My projects usually have very small user base, the speed of python or ruby is more than enough 😅.
rust is a great language, but you don't really NEED it for performance reasons until you have maybe millions of users
But Discord had to ditch Go because of the garbage collector, their systems demand crazy throughput and responsiveness and the GC was creating noticeable spikes on them. For applications at their scale and needs, Rust is better, but for the most part I think GO is better (easier to use, to train, to hire, also has good packages)
@@cat47 I think that depends on the dev's mindset in terms of developer friendliness. I am on a daily basis using Rust almost everywhere possible replacing languages like C++, Python, NodeJS.
Btw, in blockchain the industry has gladly accepted rust & inserting almost everywhere - Writing contracts, Zero-knowledge circuits, runtime modules....this leading to considering Rust even for their backend systems as well.
im still a bit confused on the part u said that typescript does not scale vertically and go easy to vertically scale, can u explain more on that part?
This is the part I wish I could redo, basically I mean if you have one cpu it can run FAR more requests running go than ts. Thus with ts you need more cpus to get the same result as go
since i've never done benchmarking or any analysis before, is there any article for me to better understand this? wanted to know more on how these things work under the hood
hey ben, what do you think about python?
It is a very good language, would not be my choice for backend development, but for data science, AI, and scraping? 10/10
@@bmdavis419 why u wouldnt use python for backend?
Awesome!
Why Don't you make a video on like day in life video ?
😂 Genuinely interested
Maybe after this 50 day period is done I might, not sure though b/c its kinda boring lol.
1. Wake up, clean up
2. Work my 9-5
3. Make a video
4. Go to the gym
5. Work on insiderviz
6. Repeat
Crazy bro
What's better for a e-commerce website, Go or TyeScript?
typescript
Yea Go is probably overkill for a basic e-commerce thing, especially if you use a CMS like sanity.io
Java Period.
When you say Typescript backend, are you talking about NodeJs?
Yep, NodeJS runtime, written in TS, compiled to JS
Such videos sometimes want me to start my own channel where I need to disprove some words said in video. As a junior dev don't listen to someone who doesn't have experience in development...
Can you at least name things you disagree with?
Basicly the video creator didn't get the point of go. Go is made for high performance network microservices. As the creator is basicly talking about vertical scaling, you normally use a horizontal scaling strategy.
Example:
You have a Server, 1 CPU and 1 GB RAM, but during the lunch break your website or application has way more load. So you add a new CPU for 200 Dollars, lets say a 4 core and again upgrade the RAM to 4 GB.
Ok... so you scale now great during lunch breaks, but what is with the other time when you don't need it? And what you do if also the 4 Cores are running out?? Buy again a new one? What happens when your mainboard doesnt support more than 4 cores? Now you need a new Mainboard too?? And here comes the horizontal scaling.
Just add another server and start another instance of you app (Loadbalancer infront of all instances). When you don't need to scale anymore, just shut down the second server and you don't pay it anymore. This is how you scale thesedays. This also has the benefit that you application will be online if one server fails. For vertical scaling, your app is down.
So this is just a summary about my own opinion. I dont want to front someone, do what you want but for me as a Go dev this completly makes no sense.
If you are building standard REST services or websites, go what makes the most fun! Later on with a database attached, security rules, additional middlewares and so on you will not feel a performance difference. The only difference you will see is resource cost. And thats why many companies are currently migrating to Go and Rust. Just imagine a Nodejs app takes 30% more RAM (which is realistic), you host like 5k Applications. Lets say every application uses 100 mb ram -> 500 GB RAM. Now add 30% on top of it and you have way higher server cost. If you calculate that with a t2.medium machine of aws (4 GB Ram, 38$ per month) you would need 125 Server => 4750 $ monthly cost. Add 30% more RAM -> 650 GB RAM -> 162,5 server needed, so 37 Servers more, which means 37 * 38$ => saving 1406 $ in server cost per month just by changing the language. This is how cloud computing works...
@@Tobi-cb8vjtobi Servers are only one element in equation which choice of language effects.
Its actually developers who cost way more then servers and its cheaper to have more servers then more developers.
Depends though, I mean at scale of Google and Facebook you would care way more about it.
At scale of a startup that is last thing you should care about.
We are also speaking only about servers here. What about client? Web? Desktop? Mobile?
What language do you use there? Is it same developer using all of those languages? Is there cost in productivity of that developer using multiple stacks?
Or are there multiple teams server/web/desktop/mobile each using own stack and syncing their work? Is there cost on getting them all on same page about what and how should be done?
I am not arguing with your point, I am genuinely curious how to solve all this. In companies I worked there was more pain related to zoo of technology and teams that prefer one over the other then performance or server costs. As if its all religions where people disagree on faith and principle and waste each other time.
Do you have experience with that?
I BTW look forward to future where Rust may become one language to rule them all with WebAssembly containers on server, web, desktop and mobile.
But for now for me its full stack TypeScript.
And only because I am closer to Startup scale projects, small teams, speed of iteration over quality/performance etc.
@@EduardsRuzga I agree too 100%, developers cost way more. In my company we have developer standards and they say: you are only allowed to use Go + Vue3. So we don't have any messy tech stack anymore with 20 languages. And personally i meant scale like google/facebook... :)
For startups i would go for the language which the team knows the best. Its important to get a prototype for startups. So your choice with Typescript is probably better there =) Good choice
I would never touch tRPC. It's an overhead.
I use Rust for my backend
ayy you know wtf your talkin about. thats dope.
Cant you just use meta frameworks w/ trpc as a glorified grpc client for go services and still have the benefits of a pure ts trpc server?
TRPC =/= GRPC I'll make a video about this at some point but at a high level trpc is a way for a TS server to talk to a TS client and grpc is a way for internal micro services written in any language to communicate.
@@bmdavis419 I understand they are two different things. What I mean is, whats stopping you from using trpc (with a T) as a grpc client and passing the data down to the client (react page)?
Java
You should use RUST over GO for your Backend?
Typescript is transpiled to JavaScript yet you reference it as if it is a runtime language. Seriously misleading.
Everyones that tho.
Wait typescript is easy to write??. Man I have been shitting my pants writing Types for react.
Stopped watching the video on the first slide. Go and typescript scale the same vertically and horizontally system/machine wise. Go has only lower footprint and requires less resources to run compared to NodeJS and can run on multiple cpu cores, however you don't need any k8s or serverless to run nodejs in parallel on multiple core cpus....
Agreed. This dev is giving newbies the wrong idea in that regard
He might have a point here tho - nowadays CPUs scale by adding more cores and if you want to get the most out of your CPU you need to use those cores. NodeJS being single-threaded in nature makes that hard without going into multi-process architectures but that's really going into horizontal scaling territory now.
Go spawns a goroutine by default to take advantage of multithreading. Just start your NodeJS app in Cluster mode to replicate same in nodejs
I agree with you @IlijaNL
what about php?
it’s 2023 bro, not 2001 anymore
Laravel and Symfony are good frameworks and stable
Not my thing at all lol. It was the first backend language I ever used in high school, but at this point I would not go back
writting php code feels like walking on the blind spot of journey
@@pramudyaindra I get what you are trying to say but it depends on many other factors but not what year it is.
Love the content! but the neutrality in 90% of these kind of videos is getting old
RN I am focused on more general stuff/languages where the truth is "both have strengths and weaknesses", but as time goes on I am gonna get more and more specific and trust me there will be many places where I do NOT have a neutral opinion. Just wait till "Vercel VS Netlify" or "Prisma VS TypeORM", trust me, a side will be taken
@@bmdavis419 Thanks for replying. I have to admit that as a huge go nerd i was expecting something and maybe that's what everyone finds somewhat frustrating on these videos. But at the end of the day, you're completely right, the right tool has to be chosen according to the job, and that's what you explained. There's nothing to disagree with your video, it's impeccable. As programmers we have to leave our love for a language or technology aside in favor of logic or budget :')
@@bmdavis419 and prisma OR typeORM VS EdgeDB and no ORM!
Hi Ben, when you will make a video about investing?
Honestly not sure, its something I am learning a ton about offline, but I am hesitant to make one b/c I don't feel nearly as qualified as I do with programming. With programming I know I know it so I'm not worried about giving bad info and if I do make a mistake its pretty low stakes.
But investing? That involves peoples actual money and bad information can do real damage. I know tons of people do "THIS STOCK IS GOING TO THE MOON" type garbage but its dishonest at best and I am not gonna do that. So I would want to do more fundamental concepts which I do not yet have a truly deep understanding of. So honestly, probably later this year after I have more experience and more time to read/learn.
@@bmdavis419 Can you share resources where you learn investing?
@@bashscript2805 I read a lot of books, as far as YT channels go this is one of my favorites: ruclips.net/user/TheSwedishInvestor