JS Questions: What is a Dynamic Programming Language?

This is the first in a series of posts I’m writing that aims to provide concise, understandable answers to Javascript-related questions, helping me better understand both foundational concepts and the changing landscape of language updates, frameworks, testing tools, etc. 

I’m starting with the basics: what is a dynamic programming language?

A dynamic programming language is a high-level language that compiles at run time. Run time is the moment when a program is executed. Compiling means translating the higher-level code (such as the js code written by a programmer) into a lower-level code–machine code–that the computer can run.

Dynamic languages lend themselves to certain types of behaviors, such as metaprogramming–code that can manipulate code. In dynamic languages, variables can be reassigned, and values can even be coerced into different types (such as using parseInt() on the string “1”).

In general, programs written in dynamic languages can be developed more quickly, but won’t run as quickly as those written in static languages.

Some examples of dynamic languages are:

 

  • Javascript
  • Python
  • Ruby
  • Perl
  • PHP

Sources

 

Rails: Rendering a File

This past week, I started building out a solo Rails project, and one of my first steps was to create a general layout for my nav bar, footer, and columns, so that I could use a cohesive structure across my site.

Since I wanted the layout to be pretty standard for all pages (and since the nav and footer are static html), I decided to use Rail’s built-in render file method, so that I wouldn’t have to house my bulky html on the application.html.erb file (or within individual pages, if I ever decide not to use them across the whole site.)

Using render is simple. Create a file containing the html to be rendered (check out render partial if you need to render more than just static content) and place it in a folder in the views directory. Then, in application.html.erb (or wherever you’d like to render your code), simply render the file in erb tags, like this:

Check out the Rails docs for more extensive info about rendering partials and templates.