Why You Should Care About DECLARATIVE Programming

In this video, we look at how the same search filter can be built using both an IMPERATIVE approach and a DECLARATIVE approach (and the benefits of the declarative approach).

  • 0:00 Introduction
  • 0:46 Imperative Approach
  • 3:16 Declarative Approach
  • 7:43 Conclusion

#angular #rxjs #programming

What is GEEK

Buddha Community

Why You Should Care About DECLARATIVE Programming
Sadie  Cassin

Sadie Cassin

1598755440

The Nature of Concise Code; Declarative Programming

The need for web developers has become far more critical, as many companies are moving, or intending to move, their services online. Many people seeking to enter this career are baffled by the sheer number of programming languages and frameworks out there today. Understandably so, it can definitely be overwhelming.

With this article I hope to tackle and clear some questions you may have about declarative programming, how it compares to imperative programming, and the transitioning from Javascript to React, which in turn, I believe can serve as a good jumping-off point into the world of coding.

What is Declarative Programming?

Let’s start off by defining “declarative programming”. According to Wikipedia, it is, at its core:

“— a style of building the structure and elements of computer programs — that expresses the logic of a computation without describing its control flow.”

That makes sense, right? Totally! Or maybe you’re like me, and found that explanation to be super vague. For now, let’s leave it at that! A few more things to clarify first.

I will be using Javascript(JS) in my examples, because that’s my preference, as I have grown to favor it over other languages.

Image for post

Source: Link

This is something you will learn soon enough about web devs; they all have their preferred language. In time, you will also find yourself leaning towards your own inclinations for a preferred language.

I have also highlighted(in bold letters) some key words throughout this article, which I feel will prove invaluable in your continued learning of subjects related to programming. I’d suggest writing them down, and maybe looking them up at a later time. They are all terminology that you will continue to see in your ventures to becoming a web developer.

Declarative vs Imperative Programming

To reiterate what I quoted before, declarative programming is “conveying the logic of a process, without necessarily defining its course for execution”.

I hear you, still confusing, and still not quite there in terms of understanding. Okay, stay with me, I can do better!

#declarative-programming #javascript #programming #react #functional-programming

Nat  Kutch

Nat Kutch

1596848280

From imperative to declarative JavaScript

Introduction

In this post, I will explain why declarative code is better than imperative code.

Then I will list some techniques to convert imperative JavaScript to a declarative one in common situations, defining key terms along the way.

Why declarative ?

First, let’s define what declarative and imperative mean.

Declarative code is one that highlights the intent of what it’s doing.

It favors the “what” over the “how”.

In other words, the exact implementations actually doing the work (aka the “how”) are hidden in order to convey what that work actually is (aka the “what”).

At the opposite, imperative code is one that favors the “how” over the “what”.

Let’s see an example:

The snippet below perform two things: it computes the square of x, then check if the result is even or not.

// imperative way

	const x = 5;

	const xSquared = x * x;

	let isEven;

	if (xSquared % 2 === 0) {
	  isEven = true;
	} else {
	  isEven = false;
	}
view raw
block1.js hosted with ❤ by GitHub

Here, we can see that we finally get isEven after several steps that we must follow in order.

These steps describe “how” we arrive to know if the square of x is even, but that’s not obvious.

If you take a non-programmer and show him this, he might have a hard time deciphering it.

Now let’s see another snippet where I introduce a magic isSquareEven function that performs the two same things than the previous one.

#functional-programming #javascript #javascript-tips #programming #declarative-programming #function

Angela  Dickens

Angela Dickens

1595593200

Functional Programming

Functional Programming is a Declarative style of Programming Paradigm for writing computer programs.
But, What are Functions ?
Functions in general, applies computation on given input and returns the output. It relates input to an output.
f(x) = x + 2;
f(1) = 1 + 2 = 3;
f(2) = 2 + 2 = 4;
Above mentioned is a simple function that adds 2 to the input value and returns output. It relates value [1,2] => [3,4]. Similarly, a function in computer programming is a block of instruction that performs computation on given input and returns the output.
Functional Programming is such a style of writing computer programs using these tiny functions that works together and perform required computation.
Functions in Functional Programming
The philosophy of functional programming is to maintain certain characteristics while writing functions in a computer program. These characteristics are the fundamental nature of functional programming that describe what shall be the behaviour of a function. These are as follows :
Declarative
A function must be declarative, it simply tells what to compute, without specifying how to compute it.
f(x) = x * 4; 👍
Declarative function that tells to multiply input by 4;
f(x) = { y = x + x; z = x + x; return y + z;} 👎
Non-Declarative function that specify how to multiply input by 4;
Pure
A function must give the same output for a given input value, at any period of time. It is not dependent upon anything outside the function definition.
f(x) = It’s never too late; 👍
Pure function that will always return It’s never too late
f(x) = If today’s Friday or Saturday then It’s never too late else It’s late. 👎
Impure function that consider day for returning value. The value is not predictable. It can change. So a function that performs anything which is unpredictable is not a pure function. The condition or the execution is dynamic or unfixed in an impure function.

#development #functional-programming #software #software-programming #declarative-programming #function

Coding 101: Programming Language Building Blocks

This article will introduce the concepts and topics common to all programming languages, that beginners and experts must know!

Do you want to learn a programming language for the first time?

Do you want to improve as a Programmer?

Well, then you’re in the right place to start. Learn any programming language without difficulty by learning the concepts and topics common to all programming languages.

Let me start by answering the following questions:

  • Why learn Programming?
  • What is Programming?
  • How to Learn a Programming Language?

Why learn Programming❔

Programming develops creative thinking

Programmers solve a problem by breaking it down into workable pieces to understand it better. When you start learning to program, you develop the habit of working your way out in a very structured format. You analyze the problem and start thinking logically and this gives rise to more creative solutions you’ve ever given.

Whether you want to uncover the secrets of the universe, or you just want to pursue a career in the 21st century, basic computer programming is an essential skill to learn.

_– _Stephen Hawking

Everybody in this country should learn how to program a computer… because it teaches you how to think.

_- _Steve Jobs

Programming Provides Life-Changing Experiences

Programming always provides you with a new challenge to take risks every time and that teaches you to take risks in your personal life too. The world is filled up with websites, apps, software and when you build these yourself you’ll feel more confident. When a programmer solves a problem that no one has ever solved before it becomes a life-changing experience for them.

What is Programming🤔?

program is a set of instructions to perform a task on a computer.

Programming is the process of designing and building an executable computer program to accomplish a specific task.

Well, according to me programming is like raising a baby. We provide knowledge (data) to help understand a baby what’s happening around. We teach a baby to be disciplined (and much more) by making rules.

Similarly, a computer is like a baby. We set rules and provide data to the computer through executable programs with the help of a Programming Language.

(Photo by Clément H on Unsplash)

That’s it👍. If you can understand this basic concept of programming, you’re good to go. Pick up a programming language and start learning. Read the following section to get an idea of where to start.

My recommendation is to choose Python Programming Language as a start, because it’s beginner-friendly.

#programming #programming-tips #programming-language #programming-top-story #computer-science #data-structures-and-algorithms #tips-for-programmers #coding

Programming In Acceleration: Levelling Up Programming Skills

Some require and some are not. But acceleration programs might require you to build one. I’ll tell you how I made a computer program for the competition.

1-Researched the source codes and pasted it on my VS code

Written on the internet “blockchain-based ticket codes” and found the Ethereum source codes in Github. Then, I’ve just copied and pasted on my VS code by naming with .sol extension. Then, I’ve got my hands on the code itself and started to correct the mistakes that the editor has shown so far. Managed to reduce 189 errors to 58 within two hours. The rest was handled by my teammate when I sent the code I’ve edited. He just fixed the codes in three more hours and my mistake was not to increase the gas price. We increased the gas price on the remix and everything worked. And he just tested the software on scalability and security. It was the perfect garment for us that everything worked except the indentation errors.

What should’ve been done by us

Found all the codes including testing, copied them, and pasted them to our text editor for further analysis. Still, we had the prototype and we could write all the test codes, migrations, etc. if needed. Even more, we should’ve researched the codes to our project before using one of the examples.

#acceleration-program #program-analysis #programming #startup #acceleration #data analysis