TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Learning Go as a Python Developer: The Good and the Bad

206 pointsby shantnutiwarialmost 3 years ago

29 comments

ActorNightlyalmost 3 years ago
&gt;sharing your code is even pain with colleagues even if they are using the same operating system, mainly because the Python requirement file doesn&#x27;t pin dependencies,<p>wat? Pretty sure you can use == in requirements.txt<p>Also, its very possible, and quite easy to just include the code for the library in your package, which effectively &quot;locks in&quot; the version. We did this all the time when building AWS lambda deployments.
评论 #32143014 未加载
评论 #32142223 未加载
评论 #32142752 未加载
评论 #32144771 未加载
评论 #32142771 未加载
评论 #32142276 未加载
评论 #32142263 未加载
评论 #32143449 未加载
评论 #32148407 未加载
评论 #32143461 未加载
评论 #32142370 未加载
评论 #32143356 未加载
评论 #32143765 未加载
loosescrewsalmost 3 years ago
While the documentation of many open source Go libraries is definitely lacking, I find that the combination of types and links to readable source in the generated docs more than make up for it. While the documentation for Python libraries is often better, it is generally much harder to answer questions not answered by the docs yourself.
评论 #32142955 未加载
nathantsalmost 3 years ago
i dragged my feet on go for a long time. i also thought that skipping go and moving to rust was the play. a few years later, i still write python often, but i don’t build systems with it. python i now use like bash, to glue things together and automate random things. it’s a fantastic language and i will never drop it.<p>the verbosity of go is the biggest hurdle for a pythonista. the thought of giving up context managers, decorators, iterators, comprehensions, exceptions, coroutines, it’s unthinkable. in comparison go is ugly. your aesthetic mind screams in protest.<p>write go full time. dive in. as months pass, not only will those aesthetic objections fade, your mental model from python cleanly transforms to go. go is what mypy tried to be. the cost was aesthetic changes. the benefit is worth it.<p>the zen of python says if it’s easy to explain it might be a good idea. this is go, and it is.<p>i rebuilt a reasonably sized project from python[1] to go[2] over the last few years. i also have a system that i maintain both python[3] and go[4] implementations for, sharing a test suite in python. squint at the implementations. consciously ignore aesthetic objections. they are basically the same, not very different from a python codebase with and without type annotations.<p>go, like python, is fantastic. use both in whatever amount works for you. don’t read about them, build with them. you won’t regret it.<p>1. <a href="https:&#x2F;&#x2F;github.com&#x2F;nathants&#x2F;cli-aws&#x2F;tree&#x2F;bb78e529e7d1d3f95acc62dd0fbe21cadc822928" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nathants&#x2F;cli-aws&#x2F;tree&#x2F;bb78e529e7d1d3f95ac...</a><p>2. <a href="https:&#x2F;&#x2F;github.com&#x2F;nathants&#x2F;libaws" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nathants&#x2F;libaws</a><p>3. <a href="https:&#x2F;&#x2F;github.com&#x2F;nathants&#x2F;s4&#x2F;tree&#x2F;python" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nathants&#x2F;s4&#x2F;tree&#x2F;python</a><p>4. <a href="https:&#x2F;&#x2F;github.com&#x2F;nathants&#x2F;s4" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nathants&#x2F;s4</a>
评论 #32143210 未加载
评论 #32145456 未加载
评论 #32143286 未加载
tptacekalmost 3 years ago
I hated the &quot;damnable use requirement&quot; (the error you get on unused imports) for years, but I&#x27;ve been keeping a count of how many bugs they&#x27;ve caught (I was surprised the first time this happened) and I&#x27;m up to 3-4 now. What people who code in Go seriously do is just hook `goimports` up to their editor, and then never think about this again.
评论 #32145520 未加载
评论 #32143706 未加载
评论 #32142275 未加载
aidenn0almost 3 years ago
I only use python casually, but it seems to me that python library authors are always refactoring and breaking interfaces.<p>Recently, there was a bug in a second order dependency, and the version that fixed this bug was after a version that moved a function into a submodule.<p>So I had to make a local patch to my dependency that changed all of the imports.<p>Was the new interface more consistent? Yes, but could they have left a shim for backwards compatibility, or just lived with the old slightly less consistent interface? Seems to me like they could.
评论 #32143452 未加载
Uptrendaalmost 3 years ago
I don&#x27;t think Python packaging is as bad as people make out (if packages only stick to the basic features of Python!) A far bigger issue I see is despite Python supposedly being &#x27;cross-platform&#x27;: the language introduces so many small, backwards-compatibility breaking changes that you really need to use the most up to date interpreter you can.<p>For instance: there is now a really cool operator that lets you do expressions where you assign a value and evaluate the result in one line. So you can write the C equivalent of something like while(buf = recv(...)) ... and it will work. Well, any program that uses this new feature won&#x27;t run on anything but the most bleeding edge Python versions. Despite a program only needing a small fix to remove such expressions. It wouldn&#x27;t run at all.<p>I think the Python interpreter needs to be &#x27;smarter&#x27; and add the capability to automatically install parallel Python versions if it detects a package using a more recent interpreter. Would honestly solve so many issues.
评论 #32145454 未加载
评论 #32149342 未加载
评论 #32153428 未加载
maerF0x0almost 3 years ago
All the docs are easily found here: <a href="https:&#x2F;&#x2F;pkg.go.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pkg.go.dev&#x2F;</a><p>The complaint about aws-sdk-go (presumably v1) is legitimate, it seems to me that code was generated and therefore the repo can be less than ideal w&#x2F; Go. I suspect that is improved&#x2F;ing in v2.<p>using goimports as your formatter solves the complaint about unused imports<p>There was a significant portion of time where python 2.x and earlier releases of Go overlapped, and finding UTF-8 safe python libraries was non-trivial. Go makes utf-8 the default. As I understand it many companies still have python2 w&#x2F;o a EoL plan.<p>One thing I really miss about working with python is list&#x2F;dict comprehensions and lambdas
评论 #32144449 未加载
brodouevencodealmost 3 years ago
Organizing a golang-based project is also something that, while documented, is not front of mind for most new golang users, nor does the &quot;beginning go&quot; posts out there do a good job of how to lay out a project for success.
评论 #32142277 未加载
评论 #32142171 未加载
cookiengineeralmost 3 years ago
I&#x27;ve been reimplementing a tool that was done in nodejs before and ported it to golang.<p>I have to say that a lot of programming paradigms are different in golang, a few parts are annoying, and some parts are &quot;getting there&quot; with generics.<p>The most annoying part if you do a lot of parsing is the golang mandated rule of what is public and what is private in a package. If you want to parse lots of JSON into a struct, mess is on you, always have to implement a custom marshal&#x2F;unmarshal for it.<p>If you always have to implement a custom JSON marshalling method, and abuse annotations for mapping upper&#x2F;lowercase properties...why was the uppercase rule mandated in the first place?<p>I wish golang had gone for an export keyword instead. Structs would have been so much cleaner.<p>The second issue I have with golang is that struct properties (as all data types) aren&#x27;t nullable except via pointers, which makes consuming JSON APIs a fustercluck to deal with some times. I wish there was a nullable string data type instead of having to use dozens of helper functions.<p>The last issue is lack of functional ideas (as of now) but they are coming. lo is a lodash inspired library that makes a lot of things easier. [1] I hope that a lot of these helpers will at some point be part of the core libraries, so that datatypes can be easily mapped, casted and filtered.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;samber&#x2F;lo" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;samber&#x2F;lo</a>
评论 #32145108 未加载
评论 #32144854 未加载
120photoalmost 3 years ago
I tried porting a Python utility I wrote to Go specifically because I did not want people to have to install any 3rd party libraries (in this case just one). If anything I had a much deeper appreciation as to how much Python does for you and just lets you work. I would still like to port someday. For now I can containerize my app but that would still require people to install docker and learn how to use docker.
评论 #32143257 未加载
评论 #32143168 未加载
wodenokotoalmost 3 years ago
I was kinda hoping an article with a headline like that would present some code and tooling and explain it in terms of how a Python programmer sees the world.
erik_seabergalmost 3 years ago
Tooling aside, Python is a more powerful language, so I’m wondering whether he started generating code to work around stuff like try&#x2F;except and defaultdict and itertools and decorators.
atwood22almost 3 years ago
I don&#x27;t understand how the author struggled to find a good DynamoDB library. The official AWS SDK has a very useable DynamoDB client and provides utility classes for marshaling and unmarshaling Go types: <a href="https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;sdk-for-go&#x2F;api&#x2F;service&#x2F;dynamodb&#x2F;dynamodbattribute&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;sdk-for-go&#x2F;api&#x2F;service&#x2F;dynamodb&#x2F;...</a>
bumper_cropalmost 3 years ago
&gt; I hate how it forces to you create a module everytime.<p>This affected me recently, so I have sympathy for the author. Trying to upgrade an older project I had to the module system meant trying to find out how to import modules which don&#x27;t have reachable URLs and were only on the GOPATH. At I hate how it forces to you create a module everytime. some point programming in Go stopped being for fun.
craigchingalmost 3 years ago
Having done both Python and Go for quite some time now, yes, Python modules are a mess, but it wasn’t so long ago that the same could be said for Go (glide-&gt; dep -&gt; go mod anyone else?) Go mod is finally maturing, but there are still some painful edges as well.
Areibmanalmost 3 years ago
&gt; I especially struggled with the DynamoDb library for Go; so much so I wrote a Python script to query Dynamodb, and called it from Go.<p>This seems like a compelling enough reason to stick with Python
评论 #32143455 未加载
benhoytalmost 3 years ago
This roughly matches my experience, though he doesn&#x27;t really discuss the language differences in this article. Here&#x27;s a similar kind of article I wrote a few years ago, &quot;Learning Go by porting a medium-sized web backend from Python&quot;: <a href="https:&#x2F;&#x2F;benhoyt.com&#x2F;writings&#x2F;learning-go&#x2F;" rel="nofollow">https:&#x2F;&#x2F;benhoyt.com&#x2F;writings&#x2F;learning-go&#x2F;</a> -- mine focuses more on language and standard library differences.
Havocalmost 3 years ago
A bit of both is my answer. For some usage cases eg cloud functions go does seem superior. Yet the convenience of hacking stuff together with python has its appeals too
travisgriggsalmost 3 years ago
I realize that Go&#x27;s original release is later than Python&#x27;s, but they still feel roughly the same vintage to me. Usually, these articles have a &quot;old to newer&quot; feel, but these two ecosystems feel just different to me. Which is not bad.<p>What would be fascinating is to see some HN links to articles where the journeyman programmer went backwards in time, e.g. &quot;Learning Fortran as a Python developer&quot; or something like that.
jbireralmost 3 years ago
So the biggest complaints, from what I read here, is &quot;it does not allow me to write bad code or make mistakes, I want something I can hack together without having to worry about conciseness&quot;, and based on groupthink &quot;HN was negative about it&quot;. Languages like Rust and Go were designed to keep this sort of thinking away.
mountainriveralmost 3 years ago
&gt; The libraries for Go aren&#x27;t as good as for Python– certainly, the documentation is lacking<p>Huh, Go has some of the best autodoc features of any language. Also the library assertion is insane to me. I switch back and forth from Go to Python all day and generally Go has more stable better maintained libs
评论 #32144652 未加载
评论 #32154007 未加载
linsomniacalmost 3 years ago
TL;DR: Python is hard because of library dependencies, go is better about that because of compiling to an executable, but is pickier about code quality (&quot;I just want to try something&quot;), and has more issues with library quality.
评论 #32143392 未加载
peterbealmost 3 years ago
Shameless plug if it helps anybody else, like it helped me; <a href="http:&#x2F;&#x2F;govspy.peterbe.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;govspy.peterbe.com&#x2F;</a>
评论 #32146604 未加载
JustSomeNobodyalmost 3 years ago
On the subject: What is a good, idiomatic, Go project to study? Something big enough to be a good example of code organization, yet small enough not to become a new hobby.
评论 #32145723 未加载
barefegalmost 3 years ago
How to combine both languages as he suggests? I.e. creating python binds for the go binary? What about the opposite?
评论 #32143306 未加载
评论 #32143192 未加载
pojzonalmost 3 years ago
About unused imports, cannot you simply use formatter on build hook ?
vippyalmost 3 years ago
&quot;I felt I was constantly fighting the compiler&#x2F;borrow checker&#x2F;whatever. I just want to write some code, dammit&quot;<p>Well here&#x27;s your problem. Type safety helps you avoid avoidable bugs. Try Haskell or Scala next.
returningfory2almost 3 years ago
&gt; I had heard of Go for many years, but never stuck with it; it gets constant negative press on Hacker News&#x2F;Reddit<p>I think on Hacker News it&#x27;s really fashionable to criticize Go, and this has led to a culture where Go gets significantly more negativity than it deserves.<p>As technologists, one of our most important jobs is to see through such fashions and judge languages&#x2F;tools&#x2F;technologies based on their actual merit.<p>While gauging sentiment about things on a forum like Hacker News is generally really helpful, it should not be the main basis of our decisions.
评论 #32143055 未加载
评论 #32142956 未加载
评论 #32143235 未加载
评论 #32142979 未加载
评论 #32143102 未加载
评论 #32150141 未加载
remix2000almost 3 years ago
I don&#x27;t understand the criticism on &quot;shared environments&quot; which the author latter voids himself, but what I <i>do</i> know is that Go makes a fairly good choice for extending Python, but isn&#x27;t really in the same ballpark as Python.<p>Some thoughts:<p>- Go singlecore is actually slower than Python (nb Stackless[0] [still stands], but not only that: graalpython&#x2F;loom is even faster, much faster)<p>- Prototyping is always slower in most AoT-compiled languages, obviously. I&#x27;d be more convinced to try Go if it had something like Cling[1].<p>- CSP is (in my opinion) less palatable than Actors and makes Go feel somewhat... dated? Matter of taste?<p>- Go doesn&#x27;t use libc which can be awkward at times.<p>[0] <a href="https:&#x2F;&#x2F;entitycrisis.blogspot.com&#x2F;2009&#x2F;11&#x2F;go-vs-stackless.html?m=1" rel="nofollow">https:&#x2F;&#x2F;entitycrisis.blogspot.com&#x2F;2009&#x2F;11&#x2F;go-vs-stackless.ht...</a><p>[1] <a href="https:&#x2F;&#x2F;root.cern&#x2F;cling&#x2F;" rel="nofollow">https:&#x2F;&#x2F;root.cern&#x2F;cling&#x2F;</a>
评论 #32147882 未加载