this post was submitted on 15 Jan 2025
55 points (75.2% liked)

Programming

18082 readers
90 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 2 years ago
MODERATORS
 
top 14 comments
sorted by: hot top controversial new old
[–] [email protected] 63 points 3 weeks ago

Maybe learn to take screenshots first? :P

[–] Solemarc 21 points 3 weeks ago (2 children)

Are you trying to use the Lord's JS to read files from your PC?

[–] [email protected] 8 points 3 weeks ago (1 children)

read svg file with path given in config

Know Jack shit about go and since all you need to do is read a file and put it in I thought I'd let ai handle it

İt took me far too long and I was just done with it by then and the ai for some reason is acting fucking playful it's even mocking me I can't handle it

[–] Solemarc 13 points 3 weeks ago (1 children)

My comment was supposed to be a bit of a joke...

Generally speaking, you cannot read a file from disk using JS in the browser because the sandbox doesn't allow the code access to your disk. If you googled something like "read a file JS" it probably made an assumption that you're using Server side like nodejs or deno. The only exception for in-browser that I know of is to upload files using an input tag.

[–] [email protected] 8 points 3 weeks ago (1 children)

that looks like a go template, so i’d wager it’s something server-side

[–] Solemarc 1 points 3 weeks ago

Maybe, I've never used go templates before.

[–] passiveaggressivesonar 1 points 3 weeks ago

You gotta warn me before you comment something so unexpectedly funny

[–] [email protected] 17 points 3 weeks ago (1 children)

I honestly don't get why people like Go. Structural typing makes it so difficult to find classes that interpret an interface. Every dumb go project has to be opened in an IDE or something with a language server to find implementors of an interface. Also, forcing every capitalised object in a module or struct to be exported is just... wat? Returning a tuple of whatever, err also feels wrong. It's like they couldn't decide between throwing exceptions or an enum and went with something in between.

I get that the inbuilt concurrency features are nice, but the rest of the language and stdlib feel very lackluster. At least that's my impression after ~2 weeks of it. My retreat to Rust was rather quick.

Anti Commercial-AI license

[–] [email protected] 7 points 3 weeks ago (2 children)

The stdlib I actually find quite complete. Especially for http projects. You really don't need third party libs for that for example.

The errors were super strange to me at the start, but I've come to really like it over exceptions. It is similar to old error codes, but I feel that this makes one always have to be mindful of error handling and the non happy path (thinking of large Python projects where no one cares about exceptions).

A lot of people tend to compare Go and Rust, but I feel that the languages are just too different. Rust is good for a variety of things which don't overlap with the things Go is good for.

[–] [email protected] 6 points 3 weeks ago (1 children)

It is similar to old error codes, but I feel that this makes one always have to be mindful of error handling and the non happy path

Technically you need a separate linter (errcheck) to ensure you don't just ignore errors. This is...not great. (That should have been a compiler error.)

[–] [email protected] 2 points 3 weeks ago (1 children)

Yes, true. Having it built in in the compilation would be nice. Or at least having errcheck as a tool which already comes packed with Go.

Go has changed over time to include more things like this. Maybe one day this will be addressed.

[–] [email protected] 2 points 3 weeks ago

Yeah, I was particularly glad to see the change in loop variable semantics become a stable part of the language. That was a terrible footgun.

There are other things I dislike about Go, but I do think it's improving while maintaining its better qualities, which is no small feat.

[–] [email protected] 2 points 3 weeks ago* (last edited 3 weeks ago)

What I don't like about Go's error handling is that it's built on returning a tuple of result/error instead of enum/union/variant/whatever-its-called. Which means that on error path you have to return something for successful result too (usually a "zero-initialized" struct because Go doesn't have optionals). You are not returning result or error, you are always returning both. This is just wrong.

[–] [email protected] 1 points 3 weeks ago

I actually like AI a little bit after seeing this. It's still a hype machine, but this one time was amusing.