Binary Options Platform Features - What You Need to Look for

Best Practices for A C Programmer

Hi all,
Long time C programmer here, primarily working in the embedded industry (particularly involving safety-critical code). I've been a lurker on this sub for a while but I'm hoping to ask some questions regarding best practices. I've been trying to start using c++ on a lot of my work - particularly taking advantage of some of the code-reuse and power of C++ (particularly constexpr, some loose template programming, stronger type checking, RAII etc).
I would consider myself maybe an 8/10 C programmer but I would conservatively maybe rate myself as 3/10 in C++ (with 1/10 meaning the absolute minmum ability to write, google syntax errata, diagnose, and debug a program). Perhaps I should preface the post that I am more than aware that C is by no means a subset of C++ and there are many language constructs permitted in one that are not in the other.
In any case, I was hoping to get a few answers regarding best practices for c++. Keep in mind that the typical target device I work with does not have a heap of any sort and so a lot of the features that constitute "modern" C++ (non-initialization use of dynamic memory, STL meta-programming, hash-maps, lambdas (as I currently understand them) are a big no-no in terms of passing safety review.

When do I overload operators inside a class as opposed to outisde?

... And what are the arguments foagainst each paradigm? See below:
/* Overload example 1 (overloaded inside class) */ class myclass { private: unsigned int a; unsigned int b; public: myclass(void); unsigned int get_a(void) const; bool operator==(const myclass &rhs); }; bool myclass::operator==(const myclass &rhs) { if (this == &rhs) { return true; } else { if (this->a == rhs.a && this->b == rhs.b) { return true; } } return false; } 
As opposed to this:
/* Overload example 2 (overloaded outside of class) */ class CD { private: unsigned int c; unsigned int d; public: CD(unsigned int _c, unsigned int _d) : d(_d), c(_c) {}; /* CTOR */ unsigned int get_c(void) const; /* trival getters */ unsigned int get_d(void) const; /* trival getters */ }; /* In this implementation, If I don't make the getters (get_c, get_d) constant, * it won't compile despite their access specifiers being public. * * It seems like the const keyword in C++ really should be interpretted as * "read-only AND no side effects" rather than just read only as in C. * But my current understanding may just be flawed... * * My confusion is as follows: The function args are constant references * so why do I have to promise that the function methods have no side-effects on * the private object members? Is this something specific to the == operator? */ bool operator==(const CD & lhs, const CD & rhs) { if(&lhs == &rhs) return true; else if((lhs.get_c() == rhs.get_c()) && (lhs.get_d() == rhs.get_d())) return true; return false; } 
When should I use the example 1 style over the example 2 style? What are the pros and cons of 1 vs 2?

What's the deal with const member functions?

This is more of a subtle confusion but it seems like in C++ the const keyword means different things base on the context in which it is used. I'm trying to develop a relatively nuanced understanding of what's happening under the hood and I most certainly have misunderstood many language features, especially because C++ has likely changed greatly in the last ~6-8 years.

When should I use enum classes versus plain old enum?

To be honest I'm not entirely certain I fully understand the implications of using enum versus enum class in C++.
This is made more confusing by the fact that there are subtle differences between the way C and C++ treat or permit various language constructs (const, enum, typedef, struct, void*, pointer aliasing, type puning, tentative declarations).
In C, enums decay to integer values at compile time. But in C++, the way I currently understand it, enums are their own type. Thus, in C, the following code would be valid, but a C++ compiler would generate a warning (or an error, haven't actually tested it)
/* Example 3: (enums : Valid in C, invalid in C++ ) */ enum COLOR { RED, BLUE, GREY }; enum PET { CAT, DOG, FROG }; /* This is compatible with a C-style enum conception but not C++ */ enum SHAPE { BALL = RED, /* In C, these work because int = int is valid */ CUBE = DOG, }; 
If my understanding is indeed the case, do enums have an implicit namespace (language construct, not the C++ keyword) as in C? As an add-on to that, in C++, you can also declare enums as a sort of inherited type (below). What am I supposed to make of this? Should I just be using it to reduce code size when possible (similar to gcc option -fuse-packed-enums)? Since most processors are word based, would it be more performant to use the processor's word type than the syntax specified above?
/* Example 4: (Purely C++ style enums, use of enum class/ enum struct) */ /* C++ permits forward enum declaration with type specified */ enum FRUIT : int; enum VEGGIE : short; enum FRUIT /* As I understand it, these are ints */ { APPLE, ORANGE, }; enum VEGGIE /* As I understand it, these are shorts */ { CARROT, TURNIP, }; 
Complicating things even further, I've also seen the following syntax:
/* What the heck is an enum class anyway? When should I use them */ enum class THING { THING1, THING2, THING3 }; /* And if classes and structs are interchangable (minus assumptions * about default access specifiers), what does that mean for * the following definition? */ enum struct FOO /* Is this even valid syntax? */ { FOO1, FOO2, FOO3 }; 
Given that enumerated types greatly improve code readability, I've been trying to wrap my head around all this. When should I be using the various language constructs? Are there any pitfalls in a given method?

When to use POD structs (a-la C style) versus a class implementation?

If I had to take a stab at answering this question, my intuition would be to use POD structs for passing aggregate types (as in function arguments) and using classes for interface abstractions / object abstractions as in the example below:
struct aggregate { unsigned int related_stuff1; unsigned int related_stuff2; char name_of_the_related_stuff[20]; }; class abstraction { private: unsigned int private_member1; unsigned int private_member2; protected: unsigned int stuff_for_child_classes; public: /* big 3 */ abstraction(void); abstraction(const abstraction &other); ~abstraction(void); /* COPY semantic ( I have a better grasp on this abstraction than MOVE) */ abstraction &operator=(const abstraction &rhs); /* MOVE semantic (subtle semantics of which I don't full grasp yet) */ abstraction &operator=(abstraction &&rhs); /* * I've seen implentations of this that use a copy + swap design pattern * but that relies on std::move and I realllllly don't get what is * happening under the hood in std::move */ abstraction &operator=(abstraction rhs); void do_some_stuff(void); /* member function */ }; 
Is there an accepted best practice for thsi or is it entirely preference? Are there arguments for only using classes? What about vtables (where byte-wise alignment such as device register overlays and I have to guarantee placement of precise members)

Is there a best practice for integrating C code?

Typically (and up to this point), I've just done the following:
/* Example 5 : Linking a C library */ /* Disable name-mangling, and then give the C++ linker / * toolchain the compiled * binaries */ #ifdef __cplusplus extern "C" { #endif /* C linkage */ #include "device_driver_header_or_a_c_library.h" #ifdef __cplusplus } #endif /* C linkage */ /* C++ code goes here */ 
As far as I know, this is the only way to prevent the C++ compiler from generating different object symbols than those in the C header file. Again, this may just be ignorance of C++ standards on my part.

What is the proper way to selectively incorporate RTTI without code size bloat?

Is there even a way? I'm relatively fluent in CMake but I guess the underlying question is if binaries that incorporate RTTI are compatible with those that dont (and the pitfalls that may ensue when mixing the two).

What about compile time string formatting?

One of my biggest gripes about C (particularly regarding string manipulation) frequently (especially on embedded targets) variadic arguments get handled at runtime. This makes string manipulation via the C standard library (printf-style format strings) uncomputable at compile time in C.
This is sadly the case even when the ranges and values of paramers and formatting outputs is entirely known beforehand. C++ template programming seems to be a big thing in "modern" C++ and I've seen a few projects on this sub that use the turing-completeness of the template system to do some crazy things at compile time. Is there a way to bypass this ABI limitation using C++ features like constexpr, templates, and lambdas? My (somewhat pessimistic) suspicion is that since the generated assembly must be ABI-compliant this isn't possible. Is there a way around this? What about the std::format stuff I've been seeing on this sub periodically?

Is there a standard practice for namespaces and when to start incorporating them?

Is it from the start? Is it when the boundaries of a module become clearly defined? Or is it just personal preference / based on project scale and modularity?
If I had to make a guess it would be at the point that you get a "build group" for a project (group of source files that should be compiled together) as that would loosely define the boundaries of a series of abstractions APIs you may provide to other parts of a project.
--EDIT-- markdown formatting
submitted by aWildElectron to cpp [link] [comments]

Seasoned Rust programmers: what patterns, idioms, conventions would you impress upon Rust newcomers?

Hey guys,
This post has some background and a broad question, I hope that's okay.
I've been building the core API server for a side project of mine in Rust. It's a HTTP service, more on that later. This is my first time _really_ using Rust (I come from the typeless Wild West that is Nodejs land), and getting started was a bit rough, arguing with the compiler, not understanding what was going on as I tried to piece together different code snippets I liked from across forums, example repos, and what I was reading in "the book".
As I started to understand things a little more, I got more comfortable with the language. Getting hip to rust-analyzer really helped me a lot; I've started to feel less like I'm arguing w the compiler and more like I'm having a conversation with it (I read that in the comments on this sub somewhere but it's also how I feel). I am no longer panicking (in an emotional sense, not a computer sense) as I set out on a new task in the codebase, I'm still learning a lot but I have a degree of confidence and familiarity now. I am very proud of my Warp+sqlx server.
As I got familiar, I started wondering what conventions or patterns I might be missing. I feel that I am missing some stuff. I am curious: from seasoned Rust programmers to newcomers like myself, what patterns, idioms, conventions do you often see missing?
I apologize for the broad question. To help, I do have a specific example of the kind of thing I think I might be missing or am unaware of:
I have models (for sqlx and requests) defined as structs in /models/modelname.rs. When I need them, I pull them into my handlers (in the peer directory /handlers). I notice a lot of libraries I use have `.builder()` functions impl'd for their types; it also looks like `.new()` is a common method (if not convention?). But this is not how I initiate my structs. In the handler, I pull in the struct and initiate it using `let my_struct = MyStruct { ..fields.. }`. Is this pattern elementary? Or would you consider it fine for a closed-source binary package (ie it's not a library going out to the community, so patterns be damned just get it initiated).
If I may, I would love to give a shouts-out to the folks working on sqlx. Great library akin to how I like to deal with database queries (not an ORM guy), but also what a welcoming, healthy, helpful community. I've also really enjoyed using Warp. Once I feel more comfortable, I hope to start contributing to the Rust community.
Update: I just want to say thank you so much to everyone for all the feedback. I’ve implemented methods for my structs - both new() and set_field - and that already makes me feel so much cleaner about my code. I’m also about to really dig into Option and Result types, so my API can provide actionable error messages when a request fails. This said - I am eager to also hear any other patterns or idioms that seem to be missing from novices, even if not called into concern from the background I provided. Again, thank you!!
submitted by mzl0 to rust [link] [comments]

MAME 0.222

MAME 0.222

MAME 0.222, the product of our May/June development cycle, is ready today, and it’s a very exciting release. There are lots of bug fixes, including some long-standing issues with classics like Bosconian and Gaplus, and missing pan/zoom effects in games on Seta hardware. Two more Nintendo LCD games are supported: the Panorama Screen version of Popeye, and the two-player Donkey Kong 3 Micro Vs. System. New versions of supported games include a review copy of DonPachi that allows the game to be paused for photography, and a version of the adult Qix game Gals Panic for the Taiwanese market.
Other advancements on the arcade side include audio circuitry emulation for 280-ZZZAP, and protection microcontroller emulation for Kick and Run and Captain Silver.
The GRiD Compass series were possibly the first rugged computers in the clamshell form factor, possibly best known for their use on NASA space shuttle missions in the 1980s. The initial model, the Compass 1101, is now usable in MAME. There are lots of improvements to the Tandy Color Computer drivers in this release, with better cartridge support being a theme. Acorn BBC series drivers now support Solidisk file system ROMs. Writing to IMD floppy images (popular for CP/M computers) is now supported, and a critical bug affecting writes to HFE disk images has been fixed. Software list additions include a collection of CDs for the SGI MIPS workstations.
There are several updates to Apple II emulation this month, including support for several accelerators, a new IWM floppy controller core, and support for using two memory cards simultaneously on the CFFA2. As usual, we’ve added the latest original software dumps and clean cracks to the software lists, including lots of educational titles.
Finally, the memory system has been optimised, yielding performance improvements in all emulated systems, you no longer need to avoid non-ASCII characters in paths when using the chdman tool, and jedutil supports more devices.
There were too many HyperScan RFID cards added to the software list to itemise them all here. You can read about all the updates in the whatsnew.txt file, or get the source and 64-bit Windows binary packages from the download page.

MAME Testers Bugs Fixed

New working machines

New working clones

Machines promoted to working

Clones promoted to working

New machines marked as NOT_WORKING

New clones marked as NOT_WORKING

New working software list additions

Software list items promoted to working

New NOT_WORKING software list additions

submitted by cuavas to emulation [link] [comments]

Where would I start with finding a privilege escalation exploit so that I can root my LG K4 (LG-M151)?

I first posted about this a little while ago
So I was given this crappy phone as a backup and told I could do whatever I wanted with it, problem is, there's no apparent way to unlock the bootloader, and the stock firmware doesn't have a fastboot binary, so there doesn't seem to be an apparent method of rooting it.
The software this phone runs seems to be quite old however, even for a 2017 model. Here's some info on what it's running
The main reason I want to be able to root this thing is honestly so that I can completely delete a bunch of the stock applications and free up a chunk of storage space. This method "uninstalls" the apps, seemingly removing them, yet they still take up storage space and show up in the list of applications as "not installed". They're inactive, but they're still eating up room.
Now, there seem to be a fair number of vulnerabilities in the kernel it's running, including some that might be useful, like Gain Privilege and Execute Code vulnerabilities. I don't know if these have been patched out of this phone's particular build of the kernel, however.
It seems you can download the stock firmware as well, and I learned that this phone does indeed have a download option that could theoretically flash things to it.
Anyway, I'm no programmer, and I know that it typically takes some type of skill to learn how to use security exploits, so where do I go from here? I just want to root this crappy phone so that I can do different and better things with it than what it's currently capable of.
EDIT: To clarify, I know there isn't an easy solution to root this phone, and I think it's largely because no one has cared to try and find a method. I want to change that. I want to try and find a method myself. Where would I start with that?
submitted by mr_bigmouth_502 to androidroot [link] [comments]

YandereDev Email Response (pm for screenshot proof)

1.How do you feel about the overall health,community,and progress that you have made in Yandere Simulator over the past 6 years?
This is an extremely broad question that covers a large number of different topics. I'd prefer to answer more direct questions about more narrow subjects.
2.What were some major roadblocks in development that either stopped/slowed down your progress? How did you deal with these issues? Looking back,was there anything you would've changed in regards to your coping?
The major roadblocks are character assassination and nonstop daily harassment. I have no coping methods for dealing with either of these things.
Public humiliation is a very profitable entertainment industry. Even if you have no skills or talents whatsoever, you can quickly get millions of views by making a video where you ridicule someone. It's even easier to get views if you ridicule a YouTuber with lots of subscribers, because the YouTube algorithm will push your video to each of that person's followers.
I've been targeted by drama YouTubers who make trashy tabloid-style videos where they demonize and villify me, because they know that these videos will get them tons of attention and money. Nothing they say about me is true, and I can debunk every claim they've made. https://yanderesimulator.com/debunk/ Despite this, I still receive harassment dozens of times every hour of the day.
I dedicate over 10 hours of my day to Yandere Sim, 7 days a week, and I only take 1 day off per month, but people still call me lazy. People send me hateful messages every day on Discord, Reddit, Twitch, Twitter, and e-mail. Many people have been tricked into thinking that I'm an exaggerated caricature of who I actually am, and they take every opportunity to treat me like shit. No matter what I accomplish, there will always be a large number of people who will only focus on my mistakes and dedicate their time to smearing my reputation. I've been unhappy and depressed for the past 70 months, and every day only gets worse. The game that I created has destroyed my life, and I'm getting almost nothing out of it.
Being harassed on a daily basis has made me depressed, killed my enthusiasm for the project, and robbed me of all motivation. I have been harassed in various ways on a daily basis for the past several years. It is guaranteed that I will continue to be harassed every day for the rest of my life, and that the severity of the harassment will only continue to intensify. There is no reason to have any hope for the future. I don't even have a future anymore. The harassment isn't going to stop until I'm dead. Under these circumstances, I can no longer find a reason to keep living.
3. Towards the beginning of development, you said that you wanted to be the sole indie developer of Yandere Simulator. How have your opinions about this changed over time in relation to you reaching out to programmers/companies for help?
I don't remember saying that.
I'd be happy to work with a company.
I receive assistance from other programmers daily. This has been the norm for multiple years.
4. What are the top 3 regrets you have from developing Yandere Simulator. What are some things you think you do well?
A) The project's overly-ambitious scope
B) Prioritizing rapidly shoving things into the game as quickly as possible so that I could maintain a steady upload schedule for YouTube
C) Interacting with fans
5.Do you think that the backlash you have received is justified in any way,why or why not? From your perspective, what is the difference between harassment and constructive criticism?
100% unjustified.
Harassment = Insults, spam.
Constructive criticism = Helpful advice.
6.Do you ever watch any videos that people have against you to see what kinds of criticisms people have to help improve the game?
What do you think of these types of videos?
I do not watch trashy videos created by trashy people for a trashy audience.
7. On your current pace,what is a rough estimate of Yandere Simulators release date if you had to guess?
12 to 24 months, depending on severity of harassment.
1. What is your opinion of including more openly gay characters/adding the option to make Yandere Chan male stalking a male senpai? Will any trans/non-binary characters be added? Will such features ever come?
I never think about this stuff.
2. Have you ever considered the possibility of receiving legal allegations for selling merch that is solely based off the unity asset models? Are you planning of changing the merch once the artstyle is changed?
This is a preposterous suggestion. The characters depicted in the merchandise have nothing to do with the Unity Asset Store models. "Schoolgirl with black ponytail and black stockings" is not a Unity Asset, and is not something that I can be sued for.
3. Many players are uncomfortable with the whole panty mechanic and think that changing the “panty buffs” to other accessories would increase the appeal to other people. Will such things ever come?
Those people need to stop being babies.
4. What is the overall direction the game is going in? In the past you have stated that Yanderedev is a mix of Persona and Hitman. Some people would even say that a mix like this doesn’t work because they are contradictory. If you kill students,Then it’s like hitman,but then you sacrifice the dialogue and depth that the persona series has. What measures are you taking to balance these two game types to provide the best experience for the players?
I made a whole video about it. https://www.youtube.com/watch?v=tNaM97tgHUM
1.Why is Osana listed as the fifth rivals Difficulty for the demo when you stated that you wanted to make a V slice to show the people in the Kickstarter what the game would be like? How hard are you planning of making the final rival?
It would be far easier to show you rather than tell you. Just wait until she is actually released.
2. What was the inspiration and thought process behind Raiburu and her being Osana’s invincible body guard? Wouldn’t having an invincible bodyguard limit the “Hitman” aspect of the game by making it so that you can only kill the rival at certain moments instead of awarding the players knowledge of the game by allowing them to kill her quickly and efficiently ?
You do not understand Raibaru as a gameplay mechanic. She just needs to be a simple speed-bump that prevents the player from charging straight at Osana at full speed. She exists to make the player solve a simple puzzle before they can kill Osana. Exactly like in Hitman, you shouldn't be allowed to charge straight at your target and kill them without consequence. That is Raibaru's purpose. You can get rid of Raibaru in less than 5 minutes.
3. In respect to Megami, what is your explanation of her apathetic nature towards other people? Is she more of someone who is secretly not as “dictatorly” in real life then in school or is there more behind her?
You do not understand Megami. Just wait and see.
4. What’s Megami's food preference?
Nutritious food.
Would you ever consider quitting Yandere simulator' even after all the funding you have received? What job would you undertake if you were to stop programming?
It is not an option.
submitted by TableNews to Osana [link] [comments]

C++ Best Practices For a C Programmer

Hi all,
Long time C programmer here, primarily working in the embedded industry (particularly involving safety-critical code). I've been a lurker on this sub for a while but I'm hoping to ask some questions regarding best practices. I've been trying to start using c++ on a lot of my work - particularly taking advantage of some of the code-reuse and power of C++ (particularly constexpr, some loose template programming, stronger type checking, RAII etc).
I would consider myself maybe an 8/10 C programmer but I would conservatively maybe rate myself as 3/10 in C++ (with 1/10 meaning the absolute minmum ability to write, google syntax errata, diagnose, and debug a program). Perhaps I should preface the post that I am more than aware that C is by no means a subset of C++ and there are many language constructs permitted in one that are not in the other.
In any case, I was hoping to get a few answers regarding best practices for c++. Keep in mind that the typical target device I work with does not have a heap of any sort and so a lot of the features that constitute "modern" C++ (non-initialization use of dynamic memory, STL meta-programming, hash-maps, lambdas (as I currently understand them) are a big no-no in terms of passing safety review.

When do I overload operators inside a class as opposed to outisde?


... And what are the arguments foagainst each paradigm? See below:
/* Overload example 1 (overloaded inside class) */ class myclass { private: unsigned int a; unsigned int b; public: myclass(void); unsigned int get_a(void) const; bool operator==(const myclass &rhs); }; bool myclass::operator==(const myclass &rhs) { if (this == &rhs) { return true; } else { if (this->a == rhs.a && this->b == rhs.b) { return true; } } return false; } 
As opposed to this:

/* Overload example 2 (overloaded outside of class) */ class CD { private: unsigned int c; unsigned int d; public: CD(unsigned int _c, unsigned int _d) : d(_d), c(_c) {}; /* CTOR */ unsigned int get_c(void) const; /* trival getters */ unsigned int get_d(void) const; /* trival getters */ }; /* In this implementation, If I don't make the getters (get_c, get_d) constant, * it won't compile despite their access specifiers being public. * * It seems like the const keyword in C++ really should be interpretted as * "read-only AND no side effects" rather than just read only as in C. * But my current understanding may just be flawed... * * My confusion is as follows: The function args are constant references * so why do I have to promise that the function methods have no side-effects on * the private object members? Is this something specific to the == operator? */ bool operator==(const CD & lhs, const CD & rhs) { if(&lhs == &rhs) return true; else if((lhs.get_c() == rhs.get_c()) && (lhs.get_d() == rhs.get_d())) return true; return false; } 
When should I use the example 1 style over the example 2 style? What are the pros and cons of 1 vs 2?

What's the deal with const member functions?

This is more of a subtle confusion but it seems like in C++ the const keyword means different things base on the context in which it is used. I'm trying to develop a relatively nuanced understanding of what's happening under the hood and I most certainly have misunderstood many language features, especially because C++ has likely changed greatly in the last ~6-8 years.

When should I use enum classes versus plain old enum?


To be honest I'm not entirely certain I fully understand the implications of using enum versus enum class in C++.
This is made more confusing by the fact that there are subtle differences between the way C and C++ treat or permit various language constructs (const, enum, typedef, struct, void*, pointer aliasing, type puning, tentative declarations).
In C, enums decay to integer values at compile time. But in C++, the way I currently understand it, enums are their own type. Thus, in C, the following code would be valid, but a C++ compiler would generate a warning (or an error, haven't actually tested it)
/* Example 3: (enums : Valid in C, invalid in C++ ) */ enum COLOR { RED, BLUE, GREY }; enum PET { CAT, DOG, FROG }; /* This is compatible with a C-style enum conception but not C++ */ enum SHAPE { BALL = RED, /* In C, these work because int = int is valid */ CUBE = DOG, }; 
If my understanding is indeed the case, do enums have an implicit namespace (language construct, not the C++ keyword) as in C? As an add-on to that, in C++, you can also declare enums as a sort of inherited type (below). What am I supposed to make of this? Should I just be using it to reduce code size when possible (similar to gcc option -fuse-packed-enums)? Since most processors are word based, would it be more performant to use the processor's word type than the syntax specified above?
/* Example 4: (Purely C++ style enums, use of enum class/ enum struct) */ /* C++ permits forward enum declaration with type specified */ enum FRUIT : int; enum VEGGIE : short; enum FRUIT /* As I understand it, these are ints */ { APPLE, ORANGE, }; enum VEGGIE /* As I understand it, these are shorts */ { CARROT, TURNIP, }; 
Complicating things even further, I've also seen the following syntax:
/* What the heck is an enum class anyway? When should I use them */ enum class THING { THING1, THING2, THING3 }; /* And if classes and structs are interchangable (minus assumptions * about default access specifiers), what does that mean for * the following definition? */ enum struct FOO /* Is this even valid syntax? */ { FOO1, FOO2, FOO3 }; 
Given that enumerated types greatly improve code readability, I've been trying to wrap my head around all this. When should I be using the various language constructs? Are there any pitfalls in a given method?

When to use POD structs (a-la C style) versus a class implementation?


If I had to take a stab at answering this question, my intuition would be to use POD structs for passing aggregate types (as in function arguments) and using classes for interface abstractions / object abstractions as in the example below:
struct aggregate { unsigned int related_stuff1; unsigned int related_stuff2; char name_of_the_related_stuff[20]; }; class abstraction { private: unsigned int private_member1; unsigned int private_member2; protected: unsigned int stuff_for_child_classes; public: /* big 3 */ abstraction(void); abstraction(const abstraction &other); ~abstraction(void); /* COPY semantic ( I have a better grasp on this abstraction than MOVE) */ abstraction &operator=(const abstraction &rhs); /* MOVE semantic (subtle semantics of which I don't full grasp yet) */ abstraction &operator=(abstraction &&rhs); /* * I've seen implentations of this that use a copy + swap design pattern * but that relies on std::move and I realllllly don't get what is * happening under the hood in std::move */ abstraction &operator=(abstraction rhs); void do_some_stuff(void); /* member function */ }; 
Is there an accepted best practice for thsi or is it entirely preference? Are there arguments for only using classes? What about vtables (where byte-wise alignment such as device register overlays and I have to guarantee placement of precise members)

Is there a best practice for integrating C code?


Typically (and up to this point), I've just done the following:
/* Example 5 : Linking a C library */ /* Disable name-mangling, and then give the C++ linker / * toolchain the compiled * binaries */ #ifdef __cplusplus extern "C" { #endif /* C linkage */ #include "device_driver_header_or_a_c_library.h" #ifdef __cplusplus } #endif /* C linkage */ /* C++ code goes here */ 
As far as I know, this is the only way to prevent the C++ compiler from generating different object symbols than those in the C header file. Again, this may just be ignorance of C++ standards on my part.

What is the proper way to selectively incorporate RTTI without code size bloat?

Is there even a way? I'm relatively fluent in CMake but I guess the underlying question is if binaries that incorporate RTTI are compatible with those that dont (and the pitfalls that may ensue when mixing the two).

What about compile time string formatting?


One of my biggest gripes about C (particularly regarding string manipulation) frequently (especially on embedded targets) variadic arguments get handled at runtime. This makes string manipulation via the C standard library (printf-style format strings) uncomputable at compile time in C.
This is sadly the case even when the ranges and values of paramers and formatting outputs is entirely known beforehand. C++ template programming seems to be a big thing in "modern" C++ and I've seen a few projects on this sub that use the turing-completeness of the template system to do some crazy things at compile time. Is there a way to bypass this ABI limitation using C++ features like constexpr, templates, and lambdas? My (somewhat pessimistic) suspicion is that since the generated assembly must be ABI-compliant this isn't possible. Is there a way around this? What about the std::format stuff I've been seeing on this sub periodically?

Is there a standard practice for namespaces and when to start incorporating them?

Is it from the start? Is it when the boundaries of a module become clearly defined? Or is it just personal preference / based on project scale and modularity?
If I had to make a guess it would be at the point that you get a "build group" for a project (group of source files that should be compiled together) as that would loosely define the boundaries of a series of abstractions APIs you may provide to other parts of a project.
--EDIT-- markdown formatting
submitted by aWildElectron to cpp_questions [link] [comments]

Step-by-Step Guide for Adding a Stack, Expanding Control Lines, and Building an Assembler

After the positive response to my first tutorial on expanding the RAM, I thought I'd continue the fun by expanding the capabilities of Ben's 8-bit CPU even further. That said, you'll need to have done the work in the previous post to be able to do this. You can get a sense for what we'll do in this Imgur gallery.
In this tutorial, we'll balance software and hardware improvements to make this a pretty capable machine:

Parts List

To only update the hardware, you'll need:
If you want to update the toolchain, you'll need:
  1. Arduino Mega 2560 (Amazon) to create the programmer.
  2. Ribbon Jumper Cables (Amazon) to connect the Arduino to the breadboard.
  3. TL866 II Plus EEPROM Programmer (Amazon) to program the ROM.
Bonus Clock Improvement: One additional thing I did is replace the 74LS04 inverter in Ben's clock circuit with a 74LS14 inverting Schmitt trigger (datasheet, Jameco). The pinouts are identical! Just drop it in, wire the existing lines, and then run the clock output through it twice (since it's inverting) to get a squeaky clean clock signal. Useful if you want to go even faster with the CPU.

Step 1: Program with an Arduino and Assembler (Image 1, Image 2)

There's a certain delight in the physical programming of a computer with switches. This is how Bill Gates and Paul Allen famously programmed the Altair 8800 and started Microsoft. But at some point, the hardware becomes limited by how effectively you can input the software. After upgrading the RAM, I quickly felt constrained by how long it took to program everything.
You can continue to program the computer physically if you want and even after upgrading that option is still available, so this step is optional. There's probably many ways to approach the programming, but this way felt simple and in the spirit of the build. We'll use an Arduino Mega 2560, like the one in Ben's 6502 build, to program the RAM. We'll start with a homemade assembler then switch to something more robust.
Preparing the Physical Interface
The first thing to do is prepare the CPU to be programmed by the Arduino. We already did the hard work on this in the RAM upgrade tutorial by using the bus to write to the RAM and disconnecting the control ROM while in program mode. Now we just need to route the appropriate lines to a convenient spot on the board to plug the Arduino into.
  1. This is optional, but I rewired all the DIP switches to have ground on one side, rather than alternating sides like Ben's build. This just makes it easier to route wires.
  2. Wire the 8 address lines from the DIP switch, connecting the side opposite to ground (the one going to the chips) to a convenient point on the board. I put them on the far left, next to the address LEDs and above the write button circuit.
  3. Wire the 8 data lines from the DIP switch, connecting the side opposite to ground (the one going to the chips) directly below the address lines. Make sure they're separated by the gutter so they're not connected.
  4. Wire a line from the write button to your input area. You want to connect the side of the button that's not connected to ground (the one going to the chip).
So now you have one convenient spot with 8 address lines, 8 data lines, and a write line. If you want to get fancy, you can wire them into some kind of connector, but I found that ribbon jumper cables work nicely and keep things tidy.
The way we'll program the RAM is to enter program mode and set all the DIP switches to the high position (e.g., 11111111). Since the switches are upside-down, this means they'll all be disconnected and not driving to ground. The address and write lines will simply be floating and the data lines will be weakly pulled up by 1k resistors. Either way, the Arduino can now drive the signals going into the chips using its outputs.
Creating the Arduino Programmer
Now that we can interface with an Arduino, we need to write some software. If you follow Ben's 6502 video, you'll have all the knowledge you need to get this working. If you want some hints and code, see below (source code):
  1. Create arrays for your data and address lines. For example: const char ADDRESS_LINES[] = {39, 41, 43, 45, 47, 49, 51, 53};. Create your write line with #define RAM_WRITE 3.
  2. Create functions to enable and disable your address and data lines. You want to enable them before writing. Make sure to disable them afterward so that you can still manually program using DIP switches without disconnecting the Arduino. The code looks like this (just change INPUT to OUTPUT accordingly): for(int n = 0; n < 8; n += 1) { pinMode(ADDRESS_LINES[n], OUTPUT); }
  3. Create a function to write to an address. It'll look like void writeData(byte writeAddress, byte writeData) and basically use two loops, one for address and one for data, followed by toggling the write.
  4. Create a char array that contains your program and data. You can use #define to create opcodes like #define LDA 0x01.
  5. In your main function, loop through the program array and send it through writeData.
With this setup, you can now load multi-line programs in a fraction of a second! This can really come in handy with debugging by stress testing your CPU with software. Make sure to test your setup with existing programs you know run reliably. Now that you have your basic setup working, you can add 8 additional lines to read the bus and expand the program to let you read memory locations or even monitor the running of your CPU.
Making an Assembler
The above will serve us well but it's missing a key feature: labels. Labels are invaluable in assembly because they're so versatile. Jumps, subroutines, variables all use labels. The problem is that labels require parsing. Parsing is a fun project on the road to a compiler but not something I wanted to delve into right now--if you're interested, you can learn about Flex and Bison. Instead, I found a custom assembler that lets you define your CPU's instruction set and it'll do everything else for you. Let's get it setup:
  1. If you're on Windows, you can use the pre-built binaries. Otherwise, you'll need to install Rust and compile via cargo build.
  2. Create a file called 8bit.cpu and define your CPU instructions (source code). For example, LDA would be lda {address} -> 0x01 @ address[7:0]. What's cool is you can also now create the instruction's immediate variant instead of having to call it LDI: lda #{value} -> 0x05 @ value[7:0].
  3. You can now write assembly by adding #include "8bit.cpu" to the top of your code. There's a lot of neat features so make sure to read the documentation!
  4. Once you've written some assembly, you can generate the machine code using ./customasm yourprogram.s -f hexc -p. This prints out a char array just like our Arduino program used!
  5. Copy the char array into your Arduino program and send it to your CPU.
At this stage, you can start creating some pretty complex programs with ease. I would definitely play around with writing some larger programs. I actually found a bug in my hardware that was hidden for a while because my programs were never very complex!

Step 2: Expand the Control Lines (Image)

Before we can expand the CPU any further, we have to address the fact we're running out of control lines. An easy way to do this is to add a 3rd 28C16 ROM and be on your way. If you want something a little more involved but satisfying, read on.
Right now the control lines are one hot encoded. This means that if you have 4 lines, you can encode 4 states. But we know that a 4-bit binary number can encode 16 states. We'll use this principle via 74LS138 decoders, just like Ben used for the step counter.
Choosing the Control Line Combinations
Everything comes with trade-offs. In the case of combining control lines, it means the two control lines we choose to combine can never be activated at the same time. We can ensure this by encoding all the inputs together in the first 74LS138 and all the outputs together in a second 74LS138. We'll keep the remaining control lines directly connected.
Rewiring the Control Lines
If your build is anything like mine, the control lines are a bit of a mess. You'll need to be careful when rewiring to ensure it all comes back together correctly. Let's get to it:
  1. Place the two 74LS138 decoders on the far right side of the breadboard with the ROMs. Connect them to power and ground.
  2. You'll likely run out of inverters, so place a 74LS04 on the breadboard above your decoders. Connect it to power and ground.
  3. Carefully take your inputs (MI, RI, II, AI, BI, J) and wire them to the outputs of the left 74LS138. Do not wire anything to O0 because that's activated by 000 which won't work for us!
  4. Carefully take your outputs (RO, CO, AO, EO) and wire them to the outputs of the right 74LS138. Remember, do not wire anything to O0!
  5. Now, the 74LS138 outputs are active low, but the ROM outputs were active high. This means you need to swap the wiring on all your existing 74LS04 inverters for the LEDs and control lines to work. Make sure you track which control lines are supposed to be active high vs. active low!
  6. Wire E3 to power and E2 to ground. Connect the E1 on both 138s together, then connect it to the same line as OE on your ROMs. This will ensure that the outputs are disabled when you're in program mode. You can actually take off the 1k pull-up resistors from the previous tutorial at this stage, because the 138s actively drive the lines going to the 74LS04 inverters rather than floating like the ROMs.
At this point, you really need to ensure that the massive rewiring job was successful. Connect 3 jumper wires to A0-A2 and test all the combinations manually. Make sure the correct LED lights up and check with a multimeteoscilloscope that you're getting the right signal at each chip. Catching mistakes at this point will save you a lot of headaches! Now that everything is working, let's finish up:
  1. Connect A0-A2 of the left 74LS138 to the left ROM's A0-A2.
  2. Connect A0-A2 of the right 74LS138 to the right ROM's A0-A2.
  3. Distribute the rest of the control signals across the two ROMs.
Changing the ROM Code
This part is easy. We just need to update all of our #define with the new addresses and program the ROMs again. For clarity that we're not using one-hot encoding anymore, I recommend using hex instead of binary. So instead of #define MI 0b0000000100000000, we can use #define MI 0x0100, #define RI 0x0200, and so on.
Testing
Expanding the control lines required physically rewiring a lot of critical stuff, so small mistakes can creep up and make mysterious errors down the road. Write a program that activates each control line at least once and make sure it works properly! With your assembler and Arduino programmer, this should be trivial.
Bonus: Adding B Register Output
With the additional control lines, don't forget you can now add a BO signal easily which lets you fully use the B register.

Step 3: Add a Stack (Image 1, Image 2)

Adding a stack significantly expands the capability of the CPU. It enables subroutines, recursion, and handling interrupts (with some additional logic). We'll create our stack with an 8-bit stack pointer hard-coded from $0100 to $01FF, just like the 6502.
Wiring up the Stack Pointer
A stack pointer is conceptually similar to a program counter. It stores an address, you can read it and write to it, and it increments. The only difference between a stack pointer and a program counter is that the stack pointer must also decrement. To create our stack pointer, we'll use two 74LS193 4-bit up/down binary counters:
  1. Place a 74LS00 NAND gate, 74LS245 transceiver, and two 74LS193 counters in a row next to your output register. Wire up power and ground.
  2. Wire the the Carry output of the right 193 to the Count Up input of the left 193. Do the same for the Borrow output and Count Down input.
  3. Connect the Clear input between the two 193s and with an active high reset line. The B register has one you can use on its 74LS173s.
  4. Connect the Load input between the two 193s and to a new active low control line called SI on your 74LS138 decoder.
  5. Connect the QA-QD outputs of the lower counter to A8-A5 and the upper counter to A4-A1. Pay special attention because the output are in a weird order (BACD) and you want to make sure the lower A is connected to A8 and the upper A is connected to A4.
  6. Connect the A-D inputs of the lower counter to B8-B5 and the upper counter to B4-B1. Again, the inputs are in a weird order and on both sides of the chip so pay special attention.
  7. Connect the B1-B8 outputs of the 74LS245 transceiver to the bus.
  8. On the 74LS245 transceiver, connect DIR to power (high) and connect OE to a new active low control line called SO on your 74LS138 decoder.
  9. Add 8 LEDs and resistors to the lower part of the 74LS245 transceiver (A1-A8) so you can see what's going on with the stack pointer.
Enabling Increment & Decrement
We've now connected everything but the Count Up and Count Down inputs. The way the 74LS193 works is that if nothing is counting, both inputs are high. If you want to increment, you keep Count Down high and pulse Count Up. To decrement, you do the opposite. We'll use a 74LS00 NAND gate for this:
  1. Take the clock from the 74LS08 AND gate and make it an input into two different NAND gates on the 74LS00.
  2. Take the output from one NAND gate and wire it to the Count Up input on the lower 74LS193 counter. Take the other output and wire it to the Count Down input.
  3. Wire up a new active high control line called SP from your ROM to the NAND gate going into Count Up.
  4. Wire up a new active high control line called SM from your ROM to the NAND gate going into Count Down.
At this point, everything should be working. Your counter should be able to reset, input a value, output a value, and increment/decrement. But the issue is it'll be writing to $0000 to $00FF in the RAM! Let's fix that.
Accessing Higher Memory Addresses
We need the stack to be in a different place in memory than our regular program. The problem is, we only have an 8-bit bus, so how do we tell the RAM we want a higher address? We'll use a special control line to do this:
  1. Wire up an active high line called SA from the 28C16 ROM to A8 on the Cypress CY7C199 RAM.
  2. Add an LED and resistor so you can see when the stack is active.
That's it! Now, whenever we need the stack we can use a combination of the control line and stack pointer to access $0100 to $01FF.
Updating the Instruction Set
All that's left now is to create some instructions that utilize the stack. We'll need to settle some conventions before we begin:
If you want to add a little personal flair to your design, you can change the convention fairly easily. Let's implement push and pop (source code):
  1. Define all your new control lines, such as #define SI 0x0700 and #define SO 0x0005.
  2. Create two new instructions: PSH (1011) and POP (1100).
  3. PSH starts the same as any other for the first two steps: MI|CO and RO|II|CE. The next step is to put the contents of the stack pointer into the address register via MI|SO|SA. Recall that SA is the special control line that tells the memory to access the $01XX bank rather than $00XX.
  4. We then take the contents of AO and write it into the RAM. We can also increment the stack pointer at this stage. All of this is done via: AO|RI|SP|SA, followed by TR.
  5. POP is pretty similar. Start off with MI|CO and RO|II|CE. We then need to take a cycle and decrement the stack pointer with SM. Like with PSH, we then set the address register with MI|SO|SA.
  6. We now just need to output the RAM into our A register with RO|AI|SA and then end the instruction with TR.
  7. Updating the assembler is easy since neither instruction has operands. For example, push is just psh -> 0x0B.
And that's it! Write some programs that take advantage of your new 256 byte stack to make sure everything works as expected.

Step 4: Add Subroutine Instructions (Image)

The last step to complete our stack is to add subroutine instructions. This allows us to write complex programs and paves the way for things like interrupt handling.
Subroutines are like a blend of push/pop instructions and a jump. Basically, when you want to call a subroutine, you save your spot in the program by pushing the program counter onto the stack, then jumping to the subroutine's location in memory. When you're done with the subroutine, you simply pop the program counter value from the stack and jump back into it.
We'll follow 6502 conventions and only save and restore the program counter for subroutines. Other CPUs may choose to save more state, but it's generally left up to the programmer to ensure they're not wiping out states in their subroutines (e.g., push the A register at the start of your subroutine if you're messing with it and restore it before you leave).
Adding an Extra Opcode Line
I've started running low on opcodes at this point. Luckily, we still have two free address lines we can use. To enable 5-bit opcodes, simply wire up the 4Q output of your upper 74LS173 register to A7 of your 28C16 ROM (this assumes your opcodes are at A3-A6).
Updating the ROM Writer
At this point, you simply need to update the Arduino writer to support 32 instructions vs. the current 16. So, for example, UCODE_TEMPLATE[16][8] becomes UCODE_TEMPLATE[32][8] and you fill in the 16 new array elements with nop. The problem is that the Arduino only has so much memory and with the way Ben's code is written to support conditional jumps, it starts to get tight.
I bet the code can be re-written to handle this, but I had a TL866II Plus EEPROM programmer handy from the 6502 build and I felt it would be easier to start using that instead. Converting to a regular C program is really simple (source code):
  1. Copy all the #define, global const arrays (don't forget to expand them from 16 to 32), and void initUCode(). Add #include and #include to the top.
  2. In your traditional int main (void) C function, after initializing with initUCode(), make two arrays: char ucode_upper[2048] and char ucode_lower[2048].
  3. Take your existing loop code that loops through all addresses: for (int address = 0; address < 2048; address++).
  4. Modify instruction to be 5-bit with int instruction = (address & 0b00011111000) >> 3;.
  5. When writing, just write to the arrays like so: ucode_lower[address] = ucode[flags][instruction][step]; and ucode_upper[address] = ucode[flags][instruction][step] >> 8;.
  6. Open a new file with FILE *f = fopen("rom_upper.hex", "wb");, write to it with fwrite(ucode_upper, sizeof(char), sizeof(ucode_upper), f); and close it with fclose(f);. Repeat this with the lower ROM too.
  7. Compile your code using gcc (you can use any C compiler), like so: gcc -Wall makerom.c -o makerom.
Running your program will spit out two binary files with the full contents of each ROM. Writing the file via the TL866II Plus requires minipro and the following command: minipro -p CAT28C16A -w rom_upper.hex.
Adding Subroutine Instructions
At this point, I cleaned up my instruction set layout a bit. I made psh and pop 1000 and 1001, respectively. I then created two new instructions: jsr and rts. These allow us to jump to a subroutine and returns from a subroutine. They're relatively simple:
  1. For jsr, the first three steps are the same as psh: MI|CO, RO|II|CE, MI|SO|SA.
  2. On the next step, instead of AO we use CO to save the program counter to the stack: CO|RI|SP|SA.
  3. We then essentially read the 2nd byte to do a jump and terminate: MI|CO, RO|J.
  4. For rts, the first four steps are the same as pop: MI|CO, RO|II|CE, SM, MI|SO|SA.
  5. On the next step, instead of AI we use J to load the program counter with the contents in stack: RO|J|SA.
  6. We're not done! If we just left this as-is, we'd jump to the 2nd byte of jsr which is not an opcode, but a memory address. All hell would break loose! We need to add a CE step to increment the program counter and then terminate.
Once you update the ROM, you should have fully functioning subroutines with 5-bit opcodes. One great way to test them is to create a recursive program to calculate something--just don't go too deep or you'll end up with a stack overflow!

Conclusion

And that's it! Another successful upgrade of your 8-bit CPU. You now have a very capable machine and toolchain. At this point I would have a bunch of fun with the software aspects. In terms of hardware, there's a number of ways to go from here:
  1. Interrupts. Interrupts are just special subroutines triggered by an external line. You can make one similar to how Ben did conditional jumps. The only added complexity is the need to load/save the flags register since an interrupt can happen at any time and you don't want to destroy the state. Given this would take more than 8 steps, you'd also need to add another line for the step counter (see below).
  2. ROM expansion. At this point, address lines on the ROM are getting tight which limits any expansion possibilities. With the new approach to ROM programming, it's trivial to switch out the 28C16 for the 28C256 that Ben uses in the 6502. These give you 4 additional address lines for flags/interrupts, opcodes, and steps.
  3. LCD output. At this point, adding a 16x2 character LCD like Ben uses in the 6502 is very possible.
  4. Segment/bank register. It's essentially a 2nd memory address register that lets you access 256-byte segments/banks of RAM using bank switching. This lets you take full advantage of the 32K of RAM in the Cypress chip.
  5. Fast increment instructions. Add these to registers by replacing 74LS173s with 74LS193s, allowing you to more quickly increment without going through the ALU. This is used to speed up loops and array operations.
submitted by MironV to beneater [link] [comments]

MAME 0.222

MAME 0.222

MAME 0.222, the product of our May/June development cycle, is ready today, and it’s a very exciting release. There are lots of bug fixes, including some long-standing issues with classics like Bosconian and Gaplus, and missing pan/zoom effects in games on Seta hardware. Two more Nintendo LCD games are supported: the Panorama Screen version of Popeye, and the two-player Donkey Kong 3 Micro Vs. System. New versions of supported games include a review copy of DonPachi that allows the game to be paused for photography, and a version of the adult Qix game Gals Panic for the Taiwanese market.
Other advancements on the arcade side include audio circuitry emulation for 280-ZZZAP, and protection microcontroller emulation for Kick and Run and Captain Silver.
The GRiD Compass series were possibly the first rugged computers in the clamshell form factor, possibly best known for their use on NASA space shuttle missions in the 1980s. The initial model, the Compass 1101, is now usable in MAME. There are lots of improvements to the Tandy Color Computer drivers in this release, with better cartridge support being a theme. Acorn BBC series drivers now support Solidisk file system ROMs. Writing to IMD floppy images (popular for CP/M computers) is now supported, and a critical bug affecting writes to HFE disk images has been fixed. Software list additions include a collection of CDs for the SGI MIPS workstations.
There are several updates to Apple II emulation this month, including support for several accelerators, a new IWM floppy controller core, and support for using two memory cards simultaneously on the CFFA2. As usual, we’ve added the latest original software dumps and clean cracks to the software lists, including lots of educational titles.
Finally, the memory system has been optimised, yielding performance improvements in all emulated systems, you no longer need to avoid non-ASCII characters in paths when using the chdman tool, and jedutil supports more devices.
There were too many HyperScan RFID cards added to the software list to itemise them all here. You can read about all the updates in the whatsnew.txt file, or get the source and 64-bit Windows binary packages from the download page.

MAME Testers Bugs Fixed

New working machines

New working clones

Machines promoted to working

Clones promoted to working

New machines marked as NOT_WORKING

New clones marked as NOT_WORKING

New working software list additions

Software list items promoted to working

New NOT_WORKING software list additions

submitted by cuavas to MAME [link] [comments]

"No one will drive us from the paradise which data created for us"

"No one will drive us from the paradise which data created for us"
-- an anonymous programmer

It's unbelievable what you can do with just a single word (data) and one symbol (the pipe |). All sorts of data modelling becomes possible with just these 2:
  1. Explicitly point out if something is nullable or not using Maybe. Opposed to Java / C where every non-atomic is nullable.
  2. Create stacks / lists, which can be defined to be empty or non-empty.
  3. Label your data. For example: data Length = Inch Double | Centimeter Double, spacecrafts don't have to explode anymore because you now know which unit your measure is in. I heard Ada has something like this as well. Or you can just use a single tag for Newton, kilogram, etc.
  4. Create (binary) trees which perform as good as the ones in traditional languages.
  5. Create tuples (triples, quadruples etc).
  6. Options where you have to pick exactly one. Like data Vehicle = Car String | Train Int | Boat Char. Particularly this case is rarely seen in traditional languages and more difficult to implement.
  7. Do enumeration like data Season = Autumn | Spring | Summer | Winter.
It is absolutely fantastic. You can create entire worlds with it. And for each case very easy to construct.
submitted by InnerMaze2 to haskell [link] [comments]

My thoughts on why rust isn't well designed or very practical

It's been a while since I wrote an essay but I'll write this in mostly the same format. I'll give you an overview, explain each point with information and examples then summarize it.
Rust claims to be safe but doesn't help more than a language such as Java, rust design is missing good practices that exist during it's initial development, rust offers no improvement over C++ (except having better default options) but in reality makes it worse and in practice is less useful than language that exist before it.

It claims to be safe

On the homepage rust claims to be memory safe. However you look elsewhere the majority of people and content claim it's safe as in you'll get less bugs than another language such as Java. This is completely not true. Below are some explains of why it doesn't help and most of us can agree Java which is also memory safe isn't considered as 'safe' nor resist bugs.

Doesn't check your arrays at compile time

Rust says it will elimination bounds checking on array access when it can prove the value will never be out of bounds. However there's no way to ask the compiler to give me an error when it can't prove the index will never be out of bounds. Why us there no option? I lost count of how many times I forgot to check the bound after I increment the array index or when I need to look ahead when parsing text.
I found while implementing the check in a toy language for school that it took less than 2 hours and improved the compile time since the check is faster than the time it took to generate the code for the runtime bound check.

Has poor error handling

To contrast Zig has amazing error handling. Rust ask you to put things in a Result (Ok(yourvalue)). However if a function returns a Result you don't have to check it. I'm not even sure if you'll get a warning (I assume you do)
With the amounts of unwraps I seen and the fact rust promotes that style with syntax error handling looks like a nightmare waiting to happen. Not ugly that but I don't believe you can ask the compiler or any sort of tool if a library will panic. I don't think I would be able to trust any sort of libraries I didn't audit or write myself. I can't just check at the namespaces/references/modules it includes/uses

Doesn't have any built in scope guard/error defer

Scopeguards is a practice a significant amount of people use to handle errors. Zig has it, it's called errdefer. D has it built in. Numerous C++ libs has an implementation (here's one from Facebook folly (SCOPE_FAIL)). Rust doesn't have it at all. There is a crate but my issue with this is 1) the syntax promotes a DISASTROUS way of handling errors 2) defer isn't part of the standard library. It's essential and not just for as a scopeguard.

It acceptable to lose data! (Subjective)

From what I seen in the community people will regularly say rust will terminate rather than running a corrupt program and that's a good thing. Losing data/memory is never a good thing and it's completely insane that this is more acceptable than implementing something that resembles error handling

Rust design is missing good practices that exist during it's initial development

Rust is not safe and doesn't help you catch errors

Covered above

Missing syntax

I'll skip the nitpicking and focus on the most important two.
When there is a binary OK/Error in a Result or Some/None in an Option you have to use a full blown match to handle it instead of something that's more readable.
In other languages there syntax to allow you to specify if something can be null (zig lets you write ?i32, C# allows you to write int?). There's also syntax to coalesce null with a value (val = myfn(abc) ?? my_default_number). For something as common as errors and null handling it should have been prioritized.

No reflection/introspection

Python/JavaScript/C#/Java all have it. Rust says to use serde which is highly suspicious. Why use a library instead of the language? It appears the answer is you have to implement a trait, which is not reflection or introspection. This makes it tedious and error prone in a few areas. Especially database access and writing http server code

Standard library missing must have (Subjective)

The standard library has a number of enums/collections/traits. There's a few standard (can be seen here if you search 'error') and it has an implementation for a number of collections. But missing everyday items like regular expression, compression/zlib/gzip, base64 encode/decode etc

Rust offers no improvement over C++ and may make it worse

Slow compile time

In C++ it's well known that templates make compile time slow. It's known you can put less in headers so it takes less time to compile. Rust however explodes compile time with traits and whatever else that's making it slow (it isn't borrow checking)

Less+lower quality static analyzers

There's quality commercial static analyzers available for C++. If we stick to free clang provides good sanitizers (array bounds, memory errors and a huge list of undefined and suspicious behaviour)

Misguiding programmers (subjective)

Officially rust says it's memory safe but the community acts like it's 'safe' as in not likely to cause difficult to fix bugs. They also insist there's no 'null' in the language which is silly since boxing an option emits null pointers. It's fine to say 'values' are 'optional' but insisting there's no null pointers is weird and may cause confusion when people try to imagine how their code will be generated.

Rust doesn't fit in anywhere

For large projects the compile time is significantly slower than C++ so it is unusable. For smaller projects python/javascript/Go/C#/java is preferred due to reflection (less boilerplate) and having a significantly larger standard library which will help reduce development time (unless you happen to already know every community library you need before you start which is generally not likely). Language listed are all memory safe.
For medium size projects C#, Java and Go are still viable and C# runs extremely fast that if you needed the execution speed you're likely to skip rust and go directly to C++ for better speed control. With clang sanitizers rust doesn't have much of a selling point past C++ with a number of disadvantage mentioned above. It mostly have better errors that are turned on by default. I haven't compared debugging in rust vs c++ or how long the compiler takes when using C++ sanitizers. If we're going to compare development time C# runtime speed is within a magnitude of speed and have vastly superior IDEs and tools even on mac and linux.

Summary

Rust lack of error handling and no compile error improvements compared to languages like C#. Rust does not appear to improve software quality. Compared to C++ rust may have slower compile times and C++ has better or on par free static analyzers with quality commercial analyzers available. The rust standard library is smaller than many languages. Rust community appears to misguide people into think it's safer than it is, recommends poor practices (panic and losing memory is 'ok') and may confuse implementation details (no 'null'). Practically in every project size another language/compiler would be better due to development time, less tedious boiler plate and tooling
submitted by IndependentDocument5 to ProgrammingLanguages [link] [comments]

Help with home gym setup for Gorgeous Glutes programme

Help with home gym setup for Gorgeous Glutes programme
After an 8 month break from any kind of lifting thanks to my body breaking down, I have decided I would like to try the Strong Curves lower body (Gorgeous Glutes) programme & I am trying to figure out how to do it at home.
I've attached a photo of the space I am currently working with. I am lucky enough to have found a good deal on 150kg of plates/olympic bar last year, plus I have a 16kg kettlebell, a 46cm plyo box (too high for hip thrusts) various resistance bands, and pull-up bagymnastics rings if I feel like doing a bit of upper body work.

https://preview.redd.it/7xgvpew5p1a51.jpg?width=4032&format=pjpg&auto=webp&s=c104e081553e9b2a79f41e3bd8e618792969f6af
I tried doing some sumo deadlifts (40kg) and glute bridges (60kg) yesterday plus some goblet squats and kettlebell swings. I was feeling pretty happy at my muscle memory since I feared I would be back to the beginning when I couldn't figure out the correct movement patterns at all!
I am contemplating spending some cash on some more equipment but would love some help from those more familiar with the programme to decide where would be best to spend.
The options are :
  • Stepper boards (for hip thrusts - only 30cm height) £58
  • A folding bench (£75-£130) - any particularly good designs or things to avoid?
  • Folding back extension bench (£72)
  • Hip thruster bench (~£400)
  • A homemade welded hip thrust bench made by my housemate from 3mm steel (£~200?)
  • A foldaway rack with hip thrust bench attachment & spotter bars (can do decent weighted back squats too) (~£850)
  • 2x Bowflex adjustable dumbbells (£512)
I am currently doing a deep self-renovation my tiny victorian terraced house at the minute so space is tight & I may have to move things around.
Everything is a really inflated price over here at the minute which is a bit of a pain - my kettlebell which I purchased for £50 is now two or even three times as expensive since lockdown!
I have no idea how I could do anything such as reverse hypers or back extensions without buying expensive/space consuming equipment & I am not sure what other exercises could be substituted.

Links to some of the stuff I have been considering :