18 ms·
Re: Moving from PHP to Go and Back Again
- rmanolis 9y agoI use Golang for everything. For example I use GopherJs with polymer for the front-end and gin for the back-end.
- edem 9y agoI see no facts or genuine refutation in this article, just opinions. Therefore I can only assume that truth hurts because the article you are trying to argue with has a bunch of valid points. If you look at the history of Go you have to realize that it was created for the reason which is in the original article: to be a better C. If you come from C it is good, sure. And you can write big projects in it like in C (just think about Linux or Unix). But if you come from a high level language like Java (which is also performant by the way) Go feels like wearing a straitjacket! Go lacks the most basic tools which any seasoned developer can expect from a language (like generics). Just look at [my response](https://medium.com/@addamsson/this-article-is-wrong-in-so-many-ways-47c91584fd6 https://medium.com/@addamsson/this-article-is-wrong-in-so-ma...) to this topic elsewhere.
- majewsky 9y agoOkay, let's say I agree with your arguments: 1. Go "is still not as fast as Java can be" [1] 2. "Go lacks the most basic tools which any seasoned developer can expect from a language (like generics)" 3. "Go does not have a de facto build system and you can’t handle dependency management in an easy way" [2] 4. odd error handling 5. not a lot of libraries to choose from [3] 6. possibly more arguments that I missed when summarizing your post The way you paint it, people would be stupid to use Go. However, thousands of very talented developers use Go everyday. How can you explain this disconnect? [1] I like how you didn't say that Go "is not as fast as Java". That's a subtle, but important difference. [2] `go install` is the build system and I have solved dependency management for myself with literally a small shell script [4], and an official solution is in the works [5]. [3] I never had trouble finding libraries for use-cases both common and obscure). [4] https://github.com/holocm/golangvend https://github.com/holocm/golangvend [5] https://github.com/golang/dep https://github.com/golang/dep
- Erlich_Bachman 9y agoIt's not really stupid, it can be misinformed, or just a matter of taste. For some people having a small couple of specific qualities of a language is more important (because they "like" them) is more important than even some objective overall quality/ease of use. Many people are just forced to used it because the company uses it. And of course, all the people who actually ARE looking for a "Better C" - then they will of course use something like Go. It would be very "stupid" to use Java in that case.
- GenericsMotors 9y ago> The way you paint it, people would be stupid to use Go. However, thousands of very talented developers use Go everyday. How can you explain this disconnect? Billions of people hold staunch religious beliefs, yet this doesn't mean they're stupid or mentally handicapped.
- edem 9y agoIt is not about stupidity, more like the blub paradox. If you only know C and Go you have no idea why for example Kotlin would be better for the majority of the cases because to see it you have to use it.
- jstewartmobile 9y agoI came to it from embedded C, and would not call it a better C. Not that it is bad. It is just a wildly different use case. The lack of a preprocessor alone (as ugly as that may be) rules it out for a great many embedded and cross-platform scenarios. The binaries are also fairly enormous. 10M for a shell util on a desktop may be good enough. Beneath that level, it is a deal-breaker and a scandal. Agree with the straitjacket part though. Comparing it to something like Clojure, the best I could say for it was, "At least I don't have to deal with the JVM..."
- powerslacker 9y agoYou are unfortunately right about the embedded scenario. It always ends up being a C/Go abomination - and eventually you end up asking yourself...why didn't I just use C?
- deleted 9y ago[deleted]
- klodolph 9y agoEveryone I know who uses Go complains about it. Every day you write Go code you will come across some piece of code that would be shorter with templates in C++ or using <algorithm>, or you could do it more simply in Python, or if you were really clever it would be a single line of Haskell. And yet we keep writing Go. By comparison, I'm a bit put off by the Rust community's evangelism, but that might just be my personal experiences with Rust community members.
- baby 9y agoI'll give you my point of view then: I'm super happy with Go and way less happy when I have to read C++ with templates.
- pjmlp 9y agoNot me, I only touch it when the customer says so, and it is usually Docker related assignment.
- megaman22 9y agoYou're attempting to slaughter all the sacred cows of this community. I predict that will end badly
- alrs 9y agoI use the quality of people's complaints in interviews all the time. I like it when they have a complaint but can see why the trade-off was made. I don't like it when they're obviously parroting HN group-think. I really don't like it when they have no complaints at all, but are able to recite the marketing happy-talk verbatim.
- emj 9y agoOften people are in all of those categories, they use what I see as marketing speech to talk about their own experiences. Those experiences might differ from mine so what I dismiss as parroting or marketing is later shown just to be difference in opinion. I admire people who can spot such things effectively and steer discussions in an productive manner. I see now that this is not really about interviews anymore but just everyday discussions.
- cft 9y agoI don't know why the author bothered to even respond to that Medium article. The Medium article starts with that Go shines as a systems programming language. He lost me right there: how can a language with a garbage collector and a runtime be called a "systems programming language"?
- pjmlp 9y agoSince Xerox PARC, UK Royal Navy, DEC, HP Labs, ETHZ, Microsoft Research have implemented full stack OSes in GC enabled systems programming languages. At ETHZ Oberon workstations were used during a couple of years by several users across the department. Most of those attempts failed due to losing the political and financial wars of bringing them into the wider market, not because of lack of features.
- cft 9y agovery interesting. I would have thought that any practical kernel written in a language with a GC would either have unpredictable slowdowns or be exceedingly complex.
- pjmlp 9y agoBlue Bottle OS, the last Oberon OS iteration done with Active Oberon had a video player as part of the standard set of applications. Just because there is a GC doesn’t mean it is the only way to allocate memory.
- jstewartmobile 9y agoWe already sacrifice some silicon for TLBs and other memory management features. Many older architectures sacrificed bits for tag information as well. Perhaps one day we will sacrifice a little more silicon to get performant hardware-assisted GC? Or not.
- pjmlp 9y agoThat is one area RISC-V guys are looking into, with Jikes RVM. "Grail Quest: A New Proposal for HW-Assisted Garbage Collection" (PDF) https://people.eecs.berkeley.edu/~maas/papers/maas-asbd16-hwgc.pdf https://people.eecs.berkeley.edu/~maas/papers/maas-asbd16-hw... Also Intel did have hardware GC with i432, but the chip suffered from many design errors that made it quite slow.
- maaaats 9y agoIt's not a good start when you have to resort to gifs ridiculing the other article.
- tempodox 9y agoYes, I wondered whether I was the only one that found this article a bit patronizing.
- adventured 9y agoIt did come across as quite patronizing. Particularly in contrast to its light-weight argument style that almost exclusively consists of one-sentence opinions, stated as fact, with very little behind them.
- maaaats 9y ago(the article has been tweaked a bit after being featured on HN, just in case my comment now seems out of place)
- frik 9y agoPHP is unique in several ways: it's especially designed for the web, is a Web framework itself, comes with everything inbuilt, has C/Java syntax, has a shared nothing architecture, replaced VB as the most popular language for beginners, is used by most websites, is easy to use just drop a php file to Apache www dir. You simply can't objectively compare PHP to other languages because it's different to all others, it's unique. And due it's wide spread usage and earlier non-academic approach it still gets (rather unfairly) some bad reputation. Anyway PHP 7.2 is great, and Go too.
- jstewartmobile 9y agoBut a pokemon character was rather unkind to it back in 2012, so here you are. Two years after that, Mickens wrote a glorious takedown[0] of Javascript--which must not have been as glorious as I thought--since people still seem hell-bent on using in as many places as possible. Alan Kay said that computing is now a pop culture... [0] https://scholar.harvard.edu/files/mickens/files/towashitallaway.pdf https://scholar.harvard.edu/files/mickens/files/towashitalla...
- spdionis 9y agoI mean, the way people bash PHP and praise javascript is completely ridiculous. The two languages are comparable at best in the amount of warts they have, while my firm opinion is that the js ecosystem is the most horrible thing in the world.
- deleted 9y ago[deleted]
- jstewartmobile 9y agoAMEN!
- warent 9y agoGo is not OOP in any shape or form, no matter what “they” try to tell you. Go is imperative language with procedural style of writing code. Yes, you have objects and you can attach methods to them, similarly to Ruby where everything is an object, but that’s basically it. Never, ever, try to repeat yourself in Go. You will crash and burn. When it comes to Go, spaghetti code is what you want to write. This was really funny. Definitely the rantings of someone who is used to too many layers of abstraction and coded themselves into a corner before finally blaming the language. I'm detecting a lack of self-awareness. Here is where the author should have used the gif that was used at the start of the article
- powerslacker 9y agoyou got me to make an account and move the gif, I hope you're happy with yourself
- warent 9y agoHappy enough to give you the ol' retweet: https://twitter.com/ArentWyatt/status/940480529740193792 https://twitter.com/ArentWyatt/status/940480529740193792 Italian chef kiss EDIT: p.s. thank you for designing your website so that can actually handle some traffic. That's worthy of the hacker news gold achievement
- majewsky 9y ago> thank you for designing your website so that can actually handle some traffic. That's worthy of the hacker news gold achievement Not really. When I had a blogpost on the frontpage for the first time, I checked the monitoring and saw a CPU load of 6% of a single core and 1 megabit per second (that's bit, not byte). [1] And it's simple, really. You just write some text on the page, add a small stylesheet. And then you just stop, resisting the urge to add any JS and tracking and hero images. You just stop. And instead of generating your HTML on the fly from a database, you just serve a static HTML file. [1] Graphs: https://blog.bethselamin.de/posts/latency-matters-aftermath.html https://blog.bethselamin.de/posts/latency-matters-aftermath....
- comandillos 9y agoFrom My point of view. Go is a great language and this author is right when talking about using Go is better than PHP in cases like Uber or Youtube. I mean, Im not a fan of PHP, I like to use low level languages the most time but web is complicated. First of all, I don't think that not abstracting all the IO and network HTTP socketing or all this stuff 'helps' somehow developing a 'better' web app. Maybe for Uber, Youtube, Google, Docker, AWS, yeah. But for the most of everyday-apps for small/mid-sized business? I don't think so. I mean, it would be great but from my point of view, developing a Go web app for this kind of business, but it could be a little bit overenginered. Using PHP/JSP would be much more straightforward for the developer/s, and maybe for maintenance. The entire cost of the app will be greather as Go developers for Web Apps cost you more than any PHP/JSP programmer out there. Remember Ruby? It's the same problem. From the point of view of engineering, right, take Go, but I think sometimes, isn't necessary. PHP is not the solution but will solve you some problems that could be great for even mid sized businesses. Just my opinion.
- powerslacker 9y agoI think JSP is a great contender, and I see your point about overengineering. PHP with type-checking is alright, but if I'm going to use a scripting language I'd prefer Python or Ruby.
- patricklouys 9y agoBoth ruby and python seem to encourage duck-typing. I worked with both of them in the past and that's the main reason why I always came back to PHP. I need my type declarations...
- spdionis 9y agoAgreed. The way i see it for the web is PHP is just a better Ruby/Python in terms of libraries, package management, deployment, language features, performance, with the only drawback being a quirky standard library.
- paxys 9y agoAll of the points this article makes are already addressed in the last one. Yes, Uber is running a production Go service with massive QPS. This is exactly what the original author meant when referring to Go's strengths with single-purpose, high performance, "nano" services with relatively little business logic. There is also the insistence that frameworks are bad and developers absolutely have to care about "granular control" and "manipulation of bytes and bits" and packets and IO (unless they're writing a "glorified todo list") which rubs me the wrong way. Why is it so hard to acknowledge that there are a large number of perfectly good websites and codebases that do well with popular frameworks? We ourselves have a proxy layer and a couple other services written in Go, and they work great, but the rest of our stack is Java and some Python. Developers are free to choose the best tool for the job when starting new project, but after a few days of messing around in Go every new service is undoubtedly built using our existing web stack.
- deleted 9y ago[deleted]
- pmontra 9y agoI don't know Go and I didn't use PHP very much so I'm qualified to comment only on this part: > I’ve worked with RoR, and a variety of frameworks in the Node world – and I have never had a framework project where I didn’t end up fighting the very system that was supposed to make development “easy”. This is not my experience with Rails, Django and Phoenix. Actually, I was probably fighting Rails in my very first project in 2006 (or was it 2005?) but I was writing it as if it were Struts (I was coming from Java.) Then I started coding as if it was Rails and got a great speedup in terms of coding time. I'm less proficient in Django. It seems that it doesn't really enforce a project structure and one can do almost what s/he wants. I've seen projects that look very different to a degree I never saw with Rails. Basically all Rails projects look the same. Phoenix is somewhat in the middle. So, if the author is wrestling with frameworks either he's not proficient with them, but this doesn't seem to be the case, or he genuinely doesn't like to be constrained by the requirements of those frameworks. This is not a bad thing per se. If one feels like that, he's going to be a happier developer writing code with the architecture he designs. I'm not sure customers will be happy too, but I don't know what kind of projects and customers he has. About me, I prefer to stick with standardized architectures that any developer after me will be able to understand in minutes. I'm a freelancer and I just don't have the time to spend a significant amount of my customers budget to learn (and make learn) more clever and optimized architectures before doing any real work. If I had my company running around one software product, then maybe I would design it from scratch. Reality check: I wrote so many MVPs in Rails, especially for customers. Given the usual outcome (failure to get traction) it would have been a waste of money to start with a more clever design.
- zaarn 9y agoFrameworks necessarily limit what you can do. For example, the labstack echo framework in Go is one of my favorite frameworks, it does a lot of work for me. On the downside, I can't hijack HTTP connections in the router, like for example, when I want to host something under customs domains and redirect internally to a subURL. I have to hack around the framework to do that, the solution is rather ugly. But there isn't much I can do otherwise that doesn't have various amounts of bugs. Frameworks will always limit what you can do, period, you will have to code around them once you want to do something they don't allow out of the box. On the other hand, the less the framework does for you, the less limiting it is but in the same moment it also does less work for you.
- rakibtg 9y agoFrom my point of view PHP 7.2 is a great choice for startups and with a small team, so build the product, make it run. If required then do some R&D to switch to go, jumping straight into go should cause some issue.
- heavenlyblue 9y agoGood luck hiring actual software engineers and not the ones who just managed to get into IT during the SEO boom. They are probably less expensive than the Py ones, but they probably don't have much of a future either.
- deleted 9y ago[deleted]
- cweagans 9y agoStill parroting that old trope, huh? The quality of an engineer is rarely dictated by their tools. You can be an excellent engineer with a shitty language, or you can be a terrible engineer with a great language. I'll be the first to admit that PHP certainly has it's share of really bad developers, but what language doesn't?
- heavenlyblue 9y agoIt is an old trope - I completely understand your point, but the fact is: wherever you're professionally going, PHP is <probably> not the language you'd like to use anyway. So why use it? I could see how doing FORTRAN for a banking institution is a good way to make money; but PHP doesn't even have that. Most of my closer friends with a Computer Science degree would probably try to stay away from PHP: neither does it pay better than other languages, and most of the companies that have chosen to work with PHP <probably> don't seem to be that appealing either. Is that an old trope? Well, I am parroting the industry: I had worked with PHP and I had realised that none of the cool people with money would do PHP anymore. It literally is similar to not using git in 2017 - if you're still doing PHP, then you're probably a dying business or a really bad software house.
- maxpert 9y agoI have been writing Go, Node.js and PHP for quite a while now. I don't think golang is overhyped; nor it's a silver bullet. There are systems like Kubernetes, etcd, and so on that are implemented in Golang and they work really well. I think problem is people trying to use Golang for EVERYTHING! There are so many things I would disagree with in the article; but I won't disagree with the fact that if you want language with dynamic nature (Ruby, PHP, JS) and you expect to find those conveniences in Golang you are flat out wrong. Reading original article this is the exact feeling I get, somebody was like "look look a cool new toy" and the herd followed.
- edem 9y agoIf you look for an oop or fp language you are also out of luck. You are only happy if you look for a better C which most people aren't.
- fileeditview 9y agoEven then you can go wrong. I've learned that first hand while trying to write some lower level networking stuff in Go. Also OOP in Go is perfectly fine.. it's just by composition only and without inheritance.
- lloeki 9y agoMany people were taught OOP the UML and Java way†, to which the concept of prototype-based inheritance is completely alien, while composition is not even on their radar. † Although they have their fair share of issues, this is not a jab at UML nor Java themselves, but the way things have been taught, terribly, for so many.
- fileeditview 9y agoYes that's true. When I was at university we learned about the concept of composition but the reference language for this 'software engineering' course was C++. The whole composition idea felt contrived at that point. Some time later I learned Lua for fun and almost instantly understood what this whole prototype based programming / composition was about :) TLDR: While I learned about composition at university, they failed to really show how it is used and what it is good for..
- robryan 9y ago> These are hard issues to solve with PHP, so hard that Facebook hand crafted a SPECIALIZED VIRTUAL FREAKIN’ MACHINE to deal with the performance issues inherent in PHP. Does that really seem like an “easy” solution? It is worth noting that this was pre-PHP7. Post-PHP7 the out of the box performance is similar or better to what Facebook did with the HHVM.
- mschuster91 9y agoAlso, very few projects will ever end up at the scale (user base/metrics) that Facebook had. 99% of all PHP software will be fine with a quadcore server with 4GB RAM, running a LAMP stack. This can be scaled as needed (eg moving off mysql, adding a reverse proxy, real load balancing).
- j0rd 9y agoI've always been really skeptical of those language performance comparisons which refer to PHP. As stated above PHP7 has similar performance when compared to HHVM which was made by Facebook. Additionally PHP has an amazing performance debugger by FB called xhprof. PHP performance could always be increased hugely by making sure is cache buckets have enough memory (opcode cache, realpath_cache_size). Secondly with any web framework your app will most likely be limited by IO (database, file lookups, networking) before it becomes limited by actual code execution performance. If anyone's ever worked on a project where the performance problem was the language and not IO I'd be really interested in hearing about it, but in my career of making websites I've never ran into this problem yet.
- blowski 9y agoDepends on the use case. I've definitely worked with projects that required a ton of capacity, because the realtime search functionality was booting the full Symfony framework every time someone typed in a letter. To get rid of those performance problems, someone builds a fragile mess of PHP. In that case something like Go or Node.js is a much better fit to the problem. But if you're building a big old MySQL CRUD app full of complicated business rules, PHP makes a lot more sense.
- jstewartmobile 9y agoHow many people here subscribe to the "they're all DSLs" theory?
- HeadlessChild 9y agoWow, that's a first. The website is hijacking the "go back" button for Google Chrome.
- tluyben2 9y agoNot strictly about Go, but how is it supposed to impress that 'big company X' uses language Y (in this case the author uses Uber as if that's some kind of + for Go); I would be far more interested in the language + framework used to solve what level of complexity and scale problem with how many servers + people. If you can build & run something with less people and servers than your competitor and which makes you make more money, I think you have something in terms of framework and language. I think K/Q exists because of that and Janestreet uses Ocaml for that reason. Also one should not forget that a company with 1000s of engineers is probably not you (yet); when you read that some company runs successfully on Node and saves $n amount of money by using it etc; when they have 1000s of engineers and devops on top of that it doesn't mean you can achieve the same (or any) success with it with 2 people. PHP for instance might be a much better choice with a small team; you don't need complex server setup, you don't need (or can handle) middle of the night alerts that require you to dive in vs just reboot the server etc.
- heavenlyblue 9y agoHow is restarting a go-based server harder than restarting a PHP-based server?
- tluyben2 9y agoFor most setups at most ISPs, PHP servers are zero setup, self contained systems which, without any setup from the client (the user, you), comes back after reboot with no issues. It has also been the case for 15+ years so it's quite something you can actually trust to happen. This is not so for Go or Node for most hosters out-of-the-box. Sure in the HN echo chamber, every hoster offers this maybe, but there are literally 100000s of small/big hosting companies/resellers in the world that run, say, CPanel. And the only thing that is trivial there is LAMP (with PHP/MySQL) hosting; the rest is just not very convenient or even impossible. So once you set it up, no there is no difference, but then you have to know how to set it up, secure it, have access to set it up and secure it and know how to maintain it which is the point i'm making (not meant about specific environments besides PHP/MySQL); if you are a small company that needs to make money, you might not(!) want to bother. Edit: Cpanel, in some near-future version will offer Node, I cannot find Go though. Edit2: I'm definitely not recommending anything here or saying Cpanel is any good; I just know it well and I know that it's the most installed 'admin panel' on hosting servers.
- herpderperator 9y agoAt my job, before I joined, I was told we were torn between using Go and Rails and ended up with both. Now we have a Rails frontend (for web requests / authentication) and a Go backend (for business logic), which communicate over Thrift RPC. I don't think it was a very wise decision because not only are you doing things twice, you're doing it three times, because you have to serialize/deserialize to/from Thrift for every request. It adds development time, more tests, and Thrift's binary protocol makes debugging RPC almost impossible. This isn't really an argument for/against Go, but it just shows that you should try to avoid using multiple codebases that have to be tightly integrated. Personally, I would've gone with a Ruby-only codebase that used Thrift RPC only if there was some backend task that was too slow in Ruby, and that Go's concurrency and speed might be better at. Then I'd serialize it and send it over to be processed by a better language. I wouldn't do it for every request. That being said, if I had the choice between writing an API in Go vs Rails, I would do it in Rails for the faster iterative development speed and quick debugging capabilities that is made possible by an interpreted language.
- bm1362 9y agoHave you tried thcurl or yab for debugging RPC? I’ve found that most services I consume using thrift have a yab template for easy testing and trace ids so I can follow the request- I haven’t really missed hand writing JSON curls yet. https://github.com/yarpc/yab/blob/dev/README.md https://github.com/yarpc/yab/blob/dev/README.md
- heavenlyblue 9y agoFor god's sake - does the structure of this project do any good to the company, or is it just there to familiarise the developers with a variety of technologies so that then they could go to another company and boast having used all of them? Hard to debug binary-based RPC? You have picked the wrong technology for communication, having forgotten that you'd need to build the necessary tools in order to debug it. There's literally nothing wrong with binary protocols, except developers forgetting about the necessary overhead of re-parsing the passed data in the debugger. But it's not an overly expensive overhead, if the architect had taken this into account. Having heard this point absolutely not for the first time, the only question that remains is: who and why did make a decision to have it this way?
- jaccarmac 9y agoPerhaps it's characteristic of all language discussions, but Go articles seem to generate an extremely polarized set of comments. My other favored languages (Common Lisp, Nim, Rust, Smalltalk) tend to do the same thing, but in Go's case the passion seems so... misguided. In my opinion, Go is just such a bland-in-a-good-way language. And I enjoy writing it, for the record. Came back to it after a while not writing it and discovered warts I had missed before, but it's still pleasant. Can't help but think people just need to relax a bit when it comes to Go. Listen to Rob Pike speak about it compared to Rich speaking about Clojure: Go's not the language to get worked up about. (Please put generics in Go 2!)
- cies 9y ago> (Please put generics in Go 2!) This. At least this is easily added. But why there is "nil" in Go I find less excusable, mainly because this "feature" is not easily (impossibly) removed.
- nine_k 9y agoWhen "bland" means "prone to copy-paste boilerplate", its starts to sound less relaxing. It sounds more like tedious search-replace and looking for not making a typo when adapting the boilerplate to the next similar-but-sightly-different use case. It turns a developer back into a coder. What Go takes away is mostly tools of abstraction. Some of them are removed for a reasonably good reason (hard to implement in 1.x). Well, people end up with codegen tools that replace not only templates and generics but also the C preprocessor.
- musage 9y agoI know this is about the weakest critique possible, but currently using Go, I know my next project won't be in it, simply for the impossibility to put an opening curly brace on its own line. Other languages that don't require semicolons at the end of a line have it, and even if they didn't, I'd rather have to put semicolons manually.. Go is "opinionated" I guess, but so am I. Whatever their target audience is, I'm not in it. One thing I used to hate about PHP but then kinda grew to like was variables being prefixed with a $, as it makes it real easy to distinguish between functions and variables at a glance. Other than that, it's just programming. For me, who is making really simple things, 99% of the work is figuring out the pseudo-code and data structures, if the language doesn't get into my way, they're pretty much all the same. I haven't tried Rust yet, but from a casual glance I do like what I see.
- donjoe 9y ago... curly brackets on new lines do work perfectly fine in case you're writing code on your own. As soon as you start working in a team and each team member starts to use their own formatting, it becomes super messy and unreadable. Either you inforce a clear style guide which leaves you to explain the team why your style is the best, or you leave this task to the language itself and never ever have to start arguing about curly brackets, whether to use tabs vs. spaces, ... (I'll stop here).
- musage 9y agoBut why should Go enforce it on behalf of everybody? A parser option to not automatically insert semicolons would be all I need, but no. To me, even with super short lines, braces at the end of the line are messy, and consistently messy is still messy. > Either you inforce a clear style guide which leaves you to explain the team why your style is the best, or you leave this task to the language itself Which then leaves the language to explain why that style is best. Did Google ever do that?
- donjoe 9y agoGo's authors didn't explicitly explain their choice of style, yet they explain why they enforce it: https://golang.org/doc/faq#Is_there_a_Go_programming_style_guide https://golang.org/doc/faq#Is_there_a_Go_programming_style_g... https://golang.org/doc/effective_go.html#formatting https://golang.org/doc/effective_go.html#formatting Style guides are a matter of taste. None is better or worse. Yet, I really don't like discussing about my taste within a team of different tastes. It's like asking someone why he/she'd prefer black coffee over cappuccino. I'd prefer someone (or the language) making a clear decision upon code style and enforcing it rather than ending up with a messy, un-styled code base.
- throwaway2016a 9y agoSome background. I actually wrote a semi-popular book on PHP (published by a major publisher) and have contributed to the core project. And I have spoken at many PHP conferences. Perhaps tellingly, PHP is rarely my first choice anymore. Which I think it a great language (contrary to many opinions) I just find other languages a better choice. Today my language usage looks like this: - Web services / APIs: Node.js [1] - Front-ends that require easily modifiable templates and quick command line scripts: PHP [2] - When I need speed and low latency for a network connected app: Go [3] - When I need speed on an app that requires no network: C [1] The promise chain asynchronous nature of Node.js makes it great for web services in my opinion. And the ability to easily have global variables that persist across connections for things like caching and pooling is a huge plus over PHP. [2] PHP is very good at spitting out HTML and making web service requests, the performance is acceptable in most cases, and it is really easy for most people to edit, even people without a CS background. Likewise, for quick command like scripts PHP is unbeatable in my opinion. The tools it provides out of the box means most common command line tasks can be done 100% with the standard library. No package manager required. Though if you need to add packages PHP is pretty good about that now. Incidentally the fact the standard lib does so much is also one of PHP weaknesses. The standard library is a mess of inconsistently named functions and classes that grew organically over 20 years. [3] I've saturated my loopback network interface on a non-trivial app on my Macbook Pro using Go. PHP and node don't even come remotely close.
- chj 9y agoin latest nodejs there is no a single place to catch exceptions in promise chain, which is very inconvenient.
- fimdomeio 9y agoI think this discussions are mostly pointless... Most of the times I can see one side or the other being right depending on the size of the project, size of the team, time to learn something new.
- tcfunk 9y ago> Would you rather? > > A – Be able to write new code 50% faster > B – Have 90% less errors in all new code you write For my employer, this is the most important question of the 3, and the answer is A every time.
- wccrawford 9y agoI guess the answer would depend on how many errors you have in the first place. If you have a ton of errors, B is going to be more important. If you have relatively few, then A is going to be a lot better. My employer would probably pick A, too. But there's a hidden side to this: If it's that much easier to code quickly, it's probably easier to understand the code as well. Which means fixing bugs is faster as well. At least, in my experience.
- leke 9y ago50% is a big number. 6 months or 1 year. 1 year or 2 years. XD
- huntedsnark 9y ago> I have never had a framework project where I didn’t end up fighting the very system that was supposed to make development “easy”. Not always, but often, I find this attitude in developers who either refuse to read documentation, or just entrenched in their ways and too stubborn to try it someone else's way. Is every project you're starting really so cutting edge that the problems others have solved and come to a consensus on don't apply to you? Perhaps, but maybe you should also be taking a look in the mirror and making an honest assessment on just how difficult you are to work with.
- Drdrdrq 9y agoI recently used Python for a project and was again reminded why PHP is still the king of smallish web sites. With PHP I could rent a cheap service to host a few sites, no problem, take FTP and just upload scripts. That was possible 15+ years ago and still works today. With Python - not so much. Sure, I can rent a whole VPS but I don't want to do server administration. And there are some options for hosting Django / Flask apps, but not many. Is it any wonder people still use PHP? I have used it for a long time and I hate the language - but it is hands down the best solution for small web pages where hosting is concerned. EDIT: thank you for the downvotes. It was nice having a constructive conversation. But then again, I knew in advance it is unpopular to mention on HN that PHP, MongoDB and similar technologies have their use cases.
- Annatar 9y agoHe never went back to PHP and most of the article is spent on extoling Go, so the title intentionally misleads. I feel jipped!