teleren/devto huggingface dataset:
Polyfill for ReactDOM.render
Published: 2023-06-10 20:07:10

In this article we are going to build a polyfill for ReacDOM.render() before react18 or ReactDOM.createRoot(${domElement}).render(${reactElement})


To do this we need to understand how reactElement is represent by react.

we have 3 cases

```
// case 1
let jsx1 = <div>Test</div>;
let reactElemen1 = { type: "div", props: { children: "Test" } };

// case 2
let jsx2 = (
  <div>
    <h1>Test</h1>
  </div>
);
let reactElemen2 = {
  type: "div",
  props: { children: { type: "h1", props: { children: "Test" } } }
};

// case 3
let jsx3 = (
  <div>
    <h1>TestH1</h1>
    <h2>TestH2</h2>
  </div>
);
let reactElemen3 = {
  type: "div",
  props: {
    children: [
      { type: "h1", props: { children: "TestH1" } },
      { type: "h2", props: { children: "TestH2" } }
    ]
  }
};
```

Now we understand how a react element can look like.
Lets start coding a function which takes reactElement and domNode, then renders all the react element as child of domNode.
Below the recursive code for this.

```
// function for setting styles for an elemement
function setStyle(domNode, styles) {
  Object.keys(styles ?? {}).forEach((styleKey: any) => {
    domNode.style[styleKey] = styles[styleKey];
  });
}

// main function for rendering reactElement to domNode
export function render(reactElement, domNode) {
  const {
    type,
    props: { children, style }
  } = reactElement;
  // first create a domElement from using type.
  let createdElement = document.createElement(type);
  //setting styles
  setStyle(createdElement, style);
  // checking if children is array
  if (Array.isArray(children)) {
    children.forEach((child) => {
      createdElement = render(child, createdElement);
    });
  // if children is object type
  } else if (typeof children === "object") {
    createdElement = render(children, createdElement);
  } else {
    // if children is of type string
    createdElement.innerHTML = children;
  }
  // append createdElement to domNode. 
  domNode.appendChild(createdElement);
  return domNode;
}
```
Here is the codesandbox for this.
[custom renderer](https://codesandbox.io/s/polyfill-for-react-renderer-bpcc3z?file=/src/index.tsx)

There you go you have created your basic custom renderer which renders reactElement to domNode.

Obviously we have not handled Component types but that i will   covering in next article.
My Journey with the Ethereum Writing Cohort
Tags: writing, web3
Published: 2023-06-10 20:05:34



#### Introduction:
In early May, while casually scrolling through Twitter, a post by a friend caught my attention. They had just signed up for the Ethereum Writing Cohort, a program designed to enhance writing skills and encourage consistency. As someone who loves writing but occasionally grapples with inconsistency, I saw this as an opportunity to improve myself. Reflecting on my sporadic writing habits, I realized the importance of honing my skills and maintaining a consistent writing practice.

### The Structure and Process:

The Ethereum Writing Cohort is a three-week program designed to foster consistent writing habits and skill improvement. Each Friday, participants propose article topics on the Ethereum Discord channel. The following Wednesday, participants submit their written articles and share the links on Discord for others to read, provide feedback, and engage. On Thursdays, a one-hour Zoom meeting is held, facilitated by Grant Nissly, to review the week's progress. During the meeting, participants have 20-minute breakout sessions with 2-3 people to exchange feedback and suggestions on their respective articles.

### Key Takeaways:
Participating in the Ethereum Writing Cohort provided me with invaluable insights and skills. Here are the key takeaways from my experience:

**Gaining Confidence:** Interacting with fellow writers and receiving feedback from them helped boost my confidence in my writing abilities. It reminded me that writing is a continuous learning process.

**Learning from Others:** Interacting with amazing writers from diverse backgrounds exposed me to various writing styles and techniques. Through observation and discussion, I discovered new ways to improve my own writing.

**Leveraging AI:** One of the most valuable lessons was learning how to utilize AI tools to improve my writing. From fixing grammar to generating concise paragraphs, I discovered how AI could enhance the quality of my work.

**Embracing Vulnerability:** The program empowered me to embrace vulnerability when sharing my work. By consistently posting my articles and welcoming constructive feedback, I developed the courage to expose my writing to others, knowing that growth comes from being open and receptive to different perspectives.


### Conclusion:
By the end of the program, I had written three articles on Web3. This accomplishment earned me a POAP NFT and reinforced my motivation to continue writing. I discovered the importance of embracing imperfection and remaining open to feedback. Notably, one of my articles on peer-to-peer interactions in Web3 garnered significant attention. I would like to express my gratitude to Ethereum community and Grant Nissly for facilitating this inspiring program. Grant's daily motivational emails and reminders played a pivotal role in keeping me motivated and focused on meeting deadlines. I highly recommend the Ethereum Writing Cohort to anyone seeking to improve their writing skills and foster growth in their writing journey.
Is it ethical to develop this?
Tags: discuss, ethics, help
Published: 2023-06-10 19:55:14

---
title: Is it ethical to develop this?
published: true
description: I am preparing a talk that focuses on the ethical dilemmas software developers face and I am looking for some help.
tags: #discuss #ethics #help
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wc5r9uh480c67g8pafg9.jpg
---

I am preparing a talk that focuses on the ethical dilemmas software developers face and I am looking for some help.

In today's interconnected world, developers hold great power in shaping the technologies and systems that influence our daily lives. With this power comes the responsibility to navigate ethical challenges and make the right choices. 

I would like to focus on exploring and discussing real-world examples and as a part of that, I would love to ask for your opinions on a few questions to back my thoughts.

So without further ado, would you say no to these business requirements if you look at them solely from an ethical point of view? (Please state your answer one by one, without reading the next one)

1. Develop a platform where people can upload and host their files.
2. Develop a platform where people can upload and host their files and make them available to any subscriber to download.
3. Develop a platform where people can buy tickets to participate in a monthly raffle to win cars or even houses.
4. Develop a platform where people can buy tickets to participate in a state-backed monthly raffle to win cars or even houses.
5. Develop a webshop engine.
6. Develop a webshop engine for a webshop that sells counterfeit products.
7. Change the default sort order to prefer the most recommended options on the booking platform.
8. Change the default sort order to prefer the most recommended options on the booking platform if you know that most recommendations are fake and generated reviews.

I would also love to know your whys in each case. What examples came to your mind when you read these?

Thanks a lot! :) 

_Cover image by <a href="https://unsplash.com/es/@clarktibbs?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Clark Tibbs</a> on <a href="https://unsplash.com/photos/oqStl2L5oxI?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>_
Dart should not be ignored
Tags: dart, programming, beginners
Published: 2023-06-10 19:50:16

## Introduction

Introduced in 2011, Dart is a modern language developed by Google, designed for crafting web, server, and mobile applications. As a general-purpose language, Dart is versatile and flexible, supporting a wide array of developments. It's a statically typed, garbage-collected language which combines object-oriented and functional programming paradigms. Dart can be compiled to JavaScript and it presents a user-friendly C-style syntax, making it relatively straightforward to learn and apply.

However, despite these features, Dart is not the favored language among the developers I encounter, and positive feedback is quite scarce. Personally, my preference leans towards Go, but I acknowledge Dart has certain distinctive elements we can glean insights from. Let's explore some unique attributes.

## Dart as a Statically Typed Language

Dart's syntax closely resembles those of Java, C#, and Kotlin. This may be advantageous as these languages are widely recognized, although I confess I'm not particularly enamored with them.

Dart, like many languages, has introduced a concise syntax for variable definition, and it seems to elevate this feature. Not only does it support conventional type declarations such as `var`, `final`, and `const`, Dart also integrates unusual variable types for static languages like `late` and `dynamic`. This surprising blend of characteristics imparts Dart with a uniqueness that can broaden our understanding of varying concepts.

## Mixins in Dart

I first encountered mixins in Ruby, a feature that although could complicate the understanding of the code, I recognized its potential. Mixins provide a means to incorporate new functionality into classes without necessitating inheritance, enhancing flexibility and promoting the object-oriented programming approach.

Dart embraces mixins but in a more declarative way. When we need to use a function from a mixin, we must import the class's extension. This enhances the readability and comprehension of the code, which is a commendable improvement.

## Null Safety Feature

While null safety is not an innovative feature, being used in numerous languages, Dart has integrated it into its core. It feels inherently a part of the language, which is a refreshing experience.

## Conclusion

The objective of this succinct article is to present a few key points aimed at fostering a less toxic environment in our world.

To summarize, Dart may not be my go-to language, nor the most favored among my developer peers. However, its unique features like unusual static type declarations, an improved version of mixins, and native null safety are enlightening and can significantly contribute to our programming knowledge. Despite my preference for Go, I respect and appreciate the diverse learning opportunities Dart presents.

I urge individuals not to despise any programming language, but instead contribute their knowledge and experimentation for its advancement. Dart may not be perfect, but its strengths make it too promising to be dismissed outright.
Threads Clear Concept
Tags: webdev, beginners, programming, tutorial
Published: 2023-06-10 19:45:20

A **thread** is a _single sequential flow of control_ within a program. It is a _lightweight process_ that shares the same address space with other threads in the same process. This means that threads can access the same data and resources, but they can also run concurrently.

**Threads** are useful for tasks that can be broken down into smaller, independent units of work. For example, a web browser might use multiple threads to download images, render pages, and play sounds. This allows the browser to do all of these things at the same time, which makes it more responsive to user input.

**Threads** can also be used to improve performance by running multiple tasks in parallel. For example, a video game might use multiple threads to handle graphics, physics, and AI. This allows the game to run at a higher frame rate, which makes it look smoother and more responsive.

Here are some examples of threads:

- A web browser might use multiple threads to download images, render pages, and play sounds.
- A video game might use multiple threads to handle graphics, physics, and AI.
- A word processor might use multiple threads to spell check, grammar check, and track changes.
- A spreadsheet might use multiple threads to calculate formulas and update data.
- Threads can be a powerful tool for improving the performance and responsiveness of a program. However, they can also be difficult to manage. If not used correctly, threads can lead to race conditions, deadlocks, and other problems.

Here are some tips for using threads effectively:

1. Use threads only for tasks that can be broken down into smaller, independent units of work.
2. Avoid using threads for tasks that require shared data or resources.
3. Use synchronization mechanisms to protect shared data from concurrent access.
4. Use thread pooling to manage a group of threads.
5. Use thread termination to gracefully shut down a thread.
****
Calling C++ functions from your Rust code
Tags: rust, programming, cpp
Published: 2023-06-10 17:24:52

C++ provides an `extern` keyword allowing you to specify functions other programming languages, including Rust, can interact with.

Calling this function requires you to provide parts you want other languages to interact with in your C++ code, compile it, and link it to your Rust project. And, In this article, I’ll go into the details of doing it.

## Why would you want to do this?

You can import from one language to another for several reasons. These reasons may include the following:

* Efficiency: Functions written in one language may be more efficient than if you write them in the other language.
    
* Readability: Sometimes, reading and writing functions in one language are more manageable than in the other.
    
* Availability of support: One of the languages may have the necessary libraries you need to carry out a task that the other may not have.
    

The list goes on, but let’s look at the next section for now and learn how to import and bind C++ functions in Rust.

## Calling C++ functions from your Rust code

In this section, I’ll show you how to run C++ functions from your Rust code.

To start, you need to prepare your C++ file. Let’s imagine you have a `main.cpp` file in your `src/`, and it contains this code in it:

```cpp
// src/main.cpp
extern "C" {
  bool UniqueFunction(int a, int b) {
    return true;
  }
}
```

To prepare this C++ code, follow these steps:
1. Create a `build.rs` file in `src/`.
2. Copy the code below into `build.rs`:
    ```Rust
// src/build.rs
fn main() {
  cc::Build::new()
    .cpp(true)
    .file("src/main.cpp")
    .compile("main.a");
}
```

3. Add a pointer to `build.rs` in `Cargo.toml` under `[packages]`
    ```toml
[package]
# ...
build = "src/build.rs"
```

`build.rs` uses the `cc` library, so install it by adding the package name under `[build-dependencies]` in `Cargo.toml`.

```toml
[build-dependencies]
cc = "1.0"
```

Now you can easily call `UniqueFunction` from your Rust code like below:

```Rust
// src/main.rs
extern "C" {
  fn UniqueFunction(a: i32, b: i32) -> bool;
}

fn main() {
  unsafe {
    println!("Value: {}", UniqueFunction(23, 4));
  }
}
```

## Can you call Rust functions from C++?

A short answer to this question is “Not easily.”To get C++ to call your Rust function is always different. Calling Rust functions from C++ varies depending on how you are calling the function and what your function does.

I’m not covering that in this article, but I’ll give you resources that may help.

* [Rust/C++ interop — Firefox Source Docs documentation](https://firefox-source-docs.mozilla.org/writing-rust-code/cpp-interop.html)
    
* [A little C with your Rust - The Embedded Rust Book](https://docs.rust-embedded.org/book/interoperability/c-with-rust.html)
    
* [FFI - The Rustonomicon](https://doc.rust-lang.org/nomicon/ffi.html)
Mastering React: A Comprehensive Guide to Building High-Performance Web Applications
Tags: webdev, react, frontend
Published: 2023-06-10 18:46:30

Welcome to "Mastering React," your ultimate guide to building high-performance web applications using React. In this comprehensive blog post, we will dive deep into the core concepts and best practices that will empower you to create robust and efficient React applications. Whether you're a beginner or an experienced developer, this guide will help you level up your React skills and deliver outstanding user experiences.

Section 1: Understanding the Power of React

Exploring the advantages of using React for web development
Key features that make React stand out from other frameworks
The virtual DOM: How React optimizes rendering and improves performance

Section 2: Building Blocks of React: Components and JSX

Introduction to React components and their role in application development
Understanding JSX: The declarative syntax for defining component structure
Best practices for creating reusable and modular components

Section 3: State Management and Data Flow in React

Managing application state using React's built-in state management
Exploring popular state management libraries like Redux and MobX
Choosing the right state management approach based on project requirements

Section 4: Optimizing Performance in React Applications

Techniques for improving rendering performance in React
Code splitting and lazy loading to optimize bundle sizes
Performance profiling and optimization using tools like React DevTools

Section 5: Advanced React Concepts and Tools

Exploring React hooks and their benefits in functional components
Server-side rendering (SSR) with React for better initial load times
Testing React applications: Best practices and recommended tools

Conclusion:
Congratulations! You've reached the end of our comprehensive guide to mastering React. By now, you should have a solid understanding of React's core concepts, best practices, and tools to build high-performance web applications. Remember to keep exploring and practicing your React skills to stay up to date with the latest developments in the React ecosystem. Happy coding!
College Decision Finally.
Tags: computerscience, career, robotics
Published: 2023-06-10 18:37:36

So after trying to self teach myself software development for 3 years I kinda realized that I really miss the school setting, and wanna improve my social skills as well. I also more or less know what short and long term goals I want to achieve with college and I wanted to find some people who are more knowledgeable to let me know if they think this is a good idea and maybe get some advice around that.

My short term goals(1-2 Years): 
Work a part time job while studying for a transfer associates degree in  computer science at the local community college, joining the robotics club and maybe studying a foreign language.

My long term goals(3-10 Years):
Graduate with a four year degree in Computer science, taking on various internships preferably ones in the the robotics field hoping it leads to a job at my dream company Tesla or any leader in the robotic/AI field.

A little more context about myself I'm 20 years old currently and I graduated high school when I was 17 in 2020 I was really confused about everything because of Corona and got lots of conflicting advice about college in the software field many people call college a scam and that you can learn everything online, and I believed them although what they said isn't necessarily wrong, it doesn't apply to everyone and that's me. I have so much trouble self teaching, no guidance, no connections, and always constantly feeling like I'm missing something. 

The big question: I wanted to ask everyone in college if I am starting too late as a 20 year old going on 21 is this a good time to go back to school? I'm not looking at the degree as my ticket to a job I'm using the school to get an education around engineering and science something that's really interested me over the years, but I don't want to set myself back and pay off massive debts, so I thought about a option that might be best for me which is the Associates transfer degree located at my community college, I live in Texas so I wanted to just start with lonestar college for 2 years and then transfer to Texas A&M to finish the bachelor's which leads me to my last and final question to you all.

My dream is to obviously get hired at a big company ones that are on the edge of cutting technology my number one pick is Tesla, but other companies in robotics and AI I would not mind working as well, I don't expect to get hired right out of college, but this is just my magnum opus, so my question is if I get my degree from Texas A&M does that reduce my chances over someone who went to an ivy league school because A&M is a state school and it would save me money doing this than to go into insane debt trying to get into an ivy league or private school.

Thank you guys for reading this if you did I appreciate any advice I get from you guys.
Unleashing my Keyboard Kung Fu on the Community.
Tags: python, beginners, introduction, discuss
Published: 2023-06-10 18:32:24

```python
# Developer Introduction

# Greetings, fellow code warriors!

# Initializing variables
name = "Mannu"
passion = "coding"
caffeine_level = 9000

# Printing introduction
print("Hey there, fellow developers!")
print("I'm", name + ",", "a", passion, "enthusiast with a caffeine level of", caffeine_level)

# Sharing coding adventures
print("The digital world has always fascinated me, so I'm on a quest to conquer programming challenges.")
print("From battling stubborn bugs to crafting elegant algorithms, I'm always ready to dive into the wild world of code.")

# Adding a touch of humor
print("But hey, it's not all serious business!")
print("When I'm not lost in lines of code, you can catch me debating the eternal struggle of tabs vs. spaces,")
print("or engaging in heated discussions about the best way to name variables (camelCase for life!)")

# Expressing excitement
print("Now, here I am, knocking on the virtual doors of this amazing developer community.")
print("I can't wait to meet fellow warriors who share my passion for pixel-perfect designs and logical thinking.")

# Farewell message
print("Happy coding,")
print(name + " A.K.A. ! Not Pro")

```

-----

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bf6osqab9da9yjakarug.png)

-----

`Btw I am also looking for gf....`