Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Saturday, May 12, 2018

What is your favorite programming language or technology and why!?

In an interview I just attended, I was asked this interesting question. I felt that I had to tell them there are no favorites. Its pretty task specific. read more below >>>

What is your favorite programming language or technology and why!?
My Answer:


When it comes to programming, I have always been very versatile. I have worked with multiple languages and technologies, so I cannot really point my finger at any such favorite. I have loved working with visual languages. For example, HTML, CSS, JS, Jquery, (The web in general) are some languages that when I write code, I can view the results without needing to do more than a simple page refresh. This motivates me to develop code very rigorously and I iteratively make my webpage better and closer the specifications. Javascript has really blossomed into something beyond my imagination. From a simple client based scripting language, it has aggressively began competing with the latest and best out there. When I first started with Javascript in 9th grade, I had little idea about any of this. I wanted to build websites and looking at JS it seemed close to C language. It was simple and the interesting concept of the language was that it was un-typed. This meant I could worry less about pointers and types. Later, python also introduced similar concepts and I believe this is the reason these are widely used today. Though type-less variables makes the developer's life harder, its ultimately more fun and simpler to understand from the start.




Being well-versed in many programming languages, I don't have a single favorite language. I move from language to language as I change my clothes. I just pick up a new technology or language when I require it. When I started working with JAVA, I picked it up in just 3 days. I worked so much with SQL that I can write nested queries without even trying for a few minutes. I love challenging myself as well as keeping up with the new technologies. I feel that any language which helps me achieve one particular task is my favorite. For example, if the coding challenge's first question had an option for python, I would go with it. I only chose javascript to avoid pointers and after thinking about JS's built-in string and array functions/methods. 




The concept of Object-oriented approach was taught to me while I was learning C++. From then on, I learnt the same features specific to JAVA and then Javascript. Finally, I learnt the python features as well. Any language is good, as long as you have a strong sense of confidence and understanding of what exactly that language was built for. When the programmers wrote the language itself, what did they have in mind? Hence, we should choose a favorite specific to the task at hand. If I am working with lists, arrays and the likes, even data structures like linked lists and others, I would right away choose python. It makes it very simple. However, if I was building games, I would use C++ and OpenGL. Though, nowadays we have very high-quality libraries that enable me to design and develop them within your browser using javascript. I want to develop software without worrying the need to by-heart or mug-up the built-ins. I look up something and use snippets from anywhere as long as its legal to put together my program which produces the desired result.




One of my main challenges was when I was building a compiler for a certain Compiler Construction course in college. The question was similar, which language would you choose. I definitely pulled away from JAVA, and C++, owing to the inherent complexity. Next, I was deciding between python and javascript. My professor is a sticker to Racket, his own programming language, which he built along with his team. This language is also non-typed, though it has a really complex learning curve. However, it is good for matching and working with S-Expression, or even reg-expressions. It was a good language for building compilers, but I found it hard from day 1. I worked on it for a few months but gave up to work with python. I wrote a compiler for the language BrainF**k and it wasn't complete, though it was doing the basic bidding. I was inspired by the repl.it compiler is written in javascript for brainf**k. Now brainf**k is my favorite language. It has like 11 tokens and barely and complexity. But the most interesting part for me was the fact that a simple hello-world program was like over 40 lines of code. 


From this, I realized the more abstraction a language has, the fewer lines of code we need. Lesser the complexity of the language, higher the lines of code we need even for the most trivial of stuff. Hence, I like to conclude by saying that I love brainf**k as it thought me the required prerequisites in the programming paradigm and showed me how one can even make a simple language with little or no regard for its usefulness. 

Friday, March 30, 2018

Working with SERIAL input from devices

Working with Windows Device Manager

Device Manager
These can be setup in the Device Manager section of the Control Panel in Windows. To access the Device Manager, please follow these steps.
         Click the bottom-left Start button on desktop, type “device manager” in the search box and tap Device Manager on the menu.
         Or else, Open Device Manager from Quick Access Menu. Press Windows + X to open the menu and choose Device Manager on it. 
         One might also Access Device Manager in Control Panel. [Google]
Once device manager is visible, we can find the device under Ports (COM & LPT). The RADAR should be listed under this section only.
Note: Device Manager is used to setup both the devices.

Reading from serial input

When we have USB COMM Port devices, we need can read data generated by them using various toolkit libraries, such as pySerial in python etc. However, we might need to Poll the device for data once or twice before actually setting up automated tasks using python.

Here I go into the thinking involved while working with such devices.
I take as example the ICM 20948 IMU component. While reading data from this device, one must:
  • Refer to the Datasheet for possible COMM Port settings and requirements.
  • Utilize Putty to connect serially and read data
  • Looking up related documentation for downloading and installing drivers. 
  • Sometimes we might have to install unsigned Drivers
    • Please refer to Google to find out how to disable Windows Driver Signature Verification at boot.
  • Next, lookout for consumer facing data reading software.
    • For example, ICM 20948 can be used with MotionLink provided by the manufacturers to view the real time data from all the sensors.
    • Such software can be customized using their own IAR Workbench IDE. 
    • Look for manufacturer provided examples. 
    • Look at other alternative locations to download related datasheets and configuration files or supporting applications
    • Be sure to try different versions of the IDE to figure out what works on your system with that particular component.

Link to my report on system for 3D-DIC measurements and techniques using ICM and RADAR component, while hooking it up with RaspberryPi.

I worked on an academic project with the Mechanical Department, where I worked with these components and used pyserial library to interact with both of them simultaneously as was the need of the project. The complete guide to software development in these scenarios can be found alongside the report of calibration and usage.
You may access the report from my drive link here

GitHub Repo












PYTHON COURSE 1a - BASIC INTRODUCTION TO PYTHON DEVELOPMENT

INSTALLING AND WORKING WITH PYTHON
1. DOWNLOAD VS CODE EDITOR

WHILE INSTALLING, BE SURE TO CLICK
  1. ADD TO PATH IF POSSIBLE
  2. ADD TO CONTEXT MENU FOR
    1. FOLDER
    2. FILE
VERSION 2.7.XX
select Add to Path option while installing.

2. NEXT,
  1. Open the command prompt by typing cmd in the Start application
  2. Then type python in Console Window to check if python is installed.
  3. If yes, the console should go into the python shell. LIKE SO

3. NEXT,
  1. Exit the shell by keying in “exit()” into python shell
  2. When in cmd console
    1. You should see the cmd root like
    2. “samar” is replaced by your username – THIS is your HOME folder.
    3. Common CMD line commands are
                                                       i.      Make Directory
        1. mkdir <space> <DIRECTORY_NAME>
                                                     ii.      Change Directory
        1. cd                        Current Directory
        2. cd <space> <DIRECTORY_NAME>  Goto DIRECTORY_NAME
        3. cd <space> <DOT DOT> (cd ..) Go One folder up or Back.
        4. Examples:
          1. cd ..
          2. cd Desktop
          3. cd Desktop/Some_Folder
          4. cd Desk*
                                                                                                                      i.      Autocompletes characters with * - 0 or more chars.
                                                                                                                    ii.      Autocompletes characters with + - 1 or more chars.
                                                   iii.      List Directories and files
        1. dir in Windows.
        2. ls in Linux.
                                                    iv.      Whatever you type here in cmd is a program
        1. If the program exists, it is opened
          1. If its console program, only console is shown.
          2. If its GUI – window based program, both console and window is shown
        2. If the program doesn’t exist, then the error command not found is shown.
4. NEXT,
  1. Download the program.
    DOWNLOAD HERE - test.py
  2. Open CMD C:\users\your_username> <ENTER CMD>
    1. Navigate to Desktop cd Desktop
  3. Create a folder using mkdir NEW_FOLDER_NAME (ex: mkdir test)
  4. Copy the test.py into the directory. Enable Show File extensions for known formats from View Options at the top
  5. AFTER making sure that the current directory is open by using cd
    1. cd should show you C:\Users\YouRs\Desktop\test
    2. else use cd test to enter the newly created folder housing the test.py file.
    3. To edit the file, use vs-code. Try Right-Click in folder and select Open with Code.
  6. Once the cmd is in test folder, we can try running the program.
  7. Just type python test.py to run the code. You should get this output
To learn more try


  1. Tutorials Point - python course