Archive for the ‘programming’ Category

Java vs JavaScript- All You Should Know

Look around and you will find many web developers, but everyone would not tell you the difference between Java and JavaScript. A famous web developer quoted the difference between these two as- “Java is to JavaScript as Ham is to Hamster”. Basically, there are no links between both languages. Both the languages serve completely different roles in web development and programming. Let us move further and look for the differences and similarities between them-

WHAT IS JAVA?

Java is a general-purpose programming language. Applications built in Java are compiled to bytecode with the help of Java Virtual Machine (JVM). In web development, Java is a server-side language which is prominently used in developing mobile applications for Androids. Apart from this, it is present as a front-end language as Java applet but is not used due to security reasons. Java-vs-JavaScript--650x162

WHAT IS JAVASCRIPT?

It is a scripting language which is considered to be one of the three core components of the web that runs in the browser and makes web pages dynamic and interactive. It is employed by a majority of websites. It is rapidly growing as a server-side language along with Node.js.

JAVA VS. JAVASCRIPT: MAJOR SIMILARITIES

Though they are different languages, there are some differences worth considering-
  • Object-Oriented Programming (OOP)
OOP both languages access to techniques like inheritance, encapsulation, and polymorphism. Both languages work on the object and their relationship with other objects.
  • Front-End Development
Both languages are used for front-end development. JS can be embedded directly into HTML, implemented as a framework or library; Java can be used as a Java applet.
  • Back-End Development
These languages are used on the server-side. Java has been used to power back-end technologies like Apache, WebSphere, and etc; whereas JavaScript-powered servers use Node.js for the same purpose. java-vs-javascript

JAVA VS. JAVASCRIPT: MAJOR DIFFERENCES

Despite having some similarities, let us not forget that both the languages were developed to serve completely different purposes. Where Java was designed to develop standalone applications, JavaScript was built specifically to interface with technologies like HTML. Let’s check out the major differences between two-
  • Compiled vs. Interpreted
While Java is considered as compiled programming language, JavaScript is considered as interpreted scripting language. Java is compiled into bytecode as mentioned above, whereas JS can be interpreted directly by a browser.
  • Type checking
Java uses static type checking where variable type is checked at compile-time. While JavaScript uses dynamic type checking where type safety is verified at runtime. It is not required for the programmer to specify the type of any variable they create in the case of JavaScript. The advantage of type checking is that less time is required to execute a code using less memory if static type checking is chosen. The primary advantage of dynamic type checking is programmer productivity—you are free to assign types at your leisure.
  • Concurrency
It refers to the ability handle the execution of several instruction sequences at the same time. Java makes use of multiple threads to perform tasks in parallel, whereas JavaScript handles concurrency on one main thread of execution with an even loop, and a forking system called Node clustering.
  • Class-Based vs Prototype Based
Java follows class based inheritance i.e. top-down, hierarchical, a class-based relationship whereby properties are defined in a class and inherited by an instance of that class. While in JavaScript, inheritance is prototypical- all objects can inherit directly from other objects.

You should consider Java if your project involves-

  • Android Apps
  • Enterprise Software
  • Scientific Computing
  • Big Data Analytics
  • General Purpose Programming of Hardware
  • Server-Side Technologies like Apache, JBoss, Geronimo, GlassFish, etc.

You should consider JavaScript if your project involves-

  • Dynamic single page applications (SPAs)
  • Front-End technologies like jQuery, AngularJS, Backbone.js, Ember.js, ReactJS etc.
  • Server-Side technologies like Node.js, MongoDB, Express.js, etc.
  • Mobile App Development through PhoneGap, React Native, etc.ot
In a nutshell, both languages are meant for different purposes and there is no way you can use these terms interchangeably.

Five Reasons to Use Spree For Your Storefront

Online stores have become pretty obvious. If you own a business that is related to selling something, then it has become necessary to take your business online. But the question that bothers a person more is which e-commerce platform is ideal for them? According to recent marketing strategies and research, an ideal e-commerce platform is the one which is cost efficient, easy to use, scalable, provide support, etc. Basically, the answer is Spree Commerce. spree-commerce-integration-service Spree Commerce is known for the best features, functionality, and user experience. More than 20,000 online stores are running on Spree Commerce. This is not enough, let us check out the reasons why Spree is the best storefront for online business-

1. It is absolutely free

Image result for spree commerce Yes, you read it right, it is free! It is an open source project which is completely free. You can simply download, set it up, and start your project. You can make any modifications in the code according to your project, you don’t have t buy any license or give a part of your revenue.

2. Ruby on Rails is the master

Image result for ruby on rails Spree is based on Ruby on Rails. It is an elegant, fast, and modern programming language that provides amazing solutions. It completes the work in less time, efforts, and resources; and also enhances the functionality, comparing to other e-commerce platforms. You can easily customize your platform according to your and customer’s needs.

3. Order management

Image result for order management on spree Managing orders, customers, and payments become a time-consuming task. Spree Commerce makes this work easy and efficient. It makes the management system fact. It gives and efficient, simple, and easily functional dashboard. You can easily adjust payment methods, product sorting, tax rates, currencies and other vital settings in just a few clicks.

4. Advanced Tools, Features, and Integration

Image result for order management on spree Apart from amazing management, it has a set of amazing features that improve the performance of your store. There are different options for SEO like keyword targeting, back linking, permalinks, meta-description of products, etc. It also supports major payment methods and gateways. It can be easily integrated with external services like Jirafe, Mandrill, Amazon, Bronto, Odoo, Shipstation, Zendesk, Netsuite, Mailchimp and etc.

5. The community is amazing

Image result for spree community Spree has a huge community with very active developers who develop the platform, add new functionalities, and solve challenges together. They also have support which solves the issues you get. There are free workshops, training, and the famous annual SpreeConf. Spree Commerce provides a complete set of documentation as well.

Conclusion

In conclusion, a good developer can build an efficient and smart solution for your e-commerce site. It gives a robust e-commerce solution. It is best for the start-up or small businesses that are short of finances. It is an amazing solution to boost your sales as well.

Ruby Metaprogramming

Ruby is definitely one of the most widely used languages nowadays. And if you are also working on Ruby, you must have heard the word ‘metaprogramming’. Even if you have used metaprogramming, there are chances that you didn’t understand it completely. Metaprogramming is an important concept of Ruby, and you need to understand the usefulness of this concept. the-black-magic-of-ruby-metaprogramming-1-638

What is ‘metaprogramming’?

It is a technique in which the written code writes itself, you can say programming of programming. This might sound confusing, but it is pretty simple to understand and work with. It helps you to add, edit, or modify the code while it is running. It can be used to create new methods or delete the existing ones. One can also reopen or modify existing classes, catch methods that do not exist. Repetitive coding can also be avoided to keep your program DRY.
Also Read-Capybara Basics For Automated testing of Ruby on Rails Application

How ‘Ruby‘ calls methods?

To understand the concept and scope of metaprogramming, it is important to understand how Ruby find a method when it is called. When a method is called in Ruby, it located that method within the code including the inheritance chain.
  1. class Employee
  2.  def test
  3.    “hello”
  4.  end
  5. end
  • charlie_will = Employee.new
  • charlie_will.test # => “hello”
  The test method is called in the example, Ruby first looks for the parent of the charlie.will object because it is an instance of the Employee class, and it has available a method called test, so this method is called. Things get more complicated however when the object is an instance of a class which has inherited from another class:  
  1. class Animal
  2.  def eats
  3.    “food”
  4.  end
  5.  def lives_in
  6.    “the wild”
  7.  end
  8. end
  9. class Pig < Animal
  10.  def lives_in
  11.    “farm”
  12.  end
  13. end
  14. babe = Pig.new
  15. babe.lives_in # => “farm”
  16. babe.eats # => “food”
  17. babe.thisdoesnotexist # => NoMethodError: undefined method `thisdoesnotexist’ for #<Pig:0x16a53c8>
In the above example, mixed inheritance is introduced. Methods defined higher in the inheritance chain needs to be considered by Ruby. When babe.lives_in is called Ruby first check the Pig class for the method, and it is called because it exists in the Pig class.
But if babe.eats method is called the story would be different. Ruby first checks the Pig class for eats method, as it does not exist in it then ‘Animal’ class will be called. In our case, it will respond as eats method exists in Animal class so it will be called. The method babe.thisdoesnotexist will throw an exception NoMethodError because the method does not exist. It means method defined in the lowest level of inheritance chain will be called if the method doesn’t exist, and an exception will be raised.  

After going through the example, we have discovered that Ruby looks up each method as follows:

  1. Ask object’s parent class if it can respond to the method, call it if found.
  2. If it does not respond, call the next parent class, continue until you reach the top of the inheritance chain.
  3. If nothing in the inheritance chain responds to the method call, the method does not exist.
 

Introducing Singleton Method

Singleton class is designed to give you the hold on to Object Oriented programming. It allows you to create an object that inherits from other classes and call their methods. It specifically does it for a single object. It is also known as Eigenclass.
  1. greeting = “Hello World”
  2. def greeting.greet
  3.  self
  4. end
  • greeting.greet # => “Hello World”
On different thing you would notice here is ‘self’. The greeting.greet method has access to the entire object it has been attached to; in Ruby, it will be referred to that object as ‘self’. In this case, it refers to the String value we attached to it. If we had attached it to anything else, it would have returned that object.
greeting = “I like cheese”
  1. class << greeting
  2.  def greet
  3.    “hello! ” + self
  4.  end
  5. end
  • greeting.greet # => “hello! I like cheese”
Singleton class method allows you to add many methods at once without prefixing all the method names. This syntax also allows you to add anything you would add while declaring the class including attr_writer, attr_reader, and attr_accessor methods.

How does it work?

When you work on the singleton class, Ruby needs a way to add methods to the object we are adding to, something that language doesn’t allow. To do so it creates a new class which is called ‘singleton class’. This class is, made the parent of the object we are working on, given the method and changes instead. It is also made an instance of the previous parent of our object so that the inheritance chain remains unchanged:

some object instance > singleton class > parent class > … > Object/BasicObject

Singleton class add one more step to the Ruby lookup method. Now Ruby looks up in the following way-
  1. Ask the object if its singleton class can respond to the method, calling it if found.
  2. Ask object’s parent class if it can respond to the method, call it if found.
  3. If it does not respond, call the next parent class, continue until you reach the top of the inheritance chain.
  4. If nothing in the inheritance chain responds to the method call, the method does not exist.
Not only can objects gain methods from their inherited classes, but now they can also gain individually unique methods as the program is running.

Putting metaprogramming to work with instance_eval and class_eval

Singleton classes are definitely helpful, but if you want to work with objects dynamically you need to be able to re-open them at runtime within other functions. Ruby does not allow you to have any class statements within a function syntactically, but instance-eval helps to do this. This method is defined in standard Kernel module of Ruby and allows you to add instance methods to an object just like our singleton class syntax.
  1. foo = “bar”
  2. foo.instance_eval do
  3.  def hi
  4.    “you smell”
  5.  end
  6. end
  • foo.hi # => “you smell”
The instance_eval method can take a block to evaluate, which can be used to define new methods as if you are writing a class. These methods will be added to the singleton class of the object.
The methods defined by instance_eval will be insurance methods. You cannot add attr_accessor to an instance method; to do so you need to operate on the class of the object instead of using class_eval:  
  1. bar = “foo”
  2. bar.class.class_eval do
  3.  def hello
  4.    “I can smell you from here”
  5.  end
  6. end
  • bar.hello # => “I can smell you from here”
Although instance_eval and class_eval are quite similar, their scope and application are slightly different. But you can remember which one to use in each situation by keeping in mind that instance methods are made by instance_eval while class methods are made by class_eval.  

Conclusion:

After reading all this, you must be still wondering what and where is metaprogramming? Coming back to the point, metaprogramming allows you to create more flexible code, be it through beautiful APIs or easily testable code. Moreover, it also allows you to do that using powerful programming techniques and syntax. IT allows you to create DRY, highly reusable and extremely concise code.  

Android O Features Every Developer Should Know

Google has launched the third developer preview build with Android O for Android app developers. It has been confirmed that the Android version will be Android 8.0. In the third preview, final Android O APIs and various alluring features were released. The features are categorized in two major categories viz. Fluid experiences and Android Vitals. Let us have a look at them- Android-O-Logo

FLUID EXPERIENCES

Fluid experiences are majorly launched for improving the UX. These features will help the Android app developers to offer better user experience. Check out the features that can be used for mobile app development:

#1 Picture in Picture

This feature allows the user to perform multiple tasks simultaneously, like in smart televisions. In this feature, the screen will be divided into two halves which mean you can play a video and do another task simultaneously. For including this feature in your project, you have to specify the user behavior while switching apps. If one of the apps include video, you have to change the code to handle playback, else updating is not required.

#2 Smart text selection

Smart text selection is the result of Google AI. It will help people to perform tasks related to text selection. It will make the selection task much easier, one need not select the whole content. When you will tap on a phrase, it will be selected automatically. This feature will work for all apps, by default.
Also Read:Current Trends for Android App Development

#3 Autofill framework

Autofill framework is a boon for e-commerce Android app developer. It will enable the app to pull from user data and suggest for different form fields while will make the login process easier and faster. This feature is also available by default, but the performance can be optimized by the developers.

#4 TensorFlow Lite Google

It is a special version of an open source TensorFlow software library that helps mobile apps remain fast and small with machine learning. Image result for android O

ANDROID VITALS

In Android O, features associated with security of Android app marketplace and optimization of app performance are under this category. Some of the features are as follow:

#1 Google Play Protect

With the introduction of this feature, no app will go on Google play store without examining its security. The apps will be scanned every day to overcome threats. Android O will run escalating security checks even on the unofficial app store. It will allow the users to check for malicious apps and even search for a lost phone.

#2 OS Optimizations

Major improvements in Android O includes improvement in boot time of Android devices, memory management, battery consumption, and overall performance. The boot time of Android O on Pixel is two times faster than Android N. Though there are limitations such as background executions, location sensing and scanning for wifi networks.

#3 Android vitals dashboard

Google has launched the dashboard on Play console which will help the developers to check their app’s performance, identify issues and overcome them. It will also play a major role in app optimization and to grow the user base.
Also Read:Kotlin- The Next-Gen Android App Development Language

#4 Android Go

It is a new OS for low-end devices which is a lightweight version of Android O, designed for the smartphones with 1 GB or less RAM. The apps available on Play Store will also be optimized to run on low memory devices.

#5 Instant Apps

Lightweight apps can be published with this feature. It will also allow users to experience app without downloading and installing them. In addition, it will also help the developers to drive revenue without a download.

#6 Dots Notification

This feature is a total savage for some users as it will display notification badges to show pending notifications without opening the app. These are some of the amazing features of Android O. You can also share your knowledge and experience with us by commenting below. We would love to hear from you.

Struggling between hiring an agency or a freelancer? Here is a solution!

Choosing between hiring a technology firm and a freelancer is undoubtedly one of the most confusing things. Everyone go through this struggle. The website is a reflection of a company. It defines their work, and give the visitor a rough idea about the company’s profile. One cannot put the company’s reputation at stake to save a few bucks. In this article, we will try to make your decision easier. There are few things you need to know about project & company before hiring.  Let us check out-

1. Know the scope of your project

Image result for scope of project The first thing you need to know is the scope of your project. Evaluate the needs & requirements of your project. Analyze the team requirement and size. You need to decide what kind of website you want to develop. If your project requires a large team, then a freelancer would not be a good choice for you.

2. Hire the right skill set

The right skill set refers to the difference between designing and development. It makes a huge difference. If you are uncertain about these things, you need to go back to the scope of the project, and then decide.
  • Web Designer: The designer develops the look and flow of the site. They work on HTML & CSS most of the time.
  • Web Developer: They are programmers who are primarily focused on coding, mechanics, and functionality of the website. They work on different frameworks and languages.
Now you can easily select which one do you want.

3. Look at their portfolio & experience

Image result for company portfolio Before jumping into an agreement or contract, you need to check out if they are reliable. Check their previous work, portfolio, website, etc. If you are planning to hire a freelancer, then you should check his/ her work profile on those websites.

4. Get to know them

Image result for teamwork Narrow down the candidates, and get to know more about them. Know more about their previous work, check out their reviews on different platforms. Good communication is critical, especially if you’re working with a remote team. Do they reply to your emails on time? Would it be possible for them to provide templates on time?

5. Hire!

Now, you have crossed all four steps, you are ready to hire the team! Image result for hire! You need to be careful while hiring someone for your work. There will be advantages and disadvantages, but you need to evaluate the pros and cons of both, and then make the decision.  

9 Things You Should Know About Ruby on Rails

There are many programming languages, different frameworks, and uncountable developers. But Ruby on Rails has become one of the most popular languages among the developers. Though most of the people start their programming career with languages like Java, C++, PHP, etc., Ruby on Rails is what startups and some full-fledged companies use while developing websites. Image result for ruby on rails The first question that crosses everyone’s mind after hearing ‘Ruby on Rails’ is ‘What is Ruby on Rails?’. In this article, we are going to discuss some important things about ‘Ruby on Rails’. Let us start-

1. What is Ruby on Rails? Is it one thing or Ruby and Rails are two different things?

To be specific, Ruby is a programming language, whereas Rails is a web application framework designed to work with Ruby. Ruby is simple to learn and is super fun. It is easier than other programming languages. But the only problem with Ruby was that it was not designed for use on the web until Rails came. Rails are the most popular framework for Ruby basically make it possible to write a Ruby application and have it be a website.

2. Is ‘Rails’ good for the beginners?

Before moving to ‘Rails’, the first thing you need to learn is Ruby. The reason behind ‘Rails’ being good for beginners is because Ruby is simple to learn. Ruby is easier because the language is super flexible and not always case sensitive. And Rails is fun for beginners because it is robust and it does so much of the hard work for you. The developers do not have to bang their heads to find a minute mistake in the whole code. Basically, the first you have to learn Ruby and then you will be able to learn Rails.

3. How is Rails developer different from Ruby programmer?

As mentioned above, you have to learn Ruby first because Rails is a framework. Technically, a good developer can easily on Ruby web apps using other web frameworks like Sinatra. But a developer would not be hired just to write Ruby, So, it is important for a Ruby developer to learn Rails for future.

4. How good should a developer be to get hired as Ruby on Rails professional? What makes Rails so special?

To be honest, it takes a lot of time to become a Ruby on Rails expert. Basically, you should be comfortable in working on Ruby. You cannot dive into Rails without learning Ruby, but it is important to learn Rails afterwards. It is just like learning to ride a bicycle before learning to ride a bike. Specifically, you need to know about all the basics including data types, object orientation, debugging, etc. And the thing that makes Rails so special is because of its rapid prototyping. You can develop a Rails app with few hours. There are few frameworks that could make it possible.

5. What could be built with it?

Well, the answer is you can build any web application with Rails. Some of the most popular website built on Ruby on Rails are Shopify, Airbnb, Bloomberg, SoundCloud, etc.

6. Is possible to build mobile apps with it?

This is a bit complicated. It is not possible to literally build a mobile app in Rails. But you can build a web application in Rails, and use it as the backend for a mobile app. There are other options like RubyMotion which makes it easy to build native iOS and Android apps using Ruby. Talking in a straightforward manner, you cannot literally use Rails in developing mobile apps, but it could be an important part of the project.

7. Shouldn’t I learn JavaScript instead?

Well, if you are asking instead, then the answer is no. And if you ask also, then the answer is yes. The reality is a Ruby on Rails developer to need to learn JavaScript one time or another. It is not a prerequisite skill but it will help in future for further progress. And if you are thinking about which one you should be learning first, then the answer is Ruby is easier to learn than JavaScript. JavaScript is the first preference of students, but in the end, you have to learn both.

8. How long would it take to learn?

A few months of dedicated study can make you comfortable with Ruby on Rails. But if you want to be a master, you have to give at least 10,000 hours. Your level of familiarity with different programming languages would have an impact on you being comfortable with Ruby on Rails.
Also Read:Java vs JavaScript- All You Should Know

9. How to get started with this?

If you are already familiar with programming languages, then it would be easy for you to learn Ruby on Rails. But if you don’t know even a single thing about coding, then first you need to learn HTML & CSS. And then you need to learn Ruby, Git & command line.
The most important thing you need to do while learning something is having a project by your side. It would help you to learn, and find out your weak spots. These are the most common questions that come to everyone’s mind. So, if you have any question, just comment below and we will try to answer it!

Kotlin- The Next-Gen Android App Development Language

Android app development is a major part of today’s technical and economical world. People use different languages for developing apps, though Java remains the most used language to develop logic. While running a Java application, the app is compiled into a set of instructions called Bytecode and runs in a virtual machine. In last few years, new programming languages have been introduced which also run on Java virtual machine. The reason behind using these languages is that the resulting app looks same for the virtual machine with simple code and some fixes that developers face while coding in Java. Image result for kotlin   Recently, one such language is introduced by JetBrains, known for IntelliJ IDEA (Android Studio is based on IntelliJ), called Kotlin. It is a statically typed programming language that runs on the JVM. It can be compiled to JavaScript source code. It has many other amazing features, and we will be knowing about them in this article.

Also Read:Swift 3.1: Swift Package Manager – Part 2

Why Kotlin instead of any other language?

Since Java is the only language most of the people use while developing the mobile apps, developers had no actual alternatives to Java app. Java comes with a lot of historical baggage and some issues. Java 8 solved some of those problems, and some were corrected in Java 10. But these two options also have loopholes. One of them is in order to use these two versions, one must have the minimum SDK to Android 24 to use Java 8 which is not an option for many developers. And Java 10 is even far from their reach. So, Kotlin was made to fill these gaps through model language. There are some core principles that Kotlin work with-
  1. Concise- Reduce amount of boilerplate code
  2. Safe- Avoid entire classes of error such as null pointer
  3. Smart- Make your code more readable and understandable
  4. Tool-friendly- One can choose any Java IDE or build from the command line
  5. Interoperable- Leverage existing frameworks and libraries of JVM, Android, and browser.

How to work on Kotlin?

Download the starter project. Extract and open the starter project in Android Studio. It is a simple app that allows users to search for books, book covers and share books with friends to explore Kotlin. Image result for kotlin vs java

It consist of three source code files, let us check it out-

MainActivity.java- an activity that displays the screen for searching and displaying a list of books. DetailActivity.java- an Activity that displays the book cover for the ID passed to it. JSONAdapter.java- a custom BaseAdapter that transforms a JSON object into a listview item. Build and run the project to see what you’re working with.

Also Read:How Swift 3.1 is different from earlier version? – Part 1

How to set up the environment of Kotlin?

Android Studio doesn’t have any idea of what to do with Kotlin. So the first thing you need to do is to install the Kotlin plugin and configure Kotlin in your project.

-Installing the Plugin

1. Go to Android Studio/ Preferences and Select the Plugins entry. kotlin for android 32. Click on Install JetBrains plugin on Plugins screen intro_to_kotlin_4 3. Search and select Kotlin from the list and click Install. intro_to_kotlin_5 4. When you are done with downloading and installing Kotlin, then you need to follow the prompts to restart the IDE. intro_to_kotlin_28

– Configure Kotlin in Project

Now the IDE knows what to do with Kotline, but your project app doesn’t, so you have to modify the project’s build configuration. How do modify the project’s build configuration? Let us check out- 1. Go to Tools-> Kotlin-> Configure Koltin in Project intro_to_kotlin_7 2. A Choose Configurator pop up will appear, select Android with Gradle from the drop down. intro_to_kotlin_8 3. On Configure Kotlin in Project popup, select the plugin version you want to use and click OK. Configure Kotlin in Project 4. These actions will make some changes to your build.gradle files.   build.gradle (Project: omg-android-starter): buildscript {  ext.kotlin_version = ‘1.0.3’ // 1  repositories {    jcenter()  }  dependencies {    classpath ‘com.android.tools.build:gradle:2.1.3′    classpath “org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version // 2    // NOTE: Do not place your application dependencies here; they belong    // in the individual module build.gradle files  } } allprojects {  repositories {    jcenter()  } }   build.gradle (Module: OMG Android):    apply plugin: ‘com.android.application’ apply plugin: ‘kotlin-android’ // 3 android {    compileSdkVersion 23    buildToolsVersion “24.0.2”    defaultConfig {        minSdkVersion 14        targetSdkVersion 23    }  sourceSets {    main.java.srcDirs += ‘src/main/kotlin’ // 4  } } dependencies {  compile ‘com.android.support:appcompat-v7:23.2.0′  compile ‘com.loopj.android:android-async-http:1.4.4′  compile ‘com.squareup.picasso:picasso:2.1.1′  compile “org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version // 5 } repositories {  mavenCentral() }   Here is a summary of what this code is about-  
  1. Declares configured Kotlin version
  2. Declares classpath dependency artifact that contains the Kotlin Gradle plugin with the version declared earlier
  3. Specifies the use of Kotlin Android plugin via apply plugin command
  4. Defines that source files found in src/main/Kotlin will be compiled. Gradle will compile source Kotlin files found in src/main/java.
  5. Added the Kotlin Standard library as a compile-time dependency to the project.

Also Read:Ruby Metaprogramming

Click on Sync Now to build a project and run it! intro_to_kotlin_25 Nothing changed visually here, it just made your work bit easier!

Here are 10 reason why Kotlin is cool-

Image result for kotlin
  1. Kotlin is open source
  2. Full Java Interoperability
  3. Kotlin compiles to JVM bytecode or JS
  4. Data Classes in Kotlin
  5. Defaulted parameters
  6. Kotlin imposes no runtime overhead
  7. Null Safety in Kotlin
  8. Extension functions
  9. Swift is like Kotlin
  10. Kotlin wants you to write less code
Inputs & Source

Ruby on Rails vs Java Enterprise, Which one is Better?

Which is the best framework for your website? Have you ever given this thing a thought? Well, there are many languages which helps to design the framework for a website. There is Ruby on Rails, JEE, ASP.NET, Django and much more. But there are few languages that most of the programmers prefer. ASP.NET is a Microsoft platform which takes it straight to the risk zone. You cannot risk being locked into a Microsoft platform whereas other platforms are niche. So everything comes down to Java Enterprise (JEE) and Ruby on Rails (RoR).

Here are some differences through which you can figure out which one is better for your website:

#1 The focus of Ruby on Rails is on fast and agile development whereas Java Enterprise focus on flexibility and integration with enterprise IT.
#2 The common tasks in RoR are made very simple as compared to JEE. In JEE, even the simplest jobs need extraordinary efforts like to write XML configuration or auto-generate boilerplate code.
#3 RoR is used by start-up employees; JEE is used in the IT nerve-centres of investment banks. Image result for java vs ruby on rails #4 As a developer, RoR is pretty easy to learn, while the main problem a newcomer faces in JEE is to choose between huge number of different libraries and different ways to do the same thing. There is no particular libraries which are widely used.
#5 There are few people who work on Ruby on Rails, while every computer science student learns Java.
#6 In manageability of the code, JEE is better as it is easier to find out the things. Image result for java vs ruby on rails #7 Fortunately, both frameworks offer reasonable support for automated regression testing; Ruby on Rails probably a bit more so, because it relies primarily on automated tests (rather than a type system) to ensure things don’t fall apart horribly.

There are many aspects on which you can compare these two. Now the choice is yours. What do you think, which one would be the best for you? Tell us in comments!


Single Sign-On In Rails Application

Single sign-on (SSO) is a property of access control of multiple related, but independent software systems. With this property a user logs in once and gains access to all systems without being prompted to log in again at each of them. Such as we once log in to google, we are permitted to access the Youtube, Docs, Google Drive etc. dnd1999110501 We may think about sharing the session cookies among the all domains but its generally not a good idea. One can steal cookies to sign in from other system or browser. Single SignOn Helps us in getting around this problem and implement a much robust system. How do we implement Single Sign-On in Rails App? We will try to get our hand around on how to build a prototype around a rails app to implement single sign-on. We will be looking a sample rails application powered by CASino gem Why we are using CASino ?
  1. Distributed under MIT LIcense
  2. Active Development since
  3. External authentication sources (LDAP, SQL)
  4. Two-factor authentication
  5. Session-overview for logged-in users
  6. Full localization support
  7. REST-API
So what is CASino exactly? CASino is a simple Single sign-on server application. It supports the CAS protocol and can therefore be used in combination with almost every web programming language out there. CAS is an authentication system originally created by Yale University to provide a trusted way for an application to authenticate a user. CAS centralizes authentication: It allows all your applications to ask users to login to a single sign-on server The implementation. Here we have two apps client and server. We assume that the app is using devise for the demonstration purposes. The Logic can easily be extended to other authentication methods though. The app is as simple as configuring a few variables in the CASino gem.
  1. user request to client domain .
  2. it redirects to the server if not authorised.
  3. Start with adding the gems client app
  4. redirects to back url to whichever client request url is
Step #1 Implementing the client application. Gemfile # If You face some compatability issues then use ruby 2.1

gem 'devise_cas_authenticatable', git: '<a href="https://github.com/jpamaya/devise_cas_authenticatable">https://github.com/jpamaya/devise_cas_authenticatable</a>'

routes.rb

devise_for :users, skip: [:sessions], controllers: { cas_sessions: 'sso_cas' }

devise_scope :user do

get "sign_in", to: "devise/cas_sessions#new"

delete "sign_out", to: "devise/cas_sessions#destroy"

end

devise.rb # ==> Configuration for SSO server authentication

config.cas_base_url = "http://localhost:4000/"

config.cas_create_user = false

config.cas_destination_logout_param_name = 'service'

config.cas_enable_single_sign_out = true

User.rb

devise :cas_authenticatable

Now run client application on localhost:3000 and begin with typing users/sign_in Since we overwrote devise’s sign in mechanism, so instead of presenting devise’s normal sign in page, we are redirected to localhost:4000 which is the backend app to authenticate the users. Lets prepare the backend app to authenticate the users.  Step #2 Start with implementing code in server app limitation use ruby ruby “2.1.5” and rails “3.2.11” check rails -v ‘~>(‘ 3.2.11′). for server app Gemfile #It users these db to store sessions and some tokens. casino will take care all about these

gem 'sqlite3'   # for sqlite support

gem 'mysql2'    # for mysql support

gem 'pg'        # for postgresql support

gem 'casino'

Run bundle install and rails g casino:install The CAS configuration is stored under config/cas.yml. This is where you configure how your SSO handles logins. An example configuration can be found in the file config/cas.yml.example provide the valid db credentials and run the migrations. Run this app on localhost:4000 , Just follow the old steps
  1. Goto localhost:3000/users/sign_in
  2. You will redirected to localhost:4000 enter credentials click sign in
  3. You will be redirected back on successful login
In the links below you can find some ready made examples for you to clone these  apps and have better understanding of SSO.
Server exampleruby “2.1.5”git clone https://github.com/codescrum/casino-sso-server-example.gitRails 4 client examplegit clone https://github.com/codescrum/casino-sso-client-rails4-example.gitRails 3 client example git clone https://github.com/codescrum/casino-sso-client-rails3-example.git
Let us know in comments if you face any troubles in the implementation !! PS: Single Sign-out has been left as a thought for another day and we will discuss that in a follow up blog.

The technology stack powering the on demand applications

Uber and Ola have given rise to a slew of Ondemand applications which claim themselves to be Uber/Ola of X. Some of the verticals where these applications have found their usability include but not limited to taxi, transportation, Logistics, Home Services, Health apps and so on. In this blog we will go deeper into the various components and technology involved in on Demand Apps. Components Involved in Building and On Demand App In most of the cases there are 3 components involved in building an On-Demand App:
  • A cloud backend for Data Interaction APIs and live dispatch of Jobs
  • An Android/iOS App user to make a job(e.g book a ride with Uber/Ola)
  • An app with the drivers to receive the jobs created by the users and attend to them.
  Lets analyze each of these components in detail and how one can go around building each of them. Web Backend Web Backend is the most critical part of the On Demand applications because backend is what powers both the consumer and the driver apps. The web backend must meet the following requirements for a successful implementation:
  • A Light footprint to dispatch the jobs on fly.
  • A Good dispatch components to maximize the efficiency of the field workers(drivers in case of uber).
  • A Socket connectivity to enable the jobs dispatch and job information to the user.
  • A Good structure for a flexible and structured development
  We have recently worked on Bodhik which is an Ondemand Application for Financial Advisory Services.