Salta al contenuto
0
  • Home
  • Piero Bosio
  • Blog
  • Mondo
  • Fediverso
  • News
  • Categorie
  • Recenti
  • Popolare
  • Tag
  • Utenti
  • Gruppi
  • Home
  • Piero Bosio
  • Blog
  • Mondo
  • Fediverso
  • News
  • Categorie
  • Recenti
  • Popolare
  • Tag
  • Utenti
  • Gruppi
Skin
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Predefinito (Nessuna skin)
  • Nessuna skin
Collassa

Piero Bosio Web Site

Forum federato con il resto del mondo. Non contano le istanze, contano le persone

  1. Home
  2. Categorie
  3. Senza categoria
  4. Everything is beautiful in #golang:"Arrays have their place, but they’re a bit inflexible, so you don’t see them too often in Go code."What for and why they designed Array then?#scentmark

Everything is beautiful in #golang:"Arrays have their place, but they’re a bit inflexible, so you don’t see them too often in Go code."What for and why they designed Array then?#scentmark

Pianificato Fissato Bloccato Spostato Senza categoria
golangscentmark
5 Post 2 Autori 0 Visualizzazioni
  • Da Vecchi a Nuovi
  • Da Nuovi a Vecchi
  • Più Voti
Rispondi
  • Topic risposta
Effettua l'accesso per rispondere
Questa discussione è stata eliminata. Solo gli utenti con diritti di gestione possono vederla.
  • petbrainundefined Questo utente è esterno a questo forum
    petbrainundefined Questo utente è esterno a questo forum
    petbrain
    scritto su ultima modifica di
    #1

    Everything is beautiful in #golang:

    "Arrays have their place, but they’re a bit inflexible, so you don’t see them too often in Go code."

    What for and why they designed Array then?

    #scentmark

    gramundefined 1 Risposta Ultima Risposta
    • fosstodon.orgundefined fosstodon.org ha condiviso questa discussione
    • petbrainundefined petbrain

      Everything is beautiful in #golang:

      "Arrays have their place, but they’re a bit inflexible, so you don’t see them too often in Go code."

      What for and why they designed Array then?

      #scentmark

      gramundefined Questo utente è esterno a questo forum
      gramundefined Questo utente è esterno a questo forum
      gram
      scritto su ultima modifica di
      #2

      @petbrain

      1. arrays are allocated on stack, not heap. slices cannot be allocated on stack because their size is not statically known.

      2. array size is static and part of the type. taking a[4] from 2-element array is compilation error.

      3. a[0] on array usually produces faster and safer code because boundary check is static.

      4. arrays power slices.

      use arrays when all items are the same type and their number is known. you'll know when you can. for example, matrices in a 3D game engine.

      gramundefined petbrainundefined 2 Risposte Ultima Risposta
      1
      • gramundefined gram

        @petbrain

        1. arrays are allocated on stack, not heap. slices cannot be allocated on stack because their size is not statically known.

        2. array size is static and part of the type. taking a[4] from 2-element array is compilation error.

        3. a[0] on array usually produces faster and safer code because boundary check is static.

        4. arrays power slices.

        use arrays when all items are the same type and their number is known. you'll know when you can. for example, matrices in a 3D game engine.

        gramundefined Questo utente è esterno a questo forum
        gramundefined Questo utente è esterno a questo forum
        gram
        scritto su ultima modifica di
        #3

        @petbrain

        a point in 3D space would be a struct{x, y, z int} but a vector in 100-dimension space would be [100]int.

        1 Risposta Ultima Risposta
        1
        • gramundefined gram

          @petbrain

          1. arrays are allocated on stack, not heap. slices cannot be allocated on stack because their size is not statically known.

          2. array size is static and part of the type. taking a[4] from 2-element array is compilation error.

          3. a[0] on array usually produces faster and safer code because boundary check is static.

          4. arrays power slices.

          use arrays when all items are the same type and their number is known. you'll know when you can. for example, matrices in a 3D game engine.

          petbrainundefined Questo utente è esterno a questo forum
          petbrainundefined Questo utente è esterno a questo forum
          petbrain
          scritto su ultima modifica di
          #4

          @orsinium 1 sounds contradictory, esp. along with 4. Anyway, pet does not care about allocation issues at the moment. It will learn that later.

          100-dimension space in a very rare case. If pet was a mathematician it would prefer variable dimensions.

          gramundefined 1 Risposta Ultima Risposta
          • petbrainundefined petbrain

            @orsinium 1 sounds contradictory, esp. along with 4. Anyway, pet does not care about allocation issues at the moment. It will learn that later.

            100-dimension space in a very rare case. If pet was a mathematician it would prefer variable dimensions.

            gramundefined Questo utente è esterno a questo forum
            gramundefined Questo utente è esterno a questo forum
            gram
            scritto su ultima modifica di
            #5

            @petbrain

            [4]int is on stack, *[4]int is on heap. slices are powered by *[N]T arrays.

            using arrays directly is rare, that's the point. however, having them in the language is essential for the language to work.

            1 Risposta Ultima Risposta
            1
            Rispondi
            • Topic risposta
            Effettua l'accesso per rispondere
            • Da Vecchi a Nuovi
            • Da Nuovi a Vecchi
            • Più Voti


            Gli ultimi otto messaggi ricevuti dalla Federazione
            • Mementoundefined
              Memento

              Marte, segnali nascosti nel sottosuolo: lo studio che fa riflettere
              https://leganerd.com/2025/09/12/marte-segnali-nascosti-nel-sottosuolo-lo-studio-che-fa-riflettere/
              @scienza

              per saperne di più

            • L'Anarchiversitarioundefined
              L'Anarchiversitario

              Pace e giustizia climatica: settimana di azione globale dal 15 al 21 settembre 2025
              @anarchia
              Torna la Settimana di azione globale per la Pace e la Giustizia Climatica. La seconda edizione, in Italia rilanciata dalla Rete Pace Disarmo, si terrà dal 15 al 21 settembre 2025 e si occuperà dei legami tra guerra, militarismo/militarizzazione e...

              Vedi https://www.rivoluzioneanarchica.it/pace-e-giustizia-climatica-settimana-di-azione-globale-dal-15-al-21-settembre-2025/

              per saperne di più

            • Elena ``of Valhalla''undefined
              Elena ``of Valhalla''

              @Sveva_1506 @matz @adriananselmo la mia impressione è che dipenda molto da chi si segue: nella mia bolla/timeline ad esempio c'è abbondanza di cazzeggio, foto di gatti, craft vari, foto di gatti, argomenti seri, e qualche altra foto di gatti, e soprattutto ci sono un sacco di thread pieni di interazioni.

              però ho dedicato del tempo (negli anni) a seguire persone che postavano cose che mi interessavano

              (e sono su un'istanza piccola, che blocca molto poco, il che aiuta)

              per saperne di più

            • quinta - Stefano Quintarelliundefined
              quinta - Stefano Quintarelli

              Revealed: Apple is teaching its AI to adapt to the Trump era https://blog.quintarelli.it/2025/09/revealed-apple-is-teaching-its-ai-to-adapt-to-the-trump-era/

              per saperne di più

            • .mau.undefined
              .mau.

              @max può anche darsi che non sappiano dell'esistenza di Friendica. Il mio primo account federato aveva il limite di 500 caratteri (che poi per quello che scrivo sono fin troppi... Per il resto ho il blog)

              per saperne di più

            • Marco Castellaniundefined
              Marco Castellani

              Vita su Marte?

              Risposta concisa: "forse". Ecco una brevissima rassegna dei vari comunicati, con diversi gradi di "ottimismo" ...

              https://caelora.blog/post/794470391138697216/vita-su-marte

              #marte #vita #nasa #caelora

              per saperne di più

            • .mau.undefined
              .mau.

              @max @robertoburioni@bird.makeup no, non lo è

              per saperne di più

            • Marco Brescianiundefined
              Marco Bresciani

              @jeffpalmer
              Thanks.
              I should be able to check for it next year: I'm going to go to Tokyo, and I'll surely visit (again!) the great YushaKobo mechanical keyboard store, hoping it'll have a Piantor or similar small things.

              per saperne di più
            • Accedi

            • Accedi o registrati per effettuare la ricerca.
            Powered by NodeBB Contributors
            • Primo post
              Ultimo post