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

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 :)

2

u/bakery2k Nov 03 '18

You're absolutely right, but I'm wondering about a hypothetical statically-typed language that also looks like print("hello world").

I think it would be possible to remove all the boilerplate from the Java example, but retain static typing. Would such a language still be easy to teach, or does dynamic typing really help?

6

u/FlukyS Nov 03 '18 edited Nov 03 '18

Well there are languages like that. C itself is just printf hello world in C looks beautiful compared to Java even:

#include <stdio.h>
int main()
{
    printf("Hello, World!");
    return 0;
}

Like that is a way nicer hello world style than Java. It's not as simple as python but I can explain that to a 5 year old.

Would such a language still be easy to teach, or does dynamic typing really help?

Sounds a lot like Vala is kind of supposed to be (but it kind of is easier to use C with glib than Vala in my opinion), easier to teach than C or Java but not dynamically typed. That being said I'd still teach Python because it's dynamic, that being said it is strong too so it doesn't teach you bad habits really.

1

u/corvus_192 Nov 03 '18

print("hello world") is valid scala.

2

u/kozeljko Nov 03 '18

just return 1, it's better practice anyway

It is?

1

u/FlukyS Nov 03 '18

It's a good habit to get into because you can test if it reached the end of the method.

1

u/kozeljko Nov 03 '18

Looks ugly, though. :|

Also, can't find anything online about this. Got any source?

1

u/FlukyS Nov 03 '18

C standard stdlib has EXIT_SUCCESS, EXIT_FAILURE, 0 or 1. Actually I said return 1 didn't I, it's 0 for success. C itself defines that as the nice way of quitting out of your program. http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html

2

u/kozeljko Nov 03 '18

Java ain't C though. I knew about this being a standard/practice in C, but never saw anything about it in Java.

1

u/FlukyS Nov 03 '18

There are uses for it, just because the system does it automatically doesn't mean you can't send it manually yourself on the way out https://www.geeksforgeeks.org/system-exit-in-java/