Go vs Python

Adrian Morales
Adrian Morales

Pros vs cons of Golang vs Python?

Whats your pick?

All urls found in this thread:
http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=go&lang2=python3
https://opensource.googleblog.com/2017/01/grumpy-go-running-python.html
https://www.techempower.com/benchmarks/#section=data-r13&hw=ph&test=plaintext&l=3vtypr&a=2
https://www.python.org/dev/peps/pep-3146/
http://talks.golang.org/2012/splash.article
https://blog.plan99.net/modern-garbage-collection-911ef4f8bd8e
http://golang.web.fc2.com/
https://github.com/InaneBob/sum_bytes
http://benchmarksgame.alioth.debian.org/
https://golang.org/ref/spec#Comparison_operators
https://golang.org/doc/code.html
http://stackoverflow.com/questions/25734504/different-pointers-are-equal
http://stackoverflow.com/questions/25749484/equal-pointers-are-different
Jayden Cox
Jayden Cox

go is faster
python is more fun
their both shit

Leo Smith
Leo Smith

go is made by google
expect it to live 5 years and then abandoned

Noah Foster
Noah Foster

go is faster
Proofs?

Andrew Torres
Andrew Torres

http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=go&lang2=python3

Now fuck off.

Christopher Thompson
Christopher Thompson

Just learn C++

Colton Smith
Colton Smith

How are these two comparable in the slightest?

Christopher Turner
Christopher Turner

Isn't Go supposed to be a C competitor? Comparing it to Python is stupid, because they're different tools used for different purposes. Go/C is for when you want to get more performance, and Python is for when you want to make something quickly.

Luis Fisher
Luis Fisher

I used to be really like the idea of Python until I actually started using it. Python is not easy not learn like many will make you believe, rather it is forgiving therefor easy to dive in, but in reality hard to master.

Python advantages over Go
- richer ecosystem
- better tooling
- bigger community
- better support for GUI programming
- faster prototyping

Go is a very unique language, it is high abstraction language, but still compiles to native executable and also has garbage collection (sub-ms pauses). The language by itself is very simple & opinionated, meaning that there is always a preferred way of doing things. There is no Java-like OOP, there is not high functional programming features. Some may say that's bad, but I personally love that about Go. I love reading other people's Go code.

Go advantages over Python
- native executable by default
- faster
- better garbage collector
- easier to master
- sane language design without OOP insanity and functional programming cancer

There you go. Even though if you are beginner I would advice not learning ether of those two. If you're studying CS, study concepts and get to know the basics of the language they teach in. If you're self thought then just focus on one platform you want to work in.

Android -> learn Java
iOS -> learn Swift
web frontend -> learn HTML, CSS, JavaScript, jQuery...
web backend -> learn PHP or Python or Ruby or NodeJS
Windows applications -> learn C#
embedded devices -> learn C
game development -> learn C++ (don't actually learn self tough game development)

Leo Howard
Leo Howard

Are you retarded? Go was released in 2009, now it is 2017. 2017-2009 = 8 years (actually more like 7 if you account for months).

Go is not a consumer product, but a developer one. Google discontinues their projects because they can't monetize the specific platform.

They are slowly rewriting all their legacy Python 2.7 codebase to Go.

Dominic Taylor
Dominic Taylor

gophers pls *go*

Jordan Moore
Jordan Moore

gophers pls *go*

Bentley Lopez
Bentley Lopez

Fucks up sage
Doesn't know how to bold text

Carter Wright
Carter Wright

I have said it here before and I'll say it again: Go is perfect for what it was designed for: server programs.

No, it's supposed to replace Java and C++ for server programs.

Not only that.
Google has written a new Python runtime in Go that transpiles Python to Go code:
https://opensource.googleblog.com/2017/01/grumpy-go-running-python.html

Jack Ramirez
Jack Ramirez

I have not seen pedobear in years.

Charles Richardson
Charles Richardson

web backend -> learn Rust
Windows applications -> learn Rust
embedded devices -> learn Rust
game development -> learn Rust
fixd

Eli Hughes
Eli Hughes

Python:

Very high level
Very well designed
Supports OOP and FP
20-30 times slower than C
Mature, no big changes expected in the foreseeable future
Widely used in industry
Outstanding third-party libraries
Arguably wider scope of application
Community is somewhat fragmented
Main competitors: Perl, Ruby, Lua, JavaScript, PHP
You can actually get paid to write Python code

Go:

Lower level than Python, higher level than C
Lots of design choices are questionable and have caused much controversy
Largely a procedural language
2-3 times slower than C
Go 2.0 will break everything (and either make Go a smashing success or sink the ship)
Niche language used by a handful
Not that many libraries available yet
Arguably suitable only for certain use cases
Not much fragmentation in Go's community
Main competitors: C, C++, D, Rust, Java
Finding a job may be challenging (but will pay better)

Mason Taylor
Mason Taylor

Being white
Getting paid to write code in any language

Jaxson Sullivan
Jaxson Sullivan

CHECKMATE ATHEISTS

Jackson Miller
Jackson Miller

Lots of design choices are questionable and have caused much controversy

DAE LIKE GENERICS LE REDDIT ARMIE, pls go

C and Go are the only sanely designed languages.

I wish Scala-tier pajeets would stop ruining programming.

Xavier Peterson
Xavier Peterson

Isn't go explicitly designed as a pajeet-friendly language?

Parker Ward
Parker Ward

Explicitly designed? I don't think so. Pajeet-friendly? Yeah it is.

Go is antithesis to what modern programming has become.

Jeremiah Wood
Jeremiah Wood

In a previous golang thread, someone posted a quote from one of Google's devs explaining that go was designed to accommodate brainless, thoughtless programming for their interns/outsourced coders. I'm sure they anti-go folks will be happy to repost it.

Owen Cooper
Owen Cooper

Explicitly designed? I don't think so.
Some people would want you believe that Go was made by Google to employ more pajeets. But reality is that Go is far from just being Google's toy project. There was a recent controversy where Google wanted to add a feature to Go that would make easier for them to maintain certain projects, but it was a half-baked solution. Community complained and Go developers immediately dropped the feature.

Go is controversial because it is very good for niche programming fields like servers and cli utilities, but doesn't excel at everything.

The key point here is our programmers are Googlers, they’re not researchers. They’re typically, fairly young, fresh out of school, probably learned Java, maybe learned C or C++, probably learned Python. They’re not capable of understanding a brilliant language but we want to use them to build good software. So, the language that we give them has to be easy for them to understand and easy to adopt.
t. Rob Pike

This is how Rob Pike sold the idea to Google to get resources. Go is nowhere near Pajeet-friendly as Java or Python for example.

Lucas Sullivan
Lucas Sullivan

garbage collector
How is that an advantage?

Asher King
Asher King

sub-ms garbage collector

Ethan Peterson
Ethan Peterson

Let me reiterate for you:
garbage collector
How is that an advantage?

Adam Kelly
Adam Kelly

Not using Cython
no u

Daniel Lopez
Daniel Lopez

The point is not freeing you from the hassle of remembering to "free" your memory, but consenting you to share memory between "threads" without the hassle of maintaining a owner that must free it when all the other users have stopped using it. In fact the latter part of my last sentence describes a gc, and in that context is mandatory (in lot of simple cases you can come up with an ad hoc solution that is probably better then a generic gc, but in the end the gc is fucking convenient and simplifies even those cases)
Even with channels, for performance sake, you want to share memory; channels maintain their second purprose: synchronization

Hunter Flores
Hunter Flores

Look on yt "static void main" from Pike. They designed the language to be ergonomic for them (unix patriarchs). Incidentally a well written language is good even for pajeets and that's how even I would sold a similar project to management.

Landon Flores
Landon Flores

Go is pratically usable everywhere.
Nobody has never said a shit about 2.0
Go has lots of things that you would consider "functional", but sometimes has preferred different compromises (like multivalued return and for cycles instead of tail recursion). Those choices are not mindless given how easy it is to read other people go code (which is shockingly one of the best language features), and that Turing machines are still the basic model for computation at the hardware level and not lamba calculus (inb4: derp, von Neumann, lamba calculus cannot).
The rest is less inaccurate.

Jace Murphy
Jace Murphy

Too much readability is not good too. Code should have a barrier against those who are too dumb and must not be allowed to touch it.

Chase Murphy
Chase Murphy

What constitutes a barrier to changing code that does not belongs to you is your own ignorance: specifically of the application domain, not of the code. If one is so stupid to change code that don't know why is there, he won't be stopped by simply don't understanding the code itself.
The right solution for the problema is not creating unreadable languages, but setting permissions on repositories...

Nicholas Myers
Nicholas Myers

This is Poe's law tier.

Juan Wood
Juan Wood

What kind of shit argument is this? Holy shit.

Matthew Fisher
Matthew Fisher

Rust is purely a fad. At least Go is out of beta and will still be around in a couple years.

Henry Butler
Henry Butler

Rust will suffer from the same problems of C++ because the design principles are nearly the same (from runtime cost free abstraction but not so programmer /compile time friendly, to a preference for having always the right functionality at hand instead of minimalism and orthogonality, passing for the usual love for simple interface even at cost of complex implementation instead of full stack simplicity).
It is only updated to the state of the art of what that community (lot of times rightfully) thinks are best programming practices right now.

Ayden Morgan
Ayden Morgan

I don't know how people stand Rust syntax.

Oliver Bailey
Oliver Bailey

Too much readability is not good too.

Samuel White
Samuel White

I really don't mind, if it becomes as complex as C++, as long as three things eventually are all true:
- the compiler proves that the complex code I've written is safe
- the compiler optimises the abstractions down to C++ performance in almost all use cases
- the compiler compiles at least as fast as modern C++ compilers

Currently only the first one is true. Waiting for Rust to mature. It's a good concept, but all software written right now hinges on the assumption that Rust will eventually become a safe C++.

Luke Sanders
Luke Sanders

Rust isn't forced to carry a massive cinderblock in the name of backwards compatibility.
It also won't suffer from the same problems of C++, because the design principles are not the same. Take a look at how Rust implemented RC/Mutex for dynamic enforcement of alias rules.
Without such enforcement, Stroustrup's model for type/resource safety is fucking useless. It all relies on being able to statically proven to not alias on function entry.
Protip: you can't do that with all mutable references in modern C++, with shared_ptr for example.

Andrew Mitchell
Andrew Mitchell

Im slowly learning Python and enjoying it without having any prior real knowledge of programming or scripting.

Fight me.

Justin Powell
Justin Powell

Python is a pretty good language, it would've been infinitely better if it used curly brackets and semicolons instead of whitespace though

Adam Campbell
Adam Campbell

What about various devices used in conjunction for a robot?

Landon Sanchez
Landon Sanchez

python would be a good language with do blocks instead of braces

Cooper Edwards
Cooper Edwards

C competitor
Doubtful. It was designed to replace C++ in most applications, but using it in place of Python is perfectly acceptable too, considering Go's focus on readability.

Zachary Morris
Zachary Morris

Why? You'll end up indenting in any case if you value readability, so why mark code structure twice (in ways that don't necessarily agree with each other) when you could do it once? Seems unnecessarily complex.

Tyler Russell
Tyler Russell

The design principles are instead nearly the same I repeat.
The features will be simply more polished, updated, and better working. Lot of shit won't be there. But in the end it will suffer from the same problem, namely complexity and on the long run deprecated things or more way to do the same things.
That community is willing to accept the trade offs like but not all programmers feel the same.

Grayson Diaz
Grayson Diaz

More on the current state of Rust vs Go/C++:
- The compiler is nowhere near as optimising as it should be. Currently some code will be faster than both C and C++, some will be on par, but the majority will be Go-Java speed.
- The compiler is not even multithreaded. The final compilation step, which I assume to be linking and optimisation, can take extremely long and all on a single core.
- Libraries, or, more importantly - high performance libraries, are lacking. As an example Go's standard library's HTTP server is ~16 times faster than Mozilla's Hyper HTTP server ( https://www.techempower.com/benchmarks/#section=data-r13&hw=ph&test=plaintext&l=3vtypr&a=2 ) and it even drops some of the requests in the benchmark. I am comparing the goto fully-featured servers, not some stripped down special purpose libraries. Work is underway to make Hyper use nonblocking I/O and such, but is not yet there.
- Rust is still changing. Go is a relatively mature language. It's had plenty of time to accumulate backwards compatible improvements, but Rust is only a year old since 1.0. A lot of important features are still in development and many libraries rely on the nightly compiler to even work.

tl;dr: Rust needs another 4-5 years to become usable in mainstream production.

Carter Gray
Carter Gray

In fact, what I don't understand of Rust (in reality of every language) are the zealots.

Tyler Morris
Tyler Morris

Brand identity or, in more severe cases - religion. This has existed among humans for millennia.

Hudson Peterson
Hudson Peterson

tl;dr: Rust needs another 4-5 years to become usable in mainstream production.
It will not survive that long. In short order it will be surpassed, abandoned, and forgotten, like Clay.

Generic programming was a mistake.

John Richardson
John Richardson

It will only go under, if Mozilla goes under. But the inverse is also true. If Mozilla does not fix all their memory leaks and data races with Servo, they are pretty much dead.

Maybe I should learn Ada.

Nathan Phillips
Nathan Phillips

No one's really a zealot here, it's just fun to watch you sperg out over simple facts or a bit of sarcasm. So much so retards like you ramble about "marketers" and such.

Camden Harris
Camden Harris

hurr

Gabriel Young
Gabriel Young

Lexing and parsing (and interpretano in the sense of interpreter) simplicity.
The possible strabism of indentation can be cured with a tool like gofmt (which works due to go extremly regular grammar)

Joshua King
Joshua King

If you cannot write lexer and parser for indent-based language, it doesn't mean that it is hard.

Charles Nguyen
Charles Nguyen

What's so complicated about parsing indentation? I get that it's slightly harder than parcing curly brackets, but only very slightly - not enough to factor into decisions about syntax. It's not tricky.

Liam Bailey
Liam Bailey

Python's fun. Once you get a grasp on it I would suggest looking through all the what's new in python docs to see some shit you probably wouldn't have found on your own and the reason they were put in.

Nicholas Miller
Nicholas Miller

If you can it doesn't mean that you should.
In a scale of complexity that goes from regular to recursively enumerable, Python grammar is context-sensitive especially because of semantic indentation (to be fair the scale is not discrete and the step to be context-free is little). The greatest part of the programming languages grammars are at least context-free.
Go is one of the few to be almost regular. This simplicity make the life easy to anyone that wants to write a tool to do something with the code, like formatting it, check that it respect some constraint, inspect it, generating anew etc. The compiler good performance is due even to this property of the language.
This is for the "complexity" part of the problem.

Now comes the controversial part: semantic indentation is prone to introduce subtle bugs, that are especially hard to find on large code bases not written by you. Think of a line that should be outside an if block, but instead stay on that indenation level for some reason (these kind of problems happens more with these languages). Maybe it causes a bug that will only happens sometimes in production and you will cry for nothing. And you will need to understand the entire surrounding code to understand the problem.

I said that this point is controversial because your experience may vary (it depends maybe by how many pajeets you must bear at work), but the first point is a clear win for the go grammar, while the advantages of semantic indentation (less parens?) are negligible.

Eli Sanchez
Eli Sanchez

They are slowly rewriting all their legacy Python 2.7 codebase to Go.

That's retarded. They should have gone Python 3 + Cython if needed.

Google has written a new Python runtime in Go that transpiles Python to Go code:
this is interesting, however transpiled code usually sucks dicks (not really good for subsequent reading/editing by humans) and compiling it the Cython way is already tried&tested thing.

Kevin Russell
Kevin Russell

Parsing Python is really fast in practice.

the advantages of semantic indentation (less parens?) are negligible
there is no such thing as improperly indented code in Python. isn't it neat?

Think of a line that should be outside an if block, but instead stay on that indenation level for some reason
Are you trying to say that this won't be obvious?
Like in-your-face obvious.
If a project is being done by such incompetent monkeys, it's doomed to fail regardless of language used.

Tyler Brown
Tyler Brown

using a million functions to avoid nested ifs
not being pajeet tier
do you also separate every function into it's own file

Zachary Roberts
Zachary Roberts

I'm not sure what you mean. Do you mean that Python doesn't let you use a gorillion layers of if-statements without getting really long lines? If so,
if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program
-- Linus Torvalds

Jonathan Nguyen
Jonathan Nguyen

Google apparently tried to modify Cython for their needs or do an extension and were rejected, so they're just going to make their legacy code fast this way.

Joshua Fisher
Joshua Fisher

Also, here's what they were trying to do:
https://www.python.org/dev/peps/pep-3146/

Xavier Flores
Xavier Flores

They tried to modify CPython (which is the standard implementation, while Cython is a Python superset which lets you mix in C), and they were not rejected - instead, they retracted the proposal when their own interest in it dropped for various reasons. Did you read that page?

Isaiah Walker
Isaiah Walker

It's not only a question of parsing but of creating tools that do static code analysis or modifications/refactoring, work on the code in a simpler way with tools like regexp, generating easly go code (this last one is really underrappreciated)...

Semantic indentation issues are well known, for some programmers that's not a problem, for others it is.

Jaxon Wright
Jaxon Wright

Here the semi official reason for not using indentation to declare block:

http://talks.golang.org/2012/splash.article

"As a simple, self-contained example, consider the representation of program structure. Some observers objected to Go's C-like block structure with braces, preferring the use of spaces for indentation, in the style of Python or Haskell. However, we have had extensive experience tracking down build and test failures caused by cross-language builds where a Python snippet embedded in another language, for instance through a SWIG invocation, is subtly and invisibly broken by a change in the indentation of the surrounding code. Our position is therefore that, although spaces for indentation is nice for small programs, it doesn't scale well, and the bigger and more heterogeneous the code base, the more trouble it can cause. It is better to forgo convenience for safety and dependability, so Go has brace-bounded blocks. "

Chase Moore
Chase Moore

It is better to forgo convenience for safety and dependability
This is the kind of thinking that got us Rust.

I'm using indentation-bounded syntax from now on.

Blake Walker
Blake Walker

gophers pls *go*

Jordan Miller
Jordan Miller

work on the code in a simpler way with tools like regexp
Are you dumb or what?

James Edwards
James Edwards

golang is surprisingly ergonomic and fun to write in, at least for the things it was designed for. you have to drag the language kicking and screaming if you want to do any "clever hacks" in it, but that's working as intended.

golang is the soldier's programming language.

ps rust sux and python a shit

Sebastian Gutierrez
Sebastian Gutierrez

go is controlled by google, stay away unless you enjoy getting buttfucked

it is also a useless language that would never would have seen the sun without the massive shilling from Google and paid shills on imageboards, hn, reddit etc.

Daniel Diaz
Daniel Diaz

ergonomic and fun
lol

Angel Mitchell
Angel Mitchell

ergonomic and fun
no generics

Adrian Powell
Adrian Powell

Go is free software. Anybody is free to make a new implementation of the language or otherwise fork Go to do something different.

Luis Lopez
Luis Lopez

So? The language is still controlled by Google in practice. It would take someting very dramatic to get people to properly fork it.

Dominic Williams
Dominic Williams

Neither, I'd use Perl instead since it has served me well over the years.

Caleb Wright
Caleb Wright

Maybe I should learn Ada
Everyone who's serious about programming should learn Ada.

Aiden Watson
Aiden Watson

oh no, google controls an implementation of their software
have you used it or just memes

Bentley Powell
Bentley Powell

Assuming you also know Python, are there things you find much easier/better in Perl than in Python? I'll probably learn Perl at some point, just out of interest, but I already know Python well so I'm wondering if learning it would be useful in a practical way.

Luis Ward
Luis Ward

oh no, google controls an implementation of their software
you just restated the problem

Ethan White
Ethan White

Dunno, I'm guessing it's probably better at text processing and regex stuff. But it's probably not worth learning just for that, if you're already comfortable with other scripting language.
Maybe Perl 6 has more to offer, but I never got into it.

Jordan Parker
Jordan Parker

what problem? that's not a problem

Andrew Harris
Andrew Harris

no generics is a meme
it is the sad reality. why would i use go over java? not that i would want to use java. i use rust

Anthony Anderson
Anthony Anderson

that's what interfaces are for. sure, it's not like a drop in replacement, but it's a simpler and more efficient way to get much of the same effect

Ayden Thompson
Ayden Thompson

When you know Perl well enough, doing text processing with something else feels like punishment. Also Moose makes you wonder why the other languages haven't done OOP this way.
If you are into hacky and autistic stuff, you should learn Perl.
Python is too neurotypical to be seriously considered here.

Adam Diaz
Adam Diaz

generics has nothing to do with interfaces. you know java 1.4 has interfaces and no generics and is much more trusted than go

Thomas Baker
Thomas Baker

not directly no, but they serve some of the same function of code reuse

William Russell
William Russell

interfaces
same as generics
kill yourself

Angel Harris
Angel Harris

I recently saw Francesc Campoy in person and I can confirm that he is indeed
T H I C C

Tyler Long
Tyler Long

https://blog.plan99.net/modern-garbage-collection-911ef4f8bd8e

Brody Allen
Brody Allen

13 minute read
okay thanks for the warning

Owen Thompson
Owen Thompson

tldr go gc is a shit compared to jvm gc

Cooper Diaz
Cooper Diaz

Rust isn't going anywhere until they severely improve the borrow checker. And that's a race against the halting the problem so good fucking luck with that.

Go is extremely performant, is extremely easy to learn, 3rd party code is almost always easy to read and there's pretty much no program out there that demands both perfect memory safety and high performance. So Rust is pretty much worthless for anything that isn't writing universal crypto libs/tools and browsers.

Jordan Lewis
Jordan Lewis

This is what java programmers really believe

Gengc looked like the best idea 20 years ago, these days... not so much. It's very cache unfriendly, it wastes a lot of memory, making the generational hypothesis work in practice is a lot of work and optimizing for throughput is the worst idea unless your program happens to have amazing scaling factors.

The approach taken by go, with well designed value types, aggressive escape and liveness analysis and a concurrent mark and sweep approach focused on latency is much better than the dead end that java is stuck in. That's why go beats java in many real world applications *already* despite being far younger. There's a reason they finally had to retrofit the JVM with escape analysis in 2010.

Nathan Bailey
Nathan Bailey

PS. I bet there's still people out there that believe JIT compilation gives java a speed advantage over AOT compilers.

Jaxson Taylor
Jaxson Taylor

this is your brain on go. not even once.

Ian Lee
Ian Lee

try sounding out the words next time if your reading comprehension is so poor

Bentley Foster
Bentley Foster

I disagree with the "Better tooling" part of the python advantages over golang.
Golang has a great tooling system.
Also it's a lot easier to learn due to the well designed simple nature of it.
Golang also has an actual purpose over Rust.

Isaiah Walker
Isaiah Walker

he thinks null terminated "strings" are sane design

Adrian Cooper
Adrian Cooper

golang slices, interface values, and strings break memory safety when subject to data races
here's pretty much no program out there that demands both perfect memory safety and high performance
dodged bullet again! top pragmatism

Kayden White
Kayden White

thinks generics have anything to do with reddit
typical gopher

Jeremiah Jones
Jeremiah Jones

literally can't think around not having generics
how does it feel to have half a brain? generics aren't some holy grail and if a language doesn't have them doesn't mean it's automatically shit you mongoloid.

fuck, even you with your half-brain should be able to understand go's type system since it's so simple, if you could stop shitposting for a solid hour

Kayden Myers
Kayden Myers

no generics
cry more go defense force

Eli Barnes
Eli Barnes

20-30 times slower than C
Depends on how you write it. You can speed things up a lot by using generators instead of lists, caching your data, and profiling different ways of doing the same thing will tell you how to optimize it further.
I've written an expanded Python implementation of some popular C program, and it's only twice as slow while doing almost twice as much, and can be imported and easily expanded as a Python package rather than clumsily parsing C version's inconsistent stdout.

Logan Smith
Logan Smith

chill my friend, it sounds like you would be interested in visiting my temple http://golang.web.fc2.com/

Hudson Kelly
Hudson Kelly

Why would you ever do that?

Nicholas Watson
Nicholas Watson

Problem with Python is the same problem every language has. It's great at what it does so people want to use it for stuff it's bad at.

As for learning the implementation details of a higher level language. idk doesn't that defeat the purpose.

Elijah Butler
Elijah Butler

go is safe, type safe, and memory safe
consider me triggered

Logan Turner
Logan Turner

Everything I mentioned is nothing special, it's actually standard. Generators are a basic feature of Python, simple caching with the help of a dictionary before you do your operations instead of repeatedly retrieving same data during them is just a better algorithm. In the end it's all about knowing what Python actually has by looking at their docs and suggestions.
I think it's actually more true that people simply don't know well the language they're using and so they just use a few most elementary types and statements that don't even scratch the surface of the possibilities it offers and of what's actually the preferred way of doing something.That's what I'm seeing fairly often when reading other people's code.

Lucas Howard
Lucas Howard

It's great at what it does
no

Jason Watson
Jason Watson

Did you try also using Cython for code where speed matters? How is it?

James Baker
James Baker

Not yet. I actually didn't go that much into speed in the above project, I just did some profiling and rethought some of the logic so that its speed is not too far away from the original C version. But if an uglier way of writing something was faster I still picked the more readable one.
When you need to optimize your Python code you can easily inspect it using "timeit" and "profile" which are part of the standard library. Try this though:
$ touch empty.py
$ time python empty.py

There are certain speed limits you can't beat because the interpreter itself takes some time to initialize. I agree with the above post that at that point you should probably be using a different language if speed is that crucial.

Luis Wright
Luis Wright

Go does not have that python 2/3 bullshit

Jose Moore
Jose Moore

Go would be nothing without paid Google shills. If you have a great product, you should not need to shill it. That is all you need to know about Go. Yes it is SHIT.

Ian Hughes
Ian Hughes

That's because it's much newer. No one cared about Python 1.x just as no one cares about Go 1.x

Go will have to make so many changes and include so many additional features to be competitive that Go 2, if it ever becomes a thing, will make the Python 2 to 3 transition look like a bugfix release.

Levi Sullivan
Levi Sullivan

Technically Python 3 was a bugfix release. Bytes/str was convenient in Python 2 but it was a huge fuckup in hindsight.

Adrian Price
Adrian Price

worse is better :^)

Benjamin Carter
Benjamin Carter

It wasn't. Not all flaws and other fuck-ups are bugs.

Henry Sanchez
Henry Sanchez

I challenge you to write fastest program in Go that would, for example, read 128MB file with random content like this:
dd if=/dev/urandom of=benis bs=1024 count=$((128*1024))
simply computing the sum of all bytes' values.
This takes 0.09 seconds in Python (with Cython) on my machine, for 2nd and later runs.

Can Go make it faster?


import mmap
from mmap import ACCESS_READ

from libc.stdint cimport uint64_t, uint8_t

def read_and_sum():
cdef uint64_t result
cdef uint8_t * bytes_pointer

chunk_size = 2 ** 12

with open('benis', 'rb') as f:
m = mmap.mmap(f.fileno(), 0, access=ACCESS_READ)

total_size = m.size()
remaining_size = total_size
result = 0

while True:
size_to_read = min(remaining_size, chunk_size)
remaining_size -= size_to_read
if not size_to_read:
break
ch = m.read(size_to_read)
read_size = len(ch)
bytes_pointer = ch
for i in range(read_size):
result += bytes_pointer[i]

return result

Austin Howard
Austin Howard

Python 2 is pretty much unnecessary now. Even PyPy got Python3 support.

Tyler Fisher
Tyler Fisher

Yeah I know. Just saying that Cython may allow you to even do some number crunching without leaving Python land, if you do it right. When bottle neck is not in your own code, then plain CPython is bretty good.

Wyatt Gutierrez
Wyatt Gutierrez

Try out Go
"Hello world!"
1.3 MB
Am I missing something?

James Price
James Price

It's by Google so it must be cool and amazing.
t.Go fanboys

Kayden Brooks
Kayden Brooks

It is statically linked. You can additionally reduce size by using flags.

Also the binary size will always be bigger then C and C++, since Go has GC included, you don't need any runtime unlike with Java/Python/Ruby...

Noah Miller
Noah Miller

you don't need any runtime unlike with Java/Python/Ruby
This means Go doesn't have that many problems with backwards compatibility. With Python you always have to hold yourself back from using the newest features because not all distros have the newest interpreter in their repos. Which is sometimes hard because Python is still adding useful features that are related to pretty common tasks.

Zachary Clark
Zachary Clark

2017
using software from distro repository instead of author's version

that's simply stupid

also, python interpreter is not that big, if you develop something big, then including it is not a big deal.

Jason Peterson
Jason Peterson

So, all who shilled for Go here can't actually write some Go code, right?

Julian Rodriguez
Julian Rodriguez

i made a naive program in rust.
your cython program (with chunk_size set to 64 * 1024) takes about 0.19 seconds
my rust program takes about 0.13 seconds


use std::fs::{File};
use std::io::{BufReader, BufRead};

fn main() {
let mut reader = BufReader::with_capacity(64 * 1024, File::open("benis").unwrap());
let mut i = 0;

loop {
let len = {
let buf = reader.fill_buf().unwrap();
if buf.is_empty() {
break;
}

for &b in buf {
i += b as u64;
}

buf.len()
};

reader.consume(len);
}

println!("{}", i);
}

Anthony Moore
Anthony Moore

made it 0.02 seconds faster

use std::fs::{File};
use std::io::{BufReader, BufRead};

fn main() {
let mut reader = BufReader::with_capacity(64 * 1024, File::open("benis").unwrap());
let mut counts = [0; 8];

loop {
let len = {
let buf = reader.fill_buf().unwrap();
if buf.is_empty() {
break;
}

let mut i = 0;
while (i + 8) <= buf.len() {
unsafe {
counts[0] += *buf.get_unchecked(i) as u64;
counts[1] += *buf.get_unchecked(i + 1) as u64;
counts[2] += *buf.get_unchecked(i + 2) as u64;
counts[3] += *buf.get_unchecked(i + 3) as u64;
counts[4] += *buf.get_unchecked(i + 4) as u64;
counts[5] += *buf.get_unchecked(i + 5) as u64;
counts[6] += *buf.get_unchecked(i + 6) as u64;
counts[7] += *buf.get_unchecked(i + 7) as u64;
}

i += 8;
}

for i in i..buf.len() {
counts[0] += buf[i] as u64;
}

buf.len()
};

reader.consume(len);
}

println!("{}", counts.iter().sum::<u64>());
}

Jayden Lee
Jayden Lee

C and Go are the only sanely designed languages.
Ignoring the only language actually went through a proper development cycle.
Most of the problems that Go, and Rust for that matter, are trying to solve were discovered in the late 70's, and mostly solved in the early 80's. And subsequently refined in 1995, 2005, and 2012.

Daniel King
Daniel King

brought it down to 0.09 seconds

extern crate memmap;

use memmap::{Mmap, Protection};

fn main() {
let mmap = Mmap::open_path("benis", Protection::Read).unwrap();
let bytes = unsafe { mmap.as_slice() };
let mut counts = [0; 8];

let mut i = 0;

while (i + 8) <= bytes.len() {
unsafe {
counts[0] += *bytes.get_unchecked(i) as u64;
counts[1] += *bytes.get_unchecked(i + 1) as u64;
counts[2] += *bytes.get_unchecked(i + 2) as u64;
counts[3] += *bytes.get_unchecked(i + 3) as u64;
counts[4] += *bytes.get_unchecked(i + 4) as u64;
counts[5] += *bytes.get_unchecked(i + 5) as u64;
counts[6] += *bytes.get_unchecked(i + 6) as u64;
counts[7] += *bytes.get_unchecked(i + 7) as u64;
}

i += 8;
}

for i in i..bytes.len() {
counts[0] += bytes[i] as u64;
}

println!("{}", counts.iter().sum::<u64>());
}

Zachary Kelly
Zachary Kelly

At this point just use the SIMD crate bro.

Xavier Reed
Xavier Reed

got it down to 0.082 seconds on my old as fuck machine
i uploaded the source to github + instructions on how to easily bench it yourself
https://github.com/InaneBob/sum_bytes

now lets see some go code faggots or c

Charles Cook
Charles Cook

your cython program (with chunk_size set to 64 * 1024) takes about 0.19 seconds
what about original size though?
on my machine increasing size didn't deliver any more speed benefit.

Luke Bailey
Luke Bailey

anyways, gj

Brayden Gomez
Brayden Gomez

const BYTES: &'static [u8] = include_bytes!("../bytes");
is it a compile-time thing? like, storing entire content right in the compiled blob?

Bentley Jackson
Bentley Jackson

Ignoring the only language actually went through a proper development cycle.
You mean, Haskell, OCaml, Erlang or what?

Jayden Price
Jayden Price

your cython program (with chunk_size set to 64 * 1024) takes about 0.19 seconds
Also which C compiler did you use?

Cooper Richardson
Cooper Richardson

I meant Ada, but I don't know the development history of the languages you mentioned.

Camden Williams
Camden Williams

microbenchmarks are literally retarded for comparisons

Samuel Foster
Samuel Foster

this

http://benchmarksgame.alioth.debian.org/

Justin Morgan
Justin Morgan

yet in every rust thread the benchmarksgame gets posted. Holla Forums if full or larping autists.
rust is masterrace

Jose Morris
Jose Morris

This is not a microbenchmark. This is a complete, well defined task. It measures both I/O and number crunching capability, both of them were said to be Go strong areas.

Isaiah Barnes
Isaiah Barnes

I don't have rust or cython installed so I'm not going to do this, but I will tell you what would happen if I did.

First I would make sure that I write a zero allocation function, of course.
The second big performance improvement would be rewriting the code to use mmap, I can do this because go has mmap packages too.

Once we get to this point it's all about vectorization of the sum. I don't know if the compiler is going to be able to vectorize automatically here (almost certainly no), if it can't I would rewrite the thing in assembly, it's kind of cheating but you had to write so much weird code to get Rust to vectorize that it would probably still be just as readable.

Now we have to programs that do exactly the same thing and of course have more or less the same performance. What does this prove? Nothing.

Ryder Sanchez
Ryder Sanchez

Now we have to programs that do exactly the same thing and of course have more or less the same performance. What does this prove? Nothing.
Somebody said that Python is slow. I called it bullshit.
If the performance is the same, this disproves that statement (about python being slow).

Dominic Mitchell
Dominic Mitchell

Cython is not Python. Also a single benchmark doesn't tell the whole story. Over a more representative set of benchmarks you would see that python and cython are slower than go and that rust is faster than go.

Honestly what I find disappointing is how slow is rust compared to C. Rust doesn't have garbage collection and doesn't have to do the stack checking that Go does for every function call, yet it manages to only be slightly faster for most things and 2x slower than C. Sad.

Cooper Carter
Cooper Carter

Go will have to make so many changes and include so many additional features to be competitive
like what?

Jaxson Russell
Jaxson Russell

Cython is not Python
Cython is de-facto tool for doing Python extensions and they are Python, of course.

it manages to only be slightly faster for most things
For example?

Logan Kelly
Logan Kelly

generics

Michael Smith
Michael Smith

Why?

Ayden Jackson
Ayden Jackson

What are you even talking about? Go 2.0 is not actively planned. Go promises compatibility with future version. There will not be Go1 vs Go2 like it was with Python (any time soon).

Go developers are open to idea of Generics, but it needs to be done correctly or it is not going to be done at all.

It is not just a simple matter like adding Generics in Java.

If programming without Generics makes your life so inconvinient then you should probably just stick to Java.

The whole point of Go is to get rich standard library, fast compilation, good enough running speed, garbage collection, native executable (no runtimes) while being

as simple as possible.

If you want BLOAT go use Scala.

Elijah Anderson
Elijah Anderson

hello go defense force

Lucas Garcia
Lucas Garcia

It is not just a simple matter like adding Generics in Java.
HAHAHAHA. it's EXACTLY like adding generics in Java, and the solution if ever done will be largely indistinguishable aside from the intracacies like subtyping, bounds, capture conversion, etc

The whole point of Go is to get:
rich standard library
every popular language (such as Java 1.4) has this, by definition.
fast compilation
every language that is not C has "fast compilation", including Java 1.4
good enough running speed
Literally Java 1.4
garbage collection
Literally Java 1.4
native executable (no runtimes)
this is meaningless, you can use an ahead of time compiler with Java to get the same effect
implying Go has no runtime
as simple as possible.
There's nothing simple about Go in contrast to current mainstream PLs. Okay to be fair it's probably simpler than Python, but not by a large amount.

Caleb Carter
Caleb Carter

So we just proved that Go is a shitty attempt to re-invent an older version of Java.

Carter Wright
Carter Wright

don't respond to your own post, stupid.

Go is leagues simpler than 95% of PLs, and much better designed too

Xavier Martinez
Xavier Martinez

so you have no point other than "hurr durr go is bad hurr hurr"

Brody Ross
Brody Ross

Python sucks. Nesting in whitespace is cancer

Asher Bell
Asher Bell

every popular language (such as Java 1.4) has this, by definition.
I don't think you know what a standard library is. C doesn't have a rich standard library, and its standard library is standardized, so no amount of popularity will make it richer.

Can you elaborate? I assume your non-Python code doesn't "nest in whitespace", since that's "cancer", so can you show us what it looks like?

Easton Ortiz
Easton Ortiz

oy vey C doesn't have lambdas

Connor Cox
Connor Cox

How would you implement lambdas in a library?

Kevin Parker
Kevin Parker

However boost did it.

Ian Howard
Ian Howard

Python sucks because of whitespace
/g/index.html

Typical autistic neckbeard reply. Yes, *C* has a small standard library, but the other 50 languages don't.

fuck off retard. you probably don't even understand how the equality operator in Go works (It's much more complex than any other popular strongly typed language such as Java, C#, ML, Haskell).

Luke Thompson
Luke Thompson

Typical autistic neckbeard reply. Yes, *C* has a small standard library, but the other 50 languages don't.
Can you explain how "every popular language has [a rich standard library] by definition"? The "by definition" part completely mystifies me.

Joseph Garcia
Joseph Garcia

something can have complex internals but still be simple mongoloid.

but please, tell me how unassailably complex and esoteric this 100% opaque, uniquely confounding language feature is https://golang.org/ref/spec#Comparison_operators

Lincoln Taylor
Lincoln Taylor

don't respond to your own post, stupid.
your vanga skills need improvement

Brandon Sanders
Brandon Sanders

I suppose this is the best place to ask.

Is it worth it to set up the 'Go environment'? That is: setting $GOPATH, using the directory structure and all this stuff: https://golang.org/doc/code.html

It seems like a hassle. At the moment I just compile my code with gccgo and disregard the directory structure entirely, but I have only been learning for a few weeks and haven't needed to import a non-stdlib library yet.

Dominic Gonzalez
Dominic Gonzalez

no dont. install rust.

Matthew Garcia
Matthew Garcia

congratulations, you fell for meme language
delete this crap and learn some real thing — rust, python 3, erlang. unlike go, each of these three is useful and has real reasons for existence.

Brayden Powell
Brayden Powell

Makes it convenient. I have shit in my rc file for golang, perl, rust, node, and php

[[ $- != *i* ]] && return

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

if [ -f ~/.bash_prompt ]; then
. ~/.bash_prompt
fi

export EDITOR=vim
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"

export PATH=$PATH:$HOME/bin/:$HOME/.local/bin/:$HOME/scripts/

# Language-specific package manager faggotry

# Golang
export GOPATH=$HOME/golang
export PATH=$PATH:$GOPATH/bin
# Rust
export PATH=$PATH:$HOME/.cargo/bin
# Perl
export PATH=$PATH:/usr/bin/core_perl/:/usr/bin/vendor_perl/
# PHP
export PATH=$PATH:$HOME/.composer/vendor/bin
# Node
export npm_config_prefix=$HOME/.node_modules
export PATH=$PATH:$HOME/.node_modules/bin

etc...

Juan Collins
Juan Collins

"rich standard library" basically means it has a bunch of shit in the standard library which is "useful and good" according to some asshole's definition of "useful and good". Off the top of my head that would be: Python, Ruby, Java, C#, PLT Scheme, PHP, and I'm not even continuing this argument further because I don't even give a shit what is in the standard lib of a PL. It's basically a way of comforting retards into your language. What is or isn't in the standard library never really matters in real code.
citing shitty informal incomplete language spec which changes every 5 days as if it has any bearing on this discussion
pathetic.
I'm not saying Go has complex internals. I'm saying it's a complicated language for what it does (almost nothing), and might as well be replaced with Java 1.4, or some decades old version of Algol, or maybe Ada or Pascal. I remember these two surprising edge cases about equality:
http://stackoverflow.com/questions/25734504/different-pointers-are-equal
http://stackoverflow.com/questions/25749484/equal-pointers-are-different
Not only are they obscure edge cases, but once you learn one of these edge cases, you'd assume the other doesn't exist, yet it does. I'm not interested in "high level" languages that can't keep something this basic simple. The only serious mainstream PL that exists is Standard ML. Everything else is script kiddie junk thrown together by some asshole who's only seriously used one or two other languages and never studied any theory. Laymen programmers go around calling PLs simple because the small part of it they understand and use day to day is easy to remember, but once they deal with other people's code and version compatability, and malice, all of which are problems that multiply with each other, it becomes a whole different story.

Cameron Price
Cameron Price

What is or isn't in the standard library never really matters in real code.

Because everybody likes defining their own type and implementation for stuff like UTF-8 strings?
Did you ever wrote something in C, for example?

James Morris
James Morris

Also note python has sane defaults:
pip install --local

Leo Thomas
Leo Thomas

you're quite queer in your opinions. Why is SML the only srs bsns language? perhaps you lack the real world experience to understand the needs of systems in production. but no, it's neat that you're passionate enough about your CS 203 class to make silly claims on a Philippine Pictogram BBS. have a gold star.

changes every 5 days
wew. so you're admitting you don't know anything about go?

It's a complicated language for what it does
the programming community at large disagrees with you. everyone from the cubicle code monkey to our lord and savior Ken.

there are legitimate issues with the language, but you've failed to bring up a single one

Grayson Powell
Grayson Powell

Never used go but I cant stand not having control over my bits in python. I need pointer math to be happy.

If I cant tell my program to xor a bmp file and then run it as native code why code at all?

And in line assembly code is like crack.

Isaiah Wood
Isaiah Wood

are you a masochist by chance?

Ian Wilson
Ian Wilson

If you need pointer math to be happy you've been so damaged by low-level programming that you can't reason about your programs on an abstract level any more. You need to use some other programming languages to get a better perspective. Doesn't have to include Python, but they have to be languages that don't let you write code the C way.

Charles Butler
Charles Butler

Why is SML the only srs bsns language?
It's the only mainstream PL with serious thought put into the design. Particularly the type system and execution semantics. It hasn't been made into a piece of shit in order to pander to retards like C# or Java for example. I'm not passionate about SML but it's the only example I can give to explain how to properly design a PL with hopes of someone understanding.
perhaps you lack the real world experience to understand the needs of systems in production
standard fucktard reply. i have more experience than you. I've written 10s of thousands of lines of code in many high leven and low level languages from ML to Java to C to Python to Perl to assembly. If you seriously think Go is any more fit to some task than SML you are seriously retarded. But nevermind, you obviously never spent a minute learning SML. Nobody who knows a fuck seriously thinks some bullshit cookie cut HTTP libraries or whatever other garbage from the standard lib of some modern mainstream PL is a differentiator of anything. You can keep appealing to "programming community" but they are a bunch of fucking monkeys who can't even walk 5 steps without introducing a remote code execution vulnerability despite having a memory safe programming language.
your CS 203 class
I didn't go to a CS class to learn about SML. I found it after exploring 7 other mainstream PLs.
changes every 5 days
wew. so you're admitting you don't know anything about go?
Well it's not like I actually code Go unironically. 5 days is an exaggeration, but from what I've seen the spec there just changes every time I look at it (says last update date on the page somewhere), do they even pin versions of the spec to specific releases of the compiler?
the programming community at large disagrees with you. everyone from the cubicle code monkey to our lord and savior Ken.
the programming community at large is retarded. my issue is legitimate, and you haven't provided an argument against it.
you're quite queer in your opinions
well, at least he recognizes that im not in one of those other standard programming cliques. i typically get marked as a retarded pajeet-tier Java coder or an autistic C slinging neckbeard when I argue on the internet
The current C code I'm writing doesn't have a single string in it aside from some temporary prints for quickly debugging the prototype (no we aren't putting logging in that shit like your stupid post-2008 web app. it will slow down too much and we don't collect info from our clients anyway). The end user interface (0.0000001% of the code) will have a few strings but I sure as fuck don't need built in language support for that or whatever trendy bullshit you are referring to. You are one of those fucking morons who passes strings around all over the code so of course you could never handle real progrmaming.

Dylan Long
Dylan Long

the programming community at large is retarded. my issue is legitimate, and you haven't provided an argument against it.
i mean it's not like I'm saying it's a show stopper that Go has the misfeature of a slightly shittier equality operator. it's just a small issue and a mark of bad PL design. The real problem I have with Go is it serves no purpose in comparison to Java 1.4 or Algol

Ian Walker
Ian Walker

gay meme language vs older gay meme language
You will never get stable work using meme languages.

Leo Thompson
Leo Thompson

it's the only example I can give to explain how to properly design a PL
I suggest you go read the various Ada rationales. The DoD doesn't muck around when it wants to design a language that detects as many errors as it can at compile time instead of runtime.

Owen Evans
Owen Evans

You are one of those fucking morons who passes strings around all over the code
oh really? what made you think so?
also, strings are just one example. of course I won't list everything.

Eli Peterson
Eli Peterson

using meme languages

Nicholas Moore
Nicholas Moore

I've written 10s of thousands of lines of code

10s of thousands is really not that much.

Luis Fisher
Luis Fisher

It's the only mainstream PL with serious thought put into the design. Particularly the type system and execution semantics. It hasn't been made into a piece of shit in order to pander to retards like C# or Java for example. I'm not passionate about SML but it's the only example I can give to explain how to properly design a PL with hopes of someone understanding.

so explain specifically how it's superior instead of listing buzzwords fam-a-lam

I didn't go to a CS class to learn about SML. I found it after exploring 7 other mainstream PLs.

kek. fizzbuzz isn't "exploring" a language

Disable AdBlock to view this page

Disable AdBlock to view this page