Getting Started with PClub

Getting Started with PClub


Programming 101

This would hopefully turn out to be a comprehensive guide to someone starting as a newbie in this vast world of programming. Here, we would like to give some personalized inputs on the generalized procedure of getting started. We will also assume that you all are well versed with using a computer.

Note: If you have done programming before, you may wish to skip the first few sections.

Text Editors

I am pretty sure, most of you must have had some experience using Notepad at some point in your life and would be thinking of using it for writing computer programs as well. While there is as such no big problem in using Notepad for writing the code, but soon it will make your life very hard. Here are some reasons why,

  • No Syntax Highlighting: Notepad doesn’t provide you with the feature of syntax highlighting and this is one of the biggest problems with vanilla Notepad. Visualizing reserved words with different colors helps a lot as you will end up making a lot fewer mistakes. It will save your life from getting miserable, debugging (removing logical and syntactical errors) your code the whole time.
  • No Autocomplete: Modern text editors come with the feature of autocomplete or if not, they have the functionality to install required plugins or extensions for the same. This feature allows you to autocomplete the variable names and reserved words. This will help in saving a lot of time and also making the code less erroneous.
  • No Formatting of code: Notepad lacks the functionality of auto indenting the code for you. Auto indenting makes the code more readable and easy to understand. It also helps in visualizing the flow of execution of the program. Lack of indentation will lead to making your code less readable and hence, debugging it highly difficult.

I hope the above reasons were convincing enough to make you switch to a better text editor. We recommend using any one amongst Sublime Text or VS Code, or a dedicated IDE(Integrated Development Environment) for that language.

We have written another blog on How to get Started with Sublime Text in Windows For Competitive Programming. Do read it for a practical walk-through.

What everyone should know in today’s world.

We provide a comprehensive list of to-dos. This list is not exhaustive; instead, it can be manipulated by the reader according to their interests and what they like among the below-mentioned points.

Choosing your first programming language

After all the setup told above, it’s finally time to start coding! But wait, there are so many languages out there, which one to choose? We know that it might get confusing to choose a particular programming language, to begin with. There are various arguments in favor of different languages and we think a good first programming language should have the following characteristics:

  • It should be relevant today. The programming languages like BASIC or any of its sisters that you might have learned about in school are not much in usage today.
  • It should be easy to set up without much extensive work.
  • It should be simple to learn. (Note: We are not asking you to master it as it takes a lot of time to master a language.)

That being said, these are our recommendations:

C/C++— These languages form the basis of modern languages like Python and Julia. They carry immense speed and control over your operations too. Although that kind of control won’t be needed in our day-to-day tasks, we suggest one should learn either one of these to make a strong base for coding. The best resource we have ever obtained is IIT Kanpur’s ESC101A course material itself. It can be found here at Prof. Nisheeth’s website. It starts right from the fact assuming you don’t know anything about programming.

Python — Python is like talking to a computer in a human’s language. It is much more human-readable than C/C++, which makes it the most popular language in the world. “Learn Python the Hard Way” by Zed Shaw provides one of the most comprehensive guides to Python. It will hardly take a few hours to complete the book, and we suggest you have Python 3.x.x installed (refer to this link for installation) and have the interpreter (refer to this link) running while you read the book so that you execute the code and experiment with the language as you learn.

JavaScript — It is extremely relevant in today’s world, especially in the field of web development. Though JavaScript is a little slower than C/C++, JavaScript is indeed a very powerful language, and most of the modern websites are built using its frameworks. This is a pretty good resource to get started with this language.

Bash — Bash is one of the most popular shell scripting languages. It is the default shell for most Linux distributions out there, and we programmers are addicted to Linux! If you don’t know what is Linux, it is an operating system used by all programmers. If you ever remember scenes from movies (The Matrix, how can one forget this) showing the person hacking a computer with lots-and-lots of green-colored text, don’t worry, you are going to get it all here in Linux! This may not be needed at the moment, but learning is always a plus-point, and who knows we may keep a super-cool session on exploring Bash scripting sometime in the future? This resource is a perfect place to start with.

Competitive Programming — A Modern Sport

Prerequisites to understand this section: Some idea about what a computer program is, input, output, variables, etc.

As you explore the world of coding, you see people who can come up with ideas quickly and type a piece of the script right away to solve a given puzzle or problem.

This forms the core of competitive programming, where you are presented with computational puzzles. They are often presented as a small story having some context, where you are expected to code a program that can give the answer to the puzzle as quickly and as efficiently as possible. You would certainly like this domain if you get high solving puzzles!

As all major companies all over the world need people with good problem-solving skills, competitive programming becomes a gym to sharpen your mind and showcase your skills on a global platform!

Let us take a simple problem from Codeforces

See the above problem, for instance. There is a problem statement, and there is a prescribed input and output format. Your program must follow the specified formats. Try working out the problem for the sample input. Basically, for all possible input in the range given, your program should generate some output.

Your program gets accepted when your output matches the output of the solution program written by the problem setter and tester! Note that your programs may be completely different, but if you have solved the problem correctly, the output must match!

Obviously, you need to be able to write a program in some language. C/C++, Python, Java are popular choices, and you are taught C in ESC101.

A good idea for a beginner is to learn the basics of a language and understand the fundamentals. As you gradually write more and more code, it becomes easier to transform your ideas into code, and the typing part becomes routine!

When you put your logic or solution into code, you have implemented an algorithm. Sometimes, you use some data structures such as arrays, trees, set, map queue, etc. Don’t worry if you aren’t familiar with data structures — They are containers to store variables in some meaningful way so that you can retrieve them or their properties later efficiently. ESC101 will expose you to some basic data structures!

As for algorithms, they are basically the steps to reach your goal. Suppose you want the biggest number from a list of numbers — You go through each number in the list and ask yourself if it is the biggest number you have seen till now? If so, remember it. And go on. In the end, you will have the biggest number on the list.

Assuming your basics are good enough, to get started, you can create accounts on various online judges. Online judges are the websites that have problems and checkers, which will run your program on their servers. They have specially designed test cases to check whether your program gives the correct output!

Codeforces, Codechef, Atcoder, TopCoder, Hackerrank, etc. are popular online judges. You can join Codeforces where we have a CP group managed by PClub where interested students compete among themselves to be the Sport Programmer of the Month! We recommend that you regularly try to participate in contests organized by Codeforces and Codechef.

There are a lot of good resources available online — This is a compilation of many popular free online resources with star ratings and all! Also, you need an efficient IDE setup to help you participate in contests. VS Code, Sublime Text, Atom, PyCharm are popular IDEs that you can choose from. If you haven’t set up your IDE yet, you may want to check out our blog that gives a detailed overview of the procedure of setting up an IDE.

Never be overwhelmed — There are a lot of things to learn in this wonderful journey! There is something called rating on Codeforces just like FIDE ratings of chess. To put things into perspective, the best of the best guys of the globe out there like tourist have a rating of about 3700. Our senior, Yash Chandnani (Y16), was leading from India until recently, at about a rating of 2700. They are all red coders! But hold on, there are only 9 red coders all over India at Codeforces at present!

Cyb3r-53cur17y: Digital Warfare

Hopefully, you could read that… It is leetspeak for Cyber-Security. Maybe you have heard about hacking, encryption, WEP/WPA, cryptography, cipher, SHA, RSA among a lot of other things? Well, this is the domain of programming where the goal is to learn how to communicate securely and at the same time, learn about common loopholes that can be exploited by someone evil and should be mitigated.

Do you see that padlock on the left of the address bar of your browser? Have you thought about what that stands for? Click on it —

It says that the connection is secure and the certificate is valid. Now, what do you mean by secure?

A “secure” communication channel between two parties A and B in the context of cybersecurity refers to three things as I understand:

  • The message from A reaches only B.
  • The message that B receives is only from A.
  • Only that message which A has sent is received by B — Message is not tampered with.

This problem existed from that day when 2 cavemen wanted to communicate without their wives eavesdropping!

When Julius Caesar wanted to communicate with his generals in a battle, he would shift each letter in his message by 3. “Send 5 legions to the north” became “Vhqg 5 ohjlrqv wr wkh qruwk”. Obviously, you understand nothing when you see it (unless you know the shift) and if you tamper with it, the “unshifted”(decoded) message will not be meaningful. So, it is somewhat secure.

Some terminology in the example above — The original message is referred to as plaintext and shifted message is called ciphertext, and the shifting procedure is the encryption algorithm here, and the value 3 here is the key it could have been any other number.

With the advent of digital computing and availability of GHz processors, lots of manual computation can now be done in under a second. Suppose, you didn’t know that how much the message is shifted with, but, you know that the algorithm used to convert the message to a cipher is by some constant shift, you need to check just 25 possible cases, which is absolutely easy to check with the help of a computer (and manually too!). Checking every possible case is known as the brute-force technique in computer science.

Nowadays, we are surrounded by a lot of devices, and we use them for a greater part of our day. Naturally, there is a lot of information that is being collected by apps and devices to deliver better service. But, we don’t want that information to be public or readily accessible by anyone! It can range from our private photos to our nation’s nuke codes!

Cybersecurity can be broadly classified into two divisions — Theoretical and Practical. By theoretical, I mean cryptanalysis of encryption algorithms, where someone who completely knows and understands our algorithm, may recover the plaintext from the ciphertext without knowing the key. And by practical, I mean actually getting access to all the confidential information stored somewhere by exploiting loopholes in programs, source code and/or launching passive/offensive attacks.

Come on, if your crush asks you for the name of your first teacher during a conversation, you are likely to not think anything about it. But, if you have set the answer to that as your security question somewhere? People can impersonate someone else on Facebook and other social media and gain sensitive information by such a social-engineering attack.

Some websites may have expressed disapproval when creating a weak password — because such passwords are common and easily broken by dictionary-attacks!

Now let me give some sources to learn further on the practical side:

Honestly, it is not very easy to jump into the theoretical part — it involves a good amount of math. But, here are some links you can definitely explore —

A simple task for you: (Hint: learn how to use Google)— YjQ1MzY0XzE1X24wN183MHU2aF9sMzM3Xw==

Web Development: Beginner’s Roadmap

Web development is the work involved in developing a web portal/ software for Internet users. Web-dev can range from developing a simple single static page of plain text(that’s how you kickstart things) to complex web-based internet applications (web apps), electronic businesses, and social network services.

Now, keeping the intro part aside, talking about some real stuff.
Web-dev has two subdivisions: Frontend and Backend. Frontend revolves around building the User Interface (UI) and everything you’ll see on different applications or software, and constructing the interface between the user and the machine.
Backend development, intuitively, handles the ‘behind-the-scenes’ functionality of software applications. It is more about connecting the webpage to a database, manage user connections, and power the application itself.
Let’s explore a bit about the two fields:

Frontend Development: The most basic technologies you’ll need to have a grip on are HTML, CSS, and JavaScript. HTML (Hypertext Markup Language) will define the skeletal structure for your application. CSS(Cascading Style Sheet) describes the presentation of Web pages, including colors, layout, and fonts. Finally, JavaScript adds the logic part to the application and is responsible for establishing connections between the frontend and backend (somewhat).

To get started with things, you can refer to these amazing resources:

For a more basic approach, you can refer to the below two resources:

After covering these subtle resources, maybe you could design your webpage and host it on IITK’s server (yes, you can do that too!).
After learning these basics, move on to learn JavaScript frameworks like React JS (for web applications) and React Native(for mobile applications). The official documentation is quite extensive and is sufficient enough for learning these super popular technologies. You can simply follow the tutorials provided in the documentation and understand the workflow!

Backend Development: Backend is much more involving in comparison to frontend. Some of the famous technologies in this field are Django( Python framework) and NodeJS( JavaScript framework). Obviously, for learning these frameworks, you need to have a good grip on Python and JavaScript, respectively. Now, backend comes in handy, mainly when you’re working on some web/mobile applications where you need to define specific functions that control things from backstage (google about “web API”).
For learning Django, follow the tutorials on the official documentation, which would be good enough from the beginner’s perspective.
For NodeJS, MDN docs are again pretty good! You can check them out here.

Well, if you think things were that simple, you might want to have a look at the flowchart below. It might scare you but believe me, it’s really cool!

_Where to test all this stuff you’ve learned?
Open Source! Honestly, contributing to open source organizations was my motivation for learning web-Dev. Almost every organization has a minimum of two projects running, which involves web development. You can choose your organizations and start to work on the relevant issues!

Bonus steps: FOSSASIA runs its annual open-source fest Codeheat. There are various projects for you to work on with some newbie issues too, which I believe any beginner can start working on irrespective of their knowledge and experience in the field.

Machine Learning — Does a machine really learn?

When you hear about Machine Learning, all that strikes you is robots mimicking humans and virtual assistants getting closer and closer to humans every single moment. Well, these are certainly true, and innovation is occurring at a very rapid pace, but we shall start with the basics. One cannot jump to the top of the pyramid (does the top exist?) without climbing it step-by-step.

Be Noted: To understand the following section, you need to have some understanding of Basic Linear Algebra and Python. It is okay if you don’t understand this stuff yet. You can always come back to this blog later when you have the pre-requisite knowledge!

We shall first answer the main question in the first place — What is Machine Learning?

Machine Learning is a branch of Computer Science that recently emerged, which helps humans in doing human tasks, the simplest of them being the identification of objects. The list is quite endless; modern-day Machine Learning models can predict, classify, and even generate new data.

Machine Learning models are mathematical models. Research in this field has occurred for a long time. Linear Regression was performed by Gauss (1809) to predict planetary movement. The field requires high computational power since millions of mathematical calculations take place before giving a useful output. Graphical Processing Units (GPUs), popularly known as Graphic cards emerged in the 21st century and were capable of handling calculations parallelly. This helped the field to prosper, and since then, there has been no stopping for groundbreaking research in ML.

The first thing a beginner should learn in Machine Learning is a Linear Regression model. We suggest you learn the concepts as illustrated in the article. Now comes the implementation part.

For this, you will need Numpy and Matplotlib. Numpy is a matrix handling library in Python. Matplotlib will help you plot your 2-dimensional data, and you can use this for visualization. A good tutorial for Numpy can be found here. One for Matplotlib can be found here. Let us proceed forward.

Linear Regression data is available in plenty on the internet. If you are smart enough, you can make your own data (Hint:Use np.linspace, and introduce some randomness in the data). Use the ordinary least-squares loss function to optimize your model, and write a code for gradient descent which will minimize the least-squares loss function. Then create random data points (or linearly spaced data points :) ) and test how well your model has predicted using Matplotlib.

Here is a bonus task for you. Try to figure out how this method of Linear Regression can be manipulated to solve for a polynomial of degree ’n’.

Feel free to ask any doubts about any secretaries. You may also refer to various blogs explaining how to write your first linear regression code. Take it this way: you have been given a problem statement, and you have to solve it in whatever way you can. All the best!

The links for the tutorials can be found here again —

  1. Linear Regression Wiki —
  2. NumPy tutorial —
  3. Matplotlib tutorial —
  4. A nice walkthrough Linear Regression —
  5. A Python implementation of Linear Regression —

This blog post is a part of the Programming Club, IIT Kanpur blog series.