Salesforce

Scala, Salesforce and Scalable Applications

Posted on Updated on

Hi All,

Scala is emerging as a very popular programming language today although it’s been introduced in 2004. It has helped the programmers find the perfect balance between object-oriented programming and functional programming. Scala allows efficient code reuse and extensibility, and its ability to handle data in real-time has made it a popular choice for Big Data projects.

Scala offers the advantage of building on the Java programming language and platform. Not only you can use all the familiar Java libraries directly in your Scala code, you can also intermingle Scala with existing or new Java code. When combined with the open source Spark, Akka toolkit it also allows you to easily spread your application across multiple systems.The Scala programming language is designed around scalability. It gives you the tools you need to spread work across multiple cores with minimal impact on your application design.

If you are optimizing for easy product iterations, while building scalable infrastructure. Scala’s powerful type system, functional idioms, and concise patterns allow your team to quickly model the business solution. The first class immutable data structures and safe asynchronous/parallelized constructs allow you to easily build distributed systems.Over the past several years, Scala has been used by multiple organizations(like LinkedIn, Twitter, Sony, Siemens, Xerox) in the construction of large scale data stores and analytics platforms.

Companies and individuals using Scala to build their own new ideas, they also utilizing other excellent tools like Play Framework, Akka, Apache Spark and Kafka etc which are not only some of the hottest tools and projects on the market right now, but also intentionally built in Scala.

Apache Spark

Spark is a fast and general-purpose engine for large-scale data processing. Developed in the AMPLab at UC Berkeley.

Akka

Akka is an extremely concurrent framework for building distributed applications.

Apache Kafka

Apache Kafka is a publish-subscribe messaging system written in Scala and Java.

Salesforce Thunder

Salesforce introduced Thunder at Dreamforce 2015. Thunder is Salesforce’s big data processing engine. It is designed to capture, filter and respond to events in real time. It is built on open source technologies like Apache Spark, Apache Kafka, Apache Storm, Apache Cassandra, Heroku.

Thunder is optimized for Machine-to-Machine(M2M) and Internet of Things(IoT) environments.

VanillaJs For Better Performance of Lightning Components

Posted on Updated on

Hi All,

Lightning is all about components. You can build applications by assembling components created by you and other developers. A component can contain other components, as well as HTML, CSS, JavaScript, or any other Web-enabled code.

If you have multiple Lightning Components on a Lightning Page/App with 3rd party libraries like jQuery,Bootstrap etc, you may face performance issues like slow loading, code conflicts, many others you don’t know.

Problems you may face while working with 3rd party libraries :

If you have 2 Lightning Components with different version of Libraries, they may conflict with each other.
If you are using same version, they may put unnecessary weight on Components which in turn load your component slowly.

So what could be the solution? The solution is to ensure that you really need to load 3rd party libraries or not.

Basically you should always avoid use of jQuery for very small things like getting element Id, Class, DOM manipulation and many others. To do these small things you have to import jQuery file in you component. Which will put unnecessary weight on your component.

Instead of this you can use getter setter methods provided by Framework or you can use VanillaJs.

You might be thinking what is “VanillaJs”?
Vanilla JavaScript is a fancy name developers have given to the core JavaScript and DOM API combined, and it is used to distinguish it from libraries such as jQuery.

VanillaJs is very easy to use, it is a fast, lightweight, cross-platform framework for building incredible, powerful JavaScript applications. You can read more about here.

VanillaJs is faster than jQuery see below comparison.

vanilla

I know you may have to write few more lines of code in comparison to jQuery, but it is better than putting unnecessary weight on components by importing library.

Comparison of jQuery and Vanilla JS for basic DOM manipulation.

Class selectors

// jQuery
$('.myClass');

// VanillaJs 
document.getElementsByClassName('myClass');

ID selectors

// jQuery
$('#myID');

// VanillaJs
document.getElementById('myID');

Tags

// jQuery
$('div');

// VanillaJs
document.getElementsByTagName('div');

Add and Remove Class

// jQuery
$('div').addClass('myClass');

// VanillaJs
var div = document.querySelector('div');
div.classList.add('myClass');

// jQuery
$('div').removeClass('myClass');

// VanillaJs
var div = document.querySelector('div');
div.classList.remove('myClass');

Add and Remove Attribute

// jQuery
$('.myClass').attr('disabled', true);

// VanillaJs
document.querySelector('.myClass').setAttribute('disabled', true);

// jQuery
$('.myClass').removeAttr('disabled');

// VanillaJs
document.querySelector('.myClass').removeAttribute('disabled');

Hope you will find VanillaJs better than jQuery with Lightning Components.

Thanks 🙂