Truly portable C applications

(lwn.net)

52 points | by signa11 3 days ago ago

35 comments

  • 100ideas 3 days ago

    Very interesting comments and moderation discussion on this article.

    • h4ch1 2 days ago

      Decent article, why the need for someone to pick up the pitchfork and emphasize their moral compass publicly like this? The comment and ensuing discussion is so pointless.

      • no_wizard 2 days ago

        Why do we pretend that these things don’t matter? Why should we?

        Why in the norm to ignore these issues - there by perpetuating them because they face no consequences - rather than pointing them out?

        Justine did write openly on the web about their prejudices and never even apologized let alone showed in anyway evolution away from fascist leaning and prejudiced politics

        • spacechild1 2 days ago

          I didn't know about Justine's politics and I'm glad I do now. She is definitely not someone I would want to be associated with, unless she clearly distanced herself from these - in my opinion - deeply problematic and disturbing views.

          EDIT: That being said, I think it should still be possible to discuss her technical contributions in some form. It's basically the old question as to which extend you can separate the work from the author.

        • lelanthran 2 days ago

          I think I am missing a lot of context in this thread - I have no idea what any of the ancestral comments are talking about :-(

          • no_wizard 2 days ago

            Its in regards to the discussions taking place in this thread: https://lwn.net/Articles/998196/

            • incrudible 2 days ago

              I fail to see anything of substance here, seems to be some person with a chip on their shoulder. Apparently the word cosmopolitan is a derogatory dog whistle for Jewish person, but why would an antisemite name their own work after something they do not like?

              • AlotOfReading 2 days ago

                Just to be clear I'm not talking about Justine here and I consider the project to be well within the normal meaning of "cosmopolitan", but dogwhistle names are absolutely a thing antisemites do.

              • 01HNNWZ0MV43FF 2 days ago

                I did the same for a different political issue once, I just thought it was funny

        • erik_seaberg 2 days ago

          It preserves HN and LWN as useful forums for purely technical discussions with high signal/noise, basically. From https://news.ycombinator.com/newsguidelines.html :

          > Please don't use Hacker News for political or ideological battle. That tramples curiosity.

        • IncreasePosts 2 days ago

          Please tell me how it matters.

          What are you arguing here? Should no one use APE? Should people use APE but just feel bad every time they do? Should people use APE but never write about it for fear of aggrandizing the author?

        • 2 days ago
          [deleted]
      • Brian_K_White 2 days ago

        I think this point was valid: "she doesn't "stick to the technology""

        The tech is cool. But the person who made it kicks puppies. You don't care? Well I do.

        • VyseofArcadia 2 days ago

          Why?

          This makes sense in the case of, for example, a bestselling author who kicks puppies. Purchasing books by this author means you are giving them money, if indirectly, and thus to some degree subsidizing their puppy kicking habit.

          That I can determine using APE gives the original author nothing.

        • SanjayMehta 2 days ago

          Werner von Braun comes to mind.

          • yawpitch 2 days ago

            Wait, Werner von Braun kicked puppies?

            • cbm-vic-20 2 days ago

              SS-Sturmbannführer von Braun, at best, looked away from the labor situation at the Mittelwerk complex that was building his rockets.

              • yawpitch 2 days ago

                Yeah, sorry, I know that particular fascist’s history, but apparently sarcasm doesn’t drip as heavily on the Internet as I thought.

                • fragmede 2 days ago

                  Poe's law strikes again!

                  • yawpitch 2 days ago

                    Ahh, never encountered Poe’s Law, thanks for that. I like it, however I’m not entirely sure that mock bewilderment at the implication that SS-Sturmbannführer Werner von Braun (PBUH) kicked puppies represents an extreme view.

        • eesmith 2 days ago

          Say a fan of ReiserFS, without 'knowledge or opinion of Hans' https://news.ycombinator.com/item?id=42115276

          In general, I've noticed that people like to kick the people with least power or privilege, which often means women are targeted as they tend to have the least power and privilege.

          Oh, a BigTech company is evil, with CO2 demands that will kill the planet, support for genocide, and developing mass surveillance to improve their bottom line? Not a problem! Look at all the cool tech toys they have!

          Someone develops cool tech toys but has horrible personal opinions? Keep him around as the Chief GNUissance and invite him to all the conferences because he didn't do anything except express opinions, but pounce on her whenever people mention her toys, because of her opinions.

          • Brian_K_White 2 days ago

            This is a very confused comment.

            Did you even read that post of mine that you searched up for some reason? What do you imagine you found there?

            And keep who around as cheif gnussance? Doesn't that usually refer to Stallman? Do you think Stallman is the same as either Reiser or Tunney?

            And who is pouncing on anyone exacly? No one is doing violence on Tunney, nor advocating it. They just opt out of lionizing her, and for a reason she creates herself.

            Why do you seem to be so scandalized at holding someone accountable for their opinions? Did you not know that some opinions are not neutral or harmless? No one cares about her opinion about tea vs coffee.

            Personally I don't actually even hate her. She says so many different conflicting things that you can't take anything quite fully seriously, including the worst bits, because 10 minutes earlier on some other site she probably said something opposite, and I frankly agree with about half of it.

            But you can't ignore the worst bits either because some things you don't get to say without consequence.

            And one thing that IS consistent is that she does it on purpose and explicitly, by her own admission, gets off on making everyone else crazy. Not just gets off on being smarter or righter, but specifically on making someone else upset for no other purpose than to laugh at that.

            I've known a hundred people like that. Most were 12-22 year old boys, and at least half of those eventually outgrew that phase, and even those that never did are mostly harmless. So I say she's not evil, she's just a garden variety douchebag.

            Someone who explicitly prides herself on violating everyone else's feelings, and who explicitly preaches that everyone else needs to grow a thicker skin, cannot possibly at the same time have any problem with something as insignificant as being called an asshole.

        • IncreasePosts 2 days ago

          [flagged]

  • p0w3n3d 3 days ago

    I have learned there is no true portability. Example: named pipes:

    I started my professional career as a C++/Qt developer. There was this code to disallow multiple application instances using named pipes. It used named pipes under both Linux and Windows - just create a named pipe "my-program-pipe" and it was a signal for other starting up instances to communicate to it "please put the main app on top" and close.

    On linux it worked like a charm. On Windows it worked like a charm...

    ...only first time. The code was written to "try create a named pipe and if failed - then it means it exists, so write to it instead and exit". This "try create" operation on windows failed but also removed the original existing pipe, thus allowing the third instance to coexist with the first one.

    What I mean - Operating Systems are more than this, you cannot write a truly portable application without knowing them all. And especially those quirks that differ...

    • sjsdaiuasgdia 2 days ago

      Hence the Cosmopolitan Libc layer that's kinda essential to the APEs described in the article. That's where all the magic is to make the same code work on a variety of operating systems.

      There's even a handy table to express syscall compatibility across all of Cosmopolitan's targets - https://justine.lol/cosmopolitan/functions.html

    • casey2 2 days ago

      You could always just write your own OS that only cares about running your app. Of course you are always going to run into problems if your program uses functions that you didn't design around. I think any Linux user could tell you that Windows programs don't run on Linux, so I don't know how you could have thought that there was some sort of portability guarantee between these two operating systems or even subsets of them.

      If this is some OOP propaganda then I'm sorry but you got duped and the c++/qt community should act more professionally.

    • Brian_K_White 2 days ago

      portability in a language is sort of like the right to persue happiness vs a garantee to be happy.

      A language can't direct the rest of the universe to ensure that something always works regardless of the environment or context.

      But it can avoid adding it's own limitations and be agnostic itself. So c is very portable, even though c on machine A has acces to machine A features and not machine B features.

      Libraries and frameworks and standards just help a little for a few common cases but they are just travel power plug adapters, not pprtability.

    • pjmlp 2 days ago

      Of course, all these "portable C" stuff only works as long as it is pure C standard library.

      One might extend the goals a bit, and include POSIX, and even then, only works if the set of target systems support POSIX, and finally if the implementation defined semantics happen to agree, and not cause random surprises.

    • actionfromafar 2 days ago

      Your general point stands, of course. One can only code against a tiny subset of features. Windows has now finally gotten "real" named pipes, though. (Since Windows 8 or whenever, can't remember exactly when.)

  • Alifatisk 2 days ago

    So am I getting this right? Cosmopolitian allows me to compile my code once, and run the same binary on every machine it supports? Is this a dream?

    • yjftsjthsd-h 2 days ago

      Yes, and yes:) It is exactly as amazing as it sounds. I'm still blown away that that includes both x86 and ARM.

    • hiccuphippo 2 days ago

      As I understand, you have to compile your code for every machine you support, then it combines them into a single executable.

    • pjmlp 2 days ago

      As long as you don't use nothing else besides C standard library.

  • RestartKernel a day ago

    This is neat, but I'd rather just pick my platform from a list of binaries. Those who don't know what they're running probably aren't spoofing their user agent either, so you can just* serve them the correct option with a big button first.

    * It doesn't seem that you can reliably get the CPU architecture from the user agent yet.

  • ngcc_hk a day ago

    Old schooler oils not find itself accept self modifying program. Yes it said it just change so to run in multiple environment so script, win binary … etc. or lie to the os what you really are.

    Is that another name for virus / worm.

    More gently, is it I just fat binary in a compact form. If so why not use label the source to cross compile so when Apple dump Intel, we do not need to carry that program.