Problem ?

Problem arises when you don’t get to know why my program dysfunctional , inspite of correct logic . The problem may be with memory handling or in the thread handling . Learning syntax is half part , gaining proficiency is another part .

What exactly is memory management ?

In C/C++ assigning memory & handling threads can PITA until one reach a level of experience . Let’s go by an example:

#include <stdlib.h>

void bad_memory(void){

int* array_alloc = malloc(20 * sizeof(int));
array_alloc[20] = 10 ;
}

int main(void){

bad_memory();
return 0 ;
}

The above code has two errors . It doesn’t pops up during compilation and during execution . First one : assigning out of bound index of array_alloc a value i.e array_alloc[20] Second one : not freeing the allocated memory resulting in memory leak .

###Valgrind to rescue ! By definition : The Valgrind tool suite provides a number of debugging and profiling tools that help you make your programs faster and more correct. The most popular of these tools is called Memcheck. It can detect many memory-related errors that are common in C and C++ programs and that can lead to crashes and unpredictable behaviour.

To rescue onself run the executable using valgrind command

valgrind --leak-check=full ./a.out

The result is as following

valgrind --leak-check=full ./a.out
==25516== Memcheck, a memory error detector
==25516== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==25516== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==25516== Command: ./a.out
==25516==
==25516== Invalid write of size 4
==25516== at 0x400512: bad_memory (in /home/rooted/Documents/git-repos/workshop/code/a.out)
==25516== by 0x400522: main (in /home/rooted/Documents/git-repos/workshop/code/a.out)
==25516== Address 0x51f2068 is 0 bytes after a block of size 40 alloc'
d
==25516== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==25516== by 0x400505: bad_memory (in /home/rooted/Documents/git-repos/workshop/code/a.out)
==25516== by 0x400522: main (in /home/rooted/Documents/git-repos/workshop/code/a.out)
==25516==
==25516==
==25516== HEAP SUMMARY:
==25516== in use at exit: 40 bytes in 1 blocks
==25516== total heap usage: 1 allocs, 0 frees, 40 bytes allocated
==25516==
==25516== 40 bytes in 1 blocks are definitely lost in loss record 1 of 1
==25516== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==25516== by 0x400505: bad_memory (in /home/rooted/Documents/git-repos/workshop/code/a.out)
==25516== by 0x400522: main (in /home/rooted/Documents/git-repos/workshop/code/a.out)
==25516==
==25516== LEAK SUMMARY:
==25516== definitely lost: 40 bytes in 1 blocks
==25516== indirectly lost: 0 bytes in 0 blocks
==25516== possibly lost: 0 bytes in 0 blocks
==25516== still reachable: 0 bytes in 0 blocks
==25516== suppressed: 0 bytes in 0 blocks
==25516==
==25516== For counts of detected and suppressed errors, rerun with: -v
==25516== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 2 from 2)

There are two errors : Heap error for invalid assign & Leaks relating lost memory .

Valgrind can also be misused to profile your code (pun intended ) Further Valgrind can also be used for Bounty programs (like google chrome).

Conclusion !

There are other tools for debugging like GDB which is very elaborate & pro-like . Apart from that Valgrind is there . As pointed out what’s better than finding out bugs as quickly without any pain .

Comments welcomed . Pros & cons ?

Brilliant jerks ?

So who are Brilliant jerks (someone awesome at coding/hacking?) Yes , they are top coder people , algorithmic strong and overrunning , specialist in their areas but with an collaboration problem with them . They get arrogant for their material and are blame gamers .

Philosphy !!

This philosphy is very much followed and applicable to startup culture and growth culture companies . Startup is not looking for brilliant geek but also for a team player , who can effectively communicate with the team and maintain the integrity. A culture where you don’t aim at others for the problem , a culture you believe in peer review system .

How to handle them?

The thing is one can’t just trust them the best way is just to avoid these people because it is very much important to preserve the existing resources and something which can go side by side with them . The collaboration part is most important .

Filtering out soon ?

So how one filter them out , it’s simple you can smell them out during the personal interview . Whether the person is trustful ,making false statement & commiting their own mistakes .

GROWTH IS DIMINISHED BY SUCH JERKS

Buzz word

Growth is buzz word in todays IT world especially startup world & culture, if one is not continously growing , that is endangering sign. Either someother company may take over you like the cases happened for Kodak. So growth hacking is like “MOVE FAST & BREAK THINGS”. One need to evolve and growt from/with the existing products and service. Its like branching out .

How to Growth hacking?

The hacking word isn’t misleading, infact it is the inspiration for the Growth Culture . It isn’t easy to continously Rise high & higher , so one need to do it either by hook or by crook . That all is matter to find way between the hurdles. So having a hackers way to do the stuff isn’t bad at all. Further this talent isn’t easily visible just through face to face interview generally & one can’t simple induce it just that . So just watch & observe precisely to find it .

Benefits

One may definitely argue and fight for the cons but the truth is Growth hacking or other alternative Productivity is addictive habit , one you are into it , one does go for it everyday & everytime. And ofcourse there are options to rollback if anything goes wrong .

Conclusion

Finding solution any-how is main motive ,it can done through being creative or just using the conventional methods.

Haskell is a functional language & very different from imperative langauges such as python,ruby,c++..etc . It is also called declarative language, the reason is simple one just describe the problem in the program instead of instructions on how to solve the problem .

Why Haskell ?

It’s just not the haskell , this is about functional language , equal importance is for the Scala . The main context for functional langauge is involvement of “Academia” , which other imperative language fails to bridge . It so much fun to learn mathematics and science using functional langauge .

Syntax

Syntax might seems very unconventional to conventional programmers , but it’s just for the good . Functional programming discourages mutable variable & does not allow reassignment to variable.

Haskel limelight:

"-- " is used for comments
let this = [ 1,23,42,97] -- 'this' represents variable name for the list
length this -- length is a function
--notice while passing arguments no brackets are used
let start = head this -- return the first element of list

let latter = tail this -- return list apart from head

let access = this !! 2 -- '!!' used to access element 2 tell the possition.
-- ofcourse indexing begins with "0"

null this --null is function 'this ' act as argument will return true if argument is null

let loop = repeat 4 --repeat act as infinite loop and generate an infinte list
--infinity concept is just kept in mind
let slice = take 2 this --slice first two elements from the list
let duplicate = replicate 2 5 --finite loop for generating argument 'n' times


let append = x ++ y -- (++) appends two lists one after another

let two_dim = [[1,4,5],[2,9,7],[1,2,3]] --syntax for two dimensional list

let concatenation = concat two_dim --this would reduce two dimensional list to one dimensional by concatenating each sublist to single list

Well if you reached so far , won’t you like to evaluate yourself .

expandList :: [Int] -> [Int]
expandList lst = if null lst then [] else (replicate (head lst) (head lst)) ++ expandList(tail lst)

You have to guess the purpose of above function .

Put it in comment section .

Internet Quote

“Genius are full of doubts while stupid are full of confidence”.

That’s true and but isn’t that is unfair ,people judge you just by confidence . One quick way to gain confidence is : “Do what you are afraid of ?”. Whether it is to prepare for a speech “ Do a mock up speech in front of friends?” Be it a algorithm problem “Just ask someone else for help if stuck but don’t put it on tomorrow !” or Be it making a Blogging site: “Just do it . Refactor it later”.

One shouldn’t wait for perfection . Iterate later . And Let keep it short that way .