hermitdev
Joined 10 years ago
Joined 10 years ago
Heh, how about how `__class__` works? Not that I recommend actually doing this, but you can literally change the type of an already instantiated object by reassigning `__class__`:
>>> class Dog:
... def hi(self):
... print("woof")
...
>>> class Cat:
... def hi(self):
... print("meow")
...
>>> dog = Dog()
>>> dog.hi()
woof
>>> dog.__class__ = Cat
>>> dog.hi()
meow
>>> isinstance(dog, Dog)
False
>>> isinstance(dog, Cat)
True
>>>Most of my work was on an intranet page used for tracking internal servers, apps and databases. One of cool (at the time) features I implemented was a server-rendered ping of the servers shown on the dashboard. We're talking usually a few hundred at a time. The site ran on IIS & NT 4, written in VBS & ASP. (I think my first server was actually a dual Alpha chip, wasn't even x86, sure as hell was way before x64).
To implement the ping functionality (yes, we're talking just a straight ICMP ping), I ended up doing a COM server, written in C++, called into it from the VBS side. Eventually, .Net came out, and once .Net Framework 1.1 was released, I was able to convince my boss to let me rewrite the whole site in ASP.Net. I ditched the C++ COM object and was able to do it in C# with raw sockets (and appropriate permissions, which was a bit of a pain to get right at the time, before google and stackoverflow were around to help). Getting the C++ COM object working was actually easier because at least the MSDN library (the entire stack of CDs & DVDs it was on) had extensive documentation. The .Net side was good initially, but it just did not have the same depth as the C++ side already had at that point.
Ironic given this article is from CNBC, employer of Cramer, host of "Mad Money", who has been so inconsistently wrong that his picks have literally sparked an ETF. Just search using your engine of choice "Inverse Cramer ETF".
I work in finance. Past performance is not a guarantee of future returns, but is a damn good indicator, which is why everyone always wants to see your past performance anyways.
Engineering is literally the art of making educated guesses and then testing/proving/disproving/improving upon them. Nothing is exact. Everything is approximate. Iterate until the result is good enough.
Taken by itself? Absolutely. In the middle of 50-deep templatized call stack? Maybe not. Compilers have their limitations (memory, runtime, other cost budgeting algorithms), and the more complex the code, the hard the optimizer has to work. But, yeah. Most of the gains from branchless code is going to come from this like numerical tools, vectorization and loop unrolling, things of that nature. It was an admittedly contrived example.
A trivial example is actually written with a branch in C/C++, but relies on compiler optimizations to kick in. If you compile a ternary operator in C/C++ (and probably rust, C# and other languages) such as in:
int min_branchless(int a, int b) {
return a < b ? a : b; // Often emits cmov with -O2
}
With gcc/clang a -O2, one would expect the compiler to emit the following assembly: cmp edi, esi
cmovle eax, edi ; select a if a <= b
ret
There's numerical tricks for other operations/comparisons, and compilers know a lot of them. But, I just suggest compiling your code and configuring your compiler to emit the generated assembly with references to the code it was generated from (you should be able to get it to emit source line references in the assembly). You'll likely be surprised at the optimizations applied at -02, and utterly confused by what you find at -03.edit: Also, it doesn't mean to never branch, but to minimize branching, especially in tight loops. Branch outside loops, not inside, for instance.
e.g. don't do:
for (...) {
if (condition independent of loop variable) {
...
} else {
...
}
}
do: if (condition independent of loop variable) {
for (...) {
...
}
} else {
for (...) {
...
}
}[0]: https://i.pinimg.com/originals/c8/84/8e/c8848e81afa88a42bd4d...
Heh. Anyone remember the ping of death[0]? A lot (most?) of computers on the early internet didn't properly handle large packets, _especially_ from ICMP pings. Once upon a time, you could send a single ping w/ a packet size of 65536 and crash the remote.
[0]: https://docs.python.org/3/whatsnew/3.14.html#a-new-type-of-i...
No, it isn't. Any decent datacenter will have on-site generation in event of power grid failure, anyway. When I was an intern, the company I worked for would routinely go off grid during the summer at a call from the electric company. The electric company actually gave us significant incentives to do so, because us running on our own 12MW generator was effectively like the grid operator farming out a 12MW peaker unit.
It's the same in the US. It's covered under CAT NMS (Consolidated Audit Trail, National Market System). Probably too much information at: https://www.catnmsplan.com/
Remember, it was originally release +20 years ago (goddamn, I feel old now); recorded video or even audio over the internet were much, much, MUCH rarer then, when "high-speed" speed internet for a lot of people meant a 56K modem.
Back then, most developer's first exposure to C# then was likely in either print form (books or maybe MSDN magazine).
It's the legal liability that SWEs don't want. e.g. You wouldn't be able to just slap "This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." on your software and walk away from it when lives are at stake. A so-called Profession Software Engineer would have to accept liability for their work product, and those of the juniors working under them.
I started down the road to becoming a Professional Engineer while I was in college as I studied Electrical Engineering and was more interested in hardware/power engineering. I took, and passed, the Engineering Intern Test in my state (which is the preliminary exam you take before you can start your journey to become a PE). Then life happened and job/career opportunities took me in a different direction/industry, and I've been doing software instead. So, I never became a licensed Professional Engineer. I'm still a licensed engineering intern, though. I'm still bound by the legal and ethical standards that it entails and could lose my license for violations.