4
kiki
26d

It’s true and you know it

Comments
  • 10
    I love me some static typing. I also love python so I'm currently in an abusive relationship...
  • 0
    But if it's incredibly inconvenient at the most fundamental level then perhaps it's only worse higher up!
  • 2
    how do I exist in a static type universe pls

    inb4 I write JavaScript duck typing into rust
  • 1
    @jestdotty my first language was c++, I have the reverse question
  • 4
    I need that free beer to cope with having to read all implementations of an interface to figure out what the set of allowed return values is, just to then discover that some of those implementations are actually returning a value outside the set assumed by most consumers and the only reason it's still working is because the situations that would pair up old providers with new consumers are kinda rare
  • 1
    to be clear, expectations are volatile, that's natural. It's our job to ensure that the correctness of our code is permanent.
  • 3
    @lorentz nice description of the insanity of dynamic typing.
  • 0
    job@Lensflare I share a job market with hacks, dilettantes and yesmen.
  • 1
    People who hate static typing are essentially comparing JS with C++. Both are bad, but for completely different reasons. JS turns out to be slightly less bad.

    It’s sad that you don’t realize that you can have the best of two worlds, static typing and a beautiful, convenient and succinct syntax.
  • 0
    @Lensflare bold generalization for a static types fan
  • 0
    @kiki maybe, but I think it’s true for most of the cases
  • 0
    @Lensflare “I think it’s true for most of the cases” is literally how I code
  • 1
    @Lensflare what lang do you think gives the best of both worlds? Coz it probably doesn't
  • 1
    @atheist Swift

    Before Swift I coded with C, C++, Java, C#, Objective-C, Kotlin, JavaScript, and a litte bit of Python, Perl and the exotic Autohotkey language.

    So I have wide spectrum of experience
  • 0
    @kiki "I don’t need to worry about that because otherwise it wouldn’t compile" is how I code.
  • 2
    @Lensflare so the problem with swift, fundamentally, is apple.
  • 3
    @atheist The thing is, I kind of agree. Being associated with Apple is probably the one major problem that it has.

    Swift is open source and is available for Windows and Linux and even embedded systems.
    But a lot of people just see Apple and dismiss it for that single reason.
  • 1
    @Lensflare that's cool, last I looked (years ago) there were problems with the standard library, outside of macos it was limited/not fully open source
  • 0
    @jestdotty but I'm a bad programmer and need static typing to spot my stupidity... 😂
  • 0
    @jestdotty I think my concern is as much about me as it is the idiots that use my code because I *know* they won't do the kind of analysis you're talking about (I don't either but I fix shit when it breaks, they whine about it)
  • 1
    @jestdotty alas, I'm good at my job and a lot of people around me aren't. So when shit goes wrong, I end up dealing with it. Add to that I'm the only one in the company that's both a decent programmer and a decent mathematician, so there are projects I get given that few others can handle on their own. Or the fuckwit data sci folks come up with some clever idea that might as well have been scribbled in crayon and they expect me to make sense of it and turn it into something that can be put into production.

    Long story short, I'm a bit fucked off with my job...
  • 1
    @jestdotty god I wish that made me happy...
  • 1
    @Lensflare I actually kinda like C++. It bothers me that the unverifiable risks become UB and not a runtime crash (and especially that this isn't really configurable) and it has some ridiculous defaults that are only there because of backwards compatibility, and way too much implicit behaviour, but the options for metaprogramming are already great and rapidly improving, and crucially, the type system is strong enough that you hardly ever have to bypass it to get shit done.
  • 1
    @lorentz I also have a kind of love hate relationship with C++.
    Regarding UB: I think a crash would require some checks and would cost some runtime cycles. It’s against the philosophy of C++ ^^
  • 1
    @Lensflare I know why they don't do it, I'm just not sure they should. I get the impression that C++ deviated from the zero-cost principle once and they're now stuck supporting heap-allocated exceptions for the rest of eternity, so they responded to that mistake with extreme zealotry that inhibits a proper discussion of the zero-cost principle as one of many values.
  • 1
    @Lensflare To be clear, I definitely wouldn't suggest that C++ should completely eliminate UB, only maybe offer tools to limit it to the tiny fraction of any real-world codebase that actually needs it. The vast majority of C++ code is perfectly happy with wrapping stuff in shared_ptr and they would be fine with references that wrap a weak pointer and abort on dangling dereference too, just to name an example of the possible runtime-detectable errors.
  • 0
    @lorentz c++ undefined behaviour is undefined by the spec but most ub is deterministic. The classic example is an infinite loop with no observable side effects, a compiler can optimise out the loop because an infinite loop is ub therefore should never happen and the compiler can assume it doesn't.
  • 0
    @atheist well yeah but you notice an infinite loop, much more than a use-after-free or a data race
  • 0
    @lorentz so by the sounds of it you prefer rust, but rust is built around a leaky abstraction. Data should be either shared between threads and immutable or unshared and mutable. Rust extends that to anything that might possibly do anything unexpected, should be given immutable data or moved. It goes too far the other way. I don't think there's a language in existence that can prevent mutex deadlocks, so at a certain point you have to write good code no matter what. I prefer FP over rust, make everything immutable by definition, no leaky abstraction, no type coloring. It's the same problem with async in js. You have one async call, suddenly everything is an async call.
  • 0
    @lorentz also use after free in c++ probably means you're using raw pointers and not modern c++. Shared pointers reset to null which dereferencing is technically ub but will near universally crash something and raise a null pointer exception. So use after free I'm not convinced is a true problem anymore.
  • 0
    Rust also allows you to do unsafe shit so you can punch through abstractions same as any other language.
  • 2
    @atheist @lorentz

    Well, I dare say that at least most of the C++ STLs and runtimes I've worked with have debug layers for precisely this kind of shit (dangling references, null pointers, thread shit, etc.) that are fairly effective.

    That's the beauty of being able to link to different runtimes.
  • 1
    @atheist and here I thought I was the biggest masochist.
    I loathe python... and basically anything that counts whitespace formatting as valid elements to a language... also loathe it for its non-static typing... but unfortunately it's a necessary evil for some of the mass algos im creating.
  • 2
    Ironically, i disagree with most of your views on awesome.

    Free beer... shitty in USA... some dark german beer sure, but i still am more of a high proof liquor fan. Everything else is just a chaser.

    Ruby annoys me.

    Static typing is my friend. I dislike just about anything that tries to assume shit about my variables.

    If i wanna make a variable, It WILL be explicitly declared!
  • 0
    @awesomeest pyright on strict. It's a pain in the ass but I find it makes code so much easier to navigate. Also ruff.
  • 0
    If you ever see a docstring linter called "what the doc" , then I've actually finished my parser/renderer/linter for restructured text... So add that to the list.
  • 0
    @Lensflare What issue do you have with C++? I mean... I'll use C vs C++ whenever possible but c++ isnt horrid.
  • 2
    @atheist
    i tend to avoid things like that for the same reason i tend to avoid frameworks... something, somewhere, will annoy me... then annoy me again... by 3x im so deep in modding the annoyances away that ive just written my own system.

    it's a serious issue when youve been modding things, far beyond what is meant to be configurable, since early childhood... you just know too much. needing to google or check some docs is often the only thing that keeps me from making and going down one hell of a hyperfocus rabbit-hole.

    it's much more of an issue now that i need to keep some form of standards so others in my company dont blow their heads off trying to figure out how tf my code works.
  • 0
    @awesomeest pyright is (IMO) the better python static type checker, I highly recommend. Ruff, a linter and auto formatter (if desired) is pretty good and unlike the stupidity of black, can be customised. I'd recommend pyright at a minimum but get why not linters. But yeah, I'm writing my own for the same reason. It seemed like a good idea at the time...
  • 0
    @atheist yeah... i just made my own version of a debugging mod... basically adds like modified print lines that alert if a variable changes type... i was drunk one night and python decided that a discord ID string, explicitly declared as such, should turn into an int... fucked up a bunch... grinded out a major debugging module in a adhd hyperfocus episode whilst intoxicated.
  • 1
    @awesomeest I dislike C++ independently of C.
    My gripes come from when I compare it to modern languages like Swift or Kotlin (or even C#).
    It is too archaic and has legacy stuff like header files and the include system. It is elegant but completely annoying in practice.
    It is unsafe by design.
    Some practically zero const abstractions like the shared pointers do fix it for some cases but that’s not enough.
  • 0
    @atheist
    > I don't think there's a language in existence that can prevent mutex deadlocks

    Swift (again 😄) in version 6 introduces a concurrency system which comes with compile time correctness guarantees about code which involves data shared between threads.
    Of course, this requires you to write correct code, but at least the compiler is able to check it and emit an error if the code contains possible thread safety problems, so this is a big win.
    It's worth mentioning that it’s possible to opt out of it.
  • 1
    @Lensflare

    Ironically, most of the stuff you mention is actually inherited from C, and is needed to keep compatibility with it.

    However, I agree that the C++ committee is often very slow to push for changes in the name of keeping backwards compatibility.

    Hopefully modules will soon replace headers.

    As for compile time checking of concurrency issues, I don't think it will ever work past some very basic instances. In addition, if it requires you to write correct code in the first place, what's the point? You already wrote correct code anyway.
  • 0
    @CoreFusionX it’s hard to explain it when you are not familiar with Swift. Swift 5 has already prepared some of the stuff needed for this to happen and it really works. It feels magical. Basically it forces you to write correct multithreading code (if you opt in), which can be checked by the compiler. It works for any arbitrary complex case, not just basic stuff.
    It works on the principles of mutable vs non mutable state, exclusive access and structured concurrency.
    You can look into the official docs if you are interested.
  • 1
    @Lensflare can your magical swift let me keep audio priority on my music when safari (or anything else) is open?
  • 0
    @awesomeest Hmmm… I gonna say… yes.
  • 0
    @Lensflare make me a fix for 50$? its an ipad
  • 0
    @awesomeest sry I don’t do freelancing. 😆
  • 2
    @Lensflare ok... do it for friendship and\or to prove swift is a worthy "elegant" language... ill even move swift to the top of my 2learn list... its currently 4th (i think)... but i already have books and a folder of 1000s of pages of docs ready
  • 0
    @awesomeest you realize that your problem is not language level but platform level?
  • 0
    @Lensflare ofc... but what else can be used to fix it (i mean aside from using another system to puppeteer it)?
  • 0
    @awesomeest no idea 😄. that’s not my area of expertise. My guess is that it’s not possible. But if it’s possible, then you can do it with Swift 😉
  • 1
    @Lensflare not swift enough
Add Comment