Yet another Go thread



  • @Ben L. said:

    Why the fuck are you using new(T)? This isn't Java. Use the constructor function.

    If you're not supposed to use new, then why is it there?



  • @morbiuswilters said:

    @Ben L. said:
    Why the fuck are you using new(T)? This isn't Java. Use the constructor function.
    If you're not supposed to use new, then why is it there?
    Maybe it's like Go's version of goto; there if you really want it, or if you're insane?



  • @morbiuswilters said:

    @Ben L. said:
    Why the fuck are you using new(T)? This isn't Java. Use the constructor function.

    If you're not supposed to use new, then why is it there?


    The context on the conversation was to use a pointer to an instance instead of the instance itself, and the way to get a pointer is either taking the address of an existing object using &, or by using new to create a new object and get a pointer to that. Ben tends to forget easily, however, even when he's the one who starts the conversation to begin with.



  • @Arnavion said:

    @morbiuswilters said:
    @Ben L. said:
    Why the fuck are you using new(T)? This isn't Java. Use the constructor function.

    If you're not supposed to use new, then why is it there?


    The context on the conversation was to use a pointer to an instance instead of the instance itself, and the way to get a pointer is either taking the address of an existing object using &, or by using new to create a new object and get a pointer to that. Ben tends to forget easily, however, even when he's the one who starts the conversation to begin with.

    Can somebody explain why Go has pointers in the first place? I thought it was GC'd. Is it just because they needed to implement reference-passing and figured it made sense to put the burden on the programmer?



  • @Ben L. said:

    @Sutherlands said:
    @Ben L. said:
    @Sutherlands said:
    If you're saying that a pointer has to implement an interface so that you can change data on the object, that's yet another WTF

    Could you rephrase that statement? I read it right now as "why can't I modify this value that was passed by value?"

    Wow.  You're really trying to take the cake for "worst programmer on this board" aren't you?  Tell me how C++ or C# manages to modify values passed to a function without allowing/making pointers implement interfaces.

    If you copy a value, which is what passing by value does, you're still able to modify it, but it DOESN'T MODIFY THE ORIGINAL (pre-copy) VALUE.

    Are you saying that I should make a language where I can change the value of an int passed to a function and suddenly everywhere that used that int now has the new value?

    Where did I say this?  Watch this:

    void Main()
    {
     var x = 1;
     var y = 2;
     SwapInts(ref x, ref y);
     x.Dump();
     y.Dump();
    }

    void SwapInts(ref int x, ref int y)
    {
       int temp = x;
       x = y;
       y = temp;
    }

    Run in LINQPad.  Produces
    2

    1

    I did all this without a pointer to an int implementing an interface.  Now, I'll ask again: why does a pointer type need to implement an interface?

     

    Note: the question is NOT "how do you change a value passed into a function."

    Using pointers to change passed in values is not what the question is about.

    I don't care about how you change a value-type inside a function so that it reflects that outside the function.



  • @Sutherlands said:

    Filed under: Please don't answer this once again with why you need pointers.



  • @PJH said:

    @MiffTheFox said:
    @DaveK said:

    @Arnavion said:

    Besides, somehow, I don't think anyone would want to run a Linux binary compiled using gcc on Windows on their servers. I certainly wouldn't.

    Why not?  Given the same target headers and libs, a GCC cross-compiler should produce the exact same output as a native version.  Do you have some germphobia-like fear that the Linux binary will somehow be contaminated by having been near Windows?


    You can't take a Linux binary across different distro families, what makes you think you can take it to a Linux from a completely non-Unix system?

    Which part of cross-compile did you miss?

    Also, which part of "given the same target headers and libs" did he miss?  I've done this, it works just fine.  I've even compiled Linux kernels on Windows.



  • @anonymous_guy said:

    @MiffTheFox said:

    The main reason binaries aren't portable across distros is that one decides to use /lib, one uses /usr/lib, one uses /var/lib, one uses /usr/share/lib, etc.

    Any moron who decides to put a shared library (*.so) in /usr/share/lib or /var/lib should be buried under a million copies of the FHS.

    If the FHS had any credibility there'd be a noticeable difference between /bin and /usr/bin rather then "/usr/bin is for software designed after 1993".



  • @MiffTheFox said:

    If the FHS had any credibility there'd be a noticeable difference between /bin and /usr/bin rather then "/usr/bin is for software designed after 1993".

    Also, DJB hates it.



  • @MiffTheFox said:

    @anonymous_guy said:
    @MiffTheFox said:

    The main reason binaries aren't portable across distros is that one decides to use /lib, one uses /usr/lib, one uses /var/lib, one uses /usr/share/lib, etc.

    Any moron who decides to put a shared library (*.so) in /usr/share/lib or /var/lib should be buried under a million copies of the FHS.

    If the FHS had any credibility there'd be a noticeable difference between /bin and /usr/bin rather then "/usr/bin is for software designed after 1993".

    /bin is just obsolete and will probably become a symlink to /usr/bin in all distros in the future. But the distinction between /bin and /usr/bin at least has a historical reason and is currently being kept for compatibility reasons. Can you name any valid reason for putting libraries in /var/lib or /usr/share/lib?



  • @anonymous_guy said:

    /bin is just obsolete and will probably become a symlink to /usr/bin in all distros in the future.

    Why wouldn't everything move to /bin and /usr/bin become the symlink? Why the superfluous /usr directory?



  • @anonymous_guy said:

    /bin is just obsolete and will probably become a symlink to /usr/bin in all distros in the future. But the distinction between /bin and /usr/bin at least has a historical reason and is currently being kept for compatibility reasons. Can you name any valid reason for putting libraries in /var/lib or /usr/share/lib?

    The only *nix I've ever seen do that is Cygwin (/usr/bin is a symlink to /bin). /var/lib I don't really have a good excuse for other then the package was compiled by someone unfamiliar with FHS. /usr/share/lib I can say because all the new trendy stuff goes in /usr/share.



  • @MiffTheFox said:

    If the FHS had any credibility there'd be a noticeable difference between /bin and /usr/bin rather then "/usr/bin is for software designed after 1993".

    /bin and /sbin are (were?) supposed to contain the essential basic tools required to bootstrap the system to the point network and external filesystems could be mounted.

    /usr and everything on it is for "everything else".



    Comes from the era of the "Unix workstations" and expensive hard disks, I guess. You could have your whole /usr mounted via NFS from a central server.

    Also, /usr/share is (was?) meant for data that is not dependent on the CPU architecture, so you could save space in multi-architecture environment; you need separate /usr/lib, /usr/bin and so on for each architecture, but need only one copy of /usr/share to serve all of your clients.




    BIG EDIT:

    Just realized I'll get pedantically dickweeded in a moment if I won't say that:

    The above is the "modern" layout, actually. In the very ancient Unix systems (and today's Minix) /usr was the place where users' home directories were stored.

    And yes, as one of system operators you were sometimes supposed to log in as "bin" or "lib" to publish a freshly compiled file or library by copying it to this pseudo-user's homedir.



  • @morbiuswilters said:

    @anonymous_guy said:
    /bin is just obsolete and will probably become a symlink to /usr/bin in all distros in the future.

    Why wouldn't everything move to /bin and /usr/bin become the symlink? Why the superfluous /usr directory?

    Good question. For people who want to have a separate /usr partition, I guess. Don't ask me why you'd want to have that, though.



  • @wrack said:

    @MiffTheFox said:
    If the FHS had any credibility there'd be a noticeable difference between /bin and /usr/bin rather then "/usr/bin is for software designed after 1993".

    /bin and /sbin are (were?) supposed to contain the essential basic tools required to bootstrap the system to the point network and external filesystems could be mounted.

    /usr and everything on it is for "everything else".



    Comes from the era of the "Unix workstations" and expensive hard disks, I guess. You could have your whole /usr mounted via NFS from a central server.

    Also, /usr/share is (was?) meant for data that is not dependent on the CPU architecture, so you could save space in multi-architecture environment; you need separate /usr/lib, /usr/bin and so on for each architecture, but need only one copy of /usr/share to serve all of your clients.

    Yes, I know that, but why is any of this in FHS in 2013?



  • @anonymous_guy said:

    Good question. For people who want to have a separate /usr partition, I guess. Don't ask me why you'd want to have that, though.

    Wrack covers it above. /usr could be mounted over NFS. That still doesn't explain why it's in FHS in 2013.



  • @MiffTheFox said:

    @anonymous_guy said:
    /bin is just obsolete and will probably become a symlink to /usr/bin in all distros in the future. But the distinction between /bin and /usr/bin at least has a historical reason and is currently being kept for compatibility reasons. Can you name any valid reason for putting libraries in /var/lib or /usr/share/lib?

    The only *nix I've ever seen do that is Cygwin (/usr/bin is a symlink to /bin).

    Since Fedora 17, /bin, /lib and /sbin are symlinks to the corresponding directories in /usr.



  • @MiffTheFox said:

    @anonymous_guy said:
    /bin is just obsolete and will probably become a symlink to /usr/bin in all distros in the future. But the distinction between /bin and /usr/bin at least has a historical reason and is currently being kept for compatibility reasons. Can you name any valid reason for putting libraries in /var/lib or /usr/share/lib?

    The only *nix I've ever seen do that is Cygwin (/usr/bin is a symlink to /bin). /var/lib I don't really have a good excuse for other then the package was compiled by someone unfamiliar with FHS. /usr/share/lib I can say because all the new trendy stuff goes in /usr/share.

    Fedora 18: bin, lib, lib64, and sbin are symlinks to usr/[the folder name].



  • @anonymous_guy said:

    Since Fedora 17, /bin, /lib and /sbin are symlinks to the corresponding directories in /usr.



    Because Red Hat's pet project, systemd, requires stuff from /usr to boot, and thus totally eliminates the possiblity of having / and /usr stored on different partitions (or on NFS).

    And Lennart & co. are arguing that this is a good thing.



  • @Sutherlands said:

    I can change the value inside a pointer and it changes the other thing that points to the same place!

    Good job. Now show me an example that uses interfaces.



  • @wrack said:

    @anonymous_guy said:
    Since Fedora 17, /bin, /lib and /sbin are symlinks to the corresponding directories in /usr.



    Because Red Hat's pet project, systemd, requires stuff from /usr to boot, and thus totally eliminates the possiblity of having / and /usr stored on different partitions (or on NFS).

    And Lennart & co. are arguing that this is a good thing.

    IIRC, you can still have a separate partition for /usr as long as it is mounted from the initramfs.



  • If I designed a Unixlike OS, it wouldn't use the FHS. Instead there'd only be four directories in /: /System, /Packages, /Shared, and /Users.



  • @MiffTheFox said:

    Filed under: i think this is how osx works tho

    Nope, OSX also has the traditional UNIX directory structure. That mixture always looked a bit WTFy to me.



  • @MiffTheFox said:

    If I designed a Unixlike OS, it wouldn't use the FHS. Instead there'd only be four directories in /: /System, /Packages, /Shared, and /Users.

    Screw caps, who wants to type all that out?

    I used to use:

    /boot - kernels, bootloaders

    /home - user data

    /pkg - any and all installed software

    /srv - data being served over the network

    /tmp - obvious

    /log - logs

    /run - pidfiles, lockfiles, etc.



  • @Ben L. said:

    @Sutherlands said:
    I can change the value inside a pointer and it changes the other thing that points to the same place!
    Good job. Now show me an example that uses interfaces.

    Uh... ok?

    void Main()
    {
     IAnimal x = new Dog();
     IAnimal y = new Cat();
     Swap(ref x, ref y);
     x.Dump();
     y.Dump();
    }


    public interface IAnimal
    {
      
    }

    public class Cat : IAnimal
    {
      
    }

    public class Dog : IAnimal
    {

    }

    void Swap(ref IAnimal x, ref IAnimal y)
    {
     IAnimal temp = x;
     x = y;
     y = temp;
    }

    Output:

    Cat
    UserQuery+Cat

    Dog
    UserQuery+Dog

    Any other homework assignments or are you going to answer the question?

    Why would I need a pointer to inherit an interface?  I feel like you're trying to get something, but I'll be darned if I can figure out what it is.  Perhaps it would be best if you show me what can be done with it (such as making an Cow moo but an ICow squawk or something)



  • @morbiuswilters said:

    Screw caps, who wants to type all that out?

    If you have to type a path, someone fucked up.


  • Considered Harmful

    @Sutherlands said:

    Any other homework assignments or are you going to answer the question?

    Now do it blindfolded and standing on one foot.



  • @blakeyrat said:

    @morbiuswilters said:
    Screw caps, who wants to type all that out?

    If you have to type a path, someone fucked up.

    Well, it's Unix.



  • @joe.edwards said:

    @Sutherlands said:
    Any other homework assignments or are you going to answer the question?

    Now do it blindfolded and standing on one foot.

    Go: Preferred language of circus performers and carnies.



  • @morbiuswilters said:

    @blakeyrat said:
    @morbiuswilters said:
    Screw caps, who wants to type all that out?

    If you have to type a path, someone fucked up.

    Well, it's Unix.

    Your statement does not contradict what he said.



  • @morbiuswilters said:

    Screw caps, who wants to type all that out?

    A good shell would tab-complete regardless of capitalization.


  • Considered Harmful

    @morbiuswilters said:

    Screw caps, who wants to type all that out?

    I used to use:

    /boot - kernels, bootloaders

    /home - user data

    /pkg - any and all installed software

    /srv - data being served over the network

    /tmp - obvious

    /log - logs

    /run - pidfiles, lockfiles, etc.


    Yeah, well all my top level directories are composed of nonprintable characters.



  • @Sutherlands said:

    @morbiuswilters said:
    @blakeyrat said:
    @morbiuswilters said:
    Screw caps, who wants to type all that out?

    If you have to type a path, someone fucked up.

    Well, it's Unix.

    Your statement does not contradict what he said.



  • @Arnavion said:

    @morbiuswilters said:
    Screw caps, who wants to type all that out?

    A good shell would tab-complete regardless of capitalization.

    Well, my shell does not.



  • @joe.edwards said:

    Yeah, well all my top level directories are composed of nonprintable characters.

    @joe.edwards said:

    Filed under: Except /porn

    So your porn is made up of printable characters, like Tom Sawyer and Don Quixote?



  • @morbiuswilters said:

    @Arnavion said:
    @morbiuswilters said:
    Screw caps, who wants to type all that out?

    A good shell would tab-complete regardless of capitalization.

    Well, my shell does not.

    Which one do you use? Any decent shell should have an option for that.



  • @anonymous_guy said:

    @morbiuswilters said:
    @Arnavion said:
    @morbiuswilters said:
    Screw caps, who wants to type all that out?

    A good shell would tab-complete regardless of capitalization.

    Well, my shell does not.

    Which one do you use? Any decent shell should have an option for that.

    Bash, but it's probably not enabled. I don't care, capitals don't belong in the filesystem.



  • This is the best thing Go has ever produced:@morbiuswilters said:

    @Ben L. said:
    Since when is a lowercase type's lowercase field public?
    Fucking hell.



  • @joe.edwards said:

    In C# I use _prefixedCamel for private instance members, regularCamel for locals and parameters, PascalCase for anything public or protected. If I could make the build break if one of our team members violated this convention, I would turn that option on.
    As long as its optional and your team can enforce whatever stlye they choose, Awesome! Style dictated by the language !Awesome (python enfoces that you have a consistant style but doesn't care what it is.)



  • @joe.edwards said:

    In C# I use _prefixedCamel for private instance members, regularCamel for locals and parameters, PascalCase for anything public or protected. If I could make the build break if one of our team members violated this convention, I would turn that option on.

    That's why God created TFS gated check-in, TFS custom build definitions and Visual Studio custom code analysis rules.



  • @Ronald said:

    @joe.edwards said:

    In C# I use _prefixedCamel for private instance members, regularCamel for locals and parameters, PascalCase for anything public or protected. If I could make the build break if one of our team members violated this convention, I would turn that option on.

    That's why God created TFS gated check-in, TFS custom build definitions and Visual Studio custom code analysis rules.

    TFS doesn't exist you idiot. It's just a story about rape and incest. None of it was real.


  • Discourse touched me in a no-no place

    @morbiuswilters said:

    I don't care, capitals don't belong in the filesystem.
    Ljubljana is greatly offended by that, and Bogota is now sobbing quietly in the corner. OTOH, Jakarta had it coming.



  • @dkf said:

    @morbiuswilters said:
    I don't care, capitals don't belong in the filesystem.
    Ljubljana is greatly offended by that, and Bogota is now sobbing quietly in the corner. OTOH, Jakarta had it coming.
    You're only allowed to make that joke if there's an actual misspelling.


Log in to reply