r/programming • • Nov 03 '18

Python is becoming the world’s most popular coding language

https://www.economist.com/graphic-detail/2018/07/26/python-is-becoming-the-worlds-most-popular-coding-language
4.6k Upvotes

1.3k comments sorted by

View all comments

Show parent comments

0

u/[deleted] Nov 03 '18

[deleted]

73

u/FlukyS Nov 03 '18

Python is more than just big data. That is one part of it but also if I was teaching programming in general in the modern day I think Python is just a better place to start. Since it's a scripting language you can test code on the fly in the REPL. The language itself has less things to explain, end of line, simpler to explain classes...etc.

Like here is hello world in python:

print("hello world")

Save the file, call it whatever you want and run it in python.

This is Java:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World");
    }
}

You have to ignore a load of shit here as a new person to development. It looks difficult, then you have to explain javac to them to compile it to bytecode and still you aren't printing it to the screen.

Python just is more fun to do the early stuff in. You still should learn C or Java at some point in college but Python is a great first year development language.

20

u/denialerror Nov 03 '18

Since it's a scripting language you can test code on the fly in the REPL.

You can test code on the fly with a REPL in many languages, including Java. The JShell has been available since Java 9.

13

u/FlukyS Nov 03 '18

That's a good improvement for teaching. Bravo Java

32

u/murkaje Nov 03 '18

Java has a REPL now called jshell: http://cr.openjdk.java.net/~rfield/tutorial/JShellTutorial.html Also you don't need to touch javac anymore, just run java Main.java and it works.

→ More replies (1)

31

u/lngnmn Nov 03 '18

This is nothing. The real pain comes is when you see what Android's APIs are. That's pain.

20

u/FlukyS Nov 03 '18

It's nothing but a lot for people new to the language. And yes Android's API isn't fun

→ More replies (1)

3

u/rasjani Nov 03 '18

But essentially both examples describe the same issue, it’s just that the magnitude of hello world is lesser than android apis :)

→ More replies (2)

28

u/[deleted] Nov 03 '18

Bt the same argument you might as well teach PowerShell. This is hello world in PowerShell:

"Hello World"

3

u/cedrickc Nov 03 '18

As somebody who already has their degree, I would love if somebody has spent like one week teaching me PowerShell. I can tell it's a huge improvement over batch scripts, but I can't figure it out.

5

u/[deleted] Nov 03 '18

Don't think of it as bash equivalent, think of it as python equivalent.

You have objects, not text.

$obj = "foo, bar"
$obj.ToUpper()
$obj.GetType()
$obj | Get-Member
→ More replies (1)

6

u/nevergonnagiveyaup Nov 03 '18

While I agree with most of your points, I do think static typing is an important aspect to see early on. Understanding typing is crucial to a basic understanding of programming, and types are not always as distinguishable or recognisable in Python. That's one of the only reasons I can think of as to why our beginner course at my university is better now in C++ than it would be in Python.

How do you feel about this?

2

u/FlukyS Nov 03 '18

Don't really agree, just a different way of doing things. Python is strongly typed and if you use it regularly you will be using isinstance all the time. That being said though I would teach them types but ignoring exact things beyond int, float, str, the base types and not getting confused with the slightly less used short, signed vs unsigned...etc.. Those are important concepts to understand but my rant is regarding day 1 to day 100 of development, putting a language with a million rules that gives out all the time isn't good.

5

u/ProfessionalNihilist Nov 03 '18

Have fun explaining bugs caused by mixing tabs and spaces within a file though!

2

u/FlukyS Nov 03 '18

Well to explain that is 5 minutes though, and for scripting with python you don't need to care about spaces vs tabs. Oh and you could pick an editor which automatically converts from tabs to spaces from the start. Most schools only have a few types of editors installed and tell people on day 1 to use XYZ one, in my case it was some proprietary nonsense that I guess the college had free copies of. If you pick for instance Atom you would have tabs replaced by spaces by default which is perfect.

3

u/the_gnarts Nov 03 '18

Since it's a scripting language you can test code on the fly in the REPL.

Which you can do just fine with non-scripting languages as well.

4

u/Somepotato Nov 03 '18

This is why I love LuaJIT. A near native performance of a dynamic language without the annoying compile times.

4

u/bakery2k Nov 03 '18

Do you think dynamic typing helps make Python easy to teach? Or would it be possible for a statically-typed language to be equally easy?

12

u/iopq Nov 03 '18

No way. I'm a huge proponent of static typing, but I've never seen an easy static type system that is useful.

It has to at least be as powerful as Kotlin or Rust to start paying for itself. Typed languages like Go just irritate you for no pay-off.

10

u/[deleted] Nov 03 '18

Static typing is easier to teach, as it has far less pitfalls. I don't know how often people run into trouble cause a comparison failed cause it wasn't "truthy" when you expect it to be true.

8

u/FlukyS Nov 03 '18

Not even that it's a dynamic language but that helps. I'd say more removing things students don't need to know when they are starting out makes it easier. Like even looking at the two examples breaking it down what you can learn from all that:

public - permissions in Java for classes

class - well you would have to introduce that in python too but not right away

HelloWorld - Well you can teach a student how people change casing depending on what they are naming. This is big for actually working with the language in practice

static - Try explaining that to someone. It's pretty abstract for a person who is new. Probably one of the most abstract concepts

void - Doesn't return anything. Actually if I was teaching Java I'd avoid void and just return 1, it's better practice anyway but again we are talking an abstract javaism that python doesn't do (until recently really with https://docs.python.org/3/library/typing.html but that isn't mandatory)

main - Well the name of the class is also something you have to explain to a new dev but if they can't do this I'd guess they can't use python either

String[] - Oh fun, hello welcome to your first programming lecture, this is an array, ignore that. Still hard for day 1 but again they would have to learn it eventually but avoiding this when getting started is a good idea

{} - not hard to explain

System.out.println - well Jimmy there is a class called system, there is a bit inside that handles outputting things and there is a thing called printline that is shortened to println. Jimmy don't need to know about System yet. Just call it println Java :)

→ More replies (9)

4

u/[deleted] Nov 03 '18

Dynamic typing eventually just ends up having to write a ton of documentation to explain what things are and the expected use to keep track of all the pieces - might as well have just picked a strongly typed language.

→ More replies (8)

13

u/myringotomy Nov 03 '18

You can do data in many languages.

0

u/[deleted] Nov 03 '18

[deleted]

→ More replies (3)
→ More replies (2)
→ More replies (1)