<p>I am currently working on a web app. I'm using PHP / MariaDB to handle the content of the pages and the user input. Based on the users input, I will need to do some calculations every hour or every day.</p>
<p>I have one server ready for the users to interact with and another server to do the calculations.</p>
<p>I am considering Go for the server to do the calculations.</p>
<p>Thoughts?</p>
<hr/>**评论:**<br/><br/>anoland: <pre><p>Things you will need to read:</p>
<p>Effective go. <a href="https://golang.org/doc/effective_go.html">https://golang.org/doc/effective_go.html</a></p>
<p>Go database example: <a href="http://go-database-sql.org/">http://go-database-sql.org/</a></p>
<p>Build a binary that connects to the db and does the calculations. Run it on a cron job. You should be set.</p></pre>levidurfee: <pre><p>Thank you for those links. I believe Go will do exactly what I need and do it fast.</p></pre>KimIlYong: <pre><p>Go is much, MUCH faster than PHP. If you do only a simple addition from database values it does not matter, but for everything more complicated (=CPU intensive) then Go will shine.</p></pre>PM_ME_YOUR_VIMRC: <pre><p>Why, so you can get more upvotes on hn?</p></pre>klaaax: <pre><p>Sorry but you don't need go for that. I would stick to PHP. Either use something like crontab or gearman to launch workers (PHP scripts) that will perform the calculations and populate your database with the result, as background processes on your server. There is absolutely nothing that would make the use of Go relevant here. </p></pre>skelterjohn: <pre><p>Go is a programming language, and this is a programming task. So, Go is relevant.</p></pre>klaaax: <pre><blockquote>
<p>Go is a programming language,</p>
</blockquote>
<p>so is brainfuck , that's not the point here. The point is using Go for the sake of it in a PHP project that doesn't require it is silly. Misleading people asking this kind of questions is at the very least dishonest. That person doesn't need Go. That person can rely on tools that are well tested an predictable, which will give him 0 development or deployement overhead.</p></pre>dAnjou: <pre><p>While I like Go and dislike PHP, this is reasonable advice. Of course it depends on various other things but for the sake of maintainability I'd stick to the language that's been used the most in the codebase and that I'm most productive in. You probably already have a CI in place and a proper development environment for PHP. Don't underestimate what maintaining multiple toolchains and environments means for maintenance overhead.</p></pre>theonlycosmonaut: <pre><p>On the other hand, learning new things is good!</p></pre>dAnjou: <pre><p>Sure, but there's a right and a wrong time for everything ;)</p></pre>hobbified: <pre><p>And neither you nor <a href="/u/klaaax" rel="nofollow">/u/klaaax</a> could reasonably have any idea whether or not this is that time.</p></pre>dAnjou: <pre><p>Does this make our point less valid?</p>
<p>OP asked: <em>Thoughts?</em>, which is a very open question. Based on the rather limited information in the original post both <a href="/u/klaaax" rel="nofollow">/u/klaaax</a> and me expressed very valid and reasonable thoughts.</p></pre>greeedy: <pre><p>I agree, it's better to stick to the language you have and try to have a clean architecture than using and whole other language. If he needs speed or something, go could be a viable option. But so would be C,C++ or whatever. Use the tools you need, for the job you want get done, not the ones who are popular. And if you want to learn something new, make a weekend play project!</p></pre>levidurfee: <pre><p>The calculations part of the web app won't be needed until after I get a decent amount of data from the users. I am going to attempt to write it in Go. If I feel that it isn't working out and I think I could have written it better in PHP, then that is what I'll do.</p>
<p>I learn best when making something that <em>might</em> be used.</p>
<ul>
<li>I don't have a deadline</li>
<li>I have been interested in Go for awhile</li>
<li>If I can't do it in Go, I can do it in PHP</li>
</ul></pre>