# Programming Languages in the Wild 1) For discussion, you chose the programming language: python 2) This language is: General Purpose 3) Is this language Turing complete?: Yes ## Uses 4) For what killer app, projects, or historical reason is this language best known or used ?: Python is best known to be easy to learn and convenient to use for a wide variety of purposes. It's widely used in machine learning/data science, web development, game development, etc. It can be used for concurrent programming at least for I/O-bound operations without a big impact to computational speed. 5) Is the answer to 4, which the language is known for, due to language features, community support or libraries, or something else?: All of the above: Python is easy to learn and use because of its intuitive and simple syntax. I personally feel like a big part of this is the dynamic typing and lack of need for handling memory management. Python allows for object oriented, functional, and imperative programming, making it flexible for all use-cases. It has wide community support across all areas, which is why it can be easily used in web development, game development, etc. It's also written in C, which is a big reason it's so commonly used in machine learning and data science; libraries like numpy, that are also written in C, allow for speedy computations. ([x](https://docs.scipy.org/doc/numpy-1.13.0/reference/internals.html)) 6) As a programmer, what is easy to do in the language?: One thing easy to do is functional programming, like using higher order functions and using lambda (anonymous functions) that can refer to non-local variables. Another thing easy to do is use classes and write object oriented programs. It's also easy to return tuples with multiple objects inside, because everything in python is an object. 7) What does the method to do the answer to 6 look like in general purpose languages like c or java?: Because C does not have higher order functions, in order to exhibit the same behavior as python, you would need to pass around function pointers to exhibit higher order function behavior, and build your own closures. Instead of using anonymous functions, you would need to define the function separately. Java 8 has anonymous functions, but "local variables referenced from a lambda expression must be final or effectively final" - so to use them, you cannot mutate a local variable in the same scope as the one that the lambda function is defined in. ([x](https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html#accessing-local-variables)) So in python, while you can do this: ```python a = 1 f = lambda x: x + a ``` You cannot do the equivalent in Java: ```java int a = 1; Consumer f = (x) -> { return x + a; //error }; ``` Java is object oriented but C is not, so you need to use functions and good modularity practices. In C, to do the same thing as returning a tuple in python, you need to declare a struct and return the struct. 8) Does the programmer have to give up anything to gain the benefits of this language?: Yes, python has the GIL (global interpreter lock) which makes it so that all python modules use the same shared memory space, controlled by one mutex (the lock), so only 1 thread really runs at a time. ([x](https://wiki.python.org/moin/GlobalInterpreterLock)) This makes python slow for CPU-bound multithread operations, since it cannot make use of the multiple cores that a machine may have. Python is also interpreted at runtime, which makes it slower as well as harder to debug (programs that would normally fail due to a "compile time" error in a compiled language will still run). These drawbacks generally lead to scalability problems. Also, since everything is an object, the programs use more memory (for example, an array of ints is really an array of pointers).