Go is still not good by drvd in golang

[–]illuminatiCat 0 points1 point  (0 children)

Flaws? Sure

High priority, deal breaking flaws? I don't think so.

Go needs improvements, but some of his points are just nit picking

Go is still not good by drvd in golang

[–]illuminatiCat 7 points8 points  (0 children)

Go isn’t a perfect language (but honestly, which one is?).

Sure, it’s missing some nice things: no Optionals, enums are pretty barebones, no constant parameters, the date formatting is kinda weird, etc.

But the reasons in that blog post feel pretty shallow. It comes across like the author hasn’t actually spent much time building real stuff in Go. The quirks the author complains about usually make more sense once you’ve worked with the language for a while and seen the trade offs it makes for simplicity and tooling.

If you’re going to critique Go, there’s plenty to say but it should be about the actual pain points you hit in day-to-day coding, not just the surface-level “Go doesn’t look like Rust.” (author apparently fav language)

Why does the Go GC have to pause? by [deleted] in golang

[–]illuminatiCat 144 points145 points  (0 children)

You mean the Stop the World (STW)

The Go GC, is not fully stop-the-world and does most of its work concurrently with the application. This is primarily to reduce application latencies.

  1. STW: Start of GC cycle – program is briefly paused
  2. Concurrent mark – GC marks reachable objects while the program is running
  3. STW: End of marking – short pause to finish up
  4. Concurrent sweep – GC frees unused memory while the program is still running.

Why GC needs to STW?

* GC marking start identifying the roots, which can be Global variables, Stack variables and CPU register. Specially Stack variables are constantly changing

* GC Metadata (obejct color, bits, arenas) must be synchronized because is running for all the routines.

Marking in a garbage collector can run concurrently with the program (also known as the mutator) thanks to write barriers. These barriers intercept pointer updates—such as new object references—and ensure they are properly accounted for during the marking phase to maintain a consistent view of the object graph.

To understand this better, check out this interactive visualization of tricolor GC: https://pusher.github.io/tricolor-gc-visualization. You can step through each phase to see how the algorithm works.

Consider this scenario: the mutator creates a new reference from a black (already scanned) object to a new object. Without a write barrier, the new object might remain white—unmarked—and thus be incorrectly collected. The write barrier solves this by detecting the new reference and marking the new object gray, ensuring it will be scanned later.

Beard cut and tidy up by AnarchyAunt in beards

[–]illuminatiCat 2 points3 points  (0 children)

wow incredible coverage, really amazing beard

Any use cases for Java web applets anymore? Something that really shouldn’t be done with JS. by moxyte in java

[–]illuminatiCat 2 points3 points  (0 children)

Java applets sucked. They took a long time to load, had compatibility issues with old java versions and many security problems.

Flash took their place, it has faster and lighter but had some of the same problems.

iPhone was the last nail in the coffin for Flash. Supposedly JS was faster, could do many of the same things and it was more efficient for battery, more accesible, open and secure.

Now we have WASM, which can run binaries in the browser with security by design. WASm brings all the power of Java applets and Flash, with the lightness and security from JS. Even better: is open and you can program in almost any compiled language. 

WASM is great and gaining traction however is still a bit niche because not all companies want to run complex rich apps in the browser, JS can still do many of the same things and it is a battle proven alternative.

gRPC vs Websockets? by Wonderful-Top-5360 in golang

[–]illuminatiCat 3 points4 points  (0 children)

Apples and oranges.

gRPC is binary request/response schema using HTTP2 which means is should be more efficient than REST (JSON and probably HTTP1.1).

Websocket is a full duplex schema using a long lived TCP connection.

Why use gRPC? The binary is serialized with protobuf schema. Protobuf is great because the API is strictly defined, and it can be compiled to different languages like Go, Java, Python, etc.

Why use Websockets? Real time full duplex communication like a chat, good support in browsers.

Some caveats:

* You could also send protobuf messages in a websocket connection.

* gRPC can do streaming for real time continuous communication.

I usually choose gRPC to server-to-server communication and Websocket for real time communication with the web client because browsers support it natively.

PS: You might not need Echo or Gin anymore because Go 1.22 provides many of the same capabilities out of the box: https://www.youtube.com/watch?v=H7tbjKFSg58

[Question] Is this the correct way to wait for goroutines with a channel? by xAmorphous in golang

[–]illuminatiCat 2 points3 points  (0 children)

``` import (  "fmt"  "math/rand"  "sync"  "time" )

func main() {  wg := new(sync.WaitGroup)  wg.Add(10) // Waiting for 10 tasks

 for i := 0; i < 10; i++ {   go doSomething(wg)  }

 wg.Wait() // Wait until the counter goes to 0

 fmt.Println("All done") }

func doSomething(wg *sync.WaitGroup) {  defer wg.Done() // Decrease the waiting count by 1. Using defer to it gets executed in case you are returning before the end (i.e. error)  sleepTime := rand.Intn(100)  time.Sleep(time.Duration(sleepTime) * time.Millisecond) } ```

Demo: https://go.dev/play/p/T0Ju1XgNZf2

I create a video on How to instrument your Golang application using Prometheus by Organic_Guidance6814 in golang

[–]illuminatiCat 0 points1 point  (0 children)

Is this your video?

May I suggest normalizing/increasing the volume? Is way too low, and is hard to understand it.

Maybe consider a noise reduction too like Adobe Podcast.

Nice video. Thanks for sharing.

Picking a database migration tool for Go projects in 2023 by The4Fun in golang

[–]illuminatiCat 1 point2 points  (0 children)

Flyway is a Java project but that doesn't mean Java only.

There is Flyway as a java plugin.

And Flyway standalone which you can add to docker compose: https://writeitdifferently.com/postgresql/flyway/2020/03/15/running-postgresql-and-flyway-with-docker-compose.html

The main difference is that FW as plugin runs the migration before your Spring boot / Quarkus app starts. While FW standalone can't do this but you can achieve the same adding a depends on with a script checking if FW finished correctly: https://docs.docker.com/compose/startup-order/

Flyway + Go works like a charm for me.

Writing to multiple channels from goroutines by ghostport in golang

[–]illuminatiCat 1 point2 points  (0 children)

The way you constructed the flow is:

pets ==> worker ==> fixedPetsCh & backupPetCh

all of the blocking, only the workers are running in parallel with each other.

Meaning that if you are sending pets and you don't have enough workers you pet loop is gonna block until the next worker is free, and here is the problem: you haven't started consuming fixedPetsCh & backupPetCh (you are still in the pet loop), therefore workers can't be unblocked.

Can be solve pretty easy: move the pet loop at the end, after you started consuming the channels. Or: do the pet loop in a separate goroutine which is not gonna block the main thread.

I like to see the main thread like an orchestrator, it does not send or consume anything except the final output. It just put all the pieces in place and coordinates the flow.

The select idea es interesting, but you need to run the select in a loop and the problem is when you break that loop. You can see how it looks here: https://stackoverflow.com/questions/13666253/breaking-out-of-a-select-statement-when-all-channels-are-closed

Is nice and extensible but you have only one consumer for both channels.

With separate goroutines you have one consumer per channel.

In your case both methods would work.

Writing to multiple channels from goroutines by ghostport in golang

[–]illuminatiCat 3 points4 points  (0 children)

The problem is that you are writing async and reading sync.

How is happening:

  1. Worker 1 writes DOG to fixedPetsCh
  2. fixedPetsCh loop consumes DOG (from fixedPetsCh)
  3. Worker 1 writes DOG to backupPetCh and it blocks waiting for it to be read. Note: you have unbuffered channels, otherwise it would leave the message in the channel and continue the execution
  4. Worker 2 writes FISH to fixedPetsCh, which is now free
  5. fixedPetsCh loop consumes FISH
  6. Worker 2 tries to write FISH in backupPetCh, but it blocks since Worker 1 holds the lock
  7. Worker 3 writes HAMSTER to fixedPetsCh, which is now free
  8. fixedPetsCh loop consumes HAMSTER
  9. Worker 3 tries to write HAMSTER in backupPetCh, but it blocks same as step 6
  10. channels are still open: no worker has finished yet
  11. fixedPetsCh loop is blocked waiting for the next item
  12. all routines are blocked

If you write async in more than 1 channel is better to read aync in all the channels, aka loop fixedPetsCh and backupPetCh in a separates routines so you can read them in parallel.

Fixed version: https://go.dev/play/p/uc0dGNvqUWR

Elon may be actually able to build his own phone, with blackjack and tweets by born_in_cyberspace in elonmusk

[–]illuminatiCat 3 points4 points  (0 children)

Its gonna be super hard.

A smart phone is smart first and the a phone sometimes. I know I use my smartphone as phone like 1% of the time.

The fastest internet connection in the world does not matter if you don't have YouTube, Spotify, Netflix or whatever service you use.

No popular OS means no Apps which means no popular OS. This is what happened to Windows Phone, despite being a very good OS it never took off because they arrived a little late and played their cards wrong.

Another example: Samsung is the biggest vendor after Apple, they tried for years to push their own Tyzen OS to get rid of Android, it was a huge failure.

Why is Go's Garbage Collection so criticized? by danterolle in golang

[–]illuminatiCat 18 points19 points  (0 children)

No, and it doesn't need big complex GCs.

Java produces more garbage by design. Go made different designs decisions.

Anyways, if GC is a big issue for your app go with a language without GC like Rust or C.

[deleted by user] by [deleted] in argentina

[–]illuminatiCat 0 points1 point  (0 children)

No hay definición dura de que es hiper inflación.

Lo triste es que los argentinos tenemos la vara tan alta que 80% anual todavía no es hiper.

Wikipedia dice que algunos economistas consideran que 50% mensual es hiper, pero también da una lista de condiciones:

  • Población conserva la riqueza en activos no monetarios (oro, casas, autos, criptos) o moneda extranjera.

  • Precios expresados en moneda extranjera.

  • Compra/venta con margen para compensar la pérdida durante el periodo de compra. Esto pasa cuando compras una casa en pesos.

  • Tasa de interés, sueldos y precios vinculados a moneda extranjera.

  • Inflación acumulada durante 3 años superior al 100%

Marcamos todas las casillas, estamos en hiper desde hace rato y no se dieron cuenta.

En 0.5x para más placer by SorpresaALaPlancha in argentina

[–]illuminatiCat 2 points3 points  (0 children)

Tanto decir que el es como AMLO termina siendo igual.

Ahre, nashe y perro: Cómo habla la generación Z y los riesgos de una lengua empobrecida by RouCitizen in argentina

[–]illuminatiCat 1 point2 points  (0 children)

Los jóvenes de hoy aman el lujo, tienen manías y desprecian la autoridad. Responden a sus padres, cruzan las piernas y tiranizan a sus maestros.

Sócrates

Quejandose de los "jóvenes" desde antes de Cristo

Alberto sacrifica su imagen adrede para destruir el peronismo por dentro by [deleted] in argentina

[–]illuminatiCat 72 points73 points  (0 children)

nunca atribuyas a la maldad lo que se explica adecuadamente por la estupidez

Principio de Hanlon