Live data from Hacker News

Martini: Classy web development in Go

martini.codegangsta.io

11–20 of 30 posts

Re: Martini: Classy web development in Go

#11
post #6

I usually don't like video walk-throughs, but this one was very snappy and a pleasure to watch. By a happy coincidence, I was just going to start building an API backend in Go today or tomorrow for a side project, and was thinking about doing it with vanilla Go but now I'll probably give Martini a shot (!).

This one was good, I don't know if there is sound as I watched it silently, but it was perfect even without it.

Im hooked, likely to start learning go soon. P.s. Big respect for being able to make the video below 3 min.

Re: Martini: Classy web development in Go

#13
post #9

Very cool. Reminiscent of express.js, but statically typed and in Go. I may look at this for future projects.

Looks like a lot of reflection. At that point, I would just stick with express and node. All that magic comes at a cost.

> Looks like a lot of reflection. At that point, I would just stick with express and node. All that magic comes at a cost.

There's one use of reflection[1], and it's to ensure that the argument is a function.

Reflection isn't inherently bad; using it at the drop of a hat is.

[1]: https://github.com/codegangsta/martini/blob/master/martini.g...

[edit]: Looks like I missed the `inject` import (thanks breakpete)

Re: Martini: Classy web development in Go

#15
post #9

Earlier quoted context omitted.

Looks like a lot of reflection. At that point, I would just stick with express and node. All that magic comes at a cost.

> Looks like a lot of reflection. At that point, I would just stick with express and node. All that magic comes at a cost. There's one use of reflection[1], and it's to ensure that the argument is a function. Reflection isn't inherently bad; using it at the drop of a hat is. [1]: https://github.com/codegangsta/martini/blob/master/martini.g... [edit]: Looks like I missed the `inject` import (thanks breakpete)

There is more. The dependency injection implementation is based on reflection, using the https://github.com/codegangsta/inject package.

See e.g

https://github.com/codegangsta/martini/blob/master/martini.g...

https://github.com/codegangsta/martini/blob/master/martini.g...

Still, the end result is a nice API.

Re: Martini: Classy web development in Go

#16
post #10

I really like the look of this. There's some very clever API design going on here, and it's clearly taking advantage of Go's language features rather than just trying to be a clone of a framework from another language. I particularly like the service injection concept. Django forces every view function to take a request object and return a response object. Flask makes these optional, but then requires you to use glob…

> The way it allows you to stack up Handlers is neat too.

Ditto. I especially like that it's fully compatible with the existing http.HandlerFunc interface, which is a big deal. This means you can just write "regular" handlers as middleware (or bring them over from existing code) without having to reinvent the wheel.

I also very much like the way it leaves sessions up to you. A few other Go frameworks leverage http.Cookie, instead of letting you use something like gorilla/sessions. I'm a big proponent of server-side sessions (wherever possible) given how simple gorilla/sessions + Redis can be to set up.

I'm a little tempted to use this myself (I've been going mostly naked so far) for my weekend (read: also weeknight) project, given that all the "real" logic (middleware, DB queries, etc.) can be dropped in alongside it.

Re: Martini: Classy web development in Go

#18
post #10

I really like the look of this. There's some very clever API design going on here, and it's clearly taking advantage of Go's language features rather than just trying to be a clone of a framework from another language. I particularly like the service injection concept. Django forces every view function to take a request object and return a response object. Flask makes these optional, but then requires you to use glob…

Thanks for the feedback! I knew from the beginning that I didn't want to create another clone framework. The Golang community needs something that is in line with it's own philosophies.

Re: Martini: Classy web development in Go

#19
Newbie question here, I've looked into gorilla/mux before, how does Martini compare to it? Do they serve the same purpose? Does it offer more features? Is it easier to use?

Great-looking website by the way. The first impression is a good impression, it's very polished.

Re: Martini: Classy web development in Go

#20
post #10

I really like the look of this. There's some very clever API design going on here, and it's clearly taking advantage of Go's language features rather than just trying to be a clone of a framework from another language. I particularly like the service injection concept. Django forces every view function to take a request object and return a response object. Flask makes these optional, but then requires you to use glob…

> The way it allows you to stack up Handlers is neat too. Ditto. I especially like that it's fully compatible with the existing http.HandlerFunc interface, which is a big deal. This means you can just write "regular" handlers as middleware (or bring them over from existing code) without having to reinvent the wheel. I also very much like the way it leaves sessions up to you. A few other Go frameworks leverage http.Co…

Yup. Making the "dropping in" part easy is partly why Martini can be kept clean on the number of dependencies it pulls in. The only external dependency on Martini is https://github.com/codegangsta/inject which I maintain anyway :)
Post reply on HN