Anyone know both PHP and GO and have use GO for a WEB here?

122 views
Skip to first unread message

nvcnvn

unread,
Aug 28, 2011, 4:26:01 AM8/28/11
to golang-nuts
Before GO I just know PHP via w3schools.com - tizag.com. I I know it
enought to edit some Opensource forum or write something ugly for
myself.
But you see, in the PHP work there is no pointer, a few a bow struct
and never ask me about Multithreading. So it hard for me to work with
GO in a effectively way.
I hope that some one can share for me some exp and some basic docs
that can help me don't make a big mistake when playing with GO.

Thanks!

Gustavo Niemeyer

unread,
Aug 28, 2011, 2:38:41 PM8/28/11
to nvcnvn, golang-nuts
> But you see, in the PHP work there is no pointer, a few a bow struct
> and never ask me about Multithreading. So it hard for me to work with
> GO in a effectively way.

I'm not a PHP developer myself, but this list tends to be friendly to
introductory questions. I recommend starting with the introductory
material in the web site, and if you'd like advice on specific aspects
you can just drop a message in the list and someone will give you a
hand.

http://golang.org/doc/docs.html

> I hope that some one can share for me some exp and some basic docs
> that can help me don't make a big mistake when playing with GO.

Don't worry about doing mistakes and just get coding. You're learning.

--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/plus
http://niemeyer.net/twitter
http://niemeyer.net/blog

-- I never filed a patent.

OmarShariffDontLikeIt

unread,
Aug 29, 2011, 6:23:52 PM8/29/11
to golang-nuts
I am a PHP developer by day, and have been for 10 years, but night I
spend all my time hip deep in Go code :)

I will tell you this, PHP and Go differ in more ways than they are
similar. They both approach particular problems in their own specific
and unique ways, so if you are a a PHP hacker, you may find that
starting with Go may be an uphill struggle. However, thats not to say
you shouldn't keep up with it!

Personally I find that Go conveniently fills the many gaps that PHP
has. We currently have many command line systems written in PHP that I
am hoping to re-write in Go, which results in a much more sustainable
system. It basically comes down to the way each language approaches
its core problem space: PHP will be forever trapped in the request-
response domain of web server request processing, which is fine and it
which it handles superbly. Go lets you do everything else :)

Things to look out for:

- PHP OOP: It doesn't translate to Go. It's just easier to forget all
that stuff and approach the Go type system for what it is. It will
save you loads of headaches and rewrites trust me :)
- Concurrency/Threading: PHP doesn't have this in any real-world way,
so this is all new and exciting (and powerful) stuff. Read and learn
this stuff, because this is were we have found the switch over point
from PHP to Go.
- Compilation: The quick compilation of Go programs may deceive you
into thinking development is very similar to PHP. It's not, and the
end result is more powerful, useful and surprising than you may
initially expect. Raw horsepower alone wil change the way you approach
software development than how you would as a PHP dev.

PHP is great and will always have a place in my heart, but try to
approach Go on its own terms; you'll get much much more out of it. And
it will make you a better PHP programmer for it too :)

Have fun!

Cheers!
> Gustavo Niemeyerhttp://niemeyer.nethttp://niemeyer.net/plushttp://niemeyer.net/twitterhttp://niemeyer.net/blog

nvcnvn

unread,
Aug 29, 2011, 10:42:41 PM8/29/11
to golang-nuts
First, your reply help me a lot! Thanks you so muc!
Second, you say:
On Aug 30, 5:23 am, OmarShariffDontLikeIt
<omarshariffdontlik...@gmail.com> wrote:
> - Concurrency/Threading: PHP doesn't have this in any real-world way,
> so this is all new and exciting (and powerful) stuff. Read and learn
> this stuff, because this is were we have found the switch over point
> from PHP to Go.

I agree with you! Concurrency/Threading are exciting and powerful as
any one using it!
But I have the trouble here!
I don't know what is the ....... real-world for multilthreading too!
I know about multilthreading after GO....
I can write a web app in GO but without multilthreading beacuse I
don't know which case that multilthreading will help me!
All the thing I know about concurrency is here http://golang.org/doc/GoCourseDay3.pdf
a example about tea and coffe.

Can you give me some example that I can do with multilthreading for a
web app?
Some example that GO + Concurrency will handle it better than PHP?

Thanks you alot and alot!

kar

unread,
Aug 30, 2011, 1:02:53 AM8/30/11
to golang-nuts
On Aug 30, 10:42 am, nvcnvn <nvcn...@gmail.com> wrote:
> I can write a web app in GO but without multilthreading beacuse I
> don't know which case that multilthreading will help me!
> All the thing I know about concurrency is herehttp://golang.org/doc/GoCourseDay3.pdf
> a example about tea and coffe.
>
> Can you give me some example that I can do with multilthreading for a
> web app?
> Some example that GO + Concurrency will handle it better than PHP?
>
> Thanks you alot and alot!

A website crawler. Multithreading/concurenncy allows multiple crawler
bots to connect and fetch at same time then qeue the pages to be
process by a single thread indexer.

Bjorn Tipling

unread,
Aug 30, 2011, 1:35:31 AM8/30/11
to kar, golang-nuts
A crawler is a good example. Another example might be API calls. Say as part of a response to a client you need to make a request to the Twitter API to get their statuses or maybe the Amazon Web Services API for whatever you get from there. If those sites are down or slow, *all* the requests to your site may be blocked while you're waiting for that one API call without concurrency.

OmarShariffDontLikeIt

unread,
Aug 30, 2011, 3:50:08 AM8/30/11
to golang-nuts
A web crawler is a good example (though PHP provides an interface to
the multi-cUrl features of cUrl).

Anything were you used to use a PHP script to do something, but had to
run the script multiple times either using cron or a complicated and
error prone fork/exec to run PHP scripts can be replaced with a much
cleaner and robust version in Go.

To be honest, I have found the power in Go routines and channels
provides me with a method of breaking my programs into independent
chunks, reducing the coupling to defined channels means I actually
approach the problem and design my programs differently than how I
would have approached them using PHP. This, I feel is the real power
of Go over PHP: programs of a particular size in PHP start to fall
apart, and (personally) the OOP features actually hinder you at this
point in PHP (thats not to say that PHP is bad; it has its time and
place, and I believe it trumps Go in those places). Go allows me to
stop and break things into separate independent chunks, and I think
the program design is much better for it. I am certainly finding Go
programs much easier to maintain and manage over similar code written
in PHP.

Like I say, the biggest challenge in switching from PHP to Go has been
how much I have learned about how to structure programs written in Go,
and to exploit the innate features of Go to accomplish this. Go feels
like a language designed for people like me :) Like I said before, PHP
is designed to work well in the request-response cycle. Go feels like
it is designed to handle large programs and to help you reach the
optimal design easily, quickly and encourage maintenance of that
program, and for me, that is all I ever wanted from a programming
language.

peterGo

unread,
Aug 30, 2011, 10:16:17 AM8/30/11
to golang-nuts
nvcnvn,

On Aug 29, 10:42 pm, nvcnvn <nvcn...@gmail.com> wrote:
> I can write a web app in GO but without multilthreading beacuse I
> don't know which case that multilthreading will help me!

College students are starting the Fall semester. They need an app to
check several bookstore websites for the best textbook prices. To be
fast, the app should check each website independently.

Peter

On Aug 29, 10:42 pm, nvcnvn <nvcn...@gmail.com> wrote:
> First, your reply help me a lot! Thanks you so muc!
> Second, you say:
> On Aug 30, 5:23 am, OmarShariffDontLikeIt
>
> <omarshariffdontlik...@gmail.com> wrote:
> > - Concurrency/Threading: PHP doesn't have this in any real-world way,
> > so this is all new and exciting (and powerful) stuff. Read and learn
> > this stuff, because this is were we have found the switch over point
> > from PHP to Go.
>
> I agree with you! Concurrency/Threading are exciting and powerful as
> any one using it!
> But I have the trouble here!
> I don't know what is the ....... real-world for multilthreading too!
> I know about multilthreading after GO....
> I can write a web app in GO but without multilthreading beacuse I
> don't know which case that multilthreading will help me!
> All the thing I know about concurrency is herehttp://golang.org/doc/GoCourseDay3.pdf

nvcnvn

unread,
Aug 30, 2011, 12:43:44 PM8/30/11
to golang-nuts
Oh thanks all of you!
Know I know some more!

two examples about web crawler and book store. I have the question.
For example I download 5 files from the web. With multilthreading I
can download 5 files concurrency instead of 1 file per time. IS it
true?
But will it faster?
I mean .. let say your internet line speed is 5mbs and your files is
1GB/file.
In this case with the help of Concurrency/Threading I still finish
sooner?
Reply all
Reply to author
Forward
0 new messages