<?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: Marcos Nolasco</title>
    <description>The latest articles on DEV Community by Marcos Nolasco (@caromarks).</description>
    <link>https://dev.to/caromarks</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%2F895362%2F08181ec3-04ff-40d0-9ef0-d63d0cea913f.jpeg</url>
      <title>DEV Community: Marcos Nolasco</title>
      <link>https://dev.to/caromarks</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/caromarks"/>
    <language>en</language>
    <item>
      <title>A basic comparison between Python and Javascript - part 1</title>
      <dc:creator>Marcos Nolasco</dc:creator>
      <pubDate>Thu, 28 Jul 2022 01:52:00 +0000</pubDate>
      <link>https://dev.to/caromarks/a-basic-comparison-between-python-and-javascript-part-1-27m7</link>
      <guid>https://dev.to/caromarks/a-basic-comparison-between-python-and-javascript-part-1-27m7</guid>
      <description>&lt;p&gt;Hi there! If you know or study Python and/or Javascript, this guide could help you! It could at least reinforce a little your understanding of their syntax.&lt;br&gt;
Python and Javascript are relativily new languages (not that much), and they're are &lt;a href="https://www.stackscale.com/blog/popular-programming-languages-2021/"&gt;2 of the most used programming languages in the world&lt;/a&gt;. Above I'll shortly compare their:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Declaration of variables and functions&lt;/li&gt;
&lt;li&gt;Data Types&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Declarations
&lt;/h2&gt;

&lt;p&gt;To work with static or dynamic data, we must know how to properly allocate and change those values.&lt;/p&gt;
&lt;h3&gt;
  
  
  Variables
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Python
&lt;/h4&gt;

&lt;p&gt;Python has no command for declaring a variable. It is created when some value is assigned to it, thus it is direct and simple. Cause there is no command for a variable declaration, there is no problem in reassigning them to another value or other type of value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name = 'Marcos'
age = 28
age = "twenty eight"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Javascript
&lt;/h4&gt;

&lt;p&gt;There are diferents ways to declare a variable in Javascript, according to its purpose. The 3 must common ways are using the keywords &lt;strong&gt;var&lt;/strong&gt; (&lt;em&gt;older, mainly used until 2015, accepts value reassignment&lt;/em&gt;), &lt;strong&gt;let&lt;/strong&gt; (&lt;em&gt;used to declare mutable data&lt;/em&gt;), or &lt;strong&gt;const&lt;/strong&gt; (&lt;em&gt;used to declare imutable data&lt;/em&gt;). All variables must also be declared with a name, called &lt;u&gt;identifier&lt;/u&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var race = 'human'
const hobby = "Gaming"
let rank = 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Functions
&lt;/h3&gt;

&lt;p&gt;To do a particular task that may be repetitive, we use a block of code called &lt;u&gt;function&lt;/u&gt;. It does nothing until it is '&lt;em&gt;called&lt;/em&gt;' (invoked, or used) somewhere else. It can be declared with or without arguments. Arguments are data that we can pass into a function.&lt;/p&gt;

&lt;h4&gt;
  
  
  Python
&lt;/h4&gt;

&lt;p&gt;To declare a function with Python we must use the &lt;strong&gt;def&lt;/strong&gt; keyword, and all lines of interest for its scope must be indented.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def simpler_function():
  simple_data = "anything you want"
  return simple_data + "is on the other side of fear"

simpler_function()

def dynamic_function(any_argument):
  return any_argument + "is on the other side of fear"

dynamic_function("anything you want")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Javascript
&lt;/h4&gt;

&lt;p&gt;A JavaScript function is defined with the &lt;strong&gt;function&lt;/strong&gt; keyword. Its scope is placed inside curly brackets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function getResult() {
  result = 42
  return result
}

getResult()

function getAnswer(problem) {
  return 42
}

getAnswer('Universe and everything else')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Data Types
&lt;/h2&gt;

&lt;p&gt;Programming is all about data dealing, so it's important to understand which kind of data each language works with, and how they do it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Numbers
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Python
&lt;/h4&gt;

&lt;p&gt;Basic numbers in Python are of 2 types: &lt;strong&gt;integers&lt;/strong&gt; (&lt;em&gt;0, negative and positive whole numbers without a fractional part&lt;/em&gt;), and &lt;strong&gt;floats&lt;/strong&gt; (&lt;em&gt;negative and positive numbers with a frational part denoted by the deciman symbol &lt;code&gt;.&lt;/code&gt;&lt;/em&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;integer_value = 8
float_value = 8.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Javascript
&lt;/h4&gt;

&lt;p&gt;Javascript has only one type of number. They can be written with or without decimals.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let integer_number = 3
let irrational_number = 3.14
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  String (texts)
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Python
&lt;/h4&gt;

&lt;p&gt;Any kind of data between single or double quotation marks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;passion = "I love to discover new things."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Javascript
&lt;/h4&gt;

&lt;p&gt;Exactly the same as Python strings&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const desire = "I wanna travel all around the world!"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Boolean
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Python
&lt;/h4&gt;

&lt;p&gt;Only have two values, written with the first letter capitalized: &lt;code&gt;True&lt;/code&gt; or &lt;code&gt;False&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Javascript
&lt;/h4&gt;

&lt;p&gt;Also only the same two values, but written all in Small Case letters: &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Containers
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Python
&lt;/h4&gt;

&lt;p&gt;The 3 most used types of data containers in Python are &lt;u&gt;tuples&lt;/u&gt;, &lt;u&gt;lists&lt;/u&gt;, and &lt;u&gt;dictionaries&lt;/u&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  Tuple
&lt;/h5&gt;

&lt;p&gt;An immutable sequence of ordered data. After it is declared, cannot be increased or decreased, and neither its items can be changed. In its declaration, it is used a sequence of data between round brackets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;imutable_data = ("any", 'kind of data', True, 8)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  List
&lt;/h5&gt;

&lt;p&gt;Created using square brackets, it is mainly used to store ordered multiple items in a single variable. Lists are mutable, as we can modify their items (&lt;em&gt;using their index&lt;/em&gt;), add new items (&lt;em&gt;using &lt;strong&gt;append&lt;/strong&gt; keyword&lt;/em&gt;), and delete any of them (&lt;em&gt;using &lt;strong&gt;remove&lt;/strong&gt; keyword&lt;/em&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fruits = ["apple", 'orange']
fruits.append("grape")
fruits.remove('apple')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Dictionary
&lt;/h5&gt;

&lt;p&gt;Dictionaries are used to store data values in &lt;em&gt;key:value&lt;/em&gt; pairs. It's mutable, but do not allow duplicated keys. It is declared within curly brackets, and a key is separated from its value by the &lt;strong&gt;comma&lt;/strong&gt; symbol (&lt;code&gt;:&lt;/code&gt;). The values in dictionary items can be of any data type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pets = {
  "cats": 2,
  "dogs": False,
  "names": ["Mira", "Andromeda"]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Javascript
&lt;/h4&gt;

&lt;p&gt;There are 2 basic data containers in Javascript: &lt;u&gt;Arrays&lt;/u&gt; and &lt;u&gt;Objects&lt;/u&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  Arrays
&lt;/h5&gt;

&lt;p&gt;Its main structure is exactly the same as Python's List: a special variable, which can hold multiple values of different types, ordered between square brackets. To add new items, we use the method &lt;code&gt;push()&lt;/code&gt;, and to remove we use &lt;code&gt;pop()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const biggestWishes = ["freedom", "happiness", "love", "imortality"]
biggestWishes.push("wealthy")
biggestWishes.pop("imortality")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Objects
&lt;/h5&gt;

&lt;p&gt;They are written with curly brackets, to contain multiple &lt;em&gt;key:value&lt;/em&gt; pairs, separated by commas.&lt;br&gt;
Don't allow duplicated keys. The values for each key can be of any data.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;``` const comparison = {&lt;br&gt;
  languages = ['Python', 'Javascript' ],&lt;br&gt;
  level = 'initial',&lt;br&gt;
  topics = 2&lt;br&gt;
}&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


## Final Considerations
There are many other topics, so I intended to write others to also basic and short comments about them. I have no interest to provide solid knowledge with this article; for that, I suggest Google it, there are bazillions of complete and comprehensive guides for each language. Go for it!
But if anyone could suggest any modification or wanna ask questions, please, reply, I'll take a look ASAP. (=
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>javascript</category>
      <category>python</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
