GoF is, in my opinion, about establishing a language to talk about commonly used constructs in languages - especially given it's providence in Christopher Alexander's A Pattern Language.
Referring to it as 'a set of tricks' would suggest to me that you've only given it a cursory glance and assumed that it's just about copying out example blocks of code, or that you've not worked in a wide enough set of languages to realize that every language has commonly used patterns for doing particular things, no matter how expressive the language is. Having a way to discuss the architecture of a piece of software without having to explain every implementation detail because there's already a shorthand refer to various parts of it is invaluable when working on larger projects. Being able to call a block of code as a flywheel is no more a trick than being able to refer to an options pricing equation as a 'modified black-scholes' - the important part is that other person knows from that what you're talking about and so you can get to the important part of the conversation.
> GoF is, in my opinion, about establishing a language to talk about commonly used constructs in languages
I think it philosphically comes in part from that place, but the particular choice of constructs it addresses are a a commonly needed set that a particular language family's lack of expressiveness in certain dimensions required to be reimplemented using basically boilerplate code each time they were used, so it spends a lot of time documenting the set of tricks necessary to implement those constructs in that language family.
> you've not worked in a wide enough set of languages to realize that every language has commonly used patterns for doing particular things, no matter how expressive the language is
The more expressive a language is, the more the "commonly used patterns" can be turned into libraries rather than templates you have to apply with substitution each time you want to use them, and the less need there is for a book documenting the justification with sample code, as you just need the actual implementing code with documentation as to its interface.
OTOH, presentationally, its possible to document constructs is a pattern language for software without as much attention to implementation in a particular language as GoF provides. GoF particular choice of constructs and its choice of how to present them, I think, are very much shaped by desire to serve as an implementation cookbook -- a set of tricks -- for a particularly industrially-popular programming language family as well as providing a common pattern language for software constructs that transcends particular programming language choices (and its success and popularity are in no small part due to its utility as a set of tricks.)
Hardly. The Go philosophy is "our language is designed to not need such architecture-astronauts' high-brow fanciness". Other than that, whatever architecture/design patterns you're used to should mostly carry-over to Go.
A change is as good as a rest. Maybe coding isn't his primary 'job'? I myself started on the business side, so the evenings and weekends learning to code were great fun and I definitely didn't see them as negative
Quick question about golang. In your code, go.user / user.go
You have a Boolean function Guest(). Is this a common practice in Golang vs. writing it as IsGuest() ?
I'm not sure if this is wholly idiomatic. I based it on the following from "Effective Go" [1]:
> There's nothing wrong with providing getters and setters yourself, and it's often appropriate to do so, but it's neither idiomatic nor necessary to put Get into the getter's name.
Since I view "is/has" as derivatives of "get", I opted to omit the "is" from Guest(). But I'm open to hearing other opinions.
There is probably plenty that is un-idiomatic all over this code and one of the reasons I put it out there is to get feedback.
Heh, true. Guest() exists because: (1) the html/templates are very limited in terms of in-template logic; and (2) I wasn't initially sure that u.Id == 0 would be the defining feature that determines that someone is a guest. So far, it seems to work well enough.
Where do you host askgolang? I have been working on a go server with websockets too. It seems like websockets cause trouble with Heroku, Google App Engine, and AWS (if you use the ELB).
This is on an instance of the smallest linode available (1024MB). It sits there with all of my other side projects.
Load average is negligible despite the HN load:
Load average: 0.04 0.06 0.06
I'm using Postgres on the backend and am not using any caching. This is being reverse proxied by nginx (so that I can host multiple golang projects on the same server over port 80).
Another thing to mention: I believe websockets use up file descriptors. If you are having issues with websockets despite nominal load, it's worth checking if you're exhausting your file descriptors.
I don't know about the architecture of Heroku, GAE, or AWS w/ ELB in terms of supporting the HTTP 1.1 Upgrade request to websockets. Perhaps they all use a reverse proxy that doesn't pass along the Upgrade request? Even nginx didn't support this before ~1.3.13.
I've been working with websockets on AWS for some data intensive bi-directional communication and haven't had any issues with it...However, I don't have it set up as an HTTP listener, I have it set to TCP 80 -> TCP <mylocalport>. The server architecture doesn't matter if a user drifts backend hosts if their connection drops and reestablishes (no stickiness needed). I haven't tried it under the HTTPS setting for SSL connections yet, but if there's flakiness, I know I can just terminate SSL on the ec2 instances instead of the ELB.
can you please try some variations in type size and weight? this would go a long way for legibility between questions, answers, comments, meta info like "submitted at", etc.
23 comments
[ 4.9 ms ] story [ 62.0 ms ] thread(aside: how is GoF "high-level/architecture/design"? it is just a collection of tricks for overcoming language inexpressiveness)
Referring to it as 'a set of tricks' would suggest to me that you've only given it a cursory glance and assumed that it's just about copying out example blocks of code, or that you've not worked in a wide enough set of languages to realize that every language has commonly used patterns for doing particular things, no matter how expressive the language is. Having a way to discuss the architecture of a piece of software without having to explain every implementation detail because there's already a shorthand refer to various parts of it is invaluable when working on larger projects. Being able to call a block of code as a flywheel is no more a trick than being able to refer to an options pricing equation as a 'modified black-scholes' - the important part is that other person knows from that what you're talking about and so you can get to the important part of the conversation.
I think it philosphically comes in part from that place, but the particular choice of constructs it addresses are a a commonly needed set that a particular language family's lack of expressiveness in certain dimensions required to be reimplemented using basically boilerplate code each time they were used, so it spends a lot of time documenting the set of tricks necessary to implement those constructs in that language family.
> you've not worked in a wide enough set of languages to realize that every language has commonly used patterns for doing particular things, no matter how expressive the language is
The more expressive a language is, the more the "commonly used patterns" can be turned into libraries rather than templates you have to apply with substitution each time you want to use them, and the less need there is for a book documenting the justification with sample code, as you just need the actual implementing code with documentation as to its interface.
OTOH, presentationally, its possible to document constructs is a pattern language for software without as much attention to implementation in a particular language as GoF provides. GoF particular choice of constructs and its choice of how to present them, I think, are very much shaped by desire to serve as an implementation cookbook -- a set of tricks -- for a particularly industrially-popular programming language family as well as providing a common pattern language for software constructs that transcends particular programming language choices (and its success and popularity are in no small part due to its utility as a set of tricks.)
Hardly. The Go philosophy is "our language is designed to not need such architecture-astronauts' high-brow fanciness". Other than that, whatever architecture/design patterns you're used to should mostly carry-over to Go.
Maybe it wasn't exactly relaxing, but it has been fun!
> this is how people get burned out...
This is how I re-energize when taking a break from medicine :-)
Thanks for sharing, BTW!
> There's nothing wrong with providing getters and setters yourself, and it's often appropriate to do so, but it's neither idiomatic nor necessary to put Get into the getter's name.
Since I view "is/has" as derivatives of "get", I opted to omit the "is" from Guest(). But I'm open to hearing other opinions.
There is probably plenty that is un-idiomatic all over this code and one of the reasons I put it out there is to get feedback.
1 = http://golang.org/doc/effective_go.html#Getters
Load average is negligible despite the HN load:
I'm using Postgres on the backend and am not using any caching. This is being reverse proxied by nginx (so that I can host multiple golang projects on the same server over port 80).I don't know about the architecture of Heroku, GAE, or AWS w/ ELB in terms of supporting the HTTP 1.1 Upgrade request to websockets. Perhaps they all use a reverse proxy that doesn't pass along the Upgrade request? Even nginx didn't support this before ~1.3.13.
can you please try some variations in type size and weight? this would go a long way for legibility between questions, answers, comments, meta info like "submitted at", etc.