10
galena
2d

Fucking hell! Why is it so hard to just create a simple websocket!
C#: Yeah, you should use ASP.Net with SignalR! But heres a totally undocumented mess of a lib to get it to work. J.k. Deadlock!
Rust: async while let OK((some)) = ws.create.unwrap_or_else().suckadick()
Why the fuck is Rust so fucking dense! I want one line that means one thing! If I would compress my code with gzip it would be less information dense than this!
Zig: Yeah, Its in Beta and shits semi stable. Atleast i got it to work? Nope!

I've ben fussing aound with these three Languages for more than a week now and can say: Just use an established way to webdev. Its not worth it to try and make it as simple as possible!

Comments
  • 1
    This is how to create a websocket server form A to Z using Python:

    https://molodetz.nl/retoor/gists/...

    I tested it to be sure. But it was literally 3 minutes or smth. I didn't have to do the apt stuff ofc. I already had python.

    Edit: whoops, forgot the pip. Applied that.
  • 1
    c#: have you tried `app.UseWebSockets()`?
  • 1
    @tosensei still, it's a lot compared to Python. I do know you can implement the socket directly in Program.cs tho like in my socket example. I played with it while ago. I'm happy that C# came to Linux. It's decent.
  • 1
    I tend to use Typescript when I don't want to make decisions about error handling and thread safety and just want something to work in the happy case with possible hidden assumptions in as few lines as possible. It has good enough types for accurate intellisense for non-library types and libraries for literally anything I'd ever want to do.
  • 1
    @tosensei Isnt that asp?
  • 1
    I will have to look at our code to see how we do it in C#. I am fairly certain we don't use ASP.
  • 0
    @galena no, asp was the stuff back in the 2000s. before dotnet. the stuff where you wrote shitty pages with vbscript.
  • 1
    @retoor Initially i focused on compiled languages, but this might acutally be a viable sölution 🤔
  • 0
    @tosensei we don't speak of asp classic! Let me forget about it please.

    But app.UseWhatever() looks like ASP.NET Core
  • 1
    @galena I also focus on those but for internet communication it's kinda bullshit. Python is not slow at all and even besides that old reputation, it made huge steps regarding performance. Python won't be the bottleneck of your application probably. If you would render big templates and many (few thousand) you can see it has some issues with it. But just for handling streams it does well. Biggest difference between a C server and Python server is memory usage and CPU usage. Python uses more CPU, but that's only local with heavy load tests. I even wrote a load balancer in python for HTTPS / SSH: https://molodetz.nl/retoor/...

    With this weird app, you can host ssh and HTTPs both on port 443 so your ssh won't be discovered. Hide in plain sight ;)
  • 1
    @retoor "Python is not slow at all" - is that why it needs a c-written library to handle anything numerically in any acceptable time?

    the performance difference between "doing math in python" and "doing math with numpy" was a factor well above 1000, last time i checked.
  • 1
    @tosensei that's correct. But that's not an network depended appliance. And what is the problem if you can indeed use those libraries? So you have the advanced number speed with the perfect glue which is python. Python is doing it so well - nobody does machine training in C itself, only components like tensorflow and stuff. Python is just unbeatable in glueing stuff together and dev performance.

    So again: python is not slow. You can use fast libraries indeed. Bam, fast python.
  • 1
    @retoor you also have to learn to "push to the internals" to do regular python fast. I saw a video on how to do this called "Idiomatic Python" on youtube. Changed the way how I looked at the language.
  • 1
    @Demolishun Idiomatic python is very famous in dem python world. Almost every python dev knows it. We had a book at the office, it's a smoll one. It's not that much. Some guide lines. Do you know the zen of python? You have to be Dutch for that maybe. Open python and type `import this`.
  • 1
    @retoor head about Zen. Can't remember looking at it. I haven't had to do python for 6 years now. I use it for scripts though.
  • 1
    @Demolishun Since you're also a C programmer, play for fun with the Python C API. It's freaking amazing. I'm writing a proxy interceptor that can replace contents in a http stream (kinda man in the middle, can be used for preventing sensitive data leaks and suck, You could block certain names for people that prefer to work under and alias) using C but make the intercepting rules completely configurable with python. So now, my C proxy intercerceptor can use thanks to python even AI! It's such a powerful combination while doing 5k/s requests. The python functions are full time in C memory. The hardest part of extending python using C is finding a use case :P Python is actually good itself on its own for 99.9% of stuff. But it's just fun I guess.
  • 0
    @retoor I once turned a C++ game engine into a Python module. I learned a lot that way.

    https://github.com/Demolishun/...

    I think its visible. If not I can adjust the settings.
Add Comment