r/javascript • u/[deleted] • Apr 15 '18
My journey from Node to Go
https://medium.com/@OmisNomis/my-journey-from-node-to-go-4b657f57836e79
26
u/thenickdude Apr 16 '18
The Node app starts accepting connections before the connection to Mongo is completed. This seems unhelpful.
1
u/bpadair31 Apr 16 '18
When you refer to Node as a language, I have no interest in anything else you have to say in relation to development.
-1
7
u/mihaelamj Apr 15 '18
There is another option: Server Side Swift. Swift is alco compiled but does not have a GC!
5
u/creedasaurus Apr 15 '18
I'm kind of fascinated by this idea of using Swift for things other than Apple development. But has there been much adoption in the industry? I dived into Go because I thought it was interesting, but I also felt the demand was growing where I'm from. Anyway, I'll have to look at Vapor. Looks cool.
2
Apr 16 '18
I've really enjoyed my limited experience with Swift. It's a shame that I have no interest in developing macOS/iOS apps because it's really a joy to work with.
If anyone cared to use it for more general-purpose stuff, I think it'd take a chunk out of C#'s market.
2
u/filleduchaos Apr 16 '18
It would take a mountain of marketing effort/outreach to get the dev community at large to see Swift as useful for anything other than making Apple apps, and Apple has no-one but themselves to blame for that.
1
Apr 16 '18
Totally. It has to be intentional on their part. I guess designing a language around a few central purposes is easier in the long run.
2
u/filleduchaos Apr 16 '18
Yeah - it doesn't seem to be hurting their bottom line much if at all. Still, it would be nice if more people knew that you no longer need a Mac/XCode to write and compile Swift.
2
0
Apr 15 '18
What framework would you recommend other than Iris?
7
Apr 15 '18
None. Use standard libs.
2
Apr 15 '18
Interesting. What is the standard lib called?
-2
Apr 15 '18
http
4
Apr 15 '18
Ah ok. I think I get why I was being downvoted now :)
0
Apr 15 '18
[deleted]
1
-1
u/PantsuWitch Apr 16 '18
Programmers, especially on reddit, are terrible people that tend to hate newcomers.
Not really, only new comers who declared themselves as "senior developer".
-1
u/Skhmt Apr 16 '18
Programmers, especially on reddit, are terrible people that tend to hate newcomers.
TIL I'm a terrible person.
0
u/yeahdixon Apr 15 '18
Go community tends to push away from using exterior libs for shortcuts and rather you just code it yourself.
2
u/monsto Apr 16 '18
Is Go that "batteries included" that Auth and ORM are part of the standard libs?
0
Apr 15 '18
[deleted]
3
u/Dedustern Apr 16 '18
The Go stdlib has nearly everything you need. There is little reason to use frameworks with Go, unless you have something really specialized said framework will solve.
Go is build for web/networking. It doesn't need a framework like other languages.
-2
0
Apr 15 '18
[deleted]
1
u/monsto Apr 16 '18
Don't take the bus to work, just walk instead of relying on transportation to solve all your problems.
There's plenty of value to not using a framework for a first few projects. But beyond that, there's plenty of upside reasons.
Confidence that authorization/authentication/accounting controls are current and bugless is only one of them.
1
Apr 15 '18
I'll be honest, I don't know (I've only been playing with Go for a week or two). I will be doing some research on this over the coming week or so, and can report back once I have a recommendation?
1
-3
0
u/dangerzone2 Apr 15 '18
I'm in a very similar situation. I've been slowly moving my favorite backend stack from Node -> TypeScript -> Go. Its a pretty natural progression.
A couple negative of go are the GOPATH weirdness and lack of 3rd party support. The 3rd party libraries are there but theres no NPM to easily search, compare and review them.
2
Apr 15 '18
Appreciate you sharing! There are definitely things I like about Go. I can see it being another tool in the tool belt, but I can't see it replacing Node
2
1
u/Pawda Apr 16 '18
Would you mind sharing why not ? IMO Go is already mature enough. I find prototyping to be still faster with Node but except that, Go already offers everything Node has and much more.
1
u/filleduchaos Apr 16 '18
Go already offers everything Node has and much more.
Even Node/JavaScript has generics (via TypeScript, but still).
1
u/Pawda Apr 16 '18 edited Apr 16 '18
Generics are eventually coming in go 2. I don't really have a position there, Golang offer other ways to do fine without them so I don't miss them. Btw, why would you mention generics on JavaScript/Node, seriously this is pure troll, the language already doesn't enforce types... Developers always needs to find issues when there is none. Are you one of the kind that prefer write a thousands lines of JavaScript in order to respect all the S.O.L.I.D. principles where 50 lines would have be enough ?
1
u/filleduchaos Apr 16 '18 edited Apr 16 '18
Golang ofter other ways to do fine without them so I don't miss them.
> Arrays, maps and slices are literally generic types
> Other ways include copying and pasting code
> doesn't miss generics
thinkingface.jpg
Edit: can't forget the other way of using Canadian Aboriginal Syllabics
0
u/monsto Apr 16 '18
Would you mind sharing why not ?
From what I've seen in this thread so far, the main reason is very clearly the foundational elitism. The mentality of scoffing at external libs "write it yourself" forces the lack of a package manager where you could find an already invented wheel... for things like front end templating.
Every major web-centric language has a package manager/repository . . . because developers are interested in building complete apps, in a timely manner, to serve a purpose, as opposed to "doing it the right way" and building from scratch.
Using a framework to build an app is like making a sandwich with premade cheese, ham, etc. Django, Laravel, Rails and Express/Koa make fine sandwiches.
1
u/Pawda Apr 16 '18 edited Apr 16 '18
Well, I cannot deny the elitism but I think it's changing with the time.
For front end templating... There is already a native package for that. (https://golang.org/pkg/html/template/)
Package management, there is dep / govendor, you can get a list of goods packages here (https://github.com/avelino/awesome-go)
Framework like echo (https://echo.labstack.com/) replicate well was you can do with express/koa, there is also a few "all batteries included" frameworks like goa (https://goa.design/)
So far with go, It's more about having quality packages than having a hundred left-pad. Personally, I like to write in a language where I can see the best practices, where main frameworks are well established and I don't have to run a 1GB boiler plate for an hello world.
There is bunch of reasons why smarts people like TJ (express/koa creator) decided to leave Node.JS for Go. https://medium.com/@tjholowaychuk/farewell-node-js-4ba9e7f3e52b
2
u/Capaj Apr 16 '18
How about sticking to REST next time? I get shivers when I see endpoints with random paths like that. Also node.js app could have been written more succinctly using koa.js.
1
Apr 16 '18
res.send(ToDo created: ${JSON.stringify(todo)}).status(201);
Please don't do this, or encourage others to do this. You're so close to sending down useful JSON that can be consumed by the client, but instead you prepend unnecessary text to the beginning and completely screw up the payload.
A response of 201 already indicates that the todo was created.
0
u/bmrobin Apr 16 '18
I've been interested in Go for awhile. this was a great write-up on your experience. thanks a lot!
0
Apr 15 '18
[deleted]
1
Apr 15 '18
Thank you! I've not tried rust, is there a reason you recommend it?
4
u/spacejack2114 Apr 15 '18
Seconded. I started tinkering with Rust a bit here and there and it's a pretty darned cool language and package manager (
git clone,cargo runis about a million times better than any cross-platform C/C++ install experience.) The main drawback is that support libs for things you might want to do may not really be there yet, or very alpha.5
u/bernardosousa Apr 16 '18
Thirded. First, I noticed that, on the official WebAssembly page, they only give three examples of languages you can compile to it: C, C++ and, you guessed it, Rust. I got curious. Wikipedia made me think about this notion of "safe code". With C at university, I was told " with great power comes great responsibility", meaning C lets you do dangerous things. It's up to you to be carful. Rust, in the other hand, tells me it will help me to write safe code without sacrificing any performance (unlike JS, which is not known for performance). I liked that promise and decided to listen to a few episodes of the New Rustacian podcast. Ended up exhausting the episodes. Now I'm reading The Rust Book, second edition. I have already explored short introductions about many languages. None have grabbed my attention like that. I don't know why I bought into it so easily, but I have a good feeling about where this is going. Hopefully learning Rust doesn't get me too frustrated about my day JS job.
0
Apr 15 '18
[deleted]
3
Apr 15 '18
Interesting! I'll have a look into Rust then! Thanks for the recommendation. I'm a self taught JS Dev so I'm always looking to pick up any missing concepts.
1
u/Cedricium JavaScript makes me go :snoo_putback: :table_flip: Apr 15 '18
Any good beginner-friendly resources for starting to learn Rust?
2
u/Dedustern Apr 16 '18
I've started to learn Rust over the weekend, it's really nice, though I will use Golang primarily at work. I can't really see many cases where Rust would be picked over Go? Although, the ecosystem/environment around Rust is much better than Go -- especially dependency management(which is a huge weakpoint of Go imo.)
0
Apr 16 '18
[deleted]
2
u/Dedustern Apr 16 '18
Yeah I'd really like to learn Rust but I can't really "imagine" what to build for fun? Like, with Go it's pretty obvious, and I've learned it pretty fast from building microservices, or doing disk I/O stuff. But coming from the "business logic" side of things, and moving towards systems/network engineering, I really have an issue picking up stuff to build. It's easier to make up some business stuff and solve it, than systems/networking stuff :-/
0
Apr 16 '18
[deleted]
2
u/Dedustern Apr 16 '18
I like fiddling with new tech. So it's fine. Want to build basic stuff, maybe I'll copy some of my Golang programs to rust :)
143
u/spacejack2114 Apr 15 '18
ಠ_ಠ