Wednesday, February 19, 2020

Exposure to functional programming languages like Python / Scala opens more opps

[1]

Python is among the fastest-growing and most popular programming languages out there today. Here are a few ways to use the coding language across industries.

https://www.techrepublic.com/article/python-5-use-cases-for-programmers/

1. Insurance

Top use: Creating business insights with machine learning
Case study: One American multinational finance and insurance corporation faced competition from smaller companies that were introducing services driven by machine learning. To compete, the insurer allowed teams to develop new applications and services using machine learning; however, with too many sets of data science tools involved, a number of different versions of Python and compatibility issues arose. The company settled on one version of Python to deliver all of the machine learning capabilities needed.

2. Retail banking

Top use: Flexible data transformation and manipulation
Case study: A large American department store chain with an in-store banking arm collects data centrally in a warehouse, and then shares it with multiple applications to enable its supply chain, retail banking, and analytics and reporting needs. While the company standardized on Python for data manipulation, each team created its own version, which created problems. The company decided on a single, standard Python build to increase engineering speed and decrease support costs.

3. Aerospace

Top use: Meeting software system deadlines
Case study: An American multinational aerospace, military, and defense corporation was contracted to provide a number of systems for the International Space Station. While aerospace software focused on critical safety systems is typically written in a language like Ada, those older languages do not lend themselves well to scripting tasks, GUI creation, or data science analysis. Selecting a single Python version offered a larger contract value and no exposure.

4. Finance

Top use: Data mining identify cross-sell opportunities
Case study: An American multinational financial services corporation wanted to mine complex customer and prospect behavioral data as part of a digital transformation project. The company used Python to initiate different data science and machine learning initiatives to examine the structured data it had been collecting for years, and correlated it with unstructured data from the web and social media to increase cross-selling and reclaim resources.

5. Business services

Top use: API access to financial information
Case study: A privately-held financial data and media company had previously provided partners with access to financial information through different electronic resources. Partners wanted to build desktop applications in a variety of languages, including Python, to incorporate the customer's API directly into their own, and created a Python Software Development Kit (SDK) for their financial information API, leading to increased revenue and customer satisfaction.


[2]

https://stackabuse.com/functional-programming-in-python/

Functional Programming is a programming paradigm with software primarily composed of functions processing data throughout its execution. Although there's not one singular definition of what is Functional Programming, we were able to examine some prominent features in Functional Languages: Pure Functions, Immutability, and Higher Order Functions.
Python allows us to code in a functional, declarative style. It even has support for many common functional features like Lambda Expressions and the map and filter functions.
However, the Python community does not consider the use of Functional Programming techniques best practice at all times. Even so, we've learned new ways to solve problems and if needed we can solve problems leveraging the expressivity of Functional Programming.

 [3]
Historical evaluation of python evolution


https://python-history.blogspot.com/2009/04/origins-of-pythons-functional-features.html

"..It is also worth nothing that even though I didn't envision Python as a functional language, the introduction of closures has been useful in the development of many other advanced programming features. For example, certain aspects of new-style classes, decorators, and other modern features rely upon this capability.

Lastly, even though a number of functional programming features have been introduced over the years, Python still lacks certain features found in “real” functional programming languages. For instance, Python does not perform certain kinds of optimizations (e.g., tail recursion). In general, because Python's extremely dynamic nature, it is impossible to do the kind of compile-time optimization known from functional languages like Haskell or ML.
.."


[4]

Tutorial: Python Functions and Functional Programming

https://www.dataquest.io/blog/introduction-functional-programming-python/

In this post, we will:
  • Explain the basics of functional programming by comparing it to object-oriented programming.
  • Cover why you might want to incorporate functional programming in your own code.
  • Show you how Python allows you to switch between the two.
  • The Lambda Expression
  • The Map Function
  • The Filter Function
  • The Reduce Function
  • Rewriting with list comprehensions
  • Writing Function Partials
[5]
 Another link to get started with language syntax

 Concluding thoughts

Getting to know your programming language of choice well by exploring its features, libraries and internals will undoubtedly help you debug and read code faster. Knowing about and using ideas from other languages or programing language theory can also be fun, interesting, and make you a stronger and more versatile programmer. However, being a Python power-user ultimately means not just knowing what you *could* do, but understanding when which skills would be more efficient. Functional programming can be incorporated into Python easily. To keep its incorporation elegant, especially in shared code spaces, I find it best to use a purely functional mindset to make code more predictable and easy, all the while maintaining simplicity and idiomaticity.

[6] Another good and concise one to get started

A practical introduction to functional programming

 

 

 





If you were to start with Scala -- Here's some starting point


[1] https://www.quora.com/How-does-Scala-compare-to-Java-8/answer/Denis-Kalinin

How does Scala compare to Java 8?


When presenting a new version of Java, Brian Goetz said that while Java is getting lambdas, it still feels like Java. I would argue that this could be seen as both advantage and disadvantage at the same time.
The main problem for me is that Java is still an imperative language. The if statement is still a statement (so you need variables to define the control flow), the HashMap still returns null, throwing and catching exceptions is still the most common way to deal with dangerous code. Introducing the Optional class doesn’t change anything for legacy code if it already relies on nulls.
In contrast, Scala has had the Option type since 2007 (version 1.1), so pretty much everything in Scala, including the standard library, uses it. There are type-safe ways for dealing with dangerous code such as the Try type or ScalaZ disjunctions. Finally, “everything is an expression”, so you don’t need variables most of the time.
Here I’m not even talking about more advanced Scala features like pattern matching or for comprehensions, which don’t exist in Java at the moment.
The only two advantages Java still has is
  • performance
  • market share
I would argue, performance differences between Scala and Java are irrelevant for many (if not most) projects. As for the market share, Scala is quite easy to grasp (see my recent article The fastest way to learn Scala
). Finally, many former Ruby/PHP/etc developers will not consider Java as a viable option exactly because of its “Java feeling”, but they can easily switch to Scala because it’s ”a statically typed language that feels dynamic” (see this presentation about switching from Rails to Scala - From a monolithic Ruby on Rails app to the JVM
).

Still, I wouldn't blame Java architects for the decisions they've made, because they are doing the best they can given the circumstances. Microsoft seemed to have taken a completely different approach to introducing new features, but they also had questionable results.


[2]
A good comparison - less than 5 min read /analysis  


[3]
Books 

You see world is getting more into functional programming.


Tuesday, February 11, 2020

Linux and bash scripting not to be forgetten in technology proliferated world

Having worked on multiple OS platforms its very easy to get confused with syntax of Linux commands that your were so good at years ago.

Thanks to the following
https://alvinalexander.com/unix/edu/examples/grep.shtml
https://alvinalexander.com/blog/post/linux-unix/unix-linux-shell-script-reference-cheat-sheet

you donot have to google multiple times.
Spend time on this page and you will find yourself recollecting some techniques 

This is best part of being in software community.
Ahamam bramhasmi





Containerization via Docker. - Howto - Whento - WhenNotto

Over previous few days was taking a look at this technology.
Clearly it gives some benefits and could easily foresee this drawbacks, in enterprise applications which involve distributed data and their is a clear and definitive need for data replication/synchronicity

Here are good links, if you have to review some readings

HOW TO 
http://jasonwilder.com/blog/2014/10/13/a-simple-way-to-dockerize-applications/ 

Good usecases this solves
WHEN TO 
https://www.airpair.com/docker/posts/8-proven-real-world-ways-to-use-docker

Drawbacks/Concerns in containerizing database
WHEN NOT TO
https://vsupalov.com/database-in-docker/
https://www.channelfutures.com/open-source/when-not-to-use-docker-understanding-the-limitations-of-containers

Good qoutes
"..Docker is also not necessarily a great packaging system either. You can make something that will run on many Linux distributions but it wont be fast, efficient nor guaranteed to be entirely compatible..."

"..you can end up shipping something that as an RPM would be 10KB, becomes 100MB using docker."


Now also like to say Google search page gives this info quick on hit page with
Keyword
"drawbacks for dockerization in distributed databases application"
Enjoy

Here are just some of the use cases that provide a consistent environment at low overhead with the enabling technology of Docker.
  • Simplifying Configuration. ...
  • Code Pipeline Management. ...
  • Developer Productivity. ...
  • App Isolation. ...
  • Server Consolidation. ...
  • Debugging Capabilities. ...
  • Multi-tenancy.
Here are examples of things Docker can't do or can't do well:
  1. Run applications as fast as a bare-metal server. Docker containers have less overhead than virtual machines. ...
  2. Provide cross-platform compatibility. ...
  3. Run applications with graphical interfaces. ...
  4. Solve all your security problems.
Popularity & Benefits of Using Docker
  • Return on Investment and Cost Savings. The first advantage of using docker is ROI. ...
  • Standardization and Productivity. ...
  • CI Efficiency. ...
  • Compatibility and Maintainability. ...
  • Simplicity and Faster Configurations. ...
  • Rapid Deployment. ...
  • Continuous Deployment and Testing. ...
  • Multi-Cloud Platforms.
Until next time..







Saturday, February 8, 2020

Microservices -- Orchestration in distributed systems - challenges


A good write up by Bernd Bucker  @ Camunda
https://www.youtube.com/watch?v=GPgOeK-QytA 
A good write up in whitepaper format 
https://thenewstack.io/5-workflow-automation-use-cases-you-might-not-have-considered/

My Work around this time line
- Automated provisioning platform 

Most of these challenges, were thought off , implemented using Spring technologies
- Centralized database workflow tables tracking status of request   (be it synchronous or asynchronous , bulk or single )
- In -memory database structures for Spring boot actuators metrics
- Logging onto to filesystem in standard format at every point in execution
  (checks, validations, external system interactions )

The SRD was indeed drafted in BPMN notation and signed off  by PO in communication with client.


Wednesday, September 25, 2019

Evolution of 'java.util.Date' to 'java.time.Instant' considering date/time format specifier and timezones

Java API for datetime formatters have evolved as well
from
import java.util.Date
import java.util.Calendar;
and
import java.text.SimpleDateFormat;
import java.text.DateFormat;

to
import java.time.format.DateTimeFormatter;

Traditional code style


    public Timestamp convertStringToTimestamp(String str_date) {
       
        try {
            DateFormat formatter;
            formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
            Date date = (Date) formatter.parse(str_date);

            java.sql.Timestamp timeStampDate = new Timestamp(date.getTime());

            return timeStampDate;
        } catch (ParseException e) {
            logger.error("Exception happened here:" + e);
            return null;
        }
    }


OR

        // Must create new SimpleDateFormat and TimeZone on each method invocation since neither of these classes are thread-safe.
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX");
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        return simpleDateFormat.format(new Timestamp(System.currentTimeMillis()));
       
Sample Output
2019-09-25T10:07:19.839Z
       

Database timestamp impendence was always there

import java.sql.Timestamp;


Newer style


private static final DateTimeFormatter TIMESTAMP_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX");
..
    public static String getCurrentTimestamp() {
        // No need to create new DateTimeFormatter or ZoneOffset on each method invocation since both of these classes are thread-safe.
        return TIMESTAMP_FORMATTER.format(OffsetDateTime.now().withOffsetSameInstant(ZoneOffset.UTC));
    }
..

Sample Output
2019-09-25T10:07:19.839Z

Plz Note: Observe the use of new formatter class (s)

import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;


   
   
Next Generation Compact Style


import java.time.Instant;
..
System.out.println(Instant.now());


   
Sample Output
2019-09-25T10:07:19.839Z    


Non-Blocking/Asynchronous API(s) using Java 8 and above


A Good Style of explaining the evolution of Java API(s) to achieve Concurrency.

https://www.callicoder.com/java-concurrency-multithreading-basics/


Analogy/Use Scenario Visualization:
(*) If you are core busniess layer, who need to integrate with legacy Java components ( which are the actual workhorses ) and you are being called from upstream busniess layers, there is always a need for Asynchronous invocation.
This is where following article

https://www.callicoder.com/java-8-completablefuture-tutorial/
best explains concepts

Prerequistie : Java Lamba familarity, Supplier , Consumer , functional interfaces in Java 

Other Analogies:
1) SwingWorker in old AWT/applet kind of application 
2) Promise in JavaScript 
3) Work delegation and collating back (Typical Manager) 



Followers