Dynamic vs. Static-typed Languages

Week 8

Friday, January 29, 2016


Dynamic

One of the two main language types in programing is "Dynamic". Some example of dynamic languages are html, css, ruby, and javascript. The system will run your application until it hits an error.


Here’s an example of a dynamic language


        
            a = 4
            def say_hi(anything)
              if anything < 100
              p 'Hi'
              else
              “Summer sausage” + anything
              end
            end
            say_hi(a)

            ~: > Hi
        
      


As you can see there was an error with Summer sausage adding 4 to it. They system wouldn’t hit that error because it worked on the IF statement. Until you pass in something else to hit the else statement. Your program will still run.



Static

The other main language types in programing is “Static. Static language means that the system will run it for error before running your application on that file.


Here’s an example of Static language


        
          a = 4
          def say_hi(anything)
            if anything < 100
            p 'Hi'
            else
            “Summer sausage” + anything
            end
          end
          say_hi(a)

          ~: >ERROR!!!!
          
        


Here you can see that the system threw out an error message even before the error occur. BTW I’m using Ruby as example because we been working on it for awhile now but it really wouldn’t give an error in Ruby but in an actual Static language it will.