News for hackers. Stuff that matters.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by andrewzah on Saturday January 30, 2021 @08:13PM (#25974747)
Can anyone answer why python is a choice anymore instead of i.e. golang for saas applications like this? I previously worked heavily with ruby and I cannot imagine building beyond >1000 LoC in interpreted, dynamically typed languages. Aside from developer familiarity which trumps all other points.

It's also significantly easier to dockerize a generated binary from golang or rust, etc. Some of my worst docker headaches have been from trying to debug something like mayan-edbms, which uses python and celery workers.

I just don't get it unless you specifically need some libraries that no other language has.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by capableweb on Saturday January 30, 2021 @08:26PM (#25974826)
> I cannot imagine building beyond >1000 LoC in interpreted, dynamically typed languages

Many have imagined and built valuable stuff in interpreted, dynamically typed languages before you, by being more focused on overall structure and making sure it's strict and resilient. One really doesn't have to search far for successful applications that are certainly way beyond 1000 LoC and still iterate pretty quickly for their size.

> significantly easier to dockerize a generated binary from golang or rust

Not sure the verboseness of either golang or rust would be worth it if you compare it with python. If you're just launching, your focus should not be on performance or how easy it is to dockerize but to figure out who your user really is. Scaling and deployment issues will happen much further down the road, and iteration speed is more important in the beginning as you have many changes. Your architecture needs to reflect this too, and dynamically typed languages (arguably) makes it easier to change things, as long as you know what you're doing.

But together with that, you are eventually gonna have to start leveraging more languages, as you have programmers working on different levels of the overall architecture. Some fit for some tasks, and when it comes to quickly launching and iterating on SaaS businesses, dynamically typed languages are a pretty good fit.

In the end, I don't really think dynamic/static typing is the most important consideration, that's such a small part of what you have to think about overall.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by cbushko on Saturday January 30, 2021 @08:33PM (#25974874)
That is a double edged sword. Sure, that dynamically typed language of python or ruby might be quick to develop on but they often contain a lot of surprising bugs.

Compilers catch a lot of bugs before your software is in production.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by IgorPartola on Sunday January 31, 2021 @12:38AM (#25976350)
I don’t know. I keep seeing this argument. I’ve been developing on the Django stack for the past 10+ years. I have fixed many bugs if mine and of others. It has been extremely rare, if at all, that they were bugs caused by an incorrect type. The closest I can think of is a typo in a method or class name, but is it really a bug if you catch it instantly? These are just not the types of bugs that end up creeping into the code.

In the meantime Django provides productivity like you can’t get many other places. It’s just a pleasure to work with and aside from a couple of setting-related places it’s code is a pleasure to read.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by necovek on Sunday January 31, 2021 @02:03AM (#25976758)
Has Django's ORM syntax changed recently?

If not, this is the first time I've heard someone say it's a pleasure to read/write.

I've done lots of Python over the years (Zope3, Django, flask, aiohttp, custom stuff...), and if there is one thing I wouldn't like to come back to, it's Django.

Sure, it's a do-everything toolset, but the syntax is an abomination (imho, at least, though I hope that doesn't need to be stressed every time).

To contrast ORM syntax, look at old SQLObject, Canonical's Storm or both SQLAlchemy's declarative and core implementations.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by IgorPartola on Sunday January 31, 2021 @08:32AM (#25978678)
It has not but it has expanded and been polished up. I used to be pretty anti-ORM because I felt like they were leaky incomplete abstractions. Having used SQLAlchemy for a major project in the past (used it on top of Django instead of the built in one) and then coming back to Django’s, I can say that Django’s is to me easier and nicer to use. The performance is now on par with the SQLA declarative implementation. I never really loved the core implementation for being as verbose as it was. I would rather write SQL directly at that point.

About the only place where I dislike Django’s ORM is stuff around aggregation and annotation. The fact that the order in which you declare your annotations matters is annoying af and while I understand the need for it, I do wish there was a better way. Having said that, I have simply started structuring my models in a way that doesn’t require complex aggregation and that made my life a lot easier. If I have an instance of a Book model I know what fields to expect it to have and don’t worry about whether this particular time it has some specific annotation attached to it or not. That has made the rest of the code a lot cleaner.

Basically, I think to each their own, but I don’t see the Django ORM as a negative. Give it a try and see how it works for you especially if you can avoid going against the grain with it.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by CameronNemo on Saturday January 30, 2021 @10:16PM (#25975483)
Tests catch bugs too. As will pylint and mypy.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by mixmastamyk on Sunday January 31, 2021 @05:33PM (#25983276)
Even pyflakes will catch the most numerous bugs.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by potta_coffee on Saturday January 30, 2021 @09:46PM (#25975280)
I used Python on the backend for years and have taken to Go, the verbosity feels like a minor complaint to me, productivity in either language feels about equal to me but the end product is just better in Go. Better performance, better packaging and deployment, etc. I still use Python a lot for other things.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by mikevm on Saturday January 30, 2021 @08:42PM (#25974932)
> Many have imagined and built valuable stuff in interpreted, dynamically typed languages before you, by being more focused on overall structure and making sure it's strict and resilient. One really doesn't have to search far for successful applications that are certainly way beyond 1000 LoC and still iterate pretty quickly for their size.

I once tried to get into a large Python project, and even the IDE (PyCharm) had trouble "guessing" the function parameter types. It's absolutely not scalable. I don't want to be reading a function and guessing "what the hell is the type of this?".

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by StavrosK on Saturday January 30, 2021 @08:46PM (#25974955)
Good news! Since ten years ago, you don't have to!

    def myfunc(foo: Dict[str, MyObject], bar: int, baz: str) -> List[MyObject]:
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by andrewzah on Saturday January 30, 2021 @08:53PM (#25974991)
This would be nice if everyone used that. When I looked at the source code for mayan-edms, they weren't using that.

Apache airflow? Doesn't use it. Jupyterhub? Doesn't use it.

I was happy to see projects like Zulip using this, but if it's optional then I can't rely on people actually using it. It's the same thing with ruby/sorbet.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by hsaliak on Saturday January 30, 2021 @09:38PM (#25975233)
That’s shifting the goalposts a bit. You can use optional typing in your project as it’s scales, and there are plenty of projects that have been stable for what they do through other testing. Pick dependencies carefully and use typing as needed
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by riverdroid on Sunday January 31, 2021 @01:32AM (#25976605)
I'd say typing is even more important when you are using other people's code with your code. It's also a huge productivity boost too when the relevant methods and types are available to you, the editor almost writes the code itself!
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by StavrosK on Saturday January 30, 2021 @08:56PM (#25975017)
The projects that don't use it probably need to maintain compatibility with Python 2, for whatever reason. I expect that more and more codebases will be at least somewhat typed as Python 2 is deprecated everywhere.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by blandflakes on Sunday January 31, 2021 @11:01AM (#25979724)
This is the same programming community that is half stuck on Python 2, no way should anybody expect types to have reached majority mindshare.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by StavrosK on Sunday January 31, 2021 @11:18AM (#25979849)
I've only heard this "stuck on Python 2" FUD from non-Python programmers, you may want to get your arguments with the times.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by blandflakes on Sunday January 31, 2021 @11:24AM (#25979888)
Weird of you to assume that I don't work in Python. Do you just not interact with the scientific Python community? Your anecdata that is blind to large swathes of the community is no more valid than my firsthand experiences. This comes off as defensive, not informed.

It's an objective fact that Python 3 was not adopted quickly (given various EOL deadline extensions) and that plenty of libraries are stuck on 2, so your point that types have been around for 10 years is not really an argument that I can actually expect to be able to use types when working within the ecosystem.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by StavrosK on Sunday January 31, 2021 @11:31AM (#25979946)
I work in web development, Django moved to 3 exclusively versions ago, and I drop support for Python 2 pretty easily in the libraries I maintain. numpy requires at least 3.7, same for pandas, and sklearn is at least 3.6. When you say "half stuck in Python 2", do you mean you have a lot of legacy code you don't want to update? Because I don't think that's Python's fault.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by blandflakes on Sunday January 31, 2021 @11:35AM (#25979969)
Ah, so the answer to "do you interact with scientists" is no, even though scientists are responsible for a huge amount of the python code that exists. Got it, maybe consider that your experience isn't universal.

I don't know why you think dismissing legacy code is valid! More code is old than new in the world, and the idea that you're only going to run into codebases with the most up to date versions of software seems pretty naive to me.

Serverless runtimes have historically been behind on Python versions, Airflow had a hell of a time with dependency issues and Python 2, etc etc.

I also don't really care whose fault it is - the question isn't "is Python morally wrong", the question is "can I rely on the technology that you offer as the solution to a problem as being actually used by the community and therefore actually a viable solution to the problem." Python type annotations are not popular.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by StavrosK on Sunday January 31, 2021 @11:46AM (#25980073)
> I don't know why you think dismissing legacy code is valid!

Because everyone everywhere has legacy code. In that sense, Python isn't split between versions any more than any other language, making that statement moot.

If you want to use type annotations, you can, for years now. If you want to use macros to generate macros in Rust, you can, it's not Rust's fault if you're stuck on 1.20 and don't want to upgrade.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by blandflakes on Sunday January 31, 2021 @11:50AM (#25980122)
I agree that all languages have legacy code, that was sort of my point :)

> If you want to use type annotations, you can, for years now.

Yes! And it's a cool feature. Can I expect most libraries to provide types so that I know I'm calling them correctly? Is it going to be an uphill battle for my team to use them, because the community at large doesn't find them necessary? The default for a majority of Python codebases is to not use types, and that's totally fine, but that also means that rather than type annotations solving the super-grand-OP's concern, they're going to potentially add friction.

It's likely, and that's FINE, that you're going to be in dynamic-land when you're working in Python, due to the preferences of the community, and it's cool that you can use annotations if you yourself want to get some nice signature checking.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by StavrosK on Sunday January 31, 2021 @11:54AM (#25980157)
But you don't need the libraries to have type annotations for them to be useful to you. You can use the libraries' classes as types, and type signatures are already very useful even if you only use them in your code. I agree that they will be even better when morelibraries declare them too, but I find that type annotations are a huge benefit in my own code either way.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by blandflakes on Sunday January 31, 2021 @11:56AM (#25980177)
I think we can agree on that - my point primarily is that:

1. In my own code, they are super helpful

2. I still get really frustrated when I'm calling other libraries (I had this experience when the various typed JSes were fighting it out as well) - in fact for a lot of web-style work that I do MOST of my code is calling a library, which is where I'd get most of the value.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by StavrosK on Sunday January 31, 2021 @11:59AM (#25980215)
Sure, I agree with that. More libraries supporting types would be great. I don't know why they don't, it's not like they need to support any Python versions that don't support types... I guess most just haven't gotten around to it.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by AlchemistCamp on Saturday January 30, 2021 @10:05PM (#25975405)
> It's absolutely not scalable.

And yet, somehow YouTube muddled along through and made it work.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by Cyphase on Saturday January 30, 2021 @10:46PM (#25975690)
And Instagram, and Dropbox (backend and client), and ...
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by necovek on Sunday January 31, 2021 @02:55AM (#25977013)
People always forget that none of the things we stress about (code cleanliness, architecture, UX,...) make or break a product.

It's some weird combination of solving an actual problem decently enough (iow, it does need to work most of the time :)), good timing and some arbitrary pick up by the masses.

Like Google succeeded because they provided a no-frills search that had no ads, and geeks like us started pushing it down the throats of our non-geeky friends as The One True Search.

I ain't saying that Python leads to bad code (because you can have bad code in any language, just like you can have good untyped Python), but that there's this talk of scalability like it's some msgic thing that's impossible if all the stars are not aligned.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by Nextgrid on Saturday January 30, 2021 @09:29PM (#25975189)
I agree that it's harder as the project gets bigger, but at the beginning you don't have to worry about that. By the time these problems become real limitations, you hopefully have a business and enough revenue to deal with them, which could include rewriting parts of or the entire application in a statically typed language if necessary.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by andrewzah on Saturday January 30, 2021 @08:37PM (#25974903)
"If you're just launching, your focus should not be on performance or how easy it is to dockerize but to figure out who your user really is."

I agree here but I should note that my main focus is spending less time debugging errors at runtime and in production, and avoiding errors in the first place. This is primarily why I use rust.

"Not sure the verboseness of either golang or rust"

Verbosity has nothing at all to do with implementing good, robust code. You could do it in python, rust, or another language. With certain languages you don't have to spend time writing guard code because it's handled natively by the compiler, type system, or both.

" dynamically typed languages (arguably) makes it easier to change things,"

They make it easier to change things, not necessarily correctly. With modern IDEs refactoring is not an issue.

"Many have imagined and built valuable stuff in interpreted, dynamically typed languages before you, by being more focused on overall structure and making sure it's strict and resilient. One really doesn't have to search far for successful applications that are certainly way beyond 1000 LoC and still iterate pretty quickly for their size."

I am aware of this, but I can't help but wonder if they would be able to iterate much more quickly knowing that the compiler and type system eliminate entire classes of bugs. Sure, you might be able to get to running code a little bit faster, but if you have to spend time guarding it and debugging runtime errors... is it really faster?

===

There seems to be this mindset that being fledgling startup means no time for silly things like types or compilation, etc, only iteration. If one actually does their market research and figures out who their users are and what they want, one should be able to iterate just as quickly in i.e. golang or another compiled language with a healthy ecosystem.

I have not worked at a FAANG company or a company even remotely the size of those companies, but I have created and maintained somewhat large ruby on rails codebases. Debugging runtime errors became my bane, especially when I could not guarantee that the persons writing the ruby code were following modern practices (or any practices at all). Not that I think compilers are perfect, but they -do- catch so many errors, some of which may have made it into runtime.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by capableweb on Tuesday February 02, 2021 @04:41PM (#26007187)
> If one actually does their market research and figures out who their users are and what they want, one should be able to iterate just as quickly in i.e. golang or another compiled language with a healthy ecosystem.

That's the key thing. You don't know until you put people in front of what you're building, to understand if you're actually solving the problem. Or even if the problem you're aiming for is the right problem. Hence you want a non-verbose and simple program that is easy to adopt to changes you want to make. Verbose languages that enforces you to be very strict, doesn't allow itself to change as much as a non-strict one. You're right that it's more error-prone, as you don't have the same guarantees. But in the beginning of launching something new to the world, you are gonna need to focus more on what needs to change, rather than how correct something is.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by cbushko on Saturday January 30, 2021 @09:12PM (#25975102)
I agree with you. I've worked at several startups and they start with 'productive' languages like python, ruby, and PHP. These are great for getting something up and running easily.

Everything looks great at the beginning. They have features, customers and a growing codebase full of technical debt. Debt that I think would be greatly reduced if the code was compiled.

Maybe it is the price you need to pay to be successful but I doubt it.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by simplecto on Saturday January 30, 2021 @08:21PM (#25974796)
Django drives the choice here. Batteries included, huge community support, and AMAZING documentation. Half the software I write is from stackoverflow. LOL

I dont see dockerizing as a problem. Once copied out from my template I never think about it. I do admit that familarity with the underlying Image OS (Debian in this case) makes debugging / fussing about a non-issue.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by cbushko on Saturday January 30, 2021 @08:29PM (#25974849)
For local development that debian container is fine but for production you want something small like scratch or alpine. The fewer binaries in the container, the better and more secure.

This is one of the benefits of golang. You compile it into a binary and copy just the binary into your scratch container. Maybe it is 20MB in size.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by simplecto on Saturday January 30, 2021 @08:40PM (#25974922)
This feels very hand-wavey to me. I can patch and ship my docker images the same way I might patch a server.

apt-get update && apt-get upgrade

rinse, repeat.

Secondly, all this cargo-culting around small containers is fine if you are cramming resources. I am not.

The reality is that my projects and many others are really, really over-provisioned. Looking at my graphs right now, I am on the front page of HN and my server load is still only 20%.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by andrewzah on Saturday January 30, 2021 @08:46PM (#25974953)
"apt-get update && apt-get upgrade"

You can do this exactly the same in alpine, with "apk update" and "apk add".

"Secondly, all this cargo-culting around small containers is fine if you are cramming resources. I am not."

The default docker python image is 885MB. python:buster-slim is 114MB which is much more reasonable. Even if you're not "cramming resources", pushing 885MB vs 115MB vs 20MB across the wire does add up over time.

In my case, we do quickly iterate and pull docker images so it does make a difference for my colleagues if the image is 30MB vs 500MB. Even if we're all on gigabit internet.

"Cargo culting" implies doing it without knowing why we're doing it. The benefits of reducing the size of docker images is apparent to everyone, although there are diminishing returns. With dive[0] it is very easy to figure out where the waste is.

"The reality is that my projects and many others are really, really over-provisioned. Looking at my graphs right now, I am on the front page of HN and my server load is still only 20%. "

Optimizing docker images has nothing to do with being over-provisioned.

I will concede that it's very different as a solo developer vs even a small team.

[0]: https://github.com/wagoodman/dive

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by CameronNemo on Saturday January 30, 2021 @10:20PM (#25975520)
Shouldn't the base image be cached? So you would not be pulling it all the time.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by andrewzah on Sunday January 31, 2021 @01:53PM (#25981399)
If it's cached, yes. However at my job we manage our own base images and we do update those somewhat frequently.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by hinkley on Saturday January 30, 2021 @10:54PM (#25975730)
Not just over time, it adds time.

Push new versions of one of those to 50 machines, versus the other.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by cbushko on Saturday January 30, 2021 @08:58PM (#25975028)
Yes, you can patch them but with a compiled binary like go, you don't have to.

You don't have to watch security lists for vulnerabilities.

You don't have to scan your docker containers because the dockerfile is 4 lines long.

You don't have to worry about a coworker adding a bad tool to your production container.

That frees up cognitive load to write your code.

Note: I am an infrastructure engineer for a small SaaS that builds and runs production.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by acdha on Saturday January 30, 2021 @09:47PM (#25975286)
> Yes, you can patch them but with a compiled binary like go, you don't have to.

> You don't have to watch security lists for vulnerabilities.

These two statements are incompatible. You have fewer things to watch but you’re definitely still going to track your dependencies. Static linking still means you have to do that, and nobody else can do it for you.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by cbushko on Saturday January 30, 2021 @10:02PM (#25975393)
Not exactly. You have to watch your libraries for vulnerabilities no matter what language you use. Link or apt-getting the library will pull in a vulnerability

I am more concerned about pulling in Linux binaries that are full of vulnerabilities.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by acdha on Sunday January 31, 2021 @12:10PM (#25980347)
This is a valid concern but in general you should be most worried about code you actually run. If you have curl in a container but your app only uses it during the startup process, the fact that it has an issue with, say, FTP almost certainly has no effect on you. OTOH, if you’re using something like libjpeg your Go code needs to be recompiled either way and you might have to manually backport a patch just like a Linux distribution will.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by vageli on Saturday January 30, 2021 @09:04PM (#25975061)
It's not only about the resources allocated to your project. Bigger images also leads to longer deployment times, which increases the feedback loop for issues. Not to mention increased costs associated with storage, bandwidth, layer caching, etc.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by simplecto on Saturday January 30, 2021 @09:22PM (#25975152)
I'm quite opinionated here, but these things only matter at significant scale. Most one-person-SaaS or SMEs never really graduates out of the first pricing tier for this stuff.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by wiredfool on Sunday January 31, 2021 @05:02AM (#25977625)
It depends what you're optimizing for.

Alpine is subtly different for python builds:

* It uses musl-c. It's not glibc, it's different. Not necessarily better or worse.

* You can't use manylinux1 wheels with alpine, so if you've got python/c extensions, you're going to be building them instead of installing upstream binaries. So cue the need for a dev toolchain, and a much longer install time.

And once you have all that, you're running a different version in dev/prod, which is one of those things that docker is supposed to be good at fixing.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by AYBABTME on Saturday January 30, 2021 @10:02PM (#25975394)
There's no difference between a 1000MB or 10MB image, aside from how much time it takes to download new versions and how much disk space it uses.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by CameronNemo on Saturday January 30, 2021 @10:18PM (#25975503)
Debian slim is certainly not 1GB. It is maybe 50-60MB larger than Alpine. And that is shared if you have multiple containers based on Debian slim.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by AYBABTME on Sunday January 31, 2021 @02:56AM (#25977018)
I didn't mention any specific distro. However, lots of ppl use ubuntu as a base image, or other non-slim images. It's not what I do but it's a reality.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by acdha on Saturday January 30, 2021 @09:43PM (#25975260)
You have to reach massive scale before you’re going to see a significant performance benefit from Go, but you’ll see productivity wins from Django from day one. If you’re not targeting that kind of public scale and don’t have a large team, there’s a lot to be said for picking a mature stack on a high productivity language.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by treis on Sunday January 31, 2021 @10:56AM (#25979684)
I used to think the same way and still kind of do. But you're neglecting another performance benefit. You have ~100 ms to respond to a request before the user perceives slowness. With Go you can do 10-100x more stuff in that timeframe.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by acdha on Sunday January 31, 2021 @12:06PM (#25980300)
Or 0 to -100x more stuff. The vast, vast majority of code is limited by the application’s workload and architecture, not the language runtime. I remember a colleague spending 3 months trying to beat Python using Go, eking out a single digit increase because it turns out that the Python stdlib C code is not easy to beat. For web apps, this is especially common: if 95% of your runtime is in the database or other external services, Amdahl’s law reigns supreme.

The other experience point which a lot of people forget the first few times is maintenance: if using Go means that you have notably more code to write and integration to support, you’re shipping fewer features and have less time to optimize the architecture. That Go code I mentioned earlier was much larger and required time to identify, integrate, and debug third-party libraries for things which are in the Python standard library.

This isn’t to say that Go is a bad choice but again a cue to make sure you’re solving the problems you actually have rather than someone else’s situation. If you’re still exploring the business case you should hesitate before copying a decision made by someone with both a well understood problem, large scale, and more people working on it.

In this thread’s context, I would highly recommend focusing on keeping the architecture easy to support and replace components when the business expands to the point where you really need to hammer specific optimizations. This is especially true in the 2020s where a large fraction of problems are either never exceeding single server scale or can be handled by trivially autoscaling containers on-demand for less than it’d cost in developer time to optimize them beyond the level you can hit in a language like Python or Node.

Again, that doesn’t mean there’s anything wrong with using Go – it’s a perfectly fine choice and has some great libraries — but it usually won’t be transformative the way some advocates claim. When you hear about huge benefits from rewrites look for how often they mention rearchitecting based on what they’d learned from the first system.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by simplecto on Sunday January 31, 2021 @04:07AM (#25977311)
Exactly this. Developers and their managers and the CTO must accept most likely their work/company does operate a huge scale.

Once you internalize that your priorities change from all the tech hype (k8s, react, whatever) to actually working on the business problems. Not solving technical ones.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by danjac on Sunday January 31, 2021 @08:59AM (#25978850)
And nothing to stop you from breaking out specific services into Go/Rust where you actually need high performance.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by arcturus17 on Saturday January 30, 2021 @08:29PM (#25974853)
> I cannot imagine building beyond >1000 LoC in interpreted, dynamically typed languages

That would include Ruby, Python, PHP, and JS. GitHub, Shopify, Wordpress, Instagram, Pinterest, Reddit, significant parts of Netflix (Node), Facebook, just off the top of my head.

And you can’t imagine writing > 1000 LOC of a startup SaaS product in any of them? Really?

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by andrewzah on Saturday January 30, 2021 @08:56PM (#25975013)
Not in 2021, no. I would go with typescript, golang+gin or preferably rust+warp/tide.

If you had asked me in 2010, 2015, or even 2018 I would've had different answers most likely.

"And you can’t imagine writing > 1000 LOC of a startup SaaS product in any of them? Really? "

After working on large rails codebases I get nauseous even thinking about having to safely maintain that level of code in dynamically typed languages.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by acdha on Saturday January 30, 2021 @09:51PM (#25975315)
> After working on large rails codebases I get nauseous even thinking about having to safely maintain that level of code in dynamically typed languages.

I can’t speak to Rails but this is easy in Python - especially because the addition of typing years back now means that a few annotations will cover most of the common mistakes before leaving your editor. In the Django community there’s a healthy distrust for the heavy levels of magic which are harder to test, which helps a lot.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by mythrwy on Saturday January 30, 2021 @09:40PM (#25975243)
I've worked on a few sizable (~100+ tables) Django Rest applications and have yet to run into all these fabled type safety issues that would prevent refactoring.

Serializers and hygienic procedures seem to take care of whatever might have been or maybe I'm just really used to the setup.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by Nextgrid on Saturday January 30, 2021 @08:19PM (#25974780)
What's the Django/Rails equivalent in Go? The value from Python isn't Python itself (though it might be easier to write in - trading off reliability for ease of use compared to a compiled language) but the ecosystem.

Fully-featured frameworks such as Django, Rails, etc give you lots of functionality out of the box which is very valuable especially at the early stages of the project where performance isn't a concern yet.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by kitd on Sunday January 31, 2021 @05:19AM (#25977703)
I think if you're using Htmx/Intercooler with Golang, you'd probably want to take a different approach from Django anyway. The backend design approach has to change slightly. You're focused less on whole pages and more on individual user interactions.

There's room for a tool that will scaffold a Go backend from an Htmx-ified web page IMHO.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by rufius on Saturday January 30, 2021 @09:40PM (#25975244)
Honestly, frameworks like Rails or Django are an anti-pattern for Golang.

The standard library makes it very easy to build web services and there’s a couple or popular packages for making routes and dealing with HTTP requests/responses simple.

There’s projects like Micro that try to do a little more batteries included but I wouldn’t consider them to be pervasive in the way Django or Rails are.

Beyond that, it’s just app logic and the typical Golang boiler plate.

Source: I’ve built a few big Golang services for a couple companies.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by treis on Saturday January 30, 2021 @10:23PM (#25975549)
>Honestly, frameworks like Rails or Django are an anti-pattern for Golang.

Which is, IMHO, the biggest thing holding Go back. The standard library does a lot but a lot is also missing. Authentication, db migration, admin panels, ORM, Asset pipeline and probably more. It's a lot of custom work to do or pulling in various libraries.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by rufius on Saturday January 30, 2021 @11:51PM (#25976083)
I have mixed feelings on this. I go back and forth on whether I agree or disagree.

For example, once an application becomes sufficiently complex, I've found ORM's to be more of a hindrance. The abstraction gets leaky and I end up having to tune custom queries to get around some pathological edge case.

That said - most of my experience is with Rails and a lot of the implicit nature of it is problematic. On the other hand, I've not had this experience with Laravel.

Which one is right? I dunno. Lately though, writing sizable web applications in Golang is working out well so I guess I'll keep doing that.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by leetrout on Sunday January 31, 2021 @01:25AM (#25976571)
Rails implicit magic is so painful.

I’ll disagree and agree on the ORM front.

A good ORM has a clean escape handle for tuning hot spots and otherwise saves you time with boilerplate queries.

Add a new field? Update the class / structs, generate a migration and move on. Without the ORM you write the migration yourself, you have to find and update all the queries and if you’re centralizing all your query building then you’re just using your own ORM-light without the battle hardened trials of other users using something open source and popular.

I insisted we use sql alchemy and alembic in our latest Go project — and I’m eyeballing Buffalo’s Soda and Fizz as a replacement.

Its generally just nerdcore navel gazing to insist on raw sql across a project in my opinion. Especially web apps / SaaS where you churn tables a lot. Simple migrations from simple models is what I love about Django and Flask/Fast API with SQL Alchemy.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by treis on Sunday January 31, 2021 @10:32AM (#25979511)
>once an application becomes sufficiently complex,

Perhaps, but most applications don't start off complex. Most of them start off pedal to the metal develop as fast as you can.

Its also a gentler introduction to Go. I've wanted to use it on past side projects but the upfront cost of learning the language + figuring out how to get everything else was too steep of a curve.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by CameronNemo on Saturday January 30, 2021 @10:25PM (#25975563)
I don't think Go will see something even close to Django until generics are merged.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by CameronNemo on Saturday January 30, 2021 @10:24PM (#25975555)
Can golang auto generate forms based on database models?

An alternative explanation for why there is no Django for Go is that Go is not expressive enough to support such levels of abstraction.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by number6 on Sunday January 31, 2021 @12:36AM (#25976342)
I would have chosen user authentication as an example. Better have a team looking over this stuff than to write this up on you own except you know exactly what you are doing. Might end somewhere with you users passwords public readable in an elastic bean stack...
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by sk5t on Saturday January 30, 2021 @10:22PM (#25975542)
Contrary perspective: only avoid frameworks when you can be assured your project is (and will remain) so narrow that it has no need of validation libraries and the like.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by sofixa on Sunday January 31, 2021 @10:07AM (#25979350)
> What's the Django/Rails equivalent in Go?

Gin-gonic and a few others try to do that job ( and provide the flexibility to plug the missing parts), but a lot of people say the stdlib is sufficient. Depending on the he case, either can work great.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by andrewzah on Saturday January 30, 2021 @08:28PM (#25974839)
"(though it might be easier to write in - trading off reliability for ease of use compared to a compiled language)"

I find the "ease" is overstated compared to time spent debugging issues in production, but that is a separate discussion.

See my comment in the sister thread about the django/rails equivalent.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by zmmmmm on Saturday January 30, 2021 @08:40PM (#25974919)
Sounds like you may not be familiar with Django, but it's honestly an amazing option if you want something that's mature, stable, well documented and full stack (the latter being key - one of the only ORMs I don't hate).

The biggest problem for Django and Python in general to me is more in the line of the scalability (performance) question. You are simply forced to put one or even two layers in front of it with a multi-process architecture just to get it to a baseline deployable state (in this case, traefik + gunicorn). But the good news is there are so many people doing that it really isn't a problem. And it turns out you probably want that architecture anyway (probably best if your application server isn't also doing your TLS etc).

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by AYBABTME on Saturday January 30, 2021 @09:56PM (#25975357)
Developing apps in Go is not a high productivity experience, compared to Rails or Django. The framework ecosystem isn't comparable, and you DIY a lot of stuff.

I'm saying this in complete self contradiction: my current stack is Next.js with Go/gRPC Web/sqlboiler

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by turtlebits on Saturday January 30, 2021 @09:23PM (#25975158)
It's most likely because of Django. Same would be for using Ruby for Rails.

It's also very unlikely you are going to write >1000 LoC (or honestly even >100 LoC) for any view function/API endpoint.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by lolinder on Saturday January 30, 2021 @09:35PM (#25975215)
But how many apps have only one view? That a single view is only 100 lines doesn't solve the maintainability problem when you have dozens of views.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by jgb1984 on Sunday January 31, 2021 @10:30AM (#25979498)
I've been writing python for a living for about 13 years now. I've dabbled in go, but found it incredibly verbose and of a much lower level than python. The error handling alone is enough to turn me off completely. So much boilerplate, so much code and words to express even simple things.

No thanks, I'll stick with python, for me it is the perfect balance between expressiveness and being easy to read.

Also Django itself and the python ecosystem is hard to beat. It gets out of my way so that I can focus on the business logic, instead of reinventing wheels.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by nickthemagicman on Saturday January 30, 2021 @09:33PM (#25975206)
I'm playing devil's advocate here. But Python has a ton of useful libraries that other languages don't have. I'm fully aware you can access those libraries in a serverless function or via docker. But some people may just want all of that native to the code to keep things super streamlined.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by neurostimulant on Sunday January 31, 2021 @05:13AM (#25977668)
Honestly, django is the only thing that keeps me on python for backend service. With microservice being all the rage these days, I don't see any battery-included framework that can rival django emerging in golang, rust, swift and other new and hip languages.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by AlchemistCamp on Saturday January 30, 2021 @10:07PM (#25975420)
> I previously worked heavily with ruby and I cannot imagine building beyond >1000 LoC in interpreted, dynamically typed languages.

Airbnb, Stripe, WhatsApp and Discord were able to and win in gigantic markets despite fierce competition.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by mixmastamyk on Sunday January 31, 2021 @04:52PM (#25982907)
If compute performance is not a requirement, python is a lot faster to develop in. Once the design has solidified, a few simple techniques can improve reliability to an acceptable degree.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by andybak on Saturday January 30, 2021 @08:19PM (#25974781)
It's more Django than Python specifically.

Does Go (genuinely) have something to match?

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by TameAntelope on Saturday January 30, 2021 @10:12PM (#25975454)
The answer is no, and you’re not going to hear it from the Go zealot replying to every comment in this thread.

Suggesting Go, given where it is right now, is betraying a lack of experience with at least one critical part of the software development lifecycle.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by simplecto on Saturday January 30, 2021 @08:47PM (#25974963)
You might want to check out https://gobuffalo.io/en
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by andrewzah on Saturday January 30, 2021 @08:24PM (#25974818)
> Does Go (genuinely) have something to match?

To the extent of django or rail's maturity and features, likely not, although I don't know what features you use django for. I guess this answers my question to an extent.

Last time I worked with golang I used gin and xorm, but there were some things I had to manually do. That being said, I find rails to be an enormous beast that provides a lot of things that one may or may not need.

In my experience, working with golang and rust, which are compiled and statically/strongly typed have saved me headaches and time even with having to hand-roll some features.

Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by uranusjr on Saturday January 30, 2021 @08:31PM (#25974861)
It’s often better to have something you may not need than have not something you may need, especially for projects you intend to grow, iterate on, and possibly pivot. If my experience has taught me anything, I can never assume what I don’t need in the future. Most features come with Django and Rails almost for free (the only downside being some additional deployment size), so why not.
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by jw14 on Saturday January 30, 2021 @08:33PM (#25974878)
Never used it but there's a port/clone of Django in Go called Beego (https://beego.me/).
Re:Docker, Django, Traefik, and IntercoolerJS: My go-to stac... by Glyptodon on Sunday January 31, 2021 @01:35AM (#25976620)
It's very easy to have pretty painless RoR codebases above 1000 LoC without any challenges or problems...