[HN Gopher] Truly portable C applications
       ___________________________________________________________________
        
       Truly portable C applications
        
       Author : signa11
       Score  : 43 points
       Date   : 2024-11-22 02:54 UTC (20 hours ago)
        
 (HTM) web link (lwn.net)
 (TXT) w3m dump (lwn.net)
        
       | p0w3n3d wrote:
       | 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 wrote:
         | 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
        
         | actionfromafar wrote:
         | 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.)
        
         | Brian_K_White wrote:
         | 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.
        
         | casey2 wrote:
         | 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.
        
       | 100ideas wrote:
       | Very interesting comments and moderation discussion on this
       | article.
        
         | h4ch1 wrote:
         | 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 wrote:
           | 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
        
             | lelanthran wrote:
             | 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 wrote:
               | Its in regards to the discussions taking place in this
               | thread: https://lwn.net/Articles/998196/
        
               | incrudible wrote:
               | 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 wrote:
               | 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.
        
             | IncreasePosts wrote:
             | 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?
        
             | erik_seaberg wrote:
             | 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.
        
             | spacechild1 wrote:
             | 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.
        
           | Brian_K_White wrote:
           | 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.
        
             | SanjayMehta wrote:
             | Werner von Braun comes to mind.
        
               | yawpitch wrote:
               | Wait, Werner von Braun kicked puppies?
        
               | cbm-vic-20 wrote:
               | SS-Sturmbannfuhrer von Braun, at best, looked away from
               | the labor situation at the Mittelwerk complex that was
               | building his rockets.
        
               | yawpitch wrote:
               | Yeah, sorry, I know that particular fascist's history,
               | but apparently sarcasm doesn't drip as heavily on the
               | Internet as I thought.
        
               | fragmede wrote:
               | Poe's law strikes again!
        
             | VyseofArcadia wrote:
             | 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_.
        
             | eesmith wrote:
             | 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.
        
       | Alifatisk wrote:
       | 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 wrote:
         | Yes, and yes:) It is exactly as amazing as it sounds. I'm still
         | blown away that that includes _both x86 and ARM_.
        
       ___________________________________________________________________
       (page generated 2024-11-22 23:01 UTC)