Thanks, I’ll give that a shot.
🇨🇦 tunetardis
- 0 Posts
- 63 Comments
Thanks, it makes me feel relieved to hear I’m not the only one finding it a little overwhelming! Previously, I had been using chatgpt and the like where I would be hunting for the answer to a particularly esoteric programming question. I’ve had a fair amount of success with that, though occasionally I would catch it in the act of contradicting itself, so I’ve learned you have to follow up on it a bit.
I turned on copilot in VSCode for the first time this week. The results so far have been less than stellar. It’s batting about .100 in terms of completing code the way I intended. Now, people tell me it needs to learn your ways, so I’m going to give it a chance. But one thing it has done is replaced the normal auto-completion which showed you what sort of arguments a function takes with something that is sometimes dead wrong. Like the code will not even compile with the suggested args.
It also has a knack for making me forget what I was trying to do. It will show me something like the left side picture with a nice rail stretching off into the distance when I had intended it to turn, and then I can’t remember whether I wanted to go left or right? I guess it’s just something you need to adjust to. Like you need to have a thought fairly firmly in your mind before you begin typing so that you can react to the AI code in a reasonable way? It may occasionally be better than what you have it mind, but you need to keep the original idea in your head for comparison purposes. I’m not good at that yet.
🇨🇦 tunetardis@lemmy.cato Programming@programming.dev•Time to make C the COBOL of this centuryEnglish3·5 months agoOuch. Well if you wanna take your chances in Canada, definitely advertise your senior COBOL dev skills! ;)
🇨🇦 tunetardis@lemmy.cato Programming@programming.dev•Time to make C the COBOL of this centuryEnglish5·5 months agoLol yeah she’s in insurance! I bet you could probably also infer from the fortran that I work for a science-y outfit.
🇨🇦 tunetardis@lemmy.cato Programming@programming.dev•Time to make C the COBOL of this centuryEnglish12·5 months agoMy wife was telling me at her work they’re desperate for cobol programmers, as they’re all retiring boomers leaving behind a giant code base. At my work, it’s legacy fortran that’s all over the place, but we’re a much smaller company.
🇨🇦 tunetardis@lemmy.cato Programming@programming.dev•[Noob here] Can someone explain to me the advantage of mutable objects?English4·5 months agoThat’s the point, when programming with immutable structures you always pass the mutability onto the enclosing structure.
I guess the point I was trying to make here was if the data type is already mutable, there is no point in sticking it in a list just so you can replace a reference with an identifier. You’re just adding an extra level of indirection. But sure yeah, if the type is inherently immutable, you have to do something.
A list is an antipattern here IMO. Just wrap it in some dedicated object (see e.g. Java’s StringBuilder).
Interesting. I’m not aware of anything like
StringBuilder
in the standard library for either Python or JavaScript. Looks like it wraps a list of characters and tries to behave as string-like as possible? You could presumably write your own class like that or download an implementation from someplace.I guess in most cases in my own code, where I need a mutable string is usually as part of a larger data structure which is the thing that gets passed around by reference, so it’s easy enough to replace a field within that.
For building up a string, I would tend to use an
io.StringIO
in Python with file-writing calls, but those aren’t meant for sharing. What you don’t want to do is use the+=
operator a lot on strings. That gets expensive unless strings are mutable (like they are in say C++'sstd::string
).
🇨🇦 tunetardis@lemmy.cato Programming@programming.dev•[Noob here] Can someone explain to me the advantage of mutable objects?English14·5 months agoWell, but then you’re basically just pushing the mutability onto the container, since you need to be able to replace elements within it.
It’s a good strategy at times though. Like say you’re working in a language where strings are immutable and you want a string you can change. You can wrap it in a list along the lines
s=['foo']
and pass references to the list around instead. Then if you gos[0]='bar'
at some point, all the references will now see['bar']
instead.
🇨🇦 tunetardis@lemmy.cato Programming@programming.dev•[Noob here] Can someone explain to me the advantage of mutable objects?English11·5 months agoAs others have pointed out, there is the issue of breaking references to objects.
There can also be a lot of memory thrashing if you have to keep reallocating and copying objects all the time. To some extent, that may be mitigated using an internment scheme for common values. In Python, for example, integers are immutable but they intern something like the first 100 or so iirc? But that doesn’t work well for everything.
Any container you want to populate dynamically should probably be mutable to avoid O(N²) nastiness.
Interesting. I had never heard of LilyPond before. I do a lot of music scoring using abc notation and even wrote myself a GUI to help with that, but it’s interesting to see that there is another script language for generating sheet music.
🇨🇦 tunetardis@lemmy.cato Mildly Infuriating@lemmy.world•I have to be knowledgeable about a particular superstition in order to sign in to access a government formEnglish3·7 months agoInteresting. I wonder what the thinking is here? It’s almost like a really poor manual password hash. Here’s something derived from my date of birth. Store that instead of the actual date. Pretty weak though.
🇨🇦 tunetardis@lemmy.cato Mildly Infuriating@lemmy.world•I wonder why people litter in the USA?English8·7 months agoIn fairness, I remember a time when everyone smoked in Japan and flicked cigarette butts all over the place.
🇨🇦 tunetardis@lemmy.cato Programmer Humor@lemmy.ml•Before and after programmingEnglish101·7 months agoI can’t speak for others, but the python3 transition wiped the smile off my face for awhile there.
I suppose it depends on the language? For the most part I think you’re right. Exceptions are only used (if at all) in situations where a program diverges unexpectedly from its normal flow. But take a language like Python. They’re just everywhere. Even your plain old
for
loop ends on an exception, and that’s just business as usual.
This could be why Obiwan wound up a hermit? (Programmers of my generation at least talk about “Obiwan errors” because his name sounds like “off-by-one”.)
There were breaking changes between C and C++ (and some divergent evolution since the initial split) as well as breaking changes between different releases of C++ itself. I am not saying these never happened, but the powers that be controlling the standard have worked hard to minimize these for better or worse.
If I took one of my earliest ANSI C programs from the 80s and ran it through a C++23 compiler, I would probably need to remove a bunch of
register
statements and maybe check if an assumption of 16-bitint
is going to land me in some trouble, but otherwise, I think it would build as long as it’s not linking in any 3rd party libraries.
I think the thing with C++ is they have tried to maintain backward compatibility from Day 1. You can take a C++ program from the 80s (or heck, even a straight up C program), and there’s a good chance it will compile as-is, which is rather astonishing considering modern C++ feels like a different language.
But I think this is what leads to a lot of the complexity as it stands? By contrast, I started Python in the Python 2 era, and when they switched to 3, I was like “Wow, did they just break hello world?” It’s a different philosophy and has its trade-offs. By reinventing itself, it can get rid of the legacy cruft that never worked well or required hacky workarounds, but old code will not simply run under the new interpreter. You have to hope your migration tools are up to the task.
🇨🇦 tunetardis@lemmy.cato Programming@programming.dev•It must a pain to make a Rich TextboxEnglish8·1 year agoYou mean like the comment fields we’re using right here on lemmy?
As others have pointed out, it’s usually some markdown that’s embedded within the text. Lemmy is using a format that’s actually called “markdown” if I’m not mistaken, or a slight variation/subset thereof.
I’ve gotten used to the double-star for bold and what not to the point that it annoys me when some message client or whatever doesn’t support it. I share code snippets with people fairly often, and the code markdown is particularly useful to maintain its legibility.
🇨🇦 tunetardis@lemmy.cato Programmer Humor@lemmy.ml•They'd still both rather use C++ than each other thoughEnglish13·1 year agoI started in C and switch to C++. It’s easy to think that the latter sort of picked up where the former left off, and that since the advent of C++11, it’s unfathomably further ahead. But C continues to develop and occasionally gets some new feature of its own. One example I can think of is the
restrict
key word that allows for certain optimizations. Afaik it’s not included in the C++ standard to date, though most compilers support it some non-standard way because of its usefulness. (With Rust, the language design itself obviates the need for such a key word, which is pretty cool.)Another feature added to C was the ability to initialize a
struct
with something likeFooBar fb = {.foo=1, .bar=2};
. I’ve seen modern C code that gives you something close to key word args like in Python using structs. As of C++20, they sort of added this but with the restriction that the named fields have to come in the same order as they were originally defined in the struct, which is a bit annoying.Over all though, C++ is way ahead of C in almost every respect.
If you want to see something really trippy, though, have a look at all the crazy stuff that’s happened to FORTRAN. Yes, it’s still around and had a major revision in 2018.
I work with 32MHz microcontrollers at work and you can do plenty with them. It’s a different world from say general CPUs where speed is king. You’re often more concerned about timing reproducibility than outright clock rates. There are also considerations about power consumption, electrical noise, functioning in extreme environments, etc. that may inform your decision to go with one controller over another.