Why Go? Use Racket!

Go Racket C/C++
channel channel blocking queue
goroutine thread light-weighted thread
select sync epoll/kqueue

I had expected Go could save us from the heavy burden of programming complex network applications (Web servers at frontend and RPC server at backend). However, I am disappointed.

It is true that Go’s concurrent programming facilities (goroutine, channel and select) works great and can remove all the asynchronous RPC calls and chains of callbacks.  For how Go can do this, you might want to watch Rob Pike’s talk, Go Concurrency Patterns, on Google I/O 2012.

However, the type system of Go is so complex; programmers need to know all the details about the implementation of standard types, before they can use them correctly.  For example, it is efficient to pass a channel as the parameter of a function all, because a channel in Go is as simple as a pointer to the channel data structure implemented in C.  It is the same for map and some other types.  But it is inefficient to pass an array or struct; instead, we should pass pointers to these types.

Another example is about interface, the base of polymorphism in Go. The reflection mechanism of Go makes it convenient to judge the real type referred to by an interface variable. But we are not allowed to convert the interface into that type. Instead, we can convert it into a pointer to that type.  This is because an interface variable is a pair of two pointers, one points to the real variable, and the other one points to a method list.

Given the pros and cons of Go, what I want is a language, which has a comprehensive type system and implements the CSP (communicating sequential processes) model. Also, I hope this language is open source (as Go), has a Web based third party libraries creation and publication system, and can express complex computing logic in an intuitive way.  I am feeling lucky that I found one — Racket.  Racket was formerly known as PLT Scheme.  I used it to learn Lisp programming 8 years ago.  I won’t know it was renamed if my old friend, Yin, do not tell me.

Racket is open source. It is an enhanced version of Scheme with macro and pattern matching functions. So it is much more powerful than C/C++/Java/Go in expressing complex algorithms. For example, using C/C++/Java, a multi-page Web-based wizard would correspond to a set of HTTP handlers, each for a page. However, using continuation, a well-known programming construct in Lisp, we would need only one handler! (Here is an example.)

Racket has hundreds of third party libraries, including network programming and Google protobuf, published on PLaneT.  And yes, Racket also implements CSP as Go, as shown in the table at the beginning of this post.

P.S. As noted in this post, Racket programs build and run much slower than Go programs.

22 Responses to “Why Go? Use Racket!”

  1. Josh Says:


  2. Chinese Whispers in Racket and Go « Yi Wang's Tech Notes Says:

    […] my previous post Why Go? Use Racket!, I pointed out that CSP facilities provided with the Go programming language also exist with […]

  3. asdf Says:

    Can’t click on “(Here is an example.)”

  4. Me Says:

    CSP = Communicating Sequential Processes

  5. Me Says:

    Racket was formally known as PLT Scheme, not DrScheme

  6. Why Go? Use Racket | Rocketboom Says:

    […] Why Go? Use Racket Source: https://cxwangyi.wordpress.com/2012/07/22/why-go-use-racket/ 0    […]

  7. A bag of ricks Says:

    What I heard was: I don’t want to use go, because I don’t want to learn about type system and crucial part of how stuff works in it.

    Whine less and don’t expect static language people to pick a dynamic type language just because of some minor/inferior features.

  8. Allen Says:

    I’m not sure I understand; your complaint with Go has to do with efficiency, so why use a language which you admit is less efficient than Go? Why not switch to some other fast concurrent language like Haskell, Rust or ML (all of which have pattern matching, btw).

    • cxwangyi Says:

      You are right. Haskell is a good choice. I am not sure ML is as good as Haskell from the perspective of concurrent programming. Anyway, I am lazy to remember syntax things, and among all Lisp-style languages Scheme has the most concise syntax. That is the reason I always put an eye on the development of Scheme.

    • Wang Yi Says:

      That is because Racket provides similar concurrent programming facility as Go. However, I changed my mind during recent months, as I had been developing a large scale machine learning system using Go, which makes me feel that high performance is really critical. Given Go authors have been successfully improving the runtime performance of compiled-code, I still have to program some computation intensive parts of the system (mostly Gibbs sampling) using C++ and make the Go program to call C++ routines. I believe Haskell, Rust and ML are superior than Go in many aspects, but I see Go on a track of fast performance improvement.

  9. Passing pointers vs. value in GoQueryBy | QueryBy, ejjuit, query, query by, queryby.com, android doubt, ios question, sql query, sqlite query, nodejsquery, dns query, update query, insert query, kony, mobilesecurity, postquery, queryposts.com, sapquery, j Says:

    […] read this interested blog post that is totally unrelated to Go and one thing the author said caught my attention, this following […]

  10. Moving pointers vs. worth in Proceed | CodersDiscuss.com Says:

    […] have read this involved article that’s completely unrelated Togo and something the writer stated captured my interest, this […]

  11. 1p – Why Go? Use Racket | Profit Goals Says:

    […] https://cxwangyi.wordpress.com/2012/07/22/why-go-use-racket/ […]

  12. 1p – Why Go? Use Racket | blog.offeryour.com Says:

    […] https://cxwangyi.wordpress.com/2012/07/22/why-go-use-racket/ […]

  13. 1p – Why Go? Use Racket | OnAdvertise.com Says:

    […] https://cxwangyi.wordpress.com/2012/07/22/why-go-use-racket/ […]

  14. 1p – Why Go? Use Racket – Exploding Ads Says:

    […] https://cxwangyi.wordpress.com/2012/07/22/why-go-use-racket/ […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 38 other followers

%d bloggers like this: