tags:

views:

593

answers:

5

Today a great friend of mine asked me what are the main differences between the newest Go language and Cython, which is a set of C-extensions for Python. I don't have much knowledge on Python, can anyone tell me why Go is better/worse than Cython?

Best regards,

Miguel Rentes

+1  A: 

GO introduces goroutines and channels. See language FAQ

Alexandru
+4  A: 

Differences? Pretty much everything!

  • Concurrency and channels.
  • Interfaces.
  • Static typechecking.
  • ...
uriel
A: 

My main reason for trying out go is the supposed ease of introducing concurrency into programs. I think that will be the 'next big thing', as processor speeds will tail off, and increasingly multiple cores are available. If you want to make use of multicore processors, you need to write your program so that it can run things concurrently.

I earlier looked at Erlang, but despite being used to Prolog I find it a bit strange still; it is so different from your 'average' programming language (of the C or Pascal family). But its concurrency features are easy to use, once you get the hang of it. With very little effort I was able to write a parallel parser, which does not use a stack, but spawns a new 'thread/process' every time there were multiple options.

So far go looks quite alright, despite some slight inconsistencies. And it's also fast, which is a bonus.

So unless Cython also makes concurrency easy, I'd favour go...

Oliver Mason
+6  A: 

Cython isn't really a language in the conventional sense. It is a preprocessor for building Python extensions that takes Python-like syntax (actually they strive for full Python compatibility) and produces C code (using the Python C API). Doing this they are able to include some special case optimisations, but the real benefits come when you add Cython specific static type information which is incorporated into the C code, bypassing the Python runtime for those operations and resulting in a high speed up.

Go is a compiled programming language. The first thing that can be done in Go is producing an executable that doesn't include the Python runtime/start a Python interpreter - this is impossible in Cython. (May not be technically impossible - but there is really no point to use Cython if you are not working with Python). Since Cython just produces C most of your questions in the comment don't really apply - you can use any C debugger (although the fact that's a Python extension makes things a bit more complicated).

thrope
+1  A: 

gevent is a concurrent library that uses Cython at its core. It seems to be pretty fast: http://nichol.as/asynchronous-servers-in-python

Ben Ford