I've seen a few people/companies do this and it always baffles me. You don't have to use every C++ feature in existence, but a little bit here and there is far more productive and safe than writing C.
You do, if you have to work with an existing code base in which every feature in existence was used.
Even if you start a new greenfield project and get to impose your own coding convention that includes what C++ features should be used, it won't stay that way when people come on board who have different ideas.
Think in object orientation: Put related nouns and verbs together: it is much easier to organize your thoughts using constructors and methods. However do not use virtual methods unless you really must, and if you do, make the class a well-defined explicit interface having only abstract methods. That said, avoid using implementation inheritance: overriding one defined method for another.
Get rid of pointers: When passing objects by reference, using references instead of pointers, especially reference to const, makes code much easier to read. When combined with vector instead of raw arrays, most uses of raw pointers go away.
Do not implement your own fancy data structures: instead use the Standard Template Library. I use STL map, set, and vector all of the time and they remove the need for most other data-structures. Also, when you can, use iterators to traverse these containers, rather than the visitor pattern. Using iterators keeps the control flow of the client contiguous, so it is much more flexible than visitors.
>Do not implement your own fancy data structures: instead use the Standard Template Library. I use STL map, set, and vector all of the time and they remove the need for most other data-structures.
Don't the STL tree and map data structures have notoriously poor performance?
From memory, std::map is comparatively slow because the spec requires pointers to indices to be stable. In practice it is slow; see khash and many others
Personally i don't think this matters too much; you're using c/c++; you're already fast
I mean it depends on the project and scope, but if you just write C-style code but use unique_ptr, vector, string, and <algorithm>, you're already at an advantage.
Take strings for example. In C you have to manually manage memory and there are a million pitfalls. Lots of programmers are lazy and use fixed-sized arrays and "unsafe" functions like strcpy which results in security vulnerabilities and large-input bugs. But even if you do it correctly you have all this mental overhead and lots of lines of code.
No because of the current active community around C++. The large standard template library is safer to use than in-house implementation of the same data structures. The C++ Boost library also gives you a large arsenal of utility functions that is vetted by the community.
So here's the problem: you can buy an older cast-iron table saw with good precision and a large bed for $50-$150 on craigslist, or you can buy a cheap piece of made-in-china plastic at home depot for $500. The cheap piece of plastic checks off more safety features from a regulatory standpoint, but tiny size and poor tolerances results in more kick-back and accidents.
Trying to write a perfect optimizer is like trying to slay a hydra. Every time you address one weakness, two more are spotted. The overall approach has to run in polynomial time (or close to it), so there will always be missed optimization chances.
And then half the time it's just your compiler being stupid.
I've heard that the gyroscopic effect in bicycles is rather small. The balance instead comes from the positive angle of the front wheel, creating feedback. If the bike leans one direction, the wheel rotates to counteract it.
I've been riding an scooter to work for a few years, and the gyroscopic effect of the wheels on a bike do make a big difference. You can't take one hand off the handle bars to use your arm to indicate on a scooter. You will lose control instantly. When I ride my bike I can ride most of the way sitting up and not holding the handle bars at all.
It doesn't matter how the bicycle balances, just that inventors thought it to be possible. Gyroscopes could have inspired that belief. Balancing was probably discovered in a "it works if we design it like this" manner, rather than from first principles.
You can measure it for yourself: balance on the bike when it is stationary, then compare the experience to when you're moving.
When you are moving, it adds in the gyroscopic balancing effect.
Gyroscopic motion means that the force applied acts about 90 degrees later, so when you turn the handlebars which are on a (roughly) vertical axis (call it the "z" axis), the force of that turn is actually applied about the axis that runs from front to back (call it the "y" axis). Gyroscopes "translate" the force.
If you're stationary, and there is no gyroscopic motion, then the only thing that turning the wheel really does is allow you to move the front of the bike to the left or right in order to change your centre of gravity.
My professor debunked this in experimental physics 101. He installed counter wheels on the wheels which spun in the opposite direction (without touching the floor obviously) and was able to still ride the bike just fine.
It may play a part in the effect, but does not explain it entirely.
Well, you can debunk that debunking easily enough if you have a bike.
Stand in front of the bike and lift up the front wheel, holding one fork in each hand.
Attempt to turn the front wheel from side to side without the seat changing position at all.
Now hold the bike up with one hand and with your other hand spin the front wheel as fast as you can.
Now with the front wheel still spinning, go back to holding one fork in each hand and attempt to turn the front wheel side to side without the seat moving at all. You will find it more challenging to do and you will notice that the tendency is for the seat to move in the opposite direction from that which you turn the front wheel.
That is, you turn the front wheel towards your right side, the seat will move towards your left side.
This is the "counter steering" effect that we use in order to balance when riding a bike, and it's entirely due to gyroscopic motion.
“It is almost certain that gyro effects are important at the initial stage of steering manoeuvres. […] My point is that gyroscopic effects are not needed to keep you from falling over when you are riding in a straight line. I am not saying anything about what happens when you actively wish to steer away from straight ahead.”
It also does some calculations that show how small the gyroscopic force is compared to the weight of (bicycle plus rider)
So the gyroscopic effect isn’t necessary to balance a bike, but likely helps in making turns.
The gyroscopic effect is not necessary, and it has been demonstrated both in reality and in simulation [0].
The central principle behind why a bicycle is self balancing while in motion is the fact that it self-steers in the same direction that it is leaning, which counteracts the fall [0][1].
Nah, that's not it. Try riding a bike in reverse (or pushing it). It's not at all stable, because the feedback is applied in the opposite direction. You'll fall right away, even though the gyroscopic effect is identical.
I'd recommend just googling how a bike works instead of pursuing this argument. There's lots of good articles, like this one: http://www.cyclelicio.us/2011/bicycle-dynamics/ It looks like my theory on wheel angle may not be entirely true either. You can also find videos on youtube.
The Veritasium video is the best one I've seen but he only describes how counter steering works at slow speeds which is more like how you balance a stationary bike. The faster you go, and the bigger the wheel, the more the counter steering is done by gyroscopic motion than moving the wheel back and forth beneath you.
Destin’s inverted steering bike is definitely an argument for that, inverting the steering does not affect the gyroscopic effect, but the bike requires re-learning how to ride.
No, it doesn't make an argument for that. It's no different from inverting your mouse wheel scroll direction. If you're used to doing it one way you have to get used to doing it another way.
> It's no different from inverting your mouse wheel scroll direction. If you're used to doing it one way you have to get used to doing it another way.
If you invert scroll direction it does not make the mouse stop working, it only hinders scrolling. But inverting steering has an immediate effect on balance, not just on your ability to take a turn.
It's always a eucatastrophe[1] for me. Some random event occurs and it gives me something to focus on. Maybe a person shows up in my life, or an event, or an idea. Contrary to common belief, trying to pull myself out through sheer will and habits never worked.
Love your games as well! Have you considered packaging them for Steam and pricing at less than 5 dollars? (i.e. a single pack of all your NES games) - if you promote to a few YouTube retro influencers you might make a few sales. :-)
Thanks. I might sell some one day, maybe as a physical cartridge release as those have better margins. Mostly though I want people to enjoy my stuff, so a lot of what I release is free.
As a kid I did the math on all the lego sets, and came to the conclusion that the 500 piece bucket was the best bargain, beating out the 1000 piece bucket by a decent amount. Most other sets were an awful value in comparison.
As an adult, I realized buying new was idiotic when I could just buy used. I ended up buying a former lego employee's collection for $60, selling the monorail it contained for $1000, and keeping the massive washing-machine sized rest for myself. Too bad deals like that come once in a lifetime!
OSB is much more nuanced than particle board, often in a bad way. Many manufactures orient the chips along a single axis, meaning it shares the anisotropic properties of solid wood where the X axis has a different strength and expansion rate than the Y axis. And looking at the 3rd dimension, the Z axis is actually quite weak. If you glue something to the face of an OSB board, you can break the joint fairly easily because the individual chips pull out.
Something I realized recently was that you can just buy popcorn kernels in bulk and pop them in the microwave using a covered bowl. I don't think I'll ever buy instant popcorn baggies again.
That's how my wife does it: buys a bag of kernels and puts some into a brown paper sack for microwave heating. Alternatively, they still sell those air poppers[0], which tend to produce better results, so you can use one of those.
Using a paper bag is especially fun if you have young kids since a kindergartner can stir the kernels with oil in a bowl, pour them into the bag, add salt, and shake vigorously. I think it was almost as much fun to make as it was to eat.
I just use a pot. I put in a tablespoon or so of coconut oil, melt it over medium heat with a few kernels and when they pop add a bunch more to almost cover the bottom of the pot. Then I put a lid on it, canted so it lets the moisture leave but not the popcorn and remove from heat when the popping slows. Then I add salt and shake and done. It takes just a few minutes.
I do almost the same. But I use olive oil and toss the freshly popped kernels in cayenne pepper and some nutritional yeast. Delicious and fairly healthy snack!
You can also just put them in a brown paper bag to replicate the popcorn bag experience. Just fold and pinch the top, add whatever salt and oil you want. Corn kernels are crazy cheap too, it's probably $0.05 a bag.
Retro games used a ton of tables. Back then memory speeds were blazing fast, but processors were sluggish, so it made sense to pack as much computation as possible into tables. The more clever you were about it, the fancier games you could make.
Not always, though it might depend on what platform you mean with retro. Kaze Emanuar on YT does a lot of development for the N64 and it feels like half the time he talks about how the memory bus affects all kinds of optimizations. In Mario 64 he replaced the original lookup table for the sine function because an approximation was faster and accurate enough (or rather two approximations for two different purposes).
I love that channel, he reworked the entire Mario 64 code [0] to make it run at stable 60FPS...because he wanted his mods to run faster.
Back when I started I thought I would make games. I used a lookup table for cos/sin kept as an integer. I only needed enough precision for rotation on 320x240. It was something like 20-30 cycles faster per pixel. Even more if you didn't have a FP co-processor.
By retro platform GP meant Atari ST and Commodore Amiga and the like: LUT were the name of the game for everything back then. Games, intros/cracktros/demos.
Heck even sprites movements often weren't done using math but using precomputed tables: storing movements in "pixels per frame".
It worked particularly well on some platforms because they had relatively big RAM amounts compared to the slow CPU and RAM access weren't as taxing as today (these CPUs didn't have L1/L2/L3 caches).
The speedup from the approximation wasn't that much if anything. He made his real improvements elswhere. But your point stands that memory speed really has moved the goalposts on what is feasible to speed up through using precalculation tables and if you can do it with math then that is often much faster.
I remember the days of resticting rotation accuracy to 360/256ths of a degree so it would fit on a byte, which then would be an index into trig lookup tables :)
I miss the days when professional software development was more akin to this sort of thing, rather than gluing together 20 Javascript frameworks on top of someone else's cloud infrastructure.
Well, consumer reports is still kicking. I don't think an aggregate review service does much good though.
Reviews for physical items are super inaccurate. The average consumer doesn't have the money to buy 10 laptops and compare them, so they buy one and hold a biased opinion about it. In 5 years when shitty battery and defective hinge become apparent, the laptop is already off the market and the user isn't interested in reviewing it.
Besides, a ton of reviews are fake these days. You just can't trust them anymore. And for many products, the manufacturer cheapens them oven time without telling the public. So a review from 2 years ago may not reflect the quality of today.
The internet used to be filled with nerds and people that are interested in things enough to seek information on the web. Now, internet is a marketing tool, filled with corp influence and mostly garbage.
I really miss the old days of niche forums, gaming communities with own servers and forums. You were actually able to get decent and reliable information, now internet is mainstream.
> The internet used to be filled with nerds and people that are interested in things enough to seek information on the web.
and/or actually do proper testing, and share their results, in a consistent manner, but the effort and time is simply no longer worth it. quality content gets buried under 10 second video clips, spam sites, and your content gets copied by large websites. 10 years ago I spent up to 200 hours testing one video card, having build identical systems to do proper apple vs apple tests. But all that time invested, even then, was barely worth it from a commitment point of view. And if you publish such an article now, your viewership is so limited to a very select few. New generation simply doesn't know how a computer actually works, where as 30 years ago, you had to learn more than just the basics to be able to operate it.
The real world used to be filled with these people too. They'd have brick and mortar shops to sell quality products, and customers could step in and get expert advice on what to purchase within their budget.
> In 5 years when shitty battery and defective hinge become apparent, the laptop is already off the market and the user isn't interested in reviewing it.
Yep, and quality can vary quite substantially from one year to the next. I mostly like my 2015 MacBook Pro 15" with an AMD dGPU, but many people hated the 2016 MacBooks with the butterfly keyboards that quickly broke and touchbar that would freeze up.
It's especially an issue for products with bad model names. Is my experience with the MSI GE72MVR Apache Pro-080 going to be insightful for anyone considering a current MSI laptop? No idea. There were tons of MSI laptop models back then too with who knows what quality.
Automated lab tests can't perfectly represent real world tests, but I'd still like to see more of them. I remember seeing a machine fold and unfold the Samsung Galaxy Fold around 119,380 times before half the screen stopped working. [1] While it's a sample size of one and not a perfect representation of real world use, it's a lot better than nothing. I'd like to see similar tests for opening and closing laptops, plugging and unplugging cables into ports, pressing keys on a keyboard, etc. Some things can't be simulated, such as long term battery health, but there's a lot that could be tested but isn't in nearly all product reviews.
Something that'd be expensive but that I'd like to see is long-term automated tests to see how frequently a machine crashes. The machine should browse the web, play games, and use commonly used software: Adobe CC, Office 365, G Suite, Slack, Zoom, VLC, ffmpeg, AutoCAD, Blender, Unity, Unreal, and various Docker instances, IDEs, compilers, runtime environments, local servers and databases, etc. It should have automatic updates on and reboot only when required for an update, though sleep and wake-up should be tested regularly. Then, one could analyze how stable of a machine it is.
Personally I'd rather buy a slightly older machine that is proven to be stable than a brand new machine with better performance but questionable stability. Unfortunately, neither is currently an option for me, and with OS and driver updates, stability and performance can worsen at any moment with little (convenient) recourse (or in the case for phones, often no recourse at all.) If my work tools were available on Linux or worked through Wine/Proton/etc., I'd probably try an immutable OS like Fedora Kinoite just so I'd hopefully have more stability. I could automate stress testing the drivers after updates to make sure they were safe. Unfortunately, depending on your hardware, it may never pass driver stress tests even on a clean install (even on Windows, which the machine was designed for!), so may have to exclude certain tests.