Programming thread

If you are a linuxfag and have a spare machine or two, you can use Synergy for maintaining trivial tasks (Slack, general web browsing/documentation searching) on other machines' monitors.
Synergy isn't Linux-only, however they don't offer a free edition any longer... you might still be able to find the free edition but its license only allowed personal use.
 
After arguing in the matrix all day I'm looking at Rocket. I have a sense of impending doom with XenForo dropping our license and then I'll have to find some sort of solution for the forum moving forward. I could easily approach a forum with PHP8/Laravel but nobody seems to use PHP anymore and I get bullied for it. It's also just not very "performant", I guess. I wouldn't know since I don't have much experience with anything else.

I'd advise not going with Rust for a webserver. Managing memory is a PITA even if the compiler keeps your from fucking it up, and 9/10 times your performance ceiling is going to be IO/queries, so something as low level as that is overkill. Something that's easy to read and develop in is a lot better than something that's fast as hell but verbose.

If I could suggest anything these days, it'd be a Python stack. Dynamic typing is nice when you're trying to script something up quickly, performance is solid, support is vast and battle tested, and it's one of the most widely used languages these days, so farming out something would be pretty easy if you needed to. Django is good if you're looking for a Rails style 'batteries included' library, but i'd go with Flask if you're looking for a more microservice-y approach.
 
  • Like
Reactions: Marvin
Dynamic typing is nice when you're trying to script something up quickly
I guess, but it really doesn't take that long to learn how to do type conversion in most strong/static-typed languages, and I think the benefits of strong typing far outweigh the disadvantages. I really like that PHP has gradually introduced some features of strongly-typed languages in recent releases and I hope to see it continue.
 
I guess, but it really doesn't take that long to learn how to do type conversion in most strong/static-typed languages, and I think the benefits of strong typing far outweigh the disadvantages. I really like that PHP has gradually introduced some features of strongly-typed languages in recent releases and I hope to see it continue.

Another big advantage of Python is its flexibility. It's pretty easy to code up a function decorator that enforces type safety on a call, so you can turn it on and off depending on when you actually need it.
You're right that understanding typing is easy enough in most languages, but for a web server it just adds developer overhead that isn't really worth it unless you're working with a lot of people IME. If Null was doing a shit ton of complex operations and had a requirement that made throwing it in a background job impossible, then I could maybe see the need for something like Rust. But if Python is scalable enough for Instagram and Lyft, then it's probably enough for the farms.
Besides, if he's coming off PHP and looking for something brand new, Python is going to have way more out there in terms of tutorials, questions asked/answered and module support.
 
Last edited:
I'd advise not going with Rust for a webserver. Managing memory is a PITA even if the compiler keeps your from fucking it up, and 9/10 times your performance ceiling is going to be IO/queries, so something as low level as that is overkill. Something that's easy to read and develop in is a lot better than something that's fast as hell but verbose.

If I could suggest anything these days, it'd be a Python stack. Dynamic typing is nice when you're trying to script something up quickly, performance is solid, support is vast and battle tested, and it's one of the most widely used languages these days, so farming out something would be pretty easy if you needed to. Django is good if you're looking for a Rails style 'batteries included' library, but i'd go with Flask if you're looking for a more microservice-y approach.
I thought Python's performance was pretty shit.
What's wrong with Java or Go? Yes, they're boring, but they work and have decent performance, good frameworks and tooling. I never wrote backend software in Python so I wouldn't know how it holds up.
I also think its wide usage is a bit of a false signal due to all the data scientists and MLers
 
  • Agree
Reactions: Marvin
I thought Python's performance was pretty shit.
Python is "slow" in the sense that if you were to compare something like Rocket with Flask, the benchmarks for Rocket would be much much higher, but in practice it doesn't make a big difference.
As an example, if I have a route with code that takes 10ms to execute in Python, but an equivalent route in Rust would execute in <1ms, but I hit my database with a query that takes 50ms to run, and the client connection has a near constant ~250ms of latency, then the performance increase (which was substantial as a percentage, going from 10 to <1), is almost completely unnoticeable. And in exchange for that very small improvement, i'm now fully saddled with the complexity of Rust for everything I do. The tradeoff just isn't worth it outside of very specific use cases.

What's wrong with Java or Go? Yes, they're boring, but they work and have decent performance, good frameworks and tooling. I never wrote backend software in Python so I wouldn't know how it holds up.
I also think its wide usage is a bit of a false signal due to all the data scientists and MLers
I'd prize Python over Java for its ergonomics. I can't comment on Go as i've never used it, but i'd rather yank out a front tooth with pliers than build anything substantial with Java ever again. Great tools with lots of support, but goddamn can it get ugly. (Granted I haven't used it in ages, so maybe it pulled a modern C++ and is now actually not half bad).
As for popularity, Python recently overtook Java in the TIOBE index as the 2nd most used programming language behind C. The days of it only being used for hobbyists and niche applications are pretty much gone.
 
Last edited:
Why not just use Erlang?

- Excellent performance: good concurrency, can link to C well
- No callback hell: everything runs according to the imperative model in lightweight threads (i.e. REAL OOP, not C++ or Java "oop")
- Developed by Swedish megacorp, reverse compatible, no trannies
- "Let it crash" philosophy, surprisingly nice debugging


Rust is only good for CPU-bound stuff. For web stuff, you're much more likely to have a significant bottleneck in IO, and your performance gains will come from more effectively applying parallelism. If your webapp is CPU-bound, odds are something is seriously wrong.

Python is "slow" in the sense that if you were to compare something like Rocket with Flask, the benchmarks for Rocket would be much much higher, but in practice it doesn't make a big difference.
As an example, if I have a route with code that takes 10ms to execute in Python, but an equivalent route in Rust would execute in <1ms, but I hit my database with a query that takes 50ms to run, and the client connection has a near constant ~250ms of latency, then the performance increase (which was substantial as a percentage, going from 10 to <1), is almost completely unnoticeable. And in exchange for that very small improvement, i'm now fully saddled with the complexity of Rust for everything I do. The tradeoff just isn't worth it outside of very specific use cases.
The problem is the GIL. The GIL will fuck you up. Synapse is written in Python, and it's slow as a dog.
 
The problem is the GIL. The GIL will fuck you up. Synapse is written in Python, and it's slow as a dog.
GIL (usually) gets released on IO. If somebody is hitting GIL issues in a web app in modern Python, something's either not designed right, or they're doing something heavy/weird enough that using a language more specialized for that kind of task might be justified. But I doubt a forum currently running in PHP would need anything like that.

On the other hand Erlang is really neat. I've been meaning to get around to experimenting with elixir, but lately most of my productive free time is spent studying for one of those damn AWS certs.
 
  • Like
Reactions: moocow and Marvin
Python is "slow" in the sense that if you were to compare something like Rocket with Flask, the benchmarks for Rocket would be much much higher, but in practice it doesn't make a big difference.
As an example, if I have a route with code that takes 10ms to execute in Python, but an equivalent route in Rust would execute in <1ms, but I hit my database with a query that takes 50ms to run, and the client connection has a near constant ~250ms of latency, then the performance increase (which was substantial as a percentage, going from 10 to <1), is almost completely unnoticeable. And in exchange for that very small improvement, i'm now fully saddled with the complexity of Rust for everything I do. The tradeoff just isn't worth it outside of very specific use cases.


I'd prize Python over Java for its ergonomics. I can't comment on Go as i've never used it, but i'd rather yank out a front tooth with pliers than build anything substantial with Java ever again. Great tools with lots of support, but goddamn can it get ugly. (Granted I haven't used it in ages, so maybe it pulled a modern C++ and is now actually not half bad).
As for popularity, Python recently overtook Java in the TIOBE index as the 2nd most used programming language behind C. The days of it only being used for hobbyists and niche applications are pretty much gone.
Your calculus is only correct in a synchronous world. If you want to reach any decent throughputs you're most likely going to have to be async. Now let's reevaluate your example. Assuming all IO operations take 0 async time (false but for discussion's sake) your rust handler can serve 1k QPS/core while your python handler only processes 100 QPS/core.
The difference between Python's CPU performance and Rust, Go, and Java is in more than one order of magnitude.
I don't work with Java, but I do work with the JVM, which is a very decent platform. There are plenty of language which target it with decent performance. I find Go annoying, but it's a matter of taste. Still, modern Java (Rx, etc.) is almost cultured.
Like I mentioned previously, I would have liked to see a breakdown of Python's popularity by field, I suspect it's all data science.
 
GIL (usually) gets released on IO. If somebody is hitting GIL issues in a web app in modern Python, something's either not designed right, or they're doing something heavy/weird enough that using a language more specialized for that kind of task might be justified. But I doubt a forum currently running in PHP would need anything like that.
Then how come Synapse is such slow shit?

Python seems fine in theory, but it's always total garbage in practice.
On the other hand Erlang is really neat. I've been meaning to get around to experimenting with elixir, but lately most of my productive free time is spent studying for one of those damn AWS certs.
Elixir is infested with trannies and webshit, it's just Erlang for recovering Ruby programmers.
 
  • Agree
Reactions: cjöcker
Your calculus is only correct in a synchronous world. If you want to reach any decent throughputs you're most likely going to have to be async. Now let's reevaluate your example. Assuming all IO operations take 0 async time (false but for discussion's sake) your rust handler can serve 1k QPS/core while your python handler only processes 100 QPS/core.
Sure, but we're talking about Kiwifarms. Even at 5k users all hitting a route at once, on the average dedicated server you're not really going to notice. And without a really noticeable difference, it's hard imo to justify the additional learning curve and developmental complexity of Rust/Java/Erlang over something like Python.

Like I mentioned previously, I would have liked to see a breakdown of Python's popularity by field, I suspect it's all data science.
Instagram, Lyft, Pintrest, and Spotify all use Python on the back end. Django is almost guaranteed a place on any "most used web frameworks of year". Hell, if you're using Linux you probably have it installed on your machine by default.

Then how come Synapse is such slow shit?
Looking at their blog, i'm leaning towards "bad design".

it's just Erlang for recovering Ruby programmers.
Ey, that describes me perfectly. I'll talk it up, but i'm still bitter Python won that war.
 
Python seems fine in theory, but it's always total garbage in practice.
it completely depends on the kind of calculations the server is doing. If you're just fetching and sending things from a database and outsourcing some data formatting, pretty much any language will do because your bottleneck is going to be I/O.
If you're doing some kind of complex proprietary calculation, you need something more heavy duty. Remember that the performance of most code really and truly does not matter. It's identifying that 5-10% where it really counts that makes or breaks the responsiveness.

That said, there's other reasons to not use python besides performance. Python is not good for maintaining large code bases because the inputs/outputs of functions between abstraction layers become non-obvious. That leads to a lot of bugs.
 
Do not shill python in this holy place; it is merely a glue language, to use it otherwise is to become a glue-eater!


That said, there's other reasons to not use python besides performance. Python is not good for maintaining large code bases because the inputs/outputs of functions between abstraction layers become non-obvious. That leads to a lot of bugs.
This function returns a thing, this other function takes a thing. Do the things match? Maybe if they look sort of correctish? Then one day they don't look sort of correctish enough anymore and you get an inexplicable runtime error.
As much as static typing obliges being over specific in unhelpful ways, the ambiguity created by duck typing is infinitely worse long term.
 
This function returns a thing, this other function takes a thing. Do the things match? Maybe if they look sort of correctish? Then one day they don't look sort of correctish enough anymore and you get an inexplicable runtime error.
As much as static typing obliges being over specific in unhelpful ways, the ambiguity created by duck typing is infinitely worse long term.

Yeah, they introduced a type hinting system to mitigate it a bit, but even then you want to have hard checks in spots where it actually matters.
 
  • Agree
Reactions: Marvin
Yeah, they introduced a type hinting system to mitigate it a bit, but even then you want to have hard checks in spots where it actually matters.
Every time I hear that this or some other language finally introduces type hinting (or annotations, or whatever you want to call them) I think to myself - what the fucking fuck? So after 20-30 years of excruciating pain they (language maintainers and toolchain developers) are FINALLY admitting that these greybeard wackos mumbling something in the corner about "type safety" might have actually had some good reasons? Well, imagine my shock!

I fucking love hearing about all these failed experiments - Lua, PHP, Python, whatever else - how they finally come to drop the pretense of dynamicness being the bestest feature no srsly guis, we're not some poo-poo "static" thing lol who wants to be "static" in a dynamic and fluid XXI century oh my god why do I have 20 GiB of stacktraces in my server log...

Obviously, some batshit insane nutjob will soon develop a new, "fully dynamic BUT SAFE (no really, trust me!)" language in a rebellion against this ossified and "static" and "obsolete" technologies. And if it gains any traction, the same story will repeat itself 20-30 years down the road.

Just as (fr)agile development methodology is rediscovered over and over, with progressively more depressing results.
 
Sure, but we're talking about Kiwifarms. Even at 5k users all hitting a route at once, on the average dedicated server you're not really going to notice. And without a really noticeable difference, it's hard imo to justify the additional learning curve and developmental complexity of Rust/Java/Erlang over something like Python.
This reminds me of something Joe Armstrong has said. Don't design your system for 10 users and scale it up. Design it for 10M users then scale it down.
Every time I hear that this or some other language finally introduces type hinting (or annotations, or whatever you want to call them) I think to myself - what the fucking fuck? So after 20-30 years of excruciating pain they (language maintainers and toolchain developers) are FINALLY admitting that these greybeard wackos mumbling something in the corner about "type safety" might have actually had some good reasons? Well, imagine my shock!
That's a bit of a mischaracterization of the problem. Successful large scale dynamic types systems, built in Erlang and Clojure, have mostly figured it out by now. You want to be dynamic most of the time, and type check at some clear boundaries. Unstructured IO (JSON) is a good place to check. Crossing modules is a good place to check.
Besides that you can "spec out" your code base to your heart's content and use generative testing to check your assumptions. It mostly works out.
One of the problems with typed languages is that besides ossifying the code base over time, they don't really solve the problem, not without plenty of case and nice features, of making illegal states impossible to represent.
Example: I have type representing a segment. x1 should always be > x0.
I have a collection of segments which should always be in rising order.
Can your type system represent this? Can it generate example data for this?
 
Back