banner



Should You Learn Python Or Javascript

Cover image for Why you should learn JavaScript and Python in 2022

Andrew Baisden

Why you should learn JavaScript and Python in 2022

A new year brings new opportunities for aspiring developers and people who are trying to leave their non tech role so that they can get hired as a developer. Ane of the most common dilemmas that these people face is figuring out what technical stack to acquire and in what direction they should exist going when information technology comes to learning a new programming language from scratch. There are endless options and many different paths that someone could choose to become downwardly.

Arguably ii of the about popular and talked about programming languages in the world are JavaScript and Python. If you search for JavaScript and Python chore roles on whatsoever job board you are highly likely to come across hundreds if not thousands of results. The market is and always will be hot for these two highly sought later on languages and that is not going to modify anytime soon. Both languages share quite a few similarities besides. They are both C based languages which substantially means that they are general purpose, procedural and accept lexical scopes among other things.

Dynamic vs Static

Ane of the biggest standout points is the fact that JavaScript and Python are dynamically typed languages. In a manner of sense a dynamically typed programming language does non require variables to be explicitly declared prior to their usage. And in the reverse a statically typed programming language prevents variables from getting reassigned to a different type. All of this will become more clear in the examples below.

Java Case

                          String              myName              ;              // Variable with a type of string              myName              =              "Tony Stark"              ;              // The cord is chosen Tony Stark              myName              =              24              ;              // Reassigning the string into a number                      

Enter fullscreen style Get out fullscreen mode

If you were to run this Java code you would go either a compile error or runtime mistake. It is not possible to reassign static types to a different type. You can just use another string similar "Steve Rogers".

JavaScript Case

                          allow              myName              ;              // Variable that has no type              myName              =              "              Tony Stark              "              ;              // The variable has a blazon of string              myName              =              24              ;              // The variable has changed its type dynamically to a number                                    

Enter fullscreen fashion Exit fullscreen mode

Now if you were to run this JavaScript code yous would become no errors as information technology is perfectly valid. The variable name is now the number 24.

Python Instance

                          my_name              =              "Tony Stark"              # The variable has a type of string                            my_name              =              24              # The variable has changed its type dynamically to an int                                    

Enter fullscreen way Exit fullscreen mode

Similarly if you lot were to run this Python code y'all would also get no errors equally information technology is perfectly valid. The variable name is now the Int 24.

Data Types

Data types are essentially ways to store data within of an application. The type of data type specifies what can be stored and how information technology tin can be managed. Below you volition find a list of some of the data types that each linguistic communication has.

JavaScript Data Types

Text Type: string
Numeric Blazon: number
Boolean Type: boolean
Mapping Type: object
Sequence Type: array

Python Data Types

Text Type: cord
Numeric Type: int, bladder, circuitous
Boolean Blazon: boolean
Mapping Type: dict
Sequence Type: listing, tuple, range

Comparing the syntax

Next we volition compare the syntax for both programming languages then you can see how like shooting fish in a barrel information technology is to transition between the two of them. Outset let me run through a few differences between the languages.

JavaScript

  • Uses semicolons
  • Uses curly braces for code blocks
  • Uses the CamelCase naming convention for variables for example firstName
  • Uses panel.log for outputting messages to the panel

Functions use this syntax:

                          function              myFunc              ()              {              console              .              log              (              '              Hullo World              '              );              }              const              myFunc2              =              ()              =>              {              console              .              log              (              '              Hello Earth 2              '              );              };              myFunc              ();              myFunc2              ();                      

Enter fullscreen mode Exit fullscreen fashion

Python

  • Does non use semicolons
  • Does not use curly braces
  • Uses the Ophidian Case naming convention for variables for example first_name
  • Uses indentation for code blocks
  • Uses print for outputting messages to the console

Functions use this syntax:

                          def              my_func              ():              print              (              'Hello Globe'              )              my_func              ()                      

Enter fullscreen mode Get out fullscreen mode

Text

Both languages output a string type variable

JavaScript Syntax

                          permit              myName              =              "              Tony Stark              "              ;              console              .              log              (              typeof              myName              );              // cord                      

Enter fullscreen way Get out fullscreen fashion

Python Syntax

                          my_name              =              "Tony Stark"              impress              (              type              (              my_name              ))              # str                                    

Enter fullscreen mode Exit fullscreen mode

Numeric

In this case both variables output a number in JavaScript

JavaScript Syntax

                          let              num              =              9000              ;              let              num2              =              9.0              ;              panel              .              log              (              typeof              num              );              // Number              console              .              log              (              typeof              num2              );              // Number                      

Enter fullscreen mode Exit fullscreen mode

Python Syntax

In this example Python is able to see the deviation between a number and a float because they are built in data types

                          num              =              9000              num_2              =              9.0              print              (              type              (              num              ))              # Int                            impress              (              type              (              num_2              ))              # Bladder                                    

Enter fullscreen mode Exit fullscreen mode

Boolean

The output is almost exactly the aforementioned the only departure is that JavaScript uses a lowercase "t" for true whereas Python uses an uppercase "T".

JavaScript Syntax

                          let              magician              =              truthful              ;              panel              .              log              (              sorcerer              );              // boolean                      

Enter fullscreen fashion Exit fullscreen way

Python Syntax

In this example Python is able to see the difference betwixt a number and a float considering they are built in data types

                          sorcerer              =              Truthful              print              (              wizard              )              # bool                                    

Enter fullscreen mode Go out fullscreen fashion

Mapping

JavaScript uses the object data construction whereas Python uses the dictionary information structure. From looking at the examples you can encounter that they are very akin. The departure is that JavaScript does not require quotes for the keys whereas Python requires them for the keys in the cardinal value pair.

The keys are on the left for example name and the values are on the right for case Tony Stark.

JavaScript Syntax

                          const              myprofile              =              {              name              :              '              Tony Stark              '              ,              age              :              48              ,              superhero              :              '              Iron Homo              '              ,              };              console              .              log              (              myprofile              );                      

Enter fullscreen mode Get out fullscreen mode

Python Syntax

                          my_profile              =              {              "name"              :              "Tony Stark"              ,              "age"              :              48              ,              "superhero"              :              "Fe Human"              ,              };              impress              (              my_profile              );                      

Enter fullscreen style Exit fullscreen mode

Sequence

JavaScript uses an Array which is a type of object data structure whereas Python uses the list data structure. Every bit you tin can see they have many similarities in terms of the syntax you write.

JavaScript Syntax

                          const              myArr              =              [              one              ,              ii              ,              3              ,              4              ,              five              ,              6              ,              7              ,              viii              ,              9              ,              x              ];              panel              .              log              (              typeof              myArr              );              // object                      

Enter fullscreen mode Go out fullscreen mode

Python Syntax

                          myArr              =              [              1              ,              two              ,              3              ,              iv              ,              5              ,              6              ,              7              ,              8              ,              9              ,              10              ]              print              (              type              (              myArr              ))              # list                                    

Enter fullscreen mode Exit fullscreen mode

Where to go from here

There are many platforms you can get to if you desire to learn JavaScript and Python. Personally I recall that freeCodeCamp and Udemy have great courses for both of them. These are the ones that I recommend.

Learn JavaScript

https://www.freecodecamp.org/learn/javascript-algorithms-and-information-structures/

https://www.udemy.com/grade/the-complete-javascript-course/

Learn Python

https://www.freecodecamp.org/learn/scientific-computing-with-python/

https://world wide web.udemy.com/class/complete-python-developer-null-to-mastery/

https://www.udemy.com/course/complete-python-bootcamp/

Should You Learn Python Or Javascript,

Source: https://dev.to/andrewbaisden/why-you-should-learn-javascript-and-python-in-2022-3719

Posted by: hesslockonamind.blogspot.com

0 Response to "Should You Learn Python Or Javascript"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel