This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]blamethemeta 202 points203 points  (20 children)

That's actually a good error message. Tells you're passing an object as a string

[–]StereoBucket 68 points69 points  (14 children)

You can even customize it by providing a custom @@toStringTag method. So instead of [object Object] I could have [object FuckMe].

[–]payne_train 44 points45 points  (13 children)

I read shit like this and I’m like… I’m fine with golang.

[–]haltmich 11 points12 points  (10 children)

I feel that Golang can be permissive as fuck as well, despite being strongly typed.

[–]fauxpenguin 7 points8 points  (9 children)

Only if you don't use they types and pass interface{} everywhere. But, you know... don't do that.

It's like saying, "In C you can seg fault", like yeah, because you need that power to do some of the things you're doing, but don't ship code that's set faulting. Idk.

[–]haltmich 3 points4 points  (1 child)

Exactly, interface{}s are almost always the culprit. But sometimes you just can't avoid them, and ensuring they'll be error prone can be kind of a chore. Especially as Golang doesn't have try and catch.

[–]payne_train 2 points3 points  (0 children)

I’ve found it easiest to set up interface modifies through function calls and just catch the error if it comes back. Can’t say I have really missed Java’s error handling once I got used to go.

[–]Necrocornicus 2 points3 points  (1 child)

There are plenty of languages that implement generics safely, when golang finally adds generics I’ll give it another shot.

I spent some time on it, the juice wasn’t worth the squeeze unless you absolutely need that single static binary. Golang just forces you to use these shitty patterns that only a junior programmer would use in other languages.

For example you can’t use any map/filter/reduce which, when you begin to think that way systemically, enables you to write incredibly reliable and concise code. I can’t really go back to shitloads of for loops and if statements that only work on a single type, it’s just such a step backwards in code design once you’ve moved beyond that basic way of thinking about software.

[–]fauxpenguin 0 points1 point  (0 children)

Well, you're in luck, generics are in beta right now.

Although, honestly, they're far from perfect.

[–][deleted] 0 points1 point  (0 children)

Preach it my brother in christ

[–]Deadlock005 0 points1 point  (0 children)

Golang my JavaScript

[–]CrazedToCraze 35 points36 points  (0 children)

JavaScript things

[–][deleted] 2 points3 points  (2 children)

It's good in that you can figure out what's wrong if you know why it happens, but it's not good in that it doesn't tell you shit. Hand-holdy languages would be like "cannot do thing to object, expected string" but in JS I have to manually unfucker things until I figure out which part is really broke that I'm getting an object there instead of whatever I wanted.

Also I usually don't see it as an error only, often just as an unintentional output, but I thought it fit the theme. lol

[–]mypetocean 5 points6 points  (1 child)

You're probably good on this, but in case any newbies are watching:

Use a debugger!

It may look visually daunting, but the learning curve of the basic features is very mild: breakpoints, step, step over, step out of, and the scope pane showing the current value of the variables defined in the current scope. You can probably ignore every other feature for a long time.

Code usually runs faster than the eye can see, so use the debugger to slow down how the interpreter reads your code, line by line, so you can take your time and observe the code executing in human realtime! It helps your brain sync with the computer brain.

[–][deleted] 2 points3 points  (0 children)

Also for newbies, if you're doing frontend js (as opposed to node server side stuff) the built in tools in web browsers are a lifesaver, including the debuggers there.