Wow, that looks like a nightmare
Yo whatup
Wow, that looks like a nightmare
Yep that’s why I refuse to use standard libraries. It just makes my code too complicated…
Semantic whitespace is awful because whitespace (something that you can’t actually see) has meaning in how the program runs. Braces {
}
for scopes gives you the ability to easily tell at a glance where a scope ends. Whitespace doesn’t allow for that. Especially, especially when you can accidentally exit a scope (two new lines in a row with Python) and it’s not actually an error (Pythons global scope). Yeah formatters and linters make this less of an issue but it sucks… Languages with legible symbols for scoping are significantly easier to reason about, see end
symbols in Lua.
It erases the type of what your pointing at. All you have is a memory location, in contrast to int*
which is a memory location of an int
Smart pointers model ownership. Instead of (maybe) a comment telling you if you have to free/delete a returned pointer this information is encoded into the type itself. But that’s not all, this special type even handles the whole deleting part once it goes away.
Since they model ownership you should only use them when ownership should be expressed. Namely something that returns a pointer to a newly allocated thing should be a std::unique_ptr
because the Callie has ownership of that memory. If they want to share it (multiple ownership of the object) there’s a cheap conversion to std::shared_ptr
.
How about a function that takes in an object cause it wants to look at it? Well that doesn’t have anything to do with ownership so make it a raw pointer, or better yet a reference to avoid nullability.
What about when you’ve got a member function that wants to return a pointer to some memory the object owns? You guessed it baby raw pointer (or again reference if it’ll never be null).
JetBrains might not be my friend but they don’t hold anywhere near the dev tool monopoly Adobe does for artists. Know what happens if JetBrains starts to blow massive ass? I finally sit down and figure out how to get my terminal editor working with my LSP. Yeah I lose some productivity but not as much as I’d lose by using Visual Studio or fuckn Eclipse.
Thanks for well contributing to Lemmy but you sure are quite the annoying character. Now don’t go and abuse your newfound abilities and remove the blocking feature <3
Instance of Vim? Swap buffers fool
Looking at code on somebody else’s screen is entirely missing the point of using tabs over spaces. The entire point is that mine looks like how I want and theirs looks like how they want even though the file is identical. We can each have wildly different tab width and it’ll look wildly different to each of us when we program. That’s again the point.
Code formatters are great! I love them. Using tabs over spaces is objectively a better formatting option. One of my favorite features in code formatters is that they’ll swap out spaces to tabs for you insane people who insist on mashing the space bar to indent.
What’s yaml have to do with anything? It’s like python with syntactic whitespace which is unrelated to this discussion. The Tab vs Space debate is entirely around non syntactic whitespace which doesn’t effect how the code is parsed. And yes Python technically does both tabs and spaces but it’s all sorts of fucky.
Terminal editors while still used a ton aren’t really what I was referring to. Newer terminal editors such as Helix have tab width configured per language most of which default to a width of 4 spaces but toml/yaml both default to 2 spaces. I was mainly referring to GUI editors as frankly that’s just what most people use nowadays. JetBrains IDEs, Visual Studio, Eclipse, VS Code, Notepad++ were primarily what I was thinking of as I’ve used all of them and they all default to a tab width of 4 hence why I said nearly universal. Also I said nearly terminal editors being the only editors I’ve used that don’t default to a width of 4 seems like a fair usage of the term.
Then don’t? The whole reason nearly all the spaces guys do 4 spaces is cause that’s the nearly universal tab width. You won’t like this but the same exact argument can be made for spaces yet I’d bet you haven’t even once configured the width of those.
I don’t actually change tab width, it’s the default 4 spaces equivalent for me but just because I don’t take advantage of the ability doesn’t mean I should prevent others from doing so.
Sometimes. I love auto formatting, I spam the shit out of it more than I spam save but it’s definitely not perfect. It gets real confused with inconsistent indention like that. Especially with Python it’ll fuckup
Tabs are objectively the better choice as it allows each dev individually to decide tab width in their editors. Spaces in contrast don’t allow this same flexibility as they are used for much more than simply indentation, for example you likely put a space after each argument or operator IE func(arg1, arg2)
or 1 + 2
.
Fuck me man that’s what I get for writing that just before bed
Lol yeah. I don’t even really write C++ but I sure as shit know a bunch of syntax and junk haha
It’s part of the type yet it’s also a unique identifier. That’s the whole thing with east or west const
. const int *
is a immutable mutable pointer that points to mutable immutable memory. int *const
is a mutable immutable pointer that points to immutable memory. int const *
is the same type as the first example, a immutable mutable pointer that points to mutable immutable memory.
Same stuff applies to references which makes it easier to think of the variable owning the *
or &
as if you want that pointer or reference to be const
it has to go after.
Edit:I am a moron who managed to get it exactly backwards :|
Well like asembly has “int types” and “float types” as there’s specific instructions for those operations but those instructions don’t actually care if the bits are for a float or an int. Types in a language are used to restrict the valid operations. In a statically typed language you cannot call cat.bark()
or dog.meow()
because the property’s of the type, what things you can do with it are known before the program runs. In a dynamically typed language such as Python cat.bark()
might or might not be valid so it has to check at runtime for a method throwing an error if it doesn’t exist.
Static/Dynamic typing is a difference of when. Java has static typing but you can also just pass raw Objects around and cast when needed. It even throws a runtime exception similar to how Python or JavaScript would fail. However Java is of course ultimately statically typed everything just shares a common parent class and has types at runtime which allows for some some psudo dynamic behavior
Assembly probably? So low level you kinda just play with bits. That’s all I can think of for an untyped language. Everything else I’m aware of is dynamically or statically typed
TypeScript is JavaScript and not in the literal it’s compiled to JS sense but in the think of TS as a linter not a language sense.
And the entire stack trace