Go is concise !

221 views
Skip to first unread message

Valentin Kasas

unread,
Jun 15, 2011, 11:41:04 AM6/15/11
to golang-nuts
package main;import . "http";func main(){HandleFunc("/",func (w
ResponseWriter,r *Request){ServeFile(w,r,".")});ListenAndServe(":
8080",nil)}

This is not very clean nor really useful, but it fits in a tweet !

ptolomy23

unread,
Jun 15, 2011, 11:48:26 AM6/15/11
to Valentin Kasas, golang-nuts
Concise isn't something to brag about; concise and maintainable is.

Nice microprogram, though.

Valentin Kasas

unread,
Jun 15, 2011, 11:54:19 AM6/15/11
to golang-nuts
> Concise isn't something to brag about; concise and maintainable is.

I agree, although, there are times when conciseness is a valuable
argument, e.g. when you argue with dirty perl/ruby programmers. ;)

Russ Cox

unread,
Jun 15, 2011, 12:13:11 PM6/15/11
to Valentin Kasas, golang-nuts
package main;import."http";func
main(){ListenAndServe(":8080",FileServer(".","/"))}

Valentin Kasas

unread,
Jun 15, 2011, 12:17:30 PM6/15/11
to golang-nuts
sweet !
how could I overlook FileServer ?

very much cleaner.
thx !

André Moraes

unread,
Jun 15, 2011, 12:51:52 PM6/15/11
to golang-nuts
On Wed, Jun 15, 2011 at 1:13 PM, Russ Cox <r...@golang.org> wrote:
> package main;import."http";func
> main(){ListenAndServe(":8080",FileServer(".","/"))}
>

This is concise and easy to understand. :-D

--
André Moraes
http://andredevchannel.blogspot.com/

Martin Capitanio

unread,
Jun 15, 2011, 1:13:45 PM6/15/11
to golan...@googlegroups.com


On Wednesday, June 15, 2011 6:51:52 PM UTC+2, André Moraes wrote:
On Wed, Jun 15, 2011 at 1:13 PM, Russ Cox <r...@golang.org> wrote:
> package main;import."http";func
> main(){ListenAndServe(":8080",FileServer(".","/"))}
>

This is concise and easy to understand. :-D


In other cases you can pipe it through the built-in Go deobfuscator :-P

Andy Balholm

unread,
Jun 15, 2011, 6:09:48 PM6/15/11
to golang-nuts
On Jun 15, 9:17 am, Valentin Kasas <valentin.ka...@gmail.com> wrote:
> how could I overlook FileServer ?

You're not the only one! After reading that, I just eliminated a whole
source file from a project I was working on.

konrad

unread,
Jun 15, 2011, 11:18:59 PM6/15/11
to golang-nuts
This dosn't really demonstrate your point. I can't think of a language
which woun't be comparable simple when all you want to do is
import a library
make one function call

Having a comprehensive libarrary, or at least one with good coverage
of your problem domain, is not the same thing as having a concise
language.

Rohit

unread,
Jun 15, 2011, 11:58:09 PM6/15/11
to golang-nuts
@konrad: Hello. You are obviously right. But do you feel Go is not
concise?

Rohit

Valentin Kasas

unread,
Jun 16, 2011, 9:58:30 AM6/16/11
to golang-nuts


On Jun 16, 5:18 am, konrad <kzielin...@gmail.com> wrote:
> This dosn't really demonstrate your point. I can't think of a language
> which woun't be comparable simple when all you want to do is
> import a library
> make one function call

You made a point. I should have titled this post "Go and its standard
library allow you to write powerful AND concise programs !" which
wouldn't have been very concise ^^.
By the way, I speak from a java programmer's point of view. With java
and its standard libraries, I think one cannot express very much with
about 100 characters.

Roberto Bayardo

unread,
Jun 16, 2011, 2:39:11 PM6/16/11
to Valentin Kasas, golang-nuts
But "concise" usually means "unreadable & unmaintainable code" (I'm looking at you Perl, and to some extent Python). 

I like that in Go its conciseness doesn't really interfere with its readability, but maybe that's just personal preference.

André Moraes

unread,
Jun 16, 2011, 2:56:42 PM6/16/11
to golang-nuts
> But "concise" usually means "unreadable & unmaintainable code" (I'm looking
> at you Perl, and to some extent Python).

Don't forget ruby

David Leimbach

unread,
Jun 16, 2011, 3:03:26 PM6/16/11
to golang-nuts
I can write a C++ word counter in one line too (using standard
libraries and templates). I think "clean, comprehendible syntax" is
more important than just concise.

Dave

Steven Blenkinsop

unread,
Jun 16, 2011, 3:09:04 PM6/16/11
to golang-nuts
On Thursday, June 16, 2011, Roberto Bayardo <bay...@alum.mit.edu> wrote:
> But "concise" usually means "unreadable & unmaintainable code" (I'm looking at you Perl, and to some extent Python).

"Concise" means providing a lot of information in a way that is both
brief and easy to understand. People often forget about the crucial
second part of the equation.

konrad

unread,
Jun 17, 2011, 2:42:02 AM6/17/11
to golang-nuts
The same program in Python by the way looks like this

import SocketServer, SimpleHttpServer
SocketServer.TCPServer(("", 8080),
SimpleHttpServer.SimpleHTTPRequestHandler
).serve_forever()


And no I don't consider Go particularly consice, incomparison to most
other languages but then again it is not trying to be as far as I'm
aware. Its just that Java is very verbose (Object oriented programming
style tends to lead to verbosity, and when thats what your language is
about ...).

On Jun 17, 4:39 am, Roberto Bayardo <baya...@alum.mit.edu> wrote:
> But "concise" usually means "unreadable & unmaintainable code" (I'm looking
> at you Perl, and to some extent Python).
>
> I like that in Go its conciseness doesn't really interfere with its
> readability, but maybe that's just personal preference.
>

woo

unread,
Jun 17, 2011, 11:47:25 AM6/17/11
to golan...@googlegroups.com
Or python2 -m SimpleHTTPServer


On 06/17/2011 02:42 PM, konrad wrote:
> The same program in Python by the way looks like this
>
> import SocketServer, SimpleHttpServer
> SocketServer.TCPServer(("", 8080),
> SimpleHttpServer.SimpleHTTPRequestHandler
> ).serve_forever()
>
>
> And no I don't consider Go particularly consice, incomparison to most
> other languages but then again it is not trying to be as far as I'm
> aware. Its just that Java is very verbose (Object oriented programming
> style tends to lead to verbosity, and when thats what your language is
> about ...).
>
> On Jun 17, 4:39 am, Roberto Bayardo<baya...@alum.mit.edu> wrote:

>> But "concise" usually means "unreadable& unmaintainable code" (I'm looking

Lars Pensjö

unread,
Jun 17, 2011, 3:51:49 AM6/17/11
to golan...@googlegroups.com


On Friday, June 17, 2011 8:42:02 AM UTC+2, konrad wrote:
And no I don't consider Go particularly consice, incomparison to most
other languages but then again it is not trying to be as far as I'm
aware. Its just that Java is very verbose (Object oriented programming
style tends to lead to verbosity, and when thats what your language is
about ...).


I think Go is a nice improvement in comparison to Java/C++ in this regard. If you do it the Go idiomatic way, not counting libraries, algorithms can be expressed both more concise and more readable at the same time.

ceving

unread,
Jun 17, 2011, 4:45:08 AM6/17/11
to golang-nuts
On Jun 15, 5:41 pm, Valentin Kasas <valentin.ka...@gmail.com> wrote:
> package main;import . "http";func main(){HandleFunc("/",func (w
> ResponseWriter,r *Request){ServeFile(w,r,".")});ListenAndServe(":
> 8080",nil)}

Bash is even more:

/etc/init.d/httpd start

> This is not very clean nor really useful, but it fits in a tweet !

This thread is "not really useful".
Reply all
Reply to author
Forward
0 new messages