Girls want diamonds and programmers want Ruby…..

“Hello World” only programmers can feel the vibes of these words. When you start learning any new language the first thing you do is print “Hello World” on the screen. Most of us started programming with C or C++. To print a single statement like this in C++ you have to learn multiple functions and keywords. But Ruby is a very easy language to learn.

Here’s the equivalent Ruby source code:

Much easier than C++, isn’t it ???

Why learn Ruby:
  • According to Ruby’s creator they are trying to make Ruby natural, not simple.
  • Ruby is succinct and reads like English, which makes the code easy to understand for beginners.
  • It has a huge useful ecosystem. Ruby has pre-written frameworks and libraries like Ruby on Rails and Chef. You can use this pre-written code for your own projects. Why spend time reinventing the wheel when someone else has already done it for you?
  • Ruby is also more forgiving of errors, so you’ll still be able to compile and run your program until you hit the problematic part.
8th Largest StackOverflow Community:

StackOverflow is a programming Q&A site you will no doubt become intimate with as a coding beginner. In terms of programming languages, Ruby has over 27k followers, making it the 9th most followed language. Ruby in general is a community that is quite welcoming to beginners.
With the rise of Node.js, Ruby on Rails’ popularity has diminished somewhat.

 Cons of Ruby:
  • Because Ruby is a dynamically typed language, the same thing can easily mean something different depending on the context. As a Ruby app grows larger and more complex, this may get difficult to maintain as errors will become difficult to track down and fix.
  • As a dynamically typed language, Ruby is slow because it is too flexible and the machine would need to do a lot of referencing to make sure what the definition of something is, and this slows Ruby performance down.

Image Source: https://www.ruby-lang.org
Download link: https://www.ruby-lang.org/en/downloads/
Documentation: https://www.ruby-lang.org/en/documentation/

-Pranam Lashkari

Advertisements

Why Node.js

 

Pros of Node.js :

  • JavaScript is used by Node.js which is an easy language to learn. So, a basic Java programmer will find it easy to upgrade to it.
  • An open source run-time environment is offered by Node.js so, it supports the caching of individual modules.
  • The asynchronous event-driven I/O assists concurrent request handling.
  • The server as well as the client-side uses the similar coding piece resulting into an easy deployment of various web applications making them more effective.
  • The community is very active and vibrant with several codes shared by GitHub, etc.
  • Since it’s a single threaded program, it offers several options for having a good grip over run-time executions like call-back methods and event loops.
  • Node package modules (npm), has already increased in size and is still growing.
  • Streaming big files is also possible with Node.js.

Cons of Node.js :

  • One of the biggest drawbacks of Node.js is that it isn’t consistent. It’s several development firms feel that the API keeps enhancing at frequent intervals.
  • It doesn’t support relational databases.
  • If you want to enhance the scalability of Node.js, having an asynchronous programming approach is essential. But developers have a split opinion on this as several feel that this approach is quite complex than the linear blocking I/O programming. Additionally, it also makes the code messy.
  • Unsuitable for large and complicated web applications as Node.js at present, isn’t supportive to both multi-threaded programming.
  • Using it is hard for programmers for high intensive computational tasks.
  • It’s essential to use a callback end up every time with a bulk of nested callbacks.

Image Source: https://nodejs.org
Download Link: https://nodejs.org/en/download

– Pranam Lashkari

Development Trends in 2017

Angular 2 and beyond

2016 also saw the release of Angular 2, and with it came a lot of changes – Google’s front-end JavaScript framework has been completely redesigned.

It now takes advantage of JavaScript ES6’s features, applications are written in TypeScript, and they now moved towards a more component driven architecture.

Yarn package manager

 

Package managers are incredibly popular tools, especially in the front-end JavaScript communities. They make it easier for developers to install, update, configure and uninstall code modules within their applications. They do so by communicating with a registry of code modules and manage the various dependencies code modules usually have.

The most popular JavaScript package managers are NPM and Bower. However, a new package manager has been developed by Facebook, in collaboration with Exponent, Google and Tilde. We expect its popularity to grow in 2017.

Static website generators

 

Static website generators create websites from plain text, usually stored in files and not in databases. In certain situations, static websites built by generators such as Jekyll, allow for some advantages, such as increased speed, security, ease of deployment and their handling of traffic surges. However, they have no real time content or user content (such as comments), which have become a “must” on the web today.

As Content Delivery Networks and APIs become more and more the way of life of the web and make it easier for content and templates to be deployed, many devs think static site generators might be an interesting area to watch in the coming year.

Rails 5

 

The newest release of Rails came with some interesting additions that web developers should get excited about

  1. Turbolinks 5 allows developers to create Single Page like Applications directly from the Rails stack, by allowing links to fetch full HTML pages and replacing the body, without the need for client-side JavaScript frameworks.
  2. ActionCable is a new way to use websockets in Rails to create real time applications. This makes creating notifications and chat features so much easier, all the while still having access to all your ActiveRecord resources.
  3. Rails 5 also merged the popular rails_api gem into its codebase. Developers can now easily create API only applications in Rails and hook them up to their favorite JavaScript or native frameworks.

 

-Pranam Lashkari

Google Speeds Up Mobile HTML With AMP

Google has stepped into the web arena once again with AMP-Accelerated Mobile Pages. It is built on HTML and associated standards and the way that it achieves its speed up is to do more with less. 

A typical web page is a mess of HTML, CSS and ad-hoc JavaScript. Google’s great idea is to reduce the mess to a regulated and approved subset. It is not so much that JavaScript is banned in AMP, but you can only use the JavaScript that is included in AMP. 

 For example, there are just four standard built-in JavaScript components

Component Description
amp-ad Container to display an ad.
amp-img Replacement for the HTML img tag.
amp-pixel Used as tracking pixel to count page views.
amp-video Replacement for the HTML5 video tag.

 At the start of an AMP page you load the AMP JavaScript library which defines these components:

<!doctype html> 
<html>    

<head>
  <meta charset=”utf-8″>
  <link rel=”canonical” href=”/hello-world.html”>
  <meta name=”viewport” 
        content=”width=device-width,
        initial-scale=1,
        minimum-scale=1,
        maximum-scale=1,
        user-scalable=no,
        minimal-ui”>
  Google Speeds Up Mobile HTML With AMP
  </script>
  <style>body {opacity: 0}</style>
  <noscript>
   <style>body {opacity: 1}</style>
  </noscript> 
 </head>
 <body>Hello World!</body> 
</html>

You can’t add any additional scripts, so we are mostly talking about creating static pages. The JavaScript library provides the standard components and deals with downloading resources. You can add CSS but it too is restricted – limited range of selectors, you can’t restyle the major semantic elements, no animation etc. 

In addition all resources have to state there size so that layout can be created and hence optimized before they finish loading. 

There is also a range of extended components can be added to the page by being explicitly loaded:

Component Description
amp-anim Runtime-managed animated image, most typically a GIF.
amp-audio Replacement for the HTML5 audio tag.
amp-carousel Generic carousel for displaying multiple similar pieces of content along a horizontal axis.
amp-fit-text Expand or shrink font size to fit the content within the space given.
amp-iframe Displays an iframe.
amp-image-lightbox Allows for a “image lightbox” or similar experience.
amp-instagram Displays an instagram embed.
amp-lightbox Allows for a “lightbox” or similar experience.
amp-twitter Displays a Twitter Tweet.
amp-youtube Displays a Youtube video.

 There is no word on how to get additional components into the library.

By cutting everything down to this simple level, things obviously can be made to go faster. Google is also offering to host a cache for AMP pages – i.e. a free content delivery network. It will also high AMP news pages but also add that this will not effect search ranking. 

 Given how many publishers use add-hoc JavaScript for serving ads, analytics and implementing paywalls, the restriction to just a core set of features is going to be unattractive. However, the changes to convert a web page to AMP are not difficult to make and the offer of free page delivery from Google seems have a lot of big publishers queuing up to use it. It is also being supported by Linkedin, Twitter, Pinterest and so on. Of course how real any of this support is will take time to discover.

The page speed increases are claimed to be from 15 to 85%. It is reported that the New York Times load time went from 3 seconds to 500 milliseconds. 

Of course page load times are important but so is page profitability. At the moment Google says it will support a range of ad-networks and while the ban on ad-hoc JavaScript does means that analytics and tracking are more difficult, Google claims that its analytic component will provide good page statistics and will get better. 

The project is open source under the Apache License 2 and available on GitHub. 

At this stage it is difficult to know what to make of AMP. It is open source and a subset of HTML/CSS/JavaScript which means if you adopt it you can serve it and any browser can consume it.

-Source: http://www.i-programmer.info/

-Pranam Lashkari

How to start programming (For beginners)

  • Choosing a Language:

1.)First you should know what kind of app or software you want to develop.

2.)Then you should try to find out which language provides you the best features according to your requirement.

3.)If you are totally a beginner and don’t know what programming is then I would suggest you to start with C, C++ or python. (if you struggle with these languages then you should switch to HTML because when you are writing a code of HTML you can see where your code is going. While working with other languages will confuse you at the beginning.)

 

  • Start programming:

1.)First thing you should know the syntax and how your chosen language works.

2.)There is a common thing in almost all the programming language that it always goes step by step from top to bottom and left to right. If you can understand these simple things, then congratulations now you are on the way to become a programmer.

3.)When you start learning a language you can start with coaching classes or you can learn it by yourself by reading book and taking online tutorials. (if you want to learn any language then self-learning is the best thing you can do to be an expert because everything you learn you have to try it first and you learn it by experiencing it.)

4.)Don’t worry when your program crashes. It is really common even with professional programmers.

5.)You should write a code which gives the required output in the least steps. So, that it takes the least time in execution and you should also take care of the memory required for the execution of the program.

6.)Try to use hard-coding for large programs. (Hard-coding means to fix data or parameters in a program in such a way that they cannot be altered without modifying the program. When you are using a value again and again in different parameters, store that value in a variable and use that variable in all the parameters. It will help you in the future when you are trying to modify the program because you have to change the value of a single variable only instead of changing all the parameters which can save your time and also save you from buggy codes.)

 

  • After creating a program:

1.)Best things about the language you will learn is when you find an error or your program crashes. When you are making an actual software you always try to make it user proof and while making it you consider the user of program as dumb, who will always try to give the input which are not supposed to be given and which will crash your program.

2.)So, to avoid the crashing of your program by any user you have to test your program by giving all the possible inputs so in future when users start using it the program doesn’t crash and won’t stop using the program because of frequent crashing.

3.)Try to use that program on different machines because all the machines have their own different structure and your program might not be compatible with all of them.

These are all the things you are required to know when you start programming.

Best of Luck, For your first code.

Happy Coding…

– Pranam Lashkari

Tips for efficient Programming

1) Avoid passing long argument lists to functions. Avoid returning long values from functions. The most efficient function types to use are void, int, or pointer.


2) Avoid initializing global variables within a small function. Instead, assign a value during variable definition.


3) Avoid converting chars to another type. char variables can be located anywhere in RAM, while word variables can only be at even addresses. Because of this, the code will result in unpredictable CPU behavior.


4) Use int instead of char or unsigned char if you want a small integer within a function. The code produced will be more efficient, and in most cases storage isn’t actually wasted.


5) Try to minimize the use of addition and subtraction with floating point numbers. These are slow operations.


6) Use shift instead of multiplication by constants which are 2^N (actually, the compiler may do this for you when optimization is switched on).


7) Use unsigned int for indices – the compiler will snip _lots_ of code.


8) Use ‘switch/case‘ constructs rather than a chain of ‘if/else‘ constructs.


9) Use logical or (‘|’) rather than ‘+’ for bit masks.


10) When defining bit fields, try to use signed integers. This produces more compact code that bit fields of unsigned integers.


11) Use ‘alloca‘ instead of ‘malloc‘ for locals. In embedded applications trying to avoid any dynamic memory allocation is usually even better.


12) Delay loops are very sophisticated routines. Developers often do something like:

int i = 1234;

while (i–);

or

int i;

for (i = 0;  i < 1234;  i++);

NEITHER WILL WORK AS YOU EXPECT when optimization is switched on!!! The optimizer will detect dead code in both examples and will eliminate it. It might even eliminate the loop completely. Adding the volatile attribute to the definition of ‘i’ might help, but don’t count on it if ‘i’ is a local variable. The compiler can still detect the calculations are wasteful, and eliminate them.

– Pranam Lashkari