Programming

I’m so glad I program in python and bash and don’t need to worry about pointers. Although bash has plenty of obnoxious stuff you have to worry about.

I remember this is the point in CS where most people hit an absolute wall and can’t seem to get past it. If you or microdaughter are feeling that way, just remember it is normal. This is where it gets a little hard and you start getting into actual computer science topics.

God, this is giving me flashbacks to the stupid exams full of “what is the output of this code?” and it’s some completely obfuscated mess where pointers change hands 40 times in 4 different functions and you have to trace what the fuck is going on by hand. Do not miss.

1 Like

Yeah I took C++ and Perl as my first two classes at SF City College because Java was so popular I couldn’t get in. Then I took Java later at Marin College and was like - oh this is so much simpler than C++.

Obviously C++ has it’s place when you need that kind of fine-grained control. But most (all?) web-apps don’t.

It’s an ancient debate I think all of us have had in the old thread before but I think C/C++ is very useful for teaching computer science, but probably not as useful at creating competent programmers in today’s world. CS education, IMO, very much focuses on the wrong things.

It was good to learn first so that I appreciated all the training wheels in Java.

Is a vector different than an array?

Just asked my boss if i could enable kms on google cloud because it’s a few bucks or something and felt I should ask before doing something that could add to the bill.

His response “I think it cost more money us talking about it then if you just had done it”

-____-

On an older Macbook Air would you use Visual Studio Code? XCode? No IDE?

VIM :)

For real though doing everything from command line and compiling by hand will give you a better understanding of the tools and expose you to concepts like linkers and stuff. It’s not too hard to compile c++ by hand unless there’s a shitload of library dependencies and i doubt you’re gonna have that. I’d rather fuss with the command line than a complicated IDE though, that’s just me. I do everything from command line and vim and I have a 2014 macbook.

1 Like

My job is really getting frustrating. Everything I do takes forever because you need to fill out tickets for access to things you dont have access to - because of the nature of what I do my work touches most of the groups in the company so my group may need access literally anywhere at anytime.

But the worst part is, a lot of times we dont even know where to ask for access. My boss is still new and doesnt know the company as well as the boss that hired me. So like, something that should be pretty simple like getting a CA cert for a new server I’m deploying can take 3 weeks because we have to figure out who the fuck can even give us that and (god forbid no) if we are even approved to get it. And that’s IF my boss stays out of his own way.

I swear like if you ask the simplest question to people they are afraid to respond in a direct manner. You’ll either get ignored or get directed to someone else. It gets really fun when you get directed back to the first person who sent you on the wild goose chase.

/rant

2 Likes

Anybody ever come across a to do list or flash card app that has reddit style upvoting/downvoting? The idea is roughly: say you’re reading something and you come across a bunch of facts you know you will forget, or you have creative ideas that you want to explore later. You put that stuff on cards or w/e, and then after you forget all about them say a week later or a month later, you go through your collection to upvote/downvote what you like. Over time, your preferences for certain facts/creative ideas will be captured by your upvotes in a somewhat different way than just messing with labels or color coding schemes for the item.

So basically Trello or Cram but with up/down voting on a card; preferably you allow yourself to vote as many times as you like because that may reflect your enthusiasm for the fact/idea over time. I’m too lazy to make my own. Also the idea may be shit.

VS Code is a a great IDE. I’d use that unless I was doing .net.

Coincidentally, I just came across this essay about libraries implementing small-string/small vector optimization in Rust, which is really great:

It’s also very in-depth and long (there’s one digression that ends up in GameBoy Advance assembly code), so plan accordingly.

1 Like

The ultimate trick is that there are at least three unused bits in any newly allocated pointer, because the new pointer will be word-aligned rather than byte-aligned, so you can use one of those bits to indicate whether the rest of the struct is a pointer + a string length or just an array of UTF-8.

As to why you would use the regular String, presumably it’s because the optimized String is not in the standard library and you wouldn’t trust some random dude to write all the crazy-unsafe code it takes to do the optimization. As to why it’s not in the standard library, presumably it’s because Rust hasn’t been around for a zillion years, so the people who write the standard library have a lot of bigger holes to fill. Also, I’m not exactly clear on whether the optimization is sound for all allocators, and it’s microscopically slower for long strings, so there might be some philosophical objection to putting non-zero cost abstractions in the standard library.

Making a union of a pointer and a bit field is clever. Clever code is bad code.

1 Like

The original MS Windows target machine was an 8088 with 1MB of RAM, 2 floppy drives, no hard drive, and < VGA graphics. On the 8088/8086, all pointers come in two parts: a 16 bit segment register and a 16 bit offset. Any instruction involving an address has an explicit or implicit segment register associated with it. Is this a 32 bit address space? No, it is not. To produce a physical address, you take segment * 16 + offset. That’s a 1MB (+64k) address space.

The experienced programmers in those days knew this relationship and used it. You have a pointer you want to add 16 to? Just increment the segment register by 1! So clever.

The memory management in Win16 uses a double indirection to overcome the lack of a CPU memory manager:
HANDLE hmem = GlobalAlloc(sizeof(MyStruct));
MyStruct far * mystruct = (MyStruct far *)GlobalLock(hmem);
// use mystruct
GlobalUnlock(hmem);
// repeat lock/unlock getting different addresses
GlobalFree(hmem);

The 80286 introduced a new protected mode where the CPU helped with memory management. It broke the relationship between segment and offset. The segment register was now called a selector, and instead of multiplying the selector, the CPU uses a table to find the address (and length) associated with a selector. No more 1MB memory limit. New products called DOS extenders are introduced to allow existing software to use the extra memory. The catch is they break all the clever code. Which was a lot of it.

One weekend some engineer at MS had the idea of recompiled windows using 286 protected mode and a DOS extender. The windows code base was not full of clever code, they mostly stuck to the contract. When he went back to work Monday morning he was able to show Bill Gates his new idea. Gates recognized that protected mode Windows could do everything the next gen of desktop apps needed. Previously MS was taking orders from IBM and IBM wanted DOS 4.0 to be something like Windows (released as OS/2) . Gates broke up with IBM and took over the desktop world. A little more clever code in Windows and that would not have happened.

4 Likes

Sounds like an argument in favour of clever code.

1 Like

Isn’t the problem here really a failure of encapsulation rather than cleverness?

It seems to me that relying on implementation details all over the place is bad architecture because it locks in the implementation, while clever code is bad because it’s hard to understand. Or rather, writing unnecessarily clever code is bad, because simpler code could do the same job. If you actually need the performance for whatever reason, then it seems like you’re stuck with having to write hard-to-understand code because the task you’re trying to do is inherently hard. If you’re in that position, then surely the right way to do it is to wrap the implementation details and cleverness in a safe and simple abstraction.

Abstinence-only cleverness education doesn’t work. You need to teach safe(r) optimization. Coders are going to optimize whether you approve or not, so you need to give them the tools to do it without catching a CVE.

That bit might be getting a little too clever.

Anyone else done a lot of work with hashicorp Vault?

Not sure if anyone is interested, but here’s a free 8 week course for Network Automation with Python for people with beginner-intermediate programming knowledge and intermediate-advanced networking. Looks like the weekly lessons are about ~2-3 hours in length but I’m just getting around to starting week 1 now.