Why learn Gradle?

Gradle is designed primarily for engineering builds, automated builds

Why should we learn Gradle when we already know how to build projects using Ant, Maven, etc?

Gradle is the latest and most powerful build tool out there

What Ant and Maven can do, Gradle can do, but what Gradle can do, gradle can’t do

At the same time, Gradle is more than just a tool. It replaces traditional XML configuration with programs to make project construction more flexible

For example: XML is very difficult to write if-else, but Gradle is very simple

Also, gradle has a wealth of third-party plugins that you can use to your heart’s content

As a developer, I can improve the technical system of Android development engineer/Java development engineer, enhance the depth of automation construction technology, and help advance to senior/senior engineer

Because now android projects/Java projects are using Gradle to build projects

Many people think that build is not to build an APK file, a JAR package so simple?

Gradle technology that deep?

The people who are ultimately responsible for the construction of the company are usually senior students, even some managers and directors

Because no matter how much code we write, it’s all about the final build file

So this link is very important, if you want to become a senior/senior engineer, Gradle is a skill that must be mastered

Why is that?

Because in the current front-line Internet enterprises, the vast majority of the interview will be automated construction

If you know how to automate builds using Gradle, you have an advantage over your competitors

What is the Groovy language?

Gradle is implemented using the Groovy language

The Groovy language is an offshoot of DSL

Before we get into Groovy, we need to clarify some of the concepts of DSL itself

DSL, domain specific language

We’ve been around DSL for a long time, but we just don’t have the concept

For example, MATLAB, which is specially used to do calculation language, is a DSL language

There is also the UML modeling language, which converts real-world models into computer models and is also a DSL model

And HTML, which is a branch of the DSL language, specifically for browser pages

So DSLS, per se, are not an alien concept

This language and our system language are at opposite ends of the spectrum

System programming languages are designed to solve all problems. For example, Java wants to do both Android and server development

DSL language was originally created to solve a problem in a specific area of computer related

System programming languages are large and comprehensive, while DSL languages are small and detailed

So DSL is complementary to our system development language, and the combination of the two will have a huge effect

After mastering a development language, mastering a DSL language is the icing on the cake

So what’s the difference between a DSL and our normal general-purpose programming language?

DSL vertical and deep development;

System programming language, horizontal to a wider range of applications to develop;

That’s the big difference

Groovy language features

Next, let’s look at the basic concepts of Groovy

First, Groovy is an agile development language based on the JVM

Based on the JVM, it’s exactly the same principle that runs behind our Java

As we all know, in order for Java to run, we first need to compile our Java files as class files

The class file is then handed to our JVM to run

Groovy is the same as the Java language in that the Groovy source files are compiled into class bytecode files, which are then handed to our JVM to run

Of course, this is not enough to capture the power of Groovy

Groovy can also interpret and execute our Groovy source files directly, just like JavaScript

Let’s look at the second feature

Groovy combines many of the powerful features of scripting languages like Python, Ruby, and Smalltalk

As we all know, scripting languages are very powerful for scripting, so Groovy can also write scripts from 6 to fly

With all the powerful scripting languages out there, why do you need Groovy?

If we’re a Java developer and we’re learning Python now, we’re learning a new language from scratch

This is not the case with Groovy, because Groovy is an extension of Java

Its syntax is very similar to our Java, so you can learn Groovy the way you learn Java

So learning Groovy on Top of Java is faster than learning any other language

Third, our Groovy works well with the Java version, which is all based on the JVM

At the same time, Groovy can use all of Java’s libraries. Isn’t that cool?

… With the concepts behind Groovy now in hand, let’s take a look at groovy’s features

One of its biggest features is syntactic support for dynamic typing, closures and other new scripting language features

Groovy’s closures are a little more powerful than those in other languages

Second, we can seamlessly integrate existing Java class libraries. We can write our Groovy programs using Java syntax/libraries, etc., but we generally don’t do that

Groovy’s syntax is similar to Java’s, but with a lot of changes

Third, Groovy supports both object-oriented and procedural programming

Object-oriented because Groovy is an extension of Java, an object-oriented programming language

Procedural orientation is because Groovy combines features of scripting languages like Python

If you’re developing in Groovy, you’ll use object-oriented features

If you develop scripts in Groovy, you’ll use procedural features

… Now that we’re done with the features, let’s look at groovy’s strengths… .

First, Groovy is a more agile programming language

Because it does so much syntactic work, much of what is written in Java can be eliminated in Groovy, which means writing the same functionality in less code

The second advantage is that it is easy to get started and powerful

Easy to get started means that with Java in hand, learning Groovy is very simple

Third, it can be used as both a programming language and a scripting language

At the end

Haha, that’s all for this article (systematic learning and growing together)