Unable to load image

Until python has @nothrow and @nogc it will never be as good as D

I was writing a python script today to scrap reddit and generate a list of transexuals and hamas simps for me to block and it was nothing but pain.

Why you ask?

Because python does nothing to warn you what error your code can throw or even if it can throw an error. In D (the far superior langue) you can tag your code @nothrow and if your code can throw any error you've not handled the compiler will throw an error. This allows for good, safe, trustworthy code the likes of which you will never get from gaython

No instead you'll write a try except for every case you can think of just to have it throw one you didn't, give up and use pokemon exception like a jr!

The case for @nogc is even simpler, my code is short lived enough that it simply doesn't need garbage collect. Instead I the almighty dev should be allowed to manually managed the memory thus ensuring I get the maximum amount of perforce.

I can't tell you how useful nogc is in D.

!codecels embrace the D, it's the future

PS: rust and go are gay.

23
Jump in the discussion.

No email address required.

    from functools import *; import gc
    
    def nogc(f):
        @wraps(f)
        def s(*a, **kw):
            gc.disable()
            try:
                 return f(*a, **kw)
            finally:
                gc.enable()
    
    def nothrow(f):
        @wraps(f)
        def s(*a, **kw):
            try:
                 return f(*a, **kw)
            except BaseException as e:
                  pass

ALL RIGHTS RESERVED. DM for licensing info

Jump in the discussion.

No email address required.

I knew if I said python couldn't do something someone would do it for me!

!codecels the xkcd was right!

Jump in the discussion.

No email address required.

nothrow should do static analysis to ensure the annotated function cannot throw, i.e. adding a compile time errror condition. What you have here is more like the opposite of nothrow, ignoring even runtime errors :marseyemojirofl:

Jump in the discussion.

No email address required.

>worrying about gc

https://i.rdrama.net/images/17135127357499669.webp

Jump in the discussion.

No email address required.

>No instead you'll write a try except for every case you can think of just to have it throw one you didn't, give up and use pokemon exception like a jr!

try:
  sumsheeeet()
except Exception:
  pass

Your code is perfect now and can never error. You're welcome.

Jump in the discussion.

No email address required.

Glad it works for you but the only D I'll be using is the one attached to me


:#marseyviewerstaretalking:

Jump in the discussion.

No email address required.

If you program anything but Java and D ur a homo

Jump in the discussion.

No email address required.

Yeah I use Java(((script)))


:#marseyviewerstaretalking:

Jump in the discussion.

No email address required.

Java(((script)))

You are a woman. Please join biofoids.

Jump in the discussion.

No email address required.

It's actually even worse than that, I use kotlin instead of Java


:#marseyviewerstaretalking:

Jump in the discussion.

No email address required.

!cuteandvalid come get ur gurl

Jump in the discussion.

No email address required.

I have a friend who LOVES Kotlin. He even hangs out in a dev chat and helps professional programmers with their code- for free :marseyxd:


Follower of Christ :marseyandjesus: Tech lover, IT Admin, heckin pupper lover and occasionally troll. I hold back feelings or opinions, right or wrong because I dislike conflict.

Jump in the discussion.

No email address required.

never even heard of D. Is that a real language

Jump in the discussion.

No email address required.

Jump in the discussion.

No email address required.

fake and straight

Jump in the discussion.

No email address required.

I will write metacode to write code to cut u

Jump in the discussion.

No email address required.

if it isn't in Assembly then I'm just gonna assume anything you write is just talking about how much you want to suck my peepee (because ur gay)

Jump in the discussion.

No email address required.

>implying i don't solely write D by calling ASM from extern

Jump in the discussion.

No email address required.

D is cool, Java is GenericTrashFactoryBuilderImpl

Jump in the discussion.

No email address required.

Instead of @nothrow maybe just write better code?

Jump in the discussion.

No email address required.

Skill issue. Simply don't write bad code and you won't run into errors.

Jump in the discussion.

No email address required.

:#marseygroomerfreebsd:

Jump in the discussion.

No email address required.

i agree

Jump in the discussion.

No email address required.

Just use except for your gay little block list script. Who fricking cares what exception it is? Is a team of devs going to have to maintain this? Do you have an ops team that has to understand it running it for you? No? Then shut the frick up about your autismo language and use what gets the job done (always Python, maybe java or C++ occasionally)

Jump in the discussion.

No email address required.

Using python is pretty gay either way but there are respectable enterprise languages out there that don't involve falling for a meme language


:#marseyviewerstaretalking:

Jump in the discussion.

No email address required.

Python is gay but it's the clear choice for quick scripts or scientific/ml so I use it (with my butt plug in)

Jump in the discussion.

No email address required.

:#marseyagree:

It just pains me to see large enterprise apps written in it


:#marseyviewerstaretalking:

Jump in the discussion.

No email address required.

Several years ago my company paid an external team to write a business rules engine for us. They did it in Python. From the start it became the most resource-demanding deployment in our cluster - the infra team had to write special rules just for it, and it was refactored several times to split it into more containers to help it scale. We're finally now almost finished with a project to rewrite it entirely in golang.

All because some hotshot data analyst wanted to be able to update/add rules himself and was too smooth brained to learn any language but Python, and somehow strong-armed management into agreeing. Why none of our architects took him out behind the cafeteria to give him a man-to-man discussion with a baseball bat I'll never know.

!codecels it's 3:30am and I'm up questioning all my life choices I just need someone to read this to help me feel anything again ty

Jump in the discussion.

No email address required.

Sorry nibba, Python is the lingua franca of the AI future. Get on board the train or die in your Java shithole with the rest of the boomers. :marseykingkrazysnake:

Jump in the discussion.

No email address required.

Python is the lingua franca of the AI future

You're just saying this because you want to frick an AI

Jump in the discussion.

No email address required.

Yes just throw more cpu and ram at the problem and hope it'll work out in a few years, you suspendered mustachioed frappe sipping zoomers will never appreciate the art of hand-crafting an inner loop in assembly to eak out the last bit of performance from your Texas Instruments cpu. Take the L and suck on Deez nuts, no cap.

Jump in the discussion.

No email address required.

if err != nil Golang is a garbage language Google invented to keep their rslur new grad devs from shooting themselves in the foot.

Jump in the discussion.

No email address required.

I mean that's fair

Jump in the discussion.

No email address required.

They already rewrote it in rust

:#smugtranstwitter:

Furry rights are human rights

Jump in the discussion.

No email address required.

Python is best understood as a "Jack of all trades, master of none" language. That said, written properly performance shouldn't be that bad. The problem is novice codecels getting away with writing shoddy code.

Jump in the discussion.

No email address required.

Yeah, and the other problem is management thinking that outsourcing a critical business app to people who don't understand our industry and who failed to get jobs anywhere productive will somehow result in better code.

Jump in the discussion.

No email address required.

Was this outsourced to :marseytunaktunak: by any chance?

Jump in the discussion.

No email address required.

>Jack of all trades

Isn't that true for everything besides DSLs and maybe low level languages?

Jump in the discussion.

No email address required.

Not really, Python has a massive (and good) standard library for tackling most tasks. The third party libraries extend that further. You can comfortably make your full stack in Python, which can't be said for most languages. Problem is that while it can do it all, it doesn't do anything particularly well.

Jump in the discussion.

No email address required.

I see. I guess when you include an ecosystem in the definition of the language, this is true.

Jump in the discussion.

No email address required.

I feel your struggle king :marseytherapist:


:#marseyviewerstaretalking:

Jump in the discussion.

No email address required.

Python is the Excel of the CS world

Jump in the discussion.

No email address required.

What'd you rewrite it in?

Jump in the discussion.

No email address required.

Using a language without a solid type system on a codebase more than 3 people have to touch does sound awful, thankfully all the r-slurs at my company are in web front end so I never had to worry

Jump in the discussion.

No email address required.

It's been ten years since python was better than node for anything that doesn't use C bindings like tensorflow

Furry rights are human rights

Jump in the discussion.

No email address required.

I agree but dramatards aren't ready for that one yet


:#marseyviewerstaretalking:

Jump in the discussion.

No email address required.

Who fricking cares what exception it is?

me

Is a team of devs going to have to maintain this?

yes, me, myself and I

Do you have an ops team that has to understand it running it for you?

Future me

Then shut the frick up about your autismo language and use what gets the job done (always Python, maybe java or C++ occasionally)

All very gay minus java.

Jump in the discussion.

No email address required.

I'm afraid the autism is terminal. A pair of programming socks and an IKEA shark have been shipped to your parents house

Jump in the discussion.

No email address required.

Me, the non IKEA shark, will also be at your parents house :sharkybodybuilder:

Jump in the discussion.

No email address required.

:marseysmugautisttalking#:


Transform your Marseys! :marseywave:
/e/marseybooba.webp
www.pastebin.com/Jj9URfVi

Jump in the discussion.

No email address required.

I didn't know people legitimately used D. I had only seen WalterBright shill it every HN comment he makes.


Follower of Christ :marseyandjesus: Tech lover, IT Admin, heckin pupper lover and occasionally troll. I hold back feelings or opinions, right or wrong because I dislike conflict.

Jump in the discussion.

No email address required.

This is how you work maxx. Run code wait for error and bug fix works extra well if ur code takes a while to run :marseyhawaii:

Jump in the discussion.

No email address required.

Just use a bare except, r-slur. That will catch everything.

Jump in the discussion.

No email address required.

I AM NOT A JAP BOY, I DO NOT COLLECT POKEMON I DON'T WANT TO CATCH THEM ALL!

Jump in the discussion.

No email address required.

Then read the docs for whatever you're using and you'll know what to catch. This seems like a serious skill issue.

Jump in the discussion.

No email address required.

>reading when the compiler could do it for me

1x

Jump in the discussion.

No email address required.

>waaaa I need a compiler to tell me I'm r-slurred

:@istillmissedtalking#:

Jump in the discussion.

No email address required.

I still wish there was syntax to have a "bare except" (that catches everything) but assign it to a variable so you can print/log it. Always struck me as odd that you couldn't do that.

Jump in the discussion.

No email address required.

But you can? Just catch BaseException or whatever?

Jump in the discussion.

No email address required.

Is it absolutely guaranteed that anything you can possibly throw derives from that?

Jump in the discussion.

No email address required.

I thought if you throw anything other than exception it becomes a type error.

Jump in the discussion.

No email address required.

huh TIL

>>> raise 'foo'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: exceptions must derive from BaseException

I'm so used to C++ where they let you throw literally fucking anything.

Jump in the discussion.

No email address required.

It was different in python 2 where I think there's one oddity where you can throw an old style class without a type error. Python 3 it should catch everything, but be warned you should probably handle keyboard interrupts separately if you have the try in a long running loop.

Jump in the discussion.

No email address required.

tbh my "catch anything" blocks are typically reserved for the top level, where I simply want to log it before exiting rather than just vomiting some shit to the console. I think in the past I resorted to something like a bare except and then inspecting some special exc_info or other type that got you the "current" exception.

Thankfully I've never had to seriously use python 2 and can freely tell any developers at my job who request python 2 support to get bent.

Jump in the discussion.

No email address required.

Bare except and using exec info to get the stack trace and exception would probably work too, just more effort.

Jump in the discussion.

No email address required.

1. "My code doesn't throw exceptions" isn't the same as "my code is correct"

2. In a short running script, using a garbage collector will likely be faster than using a manual allocator. A good GC can use a bump allocator which won't actually trigger a full collection, but something like malloc will use a free list, which does have overhead and can fuck with your cache.

Also: having a nogc annotation means you can't use a moving collector, which makes the parts of your code that do use the GC less efficient

Jump in the discussion.

No email address required.

  1. "My code doesn't throw exceptions" isn't the same as "my code is correct"

9/10s the way there

Also: having a nogc annotation means you can't use a moving collector, which makes the parts of your code that do use the GC less efficient

Which is why you @nogc everything

Jump in the discussion.

No email address required.

Which is why you @nogc everything

Why would I want to slow down my own program for no reason?

Jump in the discussion.

No email address required.

to prove ur 10x

Jump in the discussion.

No email address required.

What's even the point? Python doesn't even have strict type checking (there's the type hints which are useful but are more for documentation and IDE auto completion than anything else). Why would you need strict throw specifiers?

imo if you're writing a complicated project in python you're doing it wrong, but I still think it's the best language for small to (some) mid-sized stuff, where performance doesn't really matter.

Jump in the discussion.

No email address required.

This is a lack of experience problem, AKA "skill issue".

Jump in the discussion.

No email address required.

Exceptions are normal control flow in python, it's how iterators signal that they're empty or that a key in a dict doesn't exist. This is especially funny since they refused to implement goto, but encourage gotos up the stack.

That said, while nothrow and nogc are useful in smaller to mid-size projects, they are severely limited in big codebases or when you have dependencies (exactly when they'd be the most useful). They especially start to be a major hassle once you want to introduce higher order functions or callbacks.

>my code is short lived enough that it simply doesn't need garbage collect.

:marseygigachad:

Jump in the discussion.

No email address required.

Even D doesn't have @nogc

Enjoy no standard library calls! :killherkillher:

Jump in the discussion.

No email address required.

write your own stdlib

Jump in the discussion.

No email address required.

Is there any point to D in any form? I only ever hear about it when someone wants to bring up something mway more obscure than even goddarn lisp.

Doesn't Go fill its niche nowadays anyway?

Jump in the discussion.

No email address required.

Doesn't Go fill its niche nowadays anyway?

if you enjoy if err != nil

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.