<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: dewball345</title>
    <description>The latest articles on DEV Community by dewball345 (@dewball345).</description>
    <link>https://dev.to/dewball345</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F633805%2F12d47279-c2ad-47a6-9981-3acb924f4fcf.png</url>
      <title>DEV Community: dewball345</title>
      <link>https://dev.to/dewball345</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dewball345"/>
    <language>en</language>
    <item>
      <title>Introducing Ryact - Build Blazing-Fast SPA's with Python</title>
      <dc:creator>dewball345</dc:creator>
      <pubDate>Wed, 19 May 2021 03:00:47 +0000</pubDate>
      <link>https://dev.to/dewball345/ryact-build-blazing-fast-spa-s-with-python-4kf6</link>
      <guid>https://dev.to/dewball345/ryact-build-blazing-fast-spa-s-with-python-4kf6</guid>
      <description>&lt;p&gt;Ryact is a relatively new framework made by me. I have just started its development, so it may not be fully production-ready, but the demos that I have made work.&lt;/p&gt;

&lt;p&gt;Ryact is powered by rapydscript, which is syntactically identical to python. If you know python, you've pretty much mastered rapydscript. However, there are a few kinks here and there, so I suggest you check out their &lt;a href="https://github.com/atsepkov/RapydScript/"&gt;documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ryact is similar to react, with components and state. The main difference, however, is that Ryact doesn't have a virtual dom; instead, each stateful element (element that uses setState) is assigned a unique id and is retrieved and changed(by dom-diffing) when necessary. There isn't much that I have added - just the bare minimum, for now. The source code is around 300 lines of code, including the pre-built hash router. You can find the tutorial at: &lt;a href="https://dev.to/pixari/build-a-very-basic-spa-javascript-router-2k4p"&gt;https://dev.to/pixari/build-a-very-basic-spa-javascript-router-2k4p&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;View the repository here before continuing:&lt;br&gt;
&lt;a href="https://github.com/dewball345/ryact"&gt;https://github.com/dewball345/ryact&lt;/a&gt;, you'll need it for installation.&lt;/p&gt;
&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;The repo is set up so that you can clone it. You can install it by doing&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;git clone https://github.com/dewball345/ryact&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;If you haven't already, here are the steps in install RapydScript.&lt;/p&gt;

&lt;p&gt;Type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install rapydscript -g
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once, you have both cloned the repo and installed rapydscript, navigate to the directory and type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rapydscript execute.pyj --output example/public/index.js --import_path ryact;example --beautify --es6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to view an example page&lt;/p&gt;

&lt;p&gt;or type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rapydscript execute.pyj --output main_code/public/index.js --import_path ryact;main_code --beautify --es6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to see the output of your development code. &lt;/p&gt;

&lt;p&gt;After executing the first you should see an examples page, and for the second you will see a "hello world"&lt;/p&gt;

&lt;p&gt;Here is an example home-page in ryact:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="s"&gt;'''
Here we are importing the base classes 
from the ryact library; An important thing 
to note is that rapydscript does not support star imports, 
as they can be abused. Generally, it isn't a good 
practice to use it, so its not that bad of a 
problem, anyway.
'''&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;ryact.baseclasses&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cre&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;css&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Base&lt;/span&gt;
&lt;span class="s"&gt;'''
MyApp is a stateless component
(it does not change, so therefore 
it doesn't inherit the setState method)
'''&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Base&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;#this is what will be rendered. 
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="s"&gt;'''
        simply put, the cre() function is used to create 
        dom trees. Here, i am creating an h1 element with a 
        20px margin, blue color, and sans-serif font. 
        It's innerText is "Hello ryact..."
        If you were to convert this to html, you would get 
        &amp;lt;h1 
          style="margin:20px;color:blue;font-family:sans- 
          serif"
        &amp;gt;
           Hello ryact! Rapydscript is great, 
           but ryact makes it 
           better!
        &amp;lt;/h1&amp;gt;
        '''&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;cre&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="s"&gt;"h1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="s"&gt;'''
                The css function converts a dictionary 
                into a css string. This is mainly for 
                ease of readability, and is optional to use.
                '''&lt;/span&gt;
                &lt;span class="s"&gt;"style"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;css&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
                    &lt;span class="s"&gt;"margin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"20px"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="s"&gt;"color"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"blue"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="s"&gt;"font-family"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"sans-serif"&lt;/span&gt;
                &lt;span class="p"&gt;}),&lt;/span&gt;
                &lt;span class="s"&gt;'''
                to set the text of a header, use the 
                innerText attribute. There is an innerHTML 
                attribute as well, but I STRONGLY recommend
                to not use it. Instead, keep your 
                children in a third argument, which is a 
                list of html elements.
                '''&lt;/span&gt;
                &lt;span class="s"&gt;"innerText"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="s"&gt;'''
                Hello ryact! Rapydscript is great, 
                but ryact makes it better!
                '''&lt;/span&gt;
            &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="s"&gt;'''
You need to have this function, 
as it is called in execute.pyj. If 
you don't know what that is, it is a 
file that is called in the compilation stage.
It references this function and calls it.
'''&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;run_app&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="s"&gt;'''
    this appends our component into the "root" div. 
    Unlike react you have to manually call the .render() 
    function. This is deliberate, because it allows you 
    to pass properties that are used throughout the whole 
    class as well as passing arguments to the render() 
    function that may only need to be used by that function.
    '''&lt;/span&gt;
    &lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"root"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;render&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;🐍 The most obvious: Use python(rapydscript, which shares the same syntax as python) instead of javscript&lt;/li&gt;
&lt;li&gt;⚛️ Work with a component-based system with state-management when developing SPA's&lt;/li&gt;
&lt;li&gt;✨Use preexisting libraries like bootstrap, tailwind, and more!&lt;/li&gt;
&lt;li&gt;🔥 Create webpages that are blazing fast&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The tutorial can be found on:&lt;br&gt;
&lt;a href="https://github.com/dewball345/ryact/blob/master/TUTORIAL.md"&gt;https://github.com/dewball345/ryact/blob/master/TUTORIAL.md&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please contribute to the project by submitting a PR or even just adding an issue. Thanks!&lt;/p&gt;

</description>
      <category>react</category>
      <category>python</category>
      <category>webdev</category>
      <category>contributorswanted</category>
    </item>
  </channel>
</rss>
