16 ms·
Why Go solves so many problems for web developers
- jmspring 11y agoThe post does nothing to compare and contrast approaches -- "In PHP I will need to do X", show X, the post doesn't. Seems to be upvoted because #Go.
- hdra 11y agoExactly! Many of the things mentioned in the post aren't really helpful in building a web app from scratch. In fact, Go simply presents way too much overhead for building a webapp from scratch. I see Go as an optimization tool when concurrency is needed, the same way I would consider using it to break some part of the app when it gets way too big. It works very well for those purposes. But I would never consider Go for building a web app from scratch.
- dham 11y agoLast time I checked, the problems facing web developers were(in no particular order): Rendering HTML templates / JSON Asset compilation / Cache busting Caching Sending Email Previewing/Testing Email Background Job queuing(with failure/retry/backoff) Reliable and easy integration/feature testing Connecting to database and modeling data Authentication / Account signup / Confirmation / Forgot Password Security Payment handling PDF / Invoice rendering Deployment Making pretty good money over here and how many ROFL scale GO routines I can run never really came up. ¯\_(ツ)_/¯
- stevewilhelm 11y ago> Authentication / Account signup / Confirmation / Forgot Password +1 And Authorized data access.
- codepie 11y agoI posted[1] asking specifically about this, a couple of days ago. But didn't get any response. [1] https://news.ycombinator.com/item?id=11152976 https://news.ycombinator.com/item?id=11152976
- redtuesday 11y agoIs djangos default authentication and authorization [1] not enough (since you mentioned django in your post)? If so you could take a look at django-allauth it seems [2] or maybe at Stormpath [3] (external service) or ABAC [3] (which is probably total overkill, too enterprisy and is only used for authorization as far as I know). [1] https://docs.djangoproject.com/en/1.9/topics/auth/ https://docs.djangoproject.com/en/1.9/topics/auth/ [2] http://www.intenct.nl/projects/django-allauth/ http://www.intenct.nl/projects/django-allauth/ [3] https://docs.stormpath.com/python/ https://docs.stormpath.com/python/ [4] https://github.com/cedadev/ndg_xacml https://github.com/cedadev/ndg_xacml
- Zikes 11y agoLots of people making pretty good money developing in whatever language best suits their environment or problem at hand. ¯\_(ツ)_/¯
- deleted 11y ago[deleted]
- tie_ 11y agoEven more people are making good money developing in the language/tooling they know/favor, while it is (comparatively) poorly suited to the problem at hand.
- hdra 11y agoYou forgot jumping on the hype bandwagon and getting a piece of the hype-rush. Seriously though, Go is a really good language. Its a simple yet solid & powerful language, but why would people feel the need to present it as the silver bullet for everything?
- twic 11y agoDon't forget binding posted form data to a model, and then validating it. It seems like 60% of my web development time is spent getting that right.
- webjunkie 11y agoGotta love Django's ModelForms
- romanovcode 11y agoYou should try ASP.NET, it will reduce your 60% to about 2%.
- deleted 11y ago[deleted]
- diminish 11y agoHere a list of why OP's list of advantages of Go for web developers: * Static typing * Web sockets * Concurrency * Unit testing * Speed * Syntax * Formatting tools
- pjmlp 11y agoMy web development experience, apart from an experience with TCL that teached me never to rely on scripting languages for serious web applications, is on the JVM and .NET stacks. Both eco-systems fill all those bullet points.
- cmdkeen 11y agoBy night I might play with Django and like it. By day I make good money using C# where I get all of the above at what seems to be a much more web appropriate level than Go. One of the things that I'm really liking about the ASP.Net Core rewrite is that a framework that has been around for ages is taking an opportunity to look at what it does well, what it doesn't and what other languages / frameworks have innovated on more recently and stealing liberally. C# has been through several cycles of how to write concurrent code now and offers both Task and async/await depending on your needs. Not only is web sockets support there but SignalR is there as a useful API for common cases. If you want even better static typing you can switch to F#. Not everyone was doing web development using single threaded dynamically typed languages before Go came along.
- w84t1me 11y agoIt includes the magic upvote string in the title: "Go". The content is irrelevant, as long as it's positive.
- vegancap 11y agoAuthor here, what were your issues with the content? Apologies for any mistakes etc. Still getting to grips with the depths of the language.
- w84t1me 11y agoMy comment was more about Go posts on HN being upvoted like crazy whenever they appear rather than any specific issue with your post. It's like a magic recipe for upvotes around here.
- vegancap 11y agoI was taken aback to see my post on front page HN to be fair! Considering it was just a brief opinion post haha
- deleted 11y ago[deleted]
- mobiuscog 11y agoI thought that was 'Javascript'. I'm out of date again !
- codecurve 11y agoIt feels like the author made the jump straight from PHP to Go without spending much time actually using Node or Ruby and he's subsequently shocked at how much better modern languages are when contrasted to PHP. Many of these "solved problems" have also been solved with the other languages, albeit not always at the surface level. For Node specifically: WebSockets -> SockJS, Socket/Engine.io Concurrency -> Generator Functions Testing -> import assert from 'assert' and npm test Syntax -> Some great improvements with ES6 and solid styleguides (airbnb, standard) + eslint as an autoformatter The major win here for Go is that as a new platform it was designed with simplicity in mind. These features are probably easier to pick up in Go than any of the alternatives, which is great. However, don't make the mistake of thinking that Go is the first language to solve these problems.
- kayoone 11y ago> he's subsequently shocked at how much better modern languages are when contrasted to PHP yeah no, please compare node/ruby whatever to modern PHP and not some ancient versions you used some time ago. Modern PHP is very much up there.
- Shorel 11y agoAlso mention Laravel.
- prabodhm7 11y agoYou have made a really good research on authors background. His previous post really support your point dude.
- pluma 11y agoYou sound sarcastic. I'm not sure what you're trying to say. At a glance his previous articles seem to be about Go and PHP (with a little bit of shell scripting) as well, so GP's point seems to stand.
- vegancap 11y agoAuthor here, I have used both Node and Ruby fairly extensibly. I think I touched upon Ruby's performance issues in the post. That's why I don't consider Ruby a solid solution. Also, as far as I'm aware, Ruby doesn't have built in concurrency like Go does. Yes, Nodejs is close to being concurrent, but it really doesn't hold a candle to Go. Yes Node has socket.io, something I've used a lot and love. But Go has all of those features natively.
- lightyrs 11y agoThis was one of the more accessible Go articles I've found through hn but it would really help me if these types of examples included well-written implementations in other languages and frameworks (including third-party library implementations, if required). Does anyone have a link to an article or tutorial like that? Thanks.
- worg 11y ago"Or you can use channels, if you need a little more control." that means the guy doesn't even understand the `share memory by communicating` model of go
- vegancap 11y agoAuthor here, as I mentioned in the post I'm fairly new to Go still, so some of the edicts are unfamiliar to me. So apologies for any mistakes. This post was very much a 'why I really like Go over PHP these days'.
- m00dy 11y agoIs it only me who thinks that parsing JSON is a totally pain in Go ?
- entee 11y agoI haven't used Go, but have spent a lot of time in Scala. Any statically typed language means increased pain with JSON. Static typing really has made me appreciate a well thought out JSON data model where each key in a document can have one and only one type as its value. That said, as someone who spends a lot of time in Python as well, I can't express how much I love the deep autocompletion powers and dumb-mistake suppressing abilities of static typing.
- Zikes 11y agoIt is a bit of a pain, but I've found it to be a worthy trade-off for static typing. Finding documentation on the json struct tags was a lot more difficult than it should've been. This article seems to address a lot of the pain points I originally had: https://eager.io/blog/go-and-json/ https://eager.io/blog/go-and-json/
- grey-area 11y agoYou don't need to parse into a struct, you can also parse it yourself from map[string]interface{} if the JSON is not predictable.
- aikah 11y agoYou can unmarshall a JSON document into a map (map[string]interface{}) or implement some interface and unserialize JSON "by hand" with a method. Go type system is flat so it's often hard to express something without being tempted to "opt-out" from its rigid type system. The question is, is Go type system a good compromise between simplicity and expressiveness ? I guess language design is hard, because the competition (Nim,Rust,...) also have its share of issues.
- bostik 11y agoNot total pain, but certainly loses in convenience to python. Deserializing large and arbitrary JSON inputs is trivial with python's `json.loads()`. Element access rules have no dark corners (as long as you don't have pickled data in there). In contrast, Go and its `json.Unmarshal()` aren't that well suited for parsing arbitrary and/or complex inputs. However, if the expected input is well formed and can be directly mapped to a predefined datastructure, the convenience factor is pretty high. So, from my limited experience, I would say that JSON parsing in golang is more geared towards deserialising well defined transport formats than ingesting arbitrary inputs.
- eljimmy 11y agoI have spent a lot of time working with PHP and have also recently started using Go. The comparison between the two in this article seems shallow and kinda comes across as simply jumping on the PHP-bashing bandwagon. Good on him for learning a new language, I guess.
- smt88 11y agotl;dr Someone who doesn't understand his tools chooses PHP, and then he tries Go and likes it. But he still doesn't understand his tools. For examples, he "likes the idea of" typing, but never explains why (or why not) others should feel the same way.
- digitalpacman 11y agoSounds more like a "PHP isn't fun" post than about go. You ever try C#?
- egeozcan 11y agoExactly. I really think so many people happy with go would be way happier with C#. I see one of the reasons people don't adopt C# is "because Microsoft", which is sad, because it's such a great language.
- baconizer 11y agomore and more clients specifically required Linux at the start of conversation, this ruled out C# despite our 10+ years of experiences on MS products in our industry. (also ruled out Mono, we decided to transform and adapt and there are far better choices)
- pjmlp 11y agoThere is always Java instead of .NET, with several possible languages as option.
- konart 11y agoThe language is great, but can I compile and run this code on *nix without headache?
- egeozcan 11y agoIf you are developing a web application and do not need to use any Windows APIs, then yes, you can compile and run on Linux without any headaches.
- hnbroseph 11y agoi guess it depends on what one means by headaches. mono on linux has never been a significant interest for xamarin, and core-clr is nowhere near production ready. maybe if jetbrains' project rider gains traction and core-clr and/or mono-on-linux matures it will be a broadly appealing option.
- merb 11y agoI'm still not get the go rant. I mean it's not bad, but it's not great either. Programming in Java8 could be way easier than with go and has a better Concurrency model (CompletionStage), it sometimes could be overly verbose however that's not always a problem. Go is just good for some things, not for all.
- omaranto 11y agoThe title is strange: the article is actually about how Go solves problems for web developers, not about why.
- vegancap 11y agoSorry, shitty grammar. I've changed it now, good spot!
- vasilakisfil 11y agoHave you looked at Elixir?
- chalgo 11y agoNo mention of the pain actually setting up PHP web servers? Knowing how to tune apache/nginx fcgi etc?
- vegancap 11y agoGood point! I'll add that in, seems an obvious one to forget. I've been using nginx to load balance Go api's, so I guess I was still using nginx.
- Matt3o12_ 11y agoOne thing that always seemed pretty hard to do in Go was security. Most companies will stop at SQL Injections but I consider defense against XSS, and CSRF attacks just as important. And that is something Go does not excel at because I have not found any framework that makes adding these features as painless as possible. (I have only toyed with Go for the web so I might be wrong). Django (a python web-framework), on the other hand, is pretty good at these things[1] because they require little to no extra work, so that junior developers like me will get it right. That is the reason I would always go to Python for web development instead of Go, although, I like Go just as much and it is so much quicker. I'd be interested to hear how the big projects migrate these kind of attacks in Go. [1] https://docs.djangoproject.com/en/1.9/topics/security/ https://docs.djangoproject.com/en/1.9/topics/security/
- masklinn 11y agoI may be mistaken, but I'm reasonably sure with respect to XSS (in HTML templates anyway), the built-in html/template autoescapes provided parameters by default, much as Django templates do. You have to mark "trusted" or "pre-escaped" parameters explicitly by wrapping them in e.g. `template.HTML`.
- mayhew 11y agonosurf [1] is a pretty popular CSRF protection package for Go. You need to realize that Go's built in "web framework" is extremely minimal unlike Django. It's more comparable to something like Flask, which also doesn't have CSRF protection built-in. [1] https://github.com/justinas/nosurf https://github.com/justinas/nosurf
- austerity 11y agoAs someone who is fairly enthusiastic about Go and has implemented a few livelihood-providing production systems in it I am baffled by the number of people who keep trying to use it for application (and especially web application) development. I mean it does feel like superpower when applied to tasks you'd previously have to use C for. But have you tried any of the modern web development stacks? They are like a zillion times more productive. Hint: PHP is not one of those. I guess some people just can't get by without the iron hand of the compiler :)
- spdionis 11y agoI'd say PHP is definitely one of those. Modern PHP web development is pretty productive and definitely high quality. EDIT after reading the article: I do have to agree that concurrency in PHP is a bit of a pain, but those 3d party tools are pretty easy to use and maintain. > Without significant forethought to several levels of caching; such as in memory caching, op caching ... This is so trivial to setup it's not even worth mentioning. > Sure, PHP has PSR standards etc, but they're fairly new and developers have been slow to adopt them. Everyone I know and every library I use uses those standards. PHP is pretty standardized now, especially compared for example to js. PHP frameworks work well out of the box and contain solutions for most use-cases. Go is nice but when I tried it I really missed something like composer. "go get" and commit your dependencies to the repository? Seriously? That's wrong on so many levels. Meanwhile I think composer is one of the best package managers around.
- onion2k 11y agoI do have to agree that concurrency in PHP is a bit of a pain It is, but the overwhelming majority of tasks in a web app don't happen concurrently, so it doesn't matter. When it does matter just use something else.
- paulddraper 11y ago"just use something else" That's what I do! (Actually, I do that from the start of the project, so that adding something as pedestrian as concurrency doesn't involve a complete port to another language.)
- onion2k 11y agoI also found myself relying on a lot of third party vendors in order to do some more complex tasks, such as queuing, web sockets etc. I found myself using Pusher, RabbitMQ, Beanstalkd etc, etc. This felt kind of wrong. And yet it isn't wrong. Standing on the shoulders of giants who built, tested, and optimised applications that do complex things far better than anything an individual could ever do on their own is how you build scalable applications that don't fall over.
- wpietri 11y agoAlthough I don't deny that tanker trucks are pretty amazing feats of engineering, sometimes I just want a glass of water. Instead of figuring out how to purchase one, drive it, and park in my back yard, it's pretty nice if I can just turn on a tap, fill a glass, and turn the tap off again. The tanker truck isn't "wrong", but it sure is a lot to deal with.
- harryf 11y ago> In PHP I'd have had to use either some thread execution hack, delegating a task to a new thread using shell_exec() That's not a thread, that's a child process. Very different model of concurrency...
- vegancap 11y agoAuthor here, thanks for all your (albeit brutal) feedback :)
- pjmlp 11y agoCorrection, web developers that never used Java, C#, Scala, Clojure, F#, VB.NET, Haskell, OCaml, Erlang, or even languages like Ada or Delphi.
- cies 11y agoGo is as great for concurrency as Node.js: it forces one particular type of concurrent programming on the programmer, which IMHO does not qualify as "great". Many languages give the programmer a range of options when it comes to concurrency, including the options Go and Node.js offer. Some languages even allow these options to be implemented as libraries (so they do not have to be built-into the language; though can become part of the standard lib).
- mjw_byrne 11y agoI've done real-life web dev using PHP and using Go, and have dabbled with Node. Thoughts: 1. Go's strict, statically typed, thou-shalt-check-thy-errors approach is a breath of fresh air. The compiler does a whole load of checking which can (and therefore should) be automated, which in many other languages is left to the developer. Go code tends to have the property that if it compiles, it probably works as designed. I love this. 2. IMHO it makes more sense to think of a web app as a server application one of whose functions is to listen for and respond to HTTP requests. So, the question I'd ask is "is this a good language for server programming, and how easily can I make it speak HTTP?" In Go's case I've found the answers to be "hell yes" and "very". 3. The tooling is really nice. go fmt takes a whole load of pain away from everyone (no more effort required to format code properly, the tab/space and where-to-put-the-{ debates are solved decisively, reading other people's code is made easier), the package management is lovely, statically-linked executables are easy to move around and go doc encourages proper commenting. 4. Really good performance. 5. The biggest drawback I've seen with Go is verbosity - although a lot of the time it turns out that my verbose Go code is checking errors properly and my compact PHP code wasn't.
- codygman 11y ago> The compiler does a whole load of checking which can (and therefore should) be automated, which in many other languages is left to the developer. Go code tends to have the property that if it compiles, it probably works as designed. As someone who works with Go daily, these statements are both very untrue. Claiming "if it compiles it works" applies to Go code makes my eye twitchy. For instance, type assertions have no exhaustivity checker. Interface{} and liberal usage of it throws type safety out the window. > the package management is lovely, Go doesn't have package management per SE, just vendoring.
- mjw_byrne 11y agoI did fudge a little - "tends" and "probably". Of course compilation is not a guarantee of correctness, I just find that it gets me most of the way there. JavaScript, by comparison, feels like it's trying to give you rope to hang yourself. Maybe I'm abusing the term "package management". I'm talking about go get, the way imports function, the cute private/public lowercase/uppercase mechanism, the recently-added vendoring support etc.
- girishso 11y agoThe real pain for me to share variables from different handlers in the chain (middlewares). I know some frameworks and libraries provide "contexts", but it's something that should have been part of the standard library.
- bsaul 11y agoWhat about DB (sql) access ? The 90% user case for any webservice today is : - parse request (ok) - issue a serie of DB requests <-- GO PAIN POINT - serialize result into either HTML (ok) or Json <-- PAIN POINT I'd say 2 pain points out of 3 is pretty bad IMHO. I would recommend go only for very specialized and technical web services, such as a websocket server. But really not for the average web developer task.
- MoOmer 11y agoWhere are the pain points in DB requests or serialization? I've written several web apps with Go, and lots of ETL, and have yet to feel those as pain points.
- bsaul 11y agoGolang has nothing close to sqlalchemy, linq, activerecord or hibernate when it comes de querying a database. Last time i used go i had to write every single query and bind them manually to records in both ways. For writing simple api endpoints, this is really not up to today's standards.
- deleted 11y ago[deleted]
- wtbob 11y agoI sure wish Go would solve the problem of blogs which hide content unless JavaScript is enabled … Seriously, why is this even a thing? Why gratuitously prevent Firefox + NoScript from working?
- muloka 11y agoWhat about Lapis and Moonscript for web development?
- jasonm23 11y agoI like Moonscript and Lapis seems decent enough, but the community is still microscopic.
- romanovcode 11y agoAs a guy who writes web stuff in C# - Go solves absolutely 0 of my problems. In fact it introduces problems rather than solves them. Go is excellent but using it for webdev is stupid, sorry.
- agentultra 11y agoGolang doesn't solve any problems for web developers. Libraries solve problems for web developers that web developers have. There are libraries to solve web developer problems in every language used to write web applications. The quality of those libraries and what they let you get done is what matters. Golang solves the problems of moving bytes from one place to another with certain semantics and guarantees.