<?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: Madison Tolentino</title>
    <description>The latest articles on DEV Community by Madison Tolentino (@madison_tolentino_d23fca7).</description>
    <link>https://dev.to/madison_tolentino_d23fca7</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2554121%2F4f53e3a8-5e5e-4266-838e-a14b7c075f54.jpg</url>
      <title>DEV Community: Madison Tolentino</title>
      <link>https://dev.to/madison_tolentino_d23fca7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/madison_tolentino_d23fca7"/>
    <language>en</language>
    <item>
      <title>Why Your Second Language Could Never Compare; A Goofy Guide To Learning A New Language!</title>
      <dc:creator>Madison Tolentino</dc:creator>
      <pubDate>Wed, 11 Dec 2024 15:56:24 +0000</pubDate>
      <link>https://dev.to/madison_tolentino_d23fca7/why-your-second-language-could-never-compare-a-goofy-guide-to-learning-a-new-language-41p0</link>
      <guid>https://dev.to/madison_tolentino_d23fca7/why-your-second-language-could-never-compare-a-goofy-guide-to-learning-a-new-language-41p0</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;Names&lt;/li&gt;
&lt;li&gt;Syntax&lt;/li&gt;
&lt;li&gt;Methods, Functions, and Properties&lt;/li&gt;
&lt;li&gt;Getting Over It…&lt;/li&gt;
&lt;li&gt;Benefits To Python&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Hello there! If you decided to not read the author, I’m Madison! Fun fact about me, I love Javascript; I just spent a whole year mastering the language, I can speak it like I speak English. The ability to translate your thoughts into code within seconds warms your heart! However, one day I decided to learn a new language: Python. Honestly, I just can’t help but to critique it as if I am the coding master. (I am not…)&lt;/p&gt;

&lt;h3&gt;
  
  
  Names
&lt;/h3&gt;

&lt;p&gt;On my journey of learning, I started off small; Just a simple Codecademy to help me learn the basics. That’s when the horrors of subtle differences came to haunt me…&lt;/p&gt;

&lt;p&gt;Now, in Javascript, we have my favorite data structure: arrays! All the beautiful built-in methods, what’s not to love? But you know what it’s called in Python? A list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Javascript
const myArray = [1,2,3]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Python
my_list = [1,2,3]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And look! They are the exact same thing! I know it’s a different language, but it would be so much simpler for the coding world if we all had the same names for everything.&lt;/p&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;Before I even started coding, I thought all languages were notorious for needed a semicolon at the end of every line; Turns out, everyone uses whatever symbols they want! Even I thought it was weird when a ternary operator uses a colon in JS, but apparently Python is obsessed with them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Python
if donation &amp;gt;= 1000:
  print("You've achieved gold status")
elif donation &amp;gt;= 500:
  print("You've achieved silver donor status")
else:
  print("You've achieved bronze donor status")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everywhere I look I find colons; now I have to press &lt;strong&gt;shift&lt;/strong&gt; a lot more often.&lt;/p&gt;

&lt;p&gt;Additionally, now I have to get used to writing everything in snake case. What if I wanted a long, descriptive variable name? Now I have to do double the work just to type it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Javascript
const superLongVariableNameToExpressHowMuchILoveCamelCase = true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Python
super_long_variable_name_to_express_how_much_i_dislike_snake_case = True
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also see how in JS boolean values are in lowercase, but in Python they’re uppercase? I told you guys &lt;strong&gt;shift&lt;/strong&gt; would be used a lot more.&lt;/p&gt;

&lt;p&gt;JS also allows me to add an extra layer of protection to my variables: &lt;strong&gt;const, let,&lt;/strong&gt; or &lt;strong&gt;var&lt;/strong&gt; helps me define the “rules” of the variable, but Python loves the thrill of risks I see…&lt;/p&gt;

&lt;h3&gt;
  
  
  Methods, Functions, and Properties
&lt;/h3&gt;

&lt;p&gt;This one is enough to make my blood boil…&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Javascript
const myArray = [1,2,3]
console.log(myArray.length) // logs 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Python
my_list = [1,2,3]
print(len(my_list)) # prints 3 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Length&lt;/strong&gt; in JS is a property, but in Python it’s a function? What is the meaning of this?!&lt;/p&gt;

&lt;p&gt;Not only does Python &lt;em&gt;loooove&lt;/em&gt; to switch up names and data types, they also love to change functionality. Look at this…&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Javascript
const myArray = [1,2,3]
myArray.pop()
console.log(myArray) //[1,2]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Python
my_list = [1,2,3]
my_list.pop(2)
print(my_list) # [1,2]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, I won’t lie to you, in Python, if &lt;strong&gt;.pop()&lt;/strong&gt; is not given a value, it will remove the last index just like JS. Regardless, I now need to remember this additional functionality instead of having a separate method that can do the job just as well.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting over it…
&lt;/h3&gt;

&lt;p&gt;Now that we got that out of our system, in all seriousness, Python is just as amazing as JS. Everything has pros and cons to it; So as much as I love JS, I need to accept that nothing will ever compare.&lt;/p&gt;

&lt;p&gt;Learning a new language is actually the best thing you can do! Yes, it will be stressful, some parts may be annoying and tedious, but in the end it’ll be so worth it. Everyday you should be working towards expanding your knowledge, and Python has done exactly that for me!&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits To Python
&lt;/h3&gt;

&lt;p&gt;Actually, there are some benefits to using Python versus JS; If you think JavaScript has a lot of built-in methods, you should look at Python methods…&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Javascript
function topKFrequent(nums, k) {
    const freqMap = {};
    for (const num of nums) {
        freqMap[num] = (freqMap[num] || 0) + 1;
    }
    const sorted = Object.entries(freqMap)
        .sort((a, b) =&amp;gt; b[1] - a[1])
        .map(entry =&amp;gt; parseInt(entry[0]));
    return sorted.slice(0, k);
}
console.log(topKFrequent([1, 1, 1, 2, 2, 3], 2)); // Output: [1, 2]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Python
from collections import Counter

def top_k_frequent(nums, k):
    return [item for item, _ in Counter(nums).most_common(k)]

print(top_k_frequent([1, 1, 1, 2, 2, 3], 2))  # Output: [1, 2]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See, here we are finding the most frequent numbers in the given array/list. In JS, we would have to use a frequency object to store the count of each number, then use multiple array methods to find and return the &lt;strong&gt;k&lt;/strong&gt; most frequent numbers.&lt;/p&gt;

&lt;p&gt;However, in Python, we can import a counter, which converts our list into an object, storing each numbers’ frequency. Then, utilizing the &lt;strong&gt;.most_common()&lt;/strong&gt; method which returns our object as a list of &lt;em&gt;tuples&lt;/em&gt; of the &lt;strong&gt;k&lt;/strong&gt; most frequent numbers and their corresponding values. &lt;code&gt;item for item, _&lt;/code&gt; allows us to “destructure” our result returning only the most frequent numbers as a list.&lt;/p&gt;

&lt;p&gt;While the Python version may be more complicated to understand, it provides a pretty concise and more efficient way to solve this problem.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Like I had said before, learning a new language could be pretty annoying (trust me I know…), but there are so many benefits to it! There is a lot of interesting functionality that Python gives you access to, so I recommend trying to learn the language. Just remember my blog when you run into a slight difference between two languages!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>python</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
