TehPers
@TehPers@beehaw.org
- Comment on What are some common misconceptions about programming that you'd like to debunk? 9 months ago:
Might just be my inexperience with the library, but every time I end up with a pandas dataframe, I spend the next 4 hours trying to figure out the right sequence of index statements and function calls to get the data in the order I want. It always ends up feeling like I’m doing something wrong, and the only way to really tell is to run the code as far as I can tell. I don’t use dataframes very often though, and I’m sure it gets easier with experience.
- Comment on Never trust a programmer who says they know C++ by Louis Brandy 11 months ago:
Looks like the original post (short article?) was in 2010. Thinking of how C++ has evolved since then, I have a hard time believing anyone but the most involved and dedicated C++ developers can really understand all of how C++ works. Heck, even the compilers don’t seem to have a full grasp of C++ these days (at least with regards to modules).
- Comment on The Absolute Minimum Every Software Developer Must Know About Unicode in 2023 (Still No Excuses!) 1 year ago:
The only modern language that gets it right is Swift:
print("🤦🏼♂️".count) // => 1
Minor, but I’m not sure this is as unambiguous as the article claims. It’s true that for someone “that isn’t burdened with computer internals” that this is the most obvious “length” of the string, but programmers are by definition burdened with computer internals. That’s not to say the length shouldn’t be 1 though, it’s more that the “length” field/property has a terrible name, and asking for the length of a string is a very ambiguous question to begin with.
Instead, I think a better solution is to be clear what length you’re actually referring to. For example, with Rust, the
.len()
method documents itself as the number of bytes in the string and warns that it may not be what you’re interested in. Similarly,.chars()
clarifies that it iterates over Unicode Scalar Values, and not grapheme clusters (and that grapheme clusters are unfortunately not handled by the standard library).For most high level applications, I think you generally do want to work with grapheme clusters, and what Swift does makes sense (assuming you can also iterate over the individual bytes somehow for low level operations). As long as it is clearly documented what your “length” refers to, and assuming the other lengths can be calculated, I think any reasonably useful length is valid.
The article they link in that section does cover a lot of the nuances between them, and is a great read for more discussion around what the length should be.
Edit: I should also add that Korean, for example, adds some additional complexity to it. For example, what’s the string length of 각? Is it 1, because it visually consumes a single “space”? Or is it 3 because it’s 3 letters (ㄱ, ㅏ, ㄱ)? Swift says the length is 1.
- Comment on Which programming language is hard to understand? 1 year ago:
Before type hints, I would have said Python, but these days it’s Javascript. It takes a lot of effort to write decent size Javascript projects that others can read snippets or without any context and immediately understand well enough to contribute back to, from my experience. It’s doable, but when working on a project with others (especially when the project isn’t even your own), it can become difficult to follow the code in my opinion.
If we include esoteric languages, Seed is actually unreadable by any normal person. Writing code in Seed is extremely difficult, and with an inefficient algorithm (yes you can inverse the RNG to generate seeds directly), can be computationally expensive.
- Comment on lemmy.one has been defederated by lemmy.world 1 year ago:
Not a user of lemmy.one, but user accounts can also be compromised, and if your instance has no active admins, can something be done in that scenario? I wouldn’t be surprised if they defederated preemptively to be safe.
- Comment on Death by a thousand microservices 1 year ago:
I wish languages were more willing to release breaking versions, like a C++ v2 or such. That’s not to say languages don’t already have breaking changes between versions (Python comes to mind), but it would allow people to start fresh and clean up obsolete designs and libraries.
- Comment on Big projects are ditching TypeScript… wtf? - The Code Report 1 year ago:
As someone who has written some Python at work, whenever I need to work on some code without type hints, I spend way too much time trying to figure out what all the parameter types should be for functions. I can’t be the only one doing this though, I’ve seen functions that assume their inputs are strings receiving
pathlib.Path
on some uncommon branch that sure enough errors on some obscure user inputs.I’ve been pushing mypy hard though. It’s not perfect, but it works well enough that it’s still worth using over not using. The biggest pushback has actually been from the amount of time we’d have to spend fixing type-related bugs instead of developing new features.
- Comment on This one goes out to the sysadmins in the crowd. 1 year ago:
It means it made 100% sense.
- Comment on What do you do with your idle servers? 1 year ago:
Turn them off, or repurpose them into Minecraft servers for friends. I’m using more resources running a modded server I don’t play on than I am for actual productive work these days though.
- Comment on The Worst Programmer I Know 1 year ago:
I guess the flaw is that it’s (almost) never used only for planning and is often used as a metric of productivity. It becomes a competition to see who can check off the most story points, and velocity is often used to compare developers against each other.
- Comment on The Worst Programmer I Know 1 year ago:
Story points and velocity always felt to me like a flawed metric. It encourages volume of work, and discourages quality of work. The worse your code is, the more stories and tasks you can create to fix it, and the higher your velocity. It’s a bit of a shame that it’s used so widely as a measurement of work completed, and I wish a better means of measuring productivity would become more popular instead.
- Comment on Why should I use rust (as a Go enthusiast)? 1 year ago:
If I didn’t know people who loved the language so much, I would be too.
- Comment on Why should I use rust (as a Go enthusiast)? 1 year ago:
It looks just about as bad as C++'s template system, minus the latter’s awful compiler errors.
I’d say they’re incomparable. One’s a Turing-complete programming language, the other is not much more powerful than generics in a language like C#. That’s not to say that your impression is incorrect - both are significantly more complex than what Go had for the longest time (no generics), and likely more complex than what Go has now (though I haven’t looked much into Go’s new generics system to be honest).
If you’re looking for a reason to use Rust, I recommend picking it up and doing some projects in it. There are many, many reasons why one would choose Rust for a project (security, correctness, needs to be low level, preference, etc) and many documented scenarios where companies have found switching to Rust to be beneficial to them, but at the end of the day, only you know what your requirements and preferences are.
It seems like you prefer highly readable code. This is a pretty subjective thing though, and you may find that Go is more readable to you than any other language. I would disagree, but again, it’s a matter of preference. For some, C++ is the language they find most readable. Regardless, the only way to know if you’ll like it and want to use it is for you to pick it up and use it, and develop your opinions based on experience. If you find that spending time learning it will be a waste after trying it out for a little bit, then you have your answer.
- Comment on is Rust really that powerful / intuitive? 1 year ago:
Likely not at the start.
To add, Python lets you make a new file, write up a quick script, and start running it. You even have a REPL environment prepared for you to start throwing code at and see what happens. Rust is nothing like this (though some “script runners” exist for Rust). You’ll usually end up creating a new folder, creating a
Cargo.toml
, then asrc
directory and amain.rs
file. Now you can start writing code, but the Python developer has already ran their code a few times and iterated on it a little.For experienced users, development speed in Rust starts to pick up after the initial project setup and once the basic “boilerplate” (this depends per domain, could be arg parsing, reading a config file, setting up telemetry, etc) for their specific application type has been created, in my experience. For quickly throwing together a small script, a developer equivalently experienced in Python and Rust will likely find Python faster to use, but when looking at mid to large sized codebases, that could flip due to how strict Rust is and how that prevents problems over the long term.
- Comment on [TECHCRUNCH] Texas cannot yet enforce ID checks on porn sites 1 year ago:
watching pornography can cause mental illness and increase the demand for prostitution and child sexual exploitation.
I think they have it flipped. People not relieving themselves seems far more likely to lead to these kinds of issues. Then again, if you have to argue about whether or not porn is a “sin” to people, I don’t think you’ll get very far with actual logic.
- Comment on [help] How to decide what to do with command line parameters? 1 year ago:
Others have already mentioned
argparse
, which is a pretty great module for argument parsing if you want to use something built-in. If you’re willing to look into other libraries though, I’d recommend taking a look at Click. You should be able topip install click
to use it. It takes advantage of defining the CLI through decorators, and from my experience, works better when you want to have subcommands. - Comment on data secured 1 year ago:
I’ve never had this issue on Windows, but I have on mobile many times. The more a platform tries to hide the FS from me, the more I struggle to navigate it (surprise!). Mobile devices have been moving to be more transparent that a FS exists at least in recent times.
Casual plug for Search Everything, not FOSS but still free. It’s an alternate indexer/search for Windows, but way faster.
- Comment on is it ethical to use third party libraries and other stuff in my portfolio website? 1 year ago:
Naturally the answers to your question depend on who is looking at the website, but from my experience…
Does the ideology of ‘using other people’s tools to create a better product’ apply here in this context
Yes.
or would it be considered plagiarism?
Absolutely not. It’s showing that you can incorporate the works of others to build something great rather than spend time reinventing the wheel. Nobody’s going to look at your website’s source (assuming you link to it somewhere), see a bunch of
.ts
or.jsx
files, and think “oh this person invented Typescript/React/whatever”.Should you need to reinvent Javascript, your browser, your OS, etc…? Probably not, and as long as you’re using something built by others to build your website (vscode, node.js, etc), there’s no reason to feel like using a library would be the same. Also, for most real world projects, you’ll be using libraries you didn’t write. This is just showing that you know how to use them.
Where it would be unacceptable is if you claimed to have created those libraries/tools yourself.
- Comment on Java 21: what’s new? 1 year ago:
It’s great to see they’re putting some effort into some really powerful string templates. I like ther versitility in the approach they’ve gone. Just a couple things stood out to me.
The problem with interpolation is that it’s dangerous as a global feature, because it doesn’t allow for validation or sanitization when constructing the final string. This exposes it, for example, to SQL or JavaScript injections.
Actually no, it just makes it more verbose to create those vulnerabilities. Also, SQL injections aren’t solved by validation and sanitization (well I guess in theory they can be if you’re aggressive enough), they’re solved with parameterized queries. These issues exist regardless, but lack of interpolation makes things significantly more verbose for the 99.9% of other cases where you aren’t sending commands to a server. The cause of these vulnerabilities is inexperienced (or sometimes careless) developers trying to concat all their queries together, and this will help mitigate that but is unlikely to solve it.
The problem with interpolation seems to me to be a purely cultural thing. Pointing fingers at arbitrary reasons isn’t really helping the argument against it, and it’s completely valid to say “it just didn’t feel like it belonged in Java until now, and we wanted to make sure we got it right”, which I would much more readily believe.
There has been a lot of discussion around the choice of the expression format. Due to the existence of many libraries using $, # or {} as expression delimiters, the choice was for a format that is not valid outside String Templates
This seems backwards to me. Wouldn’t you want them to feel as familiar as possible to users of these libraries and make migration as simple as possible for as many users as possible? It’s not like the syntax for string templates would compile before anyway (unless there’s something I’m missing) since they all require the template processor to be specified.
Skimming through the rest of the features, it seems like there’s a lot of usability improvements, which is awesome to see!
- Comment on how do you spend your learning budget your company provides you with? 1 year ago:
Your company has a learning budget? If you can justify it, you can spend it on cloud-hosted resources and use them to try playing with some concept that interests you, like deploying a web service or running some heavy long-running computations. I know others who have found success in courses, but I’ve always found it easier to dig through docs and random blog posts that show up in my search results.
- Comment on The Fall of Stack Overflow 1 year ago:
You have to build Rust from source
As someone who actually did out of interest at one point, you’d be surprised how easy this actually is to do.
x.py
is a godsend.For the rest of your comment, it was immediately invalidated when you said you use Arch. The reality is that more people use Ubuntu, so you should be using Ubuntu too. Don’t use
apt
? Figure it out yourself :P - Comment on From C to Single Ownership and Memory Safety without Borrow Checking, Reference Counting, or Garbage Collection 1 year ago:
Lets say we have a spaceship game.
Some facts about our game’s code:
- All of our spaceships live in a central list.
- We also need to have a separate cache for displaying them.
- Every ship needs to be in both the central list and the display cache.
- When the ship dies, we need to remove it from both the central list and the display cache.
If we forget to remove it from the display cache, we’d get an odd bug when displaying.
Let’s use single ownership to prevent this bug at compile-time. No mainstream language prevents this kind of bug, but we’re about to do it easily!
The idea of using single-ownership to track “reminder” objects is actually really cool, and a variation of it sees use in other languages too. Traditionally, RAII is used for resource acquisition and freeing (as the name implies), so smart pointers for example. However, it can also be used for things like mutexes to automatically free up a mutex when some kind of “guard” object is dropped (both Rust and C++ support this, and Rust even enforces it). It’s not the same as a “reminder” object, but instead of having the compiler tell you “you forgot to free the mutex”, you instead automatically get the mutex freed so you don’t need to explicitly do it anymore.
The article would be right that languages don’t traditionally enable some kind of “reminder” object in the sense that you can’t compile the code without first doing X with that object. However, from my experience, the RAII approach means you don’t need those reminder objects anyway since the action that you’re supposed to take when you’re done with some resource can be done automatically in these languages.
Here’s an example in Rust translating the ship/display cache example in the article to something that takes advantage of these “guards” to automatically notify the display cache when the ship is dropped. You’ll notice that in the
main
function, nowhere do I need to explicitly tell the display cache “hey this ship was destroyed”. Instead, the cache automatically knows and updates its state when theships()
method is called to get the list of ships in the cache. I believe something similar to this can be done in C++. C# would allow you to useIDisposable
and.Dispose()
to achieve something similar too, although it wouldn’t be an automatic process like in Rust and C++.