Switching from PHP to Go

blov · · 772 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I have been developing web applications in PHP for about 15 years.</p> <p>As the language grows I get more and more frustrated with what I (just my personal opinion) think are unnecessary clutter added to the language. I also do not like how the PHP-FIG (again just my personal opinion) seem to be affecting the PHP community on a global scale with their PSRs and their rantings about how everyone are free to choose their recommendations, yet at the same time members work tirelessly in an effort to get everyone to adopt their so-called &#34;modern approach&#34;.</p> <p>I have developed other stuff than web applications in C, C++, Python and other languages. I have always enjoyed the &#34;small size of C&#34;, no clutter, and I think Go absolute looks fantastic and very well designed - especially by always having the least amount of code needed to get a job done.</p> <p>However, I feel uncertain about whether Go would suit my needs instead of PHP for web development. I mainly do custom made solutions for clients. This are all from custom shops to specialized intra-net solution.</p> <p>Anyone who care to share their experiences on shifting from PHP to Go for web application development?</p> <p>Note: I never use frameworks as I feel they mostly only add layers of complexity, I always build my own stuff, but do occasionally use specialized libraries with single responsibility and no need for further dependencies.</p> <p>Thanks!</p> <hr/>**评论:**<br/><br/>Mteigers: <pre><p>We switched our entire company from PHP to Go last year (around 6 developers). Besides legacy systems we still maintain in PHP we develop all new things in Go only. </p> <p>For the most part it&#39;s been easy for the team. Several &#34;PHP only&#34; developers were not thrilled at the idea but even they seem to be picking up pretty well. </p> <p>Things we have loved:</p> <ul> <li>The deployment strategy: one binary and occasionally a folder of templates vs having to push thousands of PHP files to a server (we have some Laravel apps)</li> <li>The development strategy: almost all of our devs are OSX users, almost all of our servers are Linux. When we were with PHP just getting a local version running for a dev was a pain. OSX ships with PHP installed already but it&#39;s always an old version and when you introduce frameworks like Laravel suddenly every dev needs to compile mcrypt into their system (side note our devs have a strange aversion to Vagrant. They must like pain). Go on the other hand just works. There are no additional modules that need to be compiled, you don&#39;t need PDO drivers and MySQL drivers, and mcrypt and iconv, etc. </li> <li>Performance: due to the compilation aspect even bad Go code outperforms great PHP code. PHP 7 is getting close to the performance but again you have to write good PHP code. </li> <li>The type system: having a statically typed language has forced our devs to become better planners. In PHP they could easily say &#34;I don&#39;t know. This function might return an object, or an array, but for now we&#39;ll return a Boolean.&#34; This easily introduces bugs into production code because they forgot to check an in_array because they thought they were dealing with an object. Also, sad to say and I&#39;m a culprit of this too. Some of our PHP projects had absolutely no tests of any kind and we would often learn of and debug bugs in production. Go on the other hand which does analysis on compilation notifies us of errors and let&#39;s us resolve before pushing to production. Our bugs are now more true bugs than developer oversight. </li> </ul> <p>Things we haven&#39;t loved:</p> <ul> <li>The type system: for most of the team Go has been the first statically typed language they&#39;ve worked with. Sometimes especially when prototyping ideas they want to throw together an array with varying types. Go doesn&#39;t aide in quick prototyping of types. Also the fact you can create new types still throws off some of our devs. </li> <li>Learning a new language: we weren&#39;t able to stop delivering new products. Couldn&#39;t take 6 months off. We still were expected to keep on delivering as if nothing had changed. It required the senior members to step up their game and help out more (thankfully the senior members had been playing with Go for months before we even approached management about switching)</li> </ul> <p>Things we have missed about PHP:</p> <ul> <li>I find myself sometimes wishing I could go full OO and have a class with inheritance and abstract classes. </li> <li>The loose type system: being able to prototype objects in PHP was nice. </li> </ul></pre>iio7: <pre><p>Thank you very much for sharing this! Very valuable!</p></pre>weberc2: <pre><p>This was a really interesting read. I&#39;m curious about why you miss inheritance and abstract classes? I quickly realized that inheritance was almost always the wrong relationship between types, and that composition + interface-polymorphism worked out better. (This is a language-agnostic principle, it&#39;s not like I came to Go and saw the light, although I do think Go helps you understand how traditional classes work behind the scenes).</p></pre>Mteigers: <pre><p>Honestly it was mostly out of habit. You work with PHP for ~5 years and ideals stick. That and coming to Go and seeing the amount of boilerplate and copied functions naturally makes you investigate ways of creating abstract classes or to inherit/implement. </p> <p>Now that I&#39;ve personally been working with Go for nearly two years those tendencies are dying off. </p></pre>weberc2: <pre><p>Sure, if you&#39;re worried about the boilerplate of delegation, Go does support a pseudo-inheritance that will get rid of that for you: <a href="http://play.golang.org/p/744_Qvnq3y" rel="nofollow">http://play.golang.org/p/744_Qvnq3y</a></p> <p>That&#39;s assuming &#34;the amount of boilerplate and copied functions&#34; bit was in the context of inheritance.</p></pre>darrrrrren: <pre><p>For me personally, it was exactly like coming to Go and seeing the light. Go forced me into fully grasping how powerful interfaces are and its made me an infinitely better modeler</p></pre>NeuroXc: <pre><p>I will probably get downvoted for this opinion because this is <a href="/r/golang">/r/golang</a> but it sounds like the issue with PHP is that your devs don&#39;t know how to use PHP, and Go is more idiot-proof. Here&#39;s why I think that.</p> <blockquote> <p>The deployment strategy: one binary and occasionally a folder of templates vs having to push thousands of PHP files to a server (we have some Laravel apps)</p> </blockquote> <p>You manually push the entire app, including vendor folder, from a dev box to the production server? You wouldn&#39;t have this pain with PHP if you used git and composer.</p> <blockquote> <p>The development strategy: almost all of our devs are OSX users, almost all of our servers are Linux. When we were with PHP just getting a local version running for a dev was a pain. OSX ships with PHP installed already but it&#39;s always an old version and when you introduce frameworks like Laravel suddenly every dev needs to compile mcrypt into their system (side note our devs have a strange aversion to Vagrant. They must like pain). Go on the other hand just works. There are no additional modules that need to be compiled, you don&#39;t need PDO drivers and MySQL drivers, and mcrypt and iconv, etc.</p> </blockquote> <p>So they were manually compiling PHP and its extensions, instead of using Homebrew? They must really like pain. Getting Homebrew set up takes 1 line of copy and pasting, and installing PHP and its extensions with Homebrew takes 5 minutes at most. It even supports PHP 7.</p> <blockquote> <p>Performance: due to the compilation aspect even bad Go code outperforms great PHP code. PHP 7 is getting close to the performance but again you have to write good PHP code.</p> </blockquote> <p>This is fair, but performance isn&#39;t a significant factor in most web apps--at least not until you get to the point of hundreds of visitors per second. Even PHP 5.6 (with opcache enabled) is faster than other popular web languages like Ruby and Python by 10-20% in most benchmarks.</p> <blockquote> <p>The type system: having a statically typed language has forced our devs to become better planners. In PHP they could easily say &#34;I don&#39;t know. This function might return an object, or an array, but for now we&#39;ll return a Boolean.&#34; This easily introduces bugs into production code because they forgot to check an in_array because they thought they were dealing with an object.</p> </blockquote> <p>PHP 7 also introduces optional static typing, which you could begin implementing in your internal apps now, and most open-source libraries will probably start to implement within a few years (once PHP 5.6 support dies). (Also, as you mention later in your post, having a weak type system can be a benefit in some ways as well.)</p> <blockquote> <p>Some of our PHP projects had absolutely no tests of any kind and we would often learn of and debug bugs in production. Go on the other hand which does analysis on compilation notifies us of errors and let&#39;s us resolve before pushing to production. Our bugs are now more true bugs than developer oversight.</p> </blockquote> <p>It&#39;s not really PHP&#39;s fault if your applications had no tests. There are linters for PHP as well which will catch the same kinds of mistakes that Go&#39;s compiler will catch, but having a compiler (or a linter) does not free you from writing tests. Even a good developer can write perfectly syntactically valid code that compiles but doesn&#39;t run properly because of a bug, even something as small as typing the wrong number or a <code>1</code> instead of an <code>i</code> (actually something I&#39;ve done before that took about a half hour to debug).</p> <p>Now I don&#39;t want to make it sound like Go is a bad language or anything. I don&#39;t have enough experience with it to make that judgment. But Reddit has this hivemind mentality that PHP is terrible, so I dislike it when people blame PHP for things that really, aren&#39;t PHP&#39;s fault.</p></pre>Mteigers: <pre><p>Not awful points. </p> <p>To &#34;rebuttal&#34; your points-</p> <p>We did/do use Composer. Still our PHP applications lay in the hundreds of files range just from our codebase. </p> <p>We do use Homebrew, and it has made lives much easier. But it&#39;s still the fact PHP needs those modules in the first place. Sure it&#39;s an install once and you&#39;re good. Not to mention communicating new modules back to ops so they could install it on the servers... But compared to Go which has no additional needed modules. </p> <p>We do happen to sit in the hundreds of requests a second range so performance is a factor when introducing new tech. </p> <p>Also we switched a little over a year ago. This was before PHP 7 spec was solidified. Had we known then that PHP 7 was going to be such a massive overhaul maybe it would have gotten more pull in decision making. </p> <p>All your points aren&#39;t bad. Just (opinion talking) Go was so simple in comparison. </p></pre>jamesrr39: <pre><blockquote> <p>Go is more idiot-proof</p> </blockquote> <p>Agreed that PHP is not necessarily a terrible language, but ultimately the question is; why risk making these mistakes when you can pick an approach that mitigates them?</p></pre>f3lbane: <pre><p>I&#39;ve been wanting to switch from PHP to something more sane. What made you choose Go over other alternatives like Python? Some of the things listed in &#34;Things we have loved&#34; are also checked off with other languages, so I assume there&#39;s more behind the decision.</p> <p>I&#39;ve got a bit of background in Python so I&#39;m relatively comfortable with it and systems like CherryPy seem alright so far. I haven&#39;t really taken the time to learn Go yet since it seems a bit daunting -- but maybe that&#39;s just me not giving it time to sink in.</p> <p>So, why Go in particular?</p></pre>Mteigers: <pre><p>Among many reasons:</p> <ul> <li>Go was the least &#34;stack changing&#34; in our minds. Go had the ability to provide its own http server built into the language. So we didn&#39;t need to learn how to tweak and set up something like Tornado, or Tomcat, etc. </li> <li>The Go syntax is closer to that of PHP than something like Ruby or Python. Remember we had some lifelong set in their ways PHP developers on the team that we wanted to alienate as little as possible. We were looking for a fast time to market language. </li> <li>Simplicity: Python is pretty close to being simple. But you still have to worry about things like pip being installed and working properly (and all of your projects packages) and the whole debacle between Python 2.x and Python 3.x. With Go we can send a binary to the server that just works with no dependencies. It will be interesting to see if we have similar issues when Go 2 comes out.</li> <li>We felt that Go handled large code bases at a core level. It felt that you couldn&#39;t easily get that same level of project and dependency management in Python without introducing massive frameworks like Django. </li> <li>EDIT: Another massive reason is the fact Go is written in Go. If I want to see how an io writer is implemented I can pull up the source code or the test that supports it. I can&#39;t do that for PHP or Python (or most any other language). I find myself reading core libs all the time for ideas on good habits and just how to do things in general. </li> </ul> <p>Disclaimer: I haven&#39;t truly given Python the college try. These are only opinions we gathered and not a jab at Python. </p></pre>Chippiewall: <pre><blockquote> <p>Go had the ability to provide its own http server built into the language. So we didn&#39;t need to learn how to tweak and set up something like Tornado, or Tomcat, etc.</p> </blockquote> <p>Python actually has its own web server built in as well. That being said Tornado is a favourite of mine - it&#39;s all user-land code too.</p> <blockquote> <p>The Go syntax is closer to that of PHP than something like Ruby or Python. Remember we had some lifelong set in their ways PHP developers on the team that we wanted to alienate as little as possible.</p> </blockquote> <p>Senior developers ought to be able to look beyond syntax. It&#39;s the semantics of the language where adaption may be slow and I feel Go differs from PHP in this regard much more.</p> <blockquote> <p>Simplicity: Python is pretty close to being simple. But you still have to worry about things like pip being installed and working properly (and all of your projects packages) and the whole debacle between Python 2.x and Python 3.x.</p> </blockquote> <p>This is probably one of the most painful aspects of Python from my perspective. Virtualenv goes a long way to resolving a lot of this but it&#39;s still a pain in the ass.</p> <blockquote> <p>We felt that Go handled large code bases at a core level. It felt that you couldn&#39;t easily get that same level of project and dependency management in Python without introducing massive frameworks like Django.</p> </blockquote> <p>I would definitely agree that Python doesn&#39;t scale particularly well.</p> <blockquote> <p>Another massive reason is the fact Go is written in Go. If I want to see how an io writer is implemented I can pull up the source code or the test that supports it. I can&#39;t do that for PHP or Python (or most any other language)</p> </blockquote> <p>Honestly in my top ten list of reasons why I love PyPy. Most of Python&#39;s standard library is already written in Python. With PyPy this is true to a greater degree and the rest is written in a Python variant (RPython).</p></pre>FeralTitan: <pre><p>I think these are really poor reasons to choose a language, seems like you made this choice emotionally and then tried to justify it after the fact.</p> <p>Here is an article i think explains some serious shortcomings in Go. <a href="http://yager.io/programming/go.html" rel="nofollow">http://yager.io/programming/go.html</a></p> <p>Personally, I feel Go&#39;s google backing is the largest driver for it yet miniscule adoption outside google.</p> <p>PS: I have worked/work on production systems in Java/Go/PHP/Python/C#/Javascript.</p></pre>argybarg: <pre><p>Disagree if you like, but they hardly seem like emotional reasons to me.</p></pre>Veus: <pre><p>Be aware that the link you refer to was written in 2014. Things may have changed since then.</p></pre>theonlycosmonaut: <pre><p>Go? Changed? Unless you mean the Rust examples may not work any more :p</p></pre>iio7: <pre><p>Most like speed and simplicity (I would guess).</p></pre>StealthyC: <pre><p>I found it very easy to learn, it&#39;s such a simple language. I got sick and didn&#39;t work for 2 days, spent my time delirious on the couch and learned go... now we are writing all our new systems in it.</p></pre>zackkitzmiller: <pre><p>A strong typing system one of the best reasons to make the move to Go. </p></pre>headzoo: <pre><blockquote> <p>I also do not like how the PHP-FIG (again just my personal opinion) seem to be affecting the PHP community on a global scale with their PSRs and their rantings about how everyone are free to choose their recommendations, yet at the same time members work tirelessly in an effort to get everyone to adopt their so-called &#34;modern approach&#34;.</p> </blockquote> <p>You are going to <em>hate</em> Go if standards and strong conventions bother you.</p></pre>heptara: <pre><p>I had not heard of php-fig before so i did some research. Their website shows they have 6 accepted standards of which 1 is deprecated and replaced with a newer version, though still accepted. Browsing them I discover that the majority of their content seem to be already enforced by Go (in some manner), either in the language syntax, by the standard automated tools (e.g. gofmt) or by angry yells from the peanut gallery.</p></pre>ihsw: <pre><p>It should be noted that FIG stands for <em>Framework Interoperability Group</em> and the rationale is to standardize development practices between all major PHP frameworks. Their standards are enforced for contributions to core framework code only rather than to the general community.</p> <p>That said, most companies use it in the same way as PEP8 is used -- for readability of code. Since there is a lot more visual noise (curly braces, semi-colons, etc) then the rules must be more stringent.</p></pre>headzoo: <pre><blockquote> <p>of which 1 is deprecated and replaced with a newer version, though still accepted</p> </blockquote> <p>PHP never lets anything go.</p></pre>iio7: <pre><p>PHP-FIG is not an official standard organization in any way.</p></pre>headzoo: <pre><p>I know.</p></pre>iio7: <pre><p>Standards and strong conventions doesn&#39;t bother me, not one bit, rather on the contrary. It&#39;s only the way the PHP-FIG works that bothers me.</p></pre>callcifer: <pre><blockquote> <p>It&#39;s only the way the PHP-FIG works that bothers me.</p> </blockquote> <p>For example?</p></pre>BoTuLoX: <pre><p>I&#39;m no PHP programmer, but Go&#39;s standard library templating as well as the ecosystem surrounding web development is great. It&#39;s trivial to use and concurrent by default so making something that scales extremely well is as easy as it gets.</p> <p>You can definitely make do with Go&#39;s standard library alone or you can pick and choose what you want from frameworks.</p> <p>I for one tend to use Go&#39;s templating from the standard library, the Gin HTTP framework (a very lightweight wrapper around net/http+the very fast httprouter mux) and contrib/sessions from gin to store per-session data.</p></pre>nanodano: <pre><p>Here is my experience:</p> <p>PHP is way more productive for web apps. Go is the choice when PHP can&#39;t handle the load or resources are scarce.</p> <p>Go&#39;s templating feature is not fun to work with if you have nested templates. I did not try out some of the frameworks out there so they might be better.</p> <p>You build your web server right in to the application too. If you want to serve endpoints but also serve static content you have to go out of your way to multiplex the HTTP server or manually create a route for each resource. Not a lot of code required to do it but it was a little &#39;gotcha&#39; and confused me and required a little research my first time around.</p> <p>There are times when Go is a good choice for making a web app. APIs are very easy to implement. When performance and resources are critical Go comes out on top.</p> <p>When it comes to a full blown CMS or a large web application, I personally still choose PHP. It&#39;s the most fluent language for the web IMHO. Go is good, and both of them have their use cases, but in general I only use Go when building services or backends to mobile apps or something similar.</p></pre>DualRearWheels: <pre><p>Go&#39;s standard lib is sufficient for most user cases. http lib is powerful, you can run production ready server with it, templates is sufficient for you to build anything on top of it instead of existing framework. mux is matter of taste, but there are lot of libs to choose from.</p> <p>And as a cherry on top, you can even make old fashioned single file CGI binaries that run quick enough on any existing web server.</p></pre>no1youknowz: <pre><p>I&#39;m starting to become one of those standard bearers for Go. Gonna buy a t-shirt too when I find a design I like.</p> <p>I must have told over 10 devs that I know personally about Go. I was a polygot, that is having developed and pushed code into production in Perl, Python, Javascript (front/back), C and PHP. I say &#34;was&#34; because I have decided in &#39;16 to just be a Go and Javscript (front) developer. </p> <p>The lack of depth of OOP did frustrate me. But actually there are ways around this issues and I have ported a large php library of mine consisting of many classes that inherit a main class. So far I have ported 20k lines of code from a PHP app that I have to Go and pushed that into production. The gains have been immeasurable. PHP as far as I am concerned is left in the dust and it doesn&#39;t matter however much they do with it, I&#39;ll never switch back.</p> <p>Oh and lets not kid ourselves. PHP 7 is no way close to speed as Go. I have a particular app that HHVM would spend 10s of minutes on up to an hour. Of which Go would eat alive!</p> <p>I personally do not miss the loose typing. I am just one developer and it makes me write good concise code. The compiler prevents me from pushing crap like with PHP. In the beginning it was annoying seeing about 15-20 lines of errors. Now it&#39;s routinely 2-3 if I have any issues that I forgot about a package being included in import and it&#39;s not required or a stray variable. </p> <p>I love the fact that I can ship full binaries as well. I have Centos 6 boxes in production due to specific issues. I needed a fast webserver. HHVM was pretty much out. PHP 7 wasn&#39;t out yet. Go to the rescue. 520 lines later and I had written a simple webserver which did everything I needed. I could&#39;nt believe it. At this point, the PHP in me died lol.</p> <p>I&#39;ll be going full Go codebase within 90 days. Can&#39;t wait really!</p></pre>weberc2: <pre><blockquote> <p>The lack of depth of OOP did frustrate me</p> </blockquote> <p>I&#39;ve been using Go since 2012, and I still don&#39;t understand what people mean when they say Go &#34;isn&#39;t OOP&#34; (not quite your sentiment). Go doesn&#39;t have the &#34;class&#34; keyword, but it has classes in every other sense. It doesn&#39;t have inheritance, but we all learned the hard way that inheritance is pretty much never the right tool for the job (neither for composition nor for polymorphism). Seriously; what else is missing?</p></pre>darrrrrren: <pre><p>This is cliché, but, generics.</p></pre>weberc2: <pre><p>Generics aren&#39;t an OOP feature. Lots of OOP languages have them, but they&#39;re not part of OO.</p></pre>darrrrrren: <pre><p>Sorry, I took your &#34;what else is missing&#34; as a more general question.</p></pre>weberc2: <pre><p>Ah, I understand (and agree).</p></pre>iio7: <pre><p>Very good point!</p></pre>postman_: <pre><p>Subtype polymorphism, late-bound <code>this</code>.</p></pre>random314: <pre><p>What most php developers doesn&#39;t understand is that php is nothing more than a templating language. It&#39;s claim to fame is its ability to put together a html page easier than any other language. That&#39;s it. That&#39;s the only thing php should be used for. </p></pre>ulfurinn: <pre><blockquote> <p>forgot about a package being included in import and it&#39;s not required</p> </blockquote> <p><a href="https://godoc.org/golang.org/x/tools/cmd/goimports" rel="nofollow">goimports</a> solves that problem once and for all.</p></pre>iio7: <pre><p>Thanks for sharing! Cool stuff!</p></pre>dericofilho: <pre><p>Types are everywhere. Interfaces (sometimes ignored by elephpants) are keystone in using the language. </p> <p><a href="http://www.cirello.org/2015/08/2015-08-25-advices-for-elephpants-coding-in-go/" rel="nofollow">http://www.cirello.org/2015/08/2015-08-25-advices-for-elephpants-coding-in-go/</a></p></pre>iio7: <pre><p>Since I wrote the initial question I decided to try code a small web CMS/Wiki in Go and I AM MIND BLOWN!</p> <p>The part that I find most fantastic is NOT what is there, but what is NOT there!</p> <p>Web server and application all compiled into one SUPER fast and extremely scalable binary only containing exactly what I need!</p> <p>The speed is amazing!</p> <p>I am most definitely leaving PHP and I am never going back!</p> <p>I haven&#39;t felt this excited about programming since I got my first Commodore 64 back in the days lol!</p></pre>Mteigers: <pre><p>Yeah it&#39;s funny. We&#39;re developing a micro service framework in Go and are measuring load times in microseconds, and complaining how requests are taking 80-130 microseconds (0.08 milliseconds). Back when we were on PHP I remember thinking &#34;Awesome. We&#39;ve got some of these requests down to 3-4 milliseconds&#34;. </p> <p>How perspective changes. </p></pre>random314: <pre><p>More like nanosecond in some cases... </p></pre>anxiousalpaca: <pre><p>I have switched from PHP to Go about 1.5 years ago (<a href="http://www.outfitadviser.eu" rel="nofollow">my website</a>). To my surprise all the functionality i need was readily available either through the standard libraries or by quick Google searches. Also the average load time of my website is like 150 ms for Google crawlers compared to seconds for an analytical tool written in PHP that also runs on the same server.</p> <p>I love the static type system, that it most likely works if it compiles, the built-in templating system and that it compiles into one binary. Just set up a reverse proxy in Apache and you can run multiple services side-by-side.</p> <p>I don&#39;t love that there&#39;s so many PHP-made plugins and stuff, so you really have to write most things on your own.</p></pre>d3sire: <pre><p>You will definitely miss php arrays. Especially when it comes to parsing json. </p></pre>justinisrael: <pre><p>Although, decoding known json formats is pretty sweet in Go, since it will map automatically (as best as it can) to your deeply nested struct definitions. </p></pre>d3sire: <pre><p>Agreed. It was pain for me working with external api&#39;s. </p></pre>iio7: <pre><p>Thanks! I&#39;ll look into that right away!</p></pre>TotesMessenger: <pre><p>I&#39;m a bot, <em>bleep</em>, <em>bloop</em>. Someone has linked to this thread from another place on reddit:</p> <ul> <li>[<a href="/r/php" rel="nofollow">/r/php</a>] <a href="https://np.reddit.com/r/PHP/comments/3wn6b9/switching_from_php_to_go_golang/" rel="nofollow">Switching from PHP to Go : golang</a></li> </ul> <p><a href="#footer" rel="nofollow"></a><em><sup>If you follow any of the above links, please respect the rules of reddit and don&#39;t vote in the other threads.</sup> <sup>(<a href="/r/TotesMessenger" rel="nofollow">Info</a></sup> <sup>/</sup> <sup><a href="/message/compose?to=/r/TotesMessenger" rel="nofollow">Contact</a>)</sup></em></p> <p><a href="#bot" rel="nofollow"></a></p></pre>bungle: <pre><p>Have you looked at Lua + OpenResty?</p></pre>iio7: <pre><p>No, but thanks. It looks interesting too.</p></pre>iio7: <pre><p>And then again.. not really :P Go has sold me!</p></pre>bungle: <pre><p>Yeah, Go is great. OpenResty on the other hand has kinda PHP style focus on a web. A lot of PHP devs seem to be moving to Go and OpenResty (or both). I don&#39;t like this over engineered &#34;lets make PHP a Java clone&#34; either, and do everything OOP.</p></pre>iio7: <pre><p>Yeah, I think PHP is getting more and more bloated.</p></pre>weberc2: <pre><p>Go is great for web development, but if you prefer the old style &#34;PHP as a template language&#34; model, Go won&#39;t solve you problems (although it has a great template library which can fill that niche, allowing for a clean separation between HTML rendering and more typical backend things).</p></pre>iio7: <pre><p>I just coded a small CMS/Wiki application in Go. I made my own HTML template and I am not going to miss anything! :)</p> <p>I actually found it a lot easier and much faster to keep things nicely separated with Go.</p> <p>&#34;PHP as a template language&#34; has forced me into some really bad habits that I (being an old-school developer) never really could shake. With Go it&#39;s the other way around!</p></pre>your_time_to_shine: <pre><p>Here is a cool <a href="https://github.com/spf13/hugo" rel="nofollow">Static Site Generator</a></p></pre>weberc2: <pre><p>Yeah, back before I did web things in languages besides PHP, I decided to use PHP to write a blog engine in a less-traditional PHP fashion (at least it was non-traditional at the time). I even made my own (simple) template parser, which was quite a bit easier than I thought it would be.</p></pre>peterrushkin: <pre><p>I thought i&#39;d share this. </p> <p><a href="https://www.reddit.com/r/PHP/comments/3wn6b9/switching_from_php_to_go_golang/cxxjaet" rel="nofollow">https://www.reddit.com/r/PHP/comments/3wn6b9/switching_from_php_to_go_golang/cxxjaet</a></p> <blockquote> <p>I think the OP is just sharing some interesting perspective. Personally I never even considered switching from PHP to Go to be a viable option. The usual alternatives are Python and Ruby. But now it sort of makes sense. Go feels like a very defective language if you&#39;re coming from a background of statically typed languages with strong typesystems. But if you&#39;re coming from PHP, Go&#39;s weak type system might actually be appealing and simplify the transition.</p> </blockquote> <p>From one of the devs of PHP.</p> <p>So much disinformation there! Such a shame!</p></pre>DownvotesEdits: <pre><p>I think you might be interested in <a href="https://github.com/ksimka/go-is-not-good" rel="nofollow">https://github.com/ksimka/go-is-not-good</a></p></pre>thukjeche: <pre><p>You might also consider development in ES (JavaScript) - and depending on your needs, with Node</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

772 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传