‘Swift’ – Apple’s new programming language

Swift is Apple’s new programming language for iOS and OS X. Swift is fast, modern, and designed for safety and it enables a level of interactive development that is not seen in other platforms. Swift has features like closures, generics, type inference, multiple return types, and namespaces that make it easier for developers to create incredible apps. Swift is completely native to Cocoa and Cocoa Touch. Its design facilitates developers to write reliable codes, thereby eliminating common programming errors. It takes the best of Objective C and brings in a lot of aspects from modern scripting languages like Python. Swift is built with the same LLVM compiler, ARC memory manager model, and run-time as that of Objective C. This means that the Swift code can fit right alongside the Objective C and C code in the same application. Developers can very quickly and easily get the code running and see the results of the code simultaneously while writing the code. Swift’s ability to coexist with Objective C makes it easier to integrate with existing apps. Benchmarks on a swift application run more than they do on objective C or Python-based applications, which is surely a grade separator. Check out some sample programs in Swift by our SD team at the GitHub repository.

Type Annotations: An Added Feature To Annotations In Java 8

Earlier we could only use annotations in Java on declarations. With Java 8, annotations can be written on any use of a type in declarations, generics, and casts. Type annotations are not one of the highlighted features of Java 8. Annotations add more behavior to the piece of code we have written. So type annotation is just an add-on to that, in the sense, that it boosts productivity and ensures higher quality for our code. For example, if you want to ensure that a particular variable is never assigned to null. You would then modify your code to annotate that particular variable, indicating that it is never assigned to null. The declaration can be like this: @NonNull String str; When you compile the code the compiler prints a warning if it detects a defect, which allows you to modify the code if an error is found. After you correct the code to remove all warnings, this particular error will not occur when the program runs. When we look for tools that make our coding easier and simpler, annotations are never hard to find! So the question may arise as to why we need type annotations when we already have ordinary annotations to boost efficiency. The simple answer to this is that type annotation allows more errors to be found automatically and gives more control over your tools. In Java 8, type annotations can be written on any use of a type, such as the following: @Untainted String query; List<@NonNull String> strings; myGraph = (@Immutable Graph) tmpGraph; Annotations on types, like annotations on declarations, can be persisted in the class file and made available at run-time via reflection (using the RetentionPolicy.CLASS or RetentionPolicy.RUNTIME policy on the annotation definition). However, there are two primary differences between type annotations and their declaration annotations. First, unlike declaration annotations, type annotations on the types of local variable declarations can be retained in the class files. Second, the full generic type is retained and is accessible at run-time. In addition to adding annotations on declarations, we can use annotations on the type. By implementing this, we can use tools such as Checker Framework to check and clear software defects that affect the program semantics and thereby boost the overall performance of the code. We should try to explore and make use of these kinds of new techniques to the fullest so that our code would be clean and efficient.

Object List Sorting Using BeanComparator

We can sort List<Objects> using BeanComparater instead of writing comparator. The beanutils.jar has to be imported. Default sort order is in ascending order. For eg. Collections.sort(postings, new BeanComparator(“resumeCount”)); OR BeanComparator bc = new BeanComparator(“resumeCount”); Collections.sort(postings, bc); Collections.reverse(postings); Pros:- Concise, Minimal code Cons:- Low performance, uses reflection (now if a field is renamed, the compiler won’t even report a problem)

What’s New In Java 8? | Important Features of Java 8

Oracle launched a new version of Java Jdk1.8 with a lot of features. Some of the important features are provided below. 1) Lambda JDK 1.8 allows you to create Lambda functions. Lambda functions will become a powerful concept once integrated with JAVA. Lambda refers to an anonymous function in a programming language. Lambda function, generally known as Lambda expression, is a function but without a name. It is very much used in languages like Python and Ruby (which is borrowed from LISP) etc. An anonymous function (lambda function) does not carry a name, access specifier, access modifier, parameters, etc. It is just to simplify the code. The lambda function is very convenient to use in the same place where we write a function. If you would like to use the function only once, the lambda function is the more convenient way. It reduces typing a lot of code because the function code is written directly where we use the function and the programmer need not go to another part of the application to see the function code (if required to modify). To write lambda function in Java, we use -> symbol. package com.inapp.java import java.util.*; public class LambdaExpressionDemo { public static void main(String args[]) { List<String> alphabets = Arrays.asList(“A”, “B”, “C”, “D”); System.out.println(“NORMAL “); for(String str : alphabets) { System.out.print(str + “\t”); } System.out.println(“\nUSING LAMBDA :”); alphabets.forEach(str -> { System.out.print(str + “\t”); } ); } } Java 8 lambda expressions help to write less code in a more readable way. The lambda expression consists of two parts, the left of the lambda arrow and the right of the lambda arrow. The Left gives the list of parameters and the right gives the body part. Here, the parameter is “str” and the body contains a single “print()” statement. 2) Functional Interfaces An interface containing only one abstract method is known as a functional interface. For example, the java.lang. A runnable interface is a functional interface as it contains only one abstract method run(). A new annotation, @FunctionalInterface, is introduced to raise compilation error if an interface marked as @FunctionalInterface contains more than one abstract method. @FunctionalInterface public interface FunctionalInterfaceDemo { public abstract void display(); } 3) Parallel Sort This is a sorting mechanism introduced in jdk1.8 for better performance. package com.inapp.java public class ParallelSortDemo { public static void main(String args[]) { String strArr[] = {“java”,”php”,”dotNet”}; String strArr1[] = {“java”,”php”,”dotNet”}; // Normal sort Arrays.sort(strArr); System.out.println(Arrays.toString(strArr)); //parallelSort Arrays.parallelSort(strArr1); System.out.println(Arrays.toString(strArr1)); } } The performance with parallelSort() can be seen when the number of arrays to sort is very large. The same sorting can also be done using a List or Set instead of arrays. 4) Addition of Calendar In the normal way, each set() method is added as a separate statement, but in JDK 1.8, Calendar. Builder is used to instantiate Calendar instance and all set methods are used as a single statement. Semicolon is given only after the build() method. package com.inapp.java import java.util.Calendar; import static java.util.Calendar.*; public class CalendarDemo { public static void main(String args[]) { Calendar calendar = Calendar.getInstance(); //NORMAL calendar.set(YEAR, 2012); calendar.set(MONTH, MARCH); calendar.set(DATE, 09); calendar.set(HOUR, 7); calendar.set(MINUTE, 55); calendar.set(SECOND, 13); calendar.set(AM_PM, PM); System.out.println(calendar.getTime()); //USING JDK1.8 Calendar calendar1 = new Calendar.Builder() .set(YEAR, 2012) .set(MONTH, MARCH) .set(DATE, 09) .set(HOUR, 7) .set(MINUTE, 55) .set(SECOND, 13) .set(AM_PM, PM) .build(); System.out.println(calendar1.getTime()); } } 5) Replacement of Permanent Generation with Metaspace JDK 1.8 removes Permanent Generation (PermGen) space and in its place introduced Metaspace. In HotSpot VM, the PermGen is used to give OutOfMemoryError due to depletion of space, which may sometimes cause memory leaks while loading and unloading a J2EE application. From JDK 1.8, most of the memory allocation for storing metadata is done through native memory. The existing classes used to retrieve the metadata of a class no more works with metaspace. A flag is introduced to limit the maximum memory allocation for metaspace – MaxMetaspaceSize. If this flag is not set, the metaspace will be dynamically updated, at intervals, as per the requirement of the application running. The garbage collector is triggered to go for garbage collection when the metadata usage is more than the size of MaxMetaspaceSize. Due to the removal of PermGen space, we cannot configure the space through XX:PermSize & -XX:MaxPermSize. 6) Small VM The goal of JDK1.8 is to have a VM that is no more than 3Mb by allowing some features to be excluded at build time. The motivation behind this is to allow the JVM to run on small devices which have very strict static and dynamic memory-footprint requirements. Have questions? Contact the technology experts at InApp to learn more.

Power your app with ‘Pop’

Pop is Facebook’s new amazing animation framework for creating awesome dynamic animations. Now that Facebook has open-sourced Pop, designers/developers can access the source code from the GitHub repo. Pop is used by developers across applications, for adding visual flair to button states, for full-screen animated transitions, and much more. All the animations seen in the Facebook app are powered by Pop. Pop houses a rich library that facilitates the quick development of animations for iOS and Mac apps. Pop was designed with three objectives, commonly needed animations, an extensible framework, and developer friendliness. The three new primitives that enhance the richness of the Pop animation engine are spring, decay, and custom. “Spring” provides for the bouncy animation and “Decay” for a slow halt movement. Facebook’s ‘Paper’ is a true example of how powerful Facebook can be if it chooses to really push an app. Pop uses dynamic animation to control the bouncing, scrolling, and unfolding effects as in Paper a social network app. By open-sourcing Pop, a whole range of innovative animation features is due to be created. Have questions? Contact the technology experts at InApp to learn more.

The Ultimate Checklist for building modern websites in ASP.NET

Web page performance is always important to us. We always like to ensure that any new features that we develop keep the application running efficiently and hopefully faster, if not equal to, the speed of the last release. The Web Development Checklist is really a simple guide with a few checks that you could do before releasing a new update or feature to your side project. The checklist helps raise awareness of common best practices for building websites. It contains links to many ASP.NET-specific tools and solutions to common problems. Not only is it a great tool for all ASP.NET developers (ASP.Net & ASP.Net MVC) to learn from, but also tracks the progress of implementing the various best practices. It mainly includes: Best practices Bundling Minification Expiration Optimize responses Images Remove headers Though most of them might have already been handled in our projects, seems it’s a good one to go through. Each of the checklist items explains how it needs to be implemented. Check it on the Web Developer Checklist for the latest updates. Have questions? Contact the technology experts at InApp to learn more.

If we override equals(), then we may or may not override hashcode(). (Java override equals | Java override hashcode)

In Java, equals() is implemented in the Object class by default. This method is used to compare two objects. The default implementation just simply compares the memory addresses of the objects. You can override the default implementation of the equals() method defined in java.lang.Object. If you override the equals(), you MUST also override hashCode(). Otherwise, a violation of the general contract for Object.hashCode() will occur, which results in unexpected behavior when your class is in conjunction with all hash-based collections. This is a general contractor in Java programming that “whenever you override equals(), override hashcode() also”. Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equal comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. If two objects are equal according to the equals() method, then calling the hashCode method on each of the two objects must produce the same integer result. It is not required that if two objects are unequal according to the equals() method, then calling the hashCode() method on each of the two objects must produce distinct integer results. Consider the following two examples. In the 1st example, I have overridden equals() only, and in the 2nd one I have implemented equals() and hashCode(), see the differences. Example 1: (java override equals() only) public class HashCodeSample { private int id; private int code; private String name; public HashCodeSample(int id, int code, String name) { super(); this.id = id; this.code = code; this.name= name; } public boolean equals(Object obj) { if (!(obj instanceof HashCodeSample)) return false; if (obj == this) return true; return this.id == ((HashCodeSample) obj).id && this.code == ((HashCodeSample) obj).code; } public static void main(String[] arr) { Map<HashCodeSample,String> m = new Hashtable<HashCodeSample,String>(); HashCodeSample h1 = new HashCodeSample(1234,8, “Test1?); HashCodeSample h2 = new HashCodeSample(1234,8, “Test2?); m.put(h1,”Hashcode Test”); System.out.println(m.get(h2)); } } Compile and run this code and this will return null. Example 2: (java override equals() and java override hashcode()) public class HashCodeSample { private int id; private int code; private String name; public HashCodeSample(int id, int code, String name) { super(); this.id = id; this.code = code; this.name= name; } public boolean equals(Object obj) { if (!(obj instanceof HashCodeSample)) return false; if (obj == this) return true; return this.id == ((HashCodeSample) obj).id && this.code == ((HashCodeSample) obj).code; } public int hashCode() { int result = 0; result = (int)(id/5) + code; return result; } public static void main(String[] arr) { Map<HashCodeSample,String> m = new Hashtable<HashCodeSample,String>(); HashCodeSample h1 = new HashCodeSample(1234,8, “Test1?); HashCodeSample h2 = new HashCodeSample(1234,8, “Test2?); m.put(h1,”Hashcode Test”); System.out.println(m.get(h2)); } } Compile and run this code and this will return the Hashcode Test What is wrong with the 1st example? The two instances of HashCodeSample are logically equal according to the class’s equals method. Because the hashCode() method is not overridden, these two instances’ identities are not in common with the default hashCode implementation. Therefore, the Object.hashCode returns two different numbers instead. Such behavior violates the “Equal objects must have equal hash codes” rule defined in the hashCode contract. Have questions? Contact the technology experts at InApp to learn more.

Wowza Adaptive Streaming Engine

Wowza is an adaptive stream engine that is used for streaming high-quality video and audio to any device. It provides live and on-demand streaming of media player technologies. It can deliver content to many popular media players such as Flash Player, Apple iPhone, iPad, iPod touch, JWPlayer, etc. Wowza Streaming Engine includes support for many streaming protocols including Adobe HTTP Dynamic Streaming (Adobe HDS), Apple HTTP Live Streaming (Apple HLS) MPEG-DASH streaming, MPEG-2 Transport Streams (MPEG-TS), Real-Time Messaging Protocol (RTMP), Real-Time Streaming Protocol (RTSP) and Real-time Transport Protocol (RTP). 1. Server installation Wowza Media Server is a Java 6 (aka 1.6) and Java 7 (aka 1.7) application and requires the installation of a Java Runtime Environment (JRE) that supports deploying Java in server environments. The JRE has everything needed to run Wowza Media Server on your system. The following Java packages can be used with Wowza Media Server: 1. Java Development Kit (JDK). 2. Java JRE. We can deploy Wowza Media Server on a 64-bit operating system with the latest 64-bit Java package (JDK, JRE). Java packages can be downloaded from the Java SE Downloads webpage. Linux This section describes how to install Wowza Media Server on Linux systems. During the installation process, the package manager will extract and install the files in the /usr/local/WowzaStreamingEngine-4.0.1 directory and the server will be installed as the root user. Debian Package Manager Systems Install sudo chmod +x WowzaMediaServer-3.6.4.deb.bin sudo ./WowzaMediaServer-3.6.4.deb.bin Uninstall sudo dpkg –-purge wowzamediaserver-3.6.4 Start Server To start the server in standalone mode on Linux, open a command shell and then enter the following commands: cd /usr/local/WowzaMediaServer/bin ./startup.sh To stop server, open a command shell and enter: cd /usr/local/WowzaMediaServer/bin ./shutdown.sh Start Engine Manager To start the server in standalone mode on Linux, open a command shell and then enter the following commands: cd /usr/local/WowzaMediaServer/manger/bin ./startmgr.sh 2. Playing video from Wowza server configuration in Wowza Streaming Engine Manager Step 1: Create a vod application from engine manager, say application name vod Select the Content Directory Use default ${com.wowza.wms.context.VHostConfigHome}/content Application-specific directory ${com.wowza.wms.context.VHostConfigHome}/content/vod Use the following directory: [absolute path of the video file] Step 2: Restart the server Step 3: Test the player by using engine manger Server : rtmp://[wowza-address]:1935/vod Stream: mp4:sample.mp4 In jwplayer jwplayer(“helloworld”).setup({ height: 420, width: 680, file: “rtmp://[wowza-address]:1935/vod/mp4:sample.mp4?, }); 3. Playing videos from other servers Media Cache configuration in Wowza Streaming Engine Manager Step 1: login Url: http://[wowza-ip-address]:8088/enginemanager log in using the user credentials Step 2: Enable Media Cache After you’ve accessed the Streaming Engine Manager, click the Server tab at the top and select Media Cache in the manager Contents pane. Enable the media cache to show the status: Enabled Step 3: Media Cache Store Configuration Media Cache Stores define where VOD file sources are cached on Wowza Streaming Engine when requested by clients. Default path of media cache is ${com.wowza.wms.context.ServerConfigHome}/mediacache It is also possible to change the location or add a new store. Step 4 : Media Cache Sources Configuration The Media Cache functionality allows content to be retrieved from three different source types, providing very flexible deployment options. The sources can be any of the following: File – Content is retrieved via standard file reads. HTTP – Content is retrieved via standard HTTP requests. S3 HTTP – Content is retrieved via standard HTTP requests that conform to S3 specifications. If you click Sources, you should then be able to see the + Add Media Cache Source button Enter the source name ex: test/ Select the Source Type There are three source type files, HTTP and amazons3 Enter the Prefix ex: amazons3/ Enter the Base Path example for amazon s3: http://s3.amazonaws.com/ example for HTTP server: http://[ip address]:[port]/ AWS Access Key ID and AWS Secret Access Key These are the key from the amazon server and this Enables re-streaming from an Amazon S3 bucket that’s not publicly available. Step 5 : Application configuration To use Media Cache within an application, you first need to select the correct application type. The correct type is VOD Edge. Add a new vod edge application and select the media cache source. Say ‘mediacache’ is the name of the vod edge application. Step 6: Restart the server Step 7: Test the player by using the engine manger To playback content when using a File Source: Use the application named media cache. Use an example File Source with the prefix amazons3. Use a file named sample.mp4 in your source location. Server: rtmp://[wowza-address]/mediacache Stream: mp4:amazons3/[bucket_name]/sample.mp4 In jwplayer jwplayer(“helloworld”).setup({ height: 420, width: 680, file:”rtmp://[wowza-address]/mediacache/_definst_/ mp4:amazons3/[bucket_name]/sample.mp4?, }); Reference: http://www.wowza.com/forums/content.php?121#mediacacheconf_wsem 4. Switch Video Bitrate For switching the multiple bitrate video, we need different bitrate video files and the src of the video is given in an xml file called .smil file. Given below is the sample .smil file for playing the video from amazon s3 using jwplayer. video src=”mp4:amazons3/[bucket_name]/sample_400.mp4? system-bitrate=”400000?/> In jwplayer jwplayer(“helloworld”).setup({ height: 420, width: 680, file:”[path of .smil file]“, }); 5. Transcoder addOn Wowza Transcoder AddOn provides the ability to ingest a live stream, decode the video then re-encode the stream to suit desired playback devices. Wowza Transcoder is a real-time video transcoding and transrating solution. Transcode Transcoding from selected non-H.264 video and non-AAC audio formatted streams to outbound H.263 or H.264 video and AAC audio; multiple bitrate streams can be created from a single input stream. Transrate Transrating incoming H.264/AAC streams to multiple bitrate outbound streams. Supported video and audio formats: Video (decoding) H.264 MPEG-2 MPEG-4 Part 2 Video (encoding) H.263v2 H.264 Audio (decoding) AAC G.711 (µ-law and A-law) MPEG-1 Layer 1/2 MPEG-1 Layer 3 (MP3) Speex Audio (encoding) AAC Wowza Transcoder AddOn is supported only with Wowza Media Server installed on 64-bit versions of Windows® or Linux® operating systems. 64-bit Java runtime is also required. Wowza Transcoder AddOn is licensed separately from Wowza Media Server. Adaptive bitrate delivery Wowza Transcoder AddOn is designed to make live adaptive bitrate delivery easy. Wowza Transcoder can ingest a single high-bitrate live stream and create multiple lower-bitrate renditions on-the-fly. These new renditions are key frame aligned to enable adaptive bitrate

Know-How’s of Visual Studio 2013 on ASP.NET MVC 5

The release of Visual Studio 2013 has unified the experience of using ASP.NET technologies. ASP.NET MVC 5 is the latest version developed with suggestions and contributions from the .NET community. ASP.NET MVC 5 comes along with the official release of Visual Studio 2013. What’s with Visual Studio 2013? Visual Studio 2013 offers a free web development environment for developing and testing next-generation standards-based web applications and services. It includes many productivity features like statement completion and IntelliSense, thus facilitating more work and less hunting for methods. It also includes powerful debugging features that enable developers to step through the codes and explore variables and data within it, fix bugs, and deploy the application. One can even step through line-by-line and get a look at what the application is doing. What showcases ASP.NET MVC 5? With ‘One ASP.NET’ a project creation wizard in MVC 5, it is possible to choose a project template and configure the authentication at the same time. Also, the seamless integration of the Web MVC project template with the new One ASP.NET is one of its kind experience. Bootstrap Framework has been made more user-friendly and customizable. It’s ideal for mobile devices because of its fast layout integration and responsiveness. ASP.NET identity has been introduced which can be used for authentication and identity management. Also, a new kind of filter called an Authentication filter is introduced to authenticate users by custom or third-party authentication providers.? In MVC 5 it’s now possible to override filters by providing an action method or controller by specifying an override filter. Attribute routing is also integrated into MVC 5 which allows for specific routes by annotating actions and controllers. Visual Studio 2013 on ASP.NET MVC 5 is a culmination of a dynamic ecosystem filled with components that empower the application with millions of lines of open-source code to use, read and learn from. Have questions? Contact the technology experts at InApp to learn more.

What is Elastic Search?

Elastic search is a real-time search and analytics engine. It is based on Apache Lucene and is open-source. It is designed to be scalable which means it is distributed and has Node Discovery in it. So it can automatically recognize other elastic search nodes and connect to them if required. It does automatic sharding, in a very simple way, it has its own identifier and just uses identifier modulo number of shards to determine what shard everything goes in. As a result of this, it can do a lot of smart things like where to route some queries and if an update comes where to put that update to make sure things are local as well. It does query distribution, so on querying one node it goes to all the nodes as well. All of those things one requires in this cloud type of world are available for free in elastic search. It has a RESTful, HTTP API with a wrapper for any language one can think of. Almost every day a new language wrapper comes out. One of the things about elastic search is that it is old JASON. It really fits the document model, because the document model uses the JASON structure. If there is a structure in a book with several authors and each author is having a last name, the elastic search will put this in a machine index so it can be searched. Elastic search is schema-less. It does field type recognition because the JASON document structure is not just strings but it can recognize a date, number, or a floating-point number. Also, if a schema is not provided it gives a field number and tries to be smart about it. Any JASON document that is put in is stored in the source document. It maintains a version number automatically, so if any update is done it increments an internal version document. Elastic search has integrated faceting, which works really fast using all the caches that are available. It adds statistical aggregates like sum, average, and number fields which are very powerful. Many of the queries that one wants to do can actually be fulfilled by this. It has many different field types, strings, all types of numeric, geospatial attachments, and arrays (arrays of numbers, arrays of strings). Among documents, it can have both sub-documents and nested documents. Elastic search assumes certain things about data, sharding, and configuration because it has a RESTful HTTP interface. It is possible to do cross-index searching and multi-document typing for all of those books/journals/documents that have authors. It is a really flexible tool that supports almost everything expected and is set to become the next evolution of search. Have questions? Contact the technology experts at InApp to learn more.

InApp India Office

121 Nila, Technopark Campus
Trivandrum, Kerala 695581
+91 (471) 277 -1800
mktg@inapp.com

InApp USA Office

999 Commercial St. Ste 210 Palo Alto, CA 94303
+1 (650) 283-7833
mktg@inapp.com

InApp Japan Office

6-12 Misuzugaoka, Aoba-ku
Yokohama,225-0016
+81-45-978-0788
mktg@inapp.com
Terms Of Use
© 2000-2026 InApp, All Rights Reserved