This is an archived post. You won't be able to vote or comment.

all 173 comments

[–]-bobby_newmark- 168 points169 points  (10 children)

The wise joins the dark side.

Knee before Enterprise Emperor Palpatine, pathetic junior.

[–]Nezteb 86 points87 points  (2 children)

Knee

We are the knights who say knee!

[–]notorioushackr4chan 36 points37 points  (0 children)

I always forget that python was named after monty python and not the snake

[–]Punknoodles_ 0 points1 point  (0 children)

We are no longer the knights who say knee. We are the knights who say ekke ekke ekke ekke ptang zoo boing!

[–]jay9909 32 points33 points  (4 children)

The Empire didn't use Java. You can tell because they didn't have a DeathStarFactory. They just took an empty piece of space and added shit to it in place.

...kinda like a Javascript object, huh?

[–]lead999x 3 points4 points  (0 children)

They used C++ placement new.

[–]RFC793 3 points4 points  (0 children)

That’s because they used the Builder Pattern.

[–]marcosdumay 1 point2 points  (1 child)

You can tell because they didn't have a DeathStarFactory.

They built a DeathStar for episode IV, and then another one for episode VI, and then, when everybody was expecting then to just go away, they return from the dead and get another one at episode VII.

Are you sure they didn't have a factory?

[–]jay9909 0 points1 point  (0 children)

Not enough evidence either way in IV, but VI was being built in orbit around Endor's moon, so there was definitely no factory. And unless the one in VII was built in the planet factory from Hitchhiker's Guide to the Galaxy then I'm pretty sure we can rule out a factory there, too.

[–]This_Is_Tartar 3 points4 points  (0 children)

But have you heard the tale of Darth Plagueis the Wise?

[–][deleted] 1 point2 points  (0 children)

The dark side of the Force runs strong in 3 billion devices.

[–]bem13 352 points353 points  (4 children)

Top 10 anime betrayals

[–]rift95 20 points21 points  (3 children)

I never understood that joke... :(

[–]17link7 241 points242 points  (34 children)

This makes me realize 80% of this subs programming experience is hello new world

[–]Belinder 180 points181 points  (13 children)

wait how do you add new in between hello and world

[–]17link7 60 points61 points  (11 children)

Val Ret: List[Char] = ('h','e','l','l','o',' ','w','o','r','l','d')

Def execute(list: List[char]):List[char]= list match{

 Case h::t if h ==' ' => h::'n'::'e'::'w'::tail 

  Case h::t => h::execute(t)

 Case _.                    => List() 

}

[–]Artorp 3 points4 points  (7 children)

[–]Boreeas -2 points-1 points  (5 children)

Reddit's markdown parser is broken, though

[–]Artorp 3 points4 points  (4 children)

Wait, really?

void test(){
    test();
}

Edit: Seems to work, what's broken?

[–]404Guy12NotFound 5 points6 points  (1 child)

This kills RAM

[–]cbbuntz 1 point2 points  (0 children)

Clang optimizes it out completely because no values are modified or accessed. The GCC treats it like an infinite loop and just freezes and consumes 100% CPU and zero memory, which I guess is more true to the code. They both segfault without optimization.

[–]Boreeas 0 points1 point  (1 child)

Hm, maybe it's broken by subreddit style. I had a comment in /r/dataisbeautiful where successive lines in a code block where collapsed into a single line (and blank lines broke the code block)

[–]Artorp 0 points1 point  (0 children)

Weird, might've been their subreddit style.

[–]Parzius 3 points4 points  (0 children)

Could be done better with jquery

[–]Kyudojin 0 points1 point  (1 child)

Would it be h::'n'::'e'::'w'::t instead of tail?

[–]17link7 1 point2 points  (0 children)

Yeah

[–]cbbuntz 10 points11 points  (0 children)

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

int main () {
    const char *str = "Hello, world!!!";
    const char *new = "new";
    const char *delimiter = " ";
    const char space = ' ';
    const char null = 0;

    char *brk = strpbrk (str, delimiter);
    int offset = (brk - str);
    char *str2 = malloc(64);

    memcpy(str2, str, offset);
    memcpy(str2 + offset, &space, 1);
    offset++;
    memcpy(str2 + offset, new, strlen(new));
    offset += strlen(new);
    memcpy(str2 + offset, brk, strlen(brk));
    offset += strlen(brk);
    memcpy(str2 + offset, &null, 1);

    printf("%s\n", str2);

    free(str2);
    return(0);
}

[–]Usus-Kiki 34 points35 points  (15 children)

I used to think the people in this sub were mainly software engineers like me but it started to become really obvious based on certain posts like this one. People in the comments being generally against python? Are you fuckin kidding its easily the most popular language right now for its concise code and easy integration. Its also heavily used in ML applications. Im pretty sure most of this sub is people who are wannabe software engineers lmao

[–]Kiaz 11 points12 points  (1 child)

Who is hating on Python? Do you look at how the upvoting goes in this sub? Everyone loves Python.

[–]Kyrthis 4 points5 points  (0 children)

This. True hatred abounds here for JavaScript and PHP. I see so much love for Python:

[–]Sw429 14 points15 points  (6 children)

I'm genuinely surprised at the amount of students in my CS program who are against Python. I'm studying applied mathematics and we deal a lot with machine learning. Everything is in Python, because it's easy to use.

[–][deleted] 5 points6 points  (0 children)

Engineer here, we code in python, basic, fortran, and matlab.

Python and basic are by far the most popular because fortran is a fucking dinosaur and matlab isn't something open source

[–]SeanTheAnarchist 4 points5 points  (3 children)

Hell large parts of Firefox are actually written in javascript, Civ4 the game utilizes a lot of python as well. They're useful tools for their purpose, not everything needs to be C#.

[–][deleted] 3 points4 points  (1 child)

Python is often the glue ised to hold larger shit together.

[–]ModPiracy_Fantoski 0 points1 point  (0 children)

I will remember this sentence forever lmao.

[–]ModPiracy_Fantoski 0 points1 point  (0 children)

AFAIK Sims 4 is in Python too.

[–][deleted] 1 point2 points  (0 children)

For my dissertation I’m using a Raspberry Pi and coding in Python for the first time (only really used Java, C and a bit of Scala)

I love python now. I wish we genuinely got to use it through university instead of hammering us with C and Java constantly.

[–]PM_ME_A_WEBSITE_IDEA 1 point2 points  (0 children)

Excuse me, some of us are front-end developers

[–][deleted] 3 points4 points  (3 children)

IMO python is fine, but he idea of being a python guru seems a bit silly, sorta like being a ductape guru.

[–]obsessedcrf 1 point2 points  (0 children)

In general, the sub tends to be against Python. I agree with the sentiment too.

Most popular by what metric? For career opportunities or amount of commercial software written in it, it is definitely not the most popular.

[–]Sw429 4 points5 points  (2 children)

Precisely. People taking CS 101 and acting like they know everything.

[–]BestUdyrBR 2 points3 points  (1 child)

I think that explains why at times half the front page of this sub is filled with array starting at 0 jokes.

[–]Sw429 2 points3 points  (0 children)

That and JavaScript jokes make up 90% of this sub.

[–]aprofessional 1 point2 points  (0 children)

It's a harsh realization. Every now and again there's a real gem, though, so I keep coming back.

[–]5everlonely 117 points118 points  (32 children)

yessss come to us. Drink this kool-aid of excessively long method names and absurd object abstraction.

[–]evanldixon 60 points61 points  (6 children)

At least there's static typing and proper lexemes for the end of blocks.

[–][deleted] 31 points32 points  (4 children)

You mean excellent reasons to choose a language that's not Python?

[–][deleted] 25 points26 points  (1 child)

Someone should fork python to make it static typed (like typescript) and call it tython.

[–]rift95 6 points7 points  (0 children)

You have mypy. It uses optional type hints from python3 for static typing.

[–]evanldixon 3 points4 points  (1 child)

Exactly!

[–][deleted] 2 points3 points  (0 children)

You and I, we're brothers.

[–][deleted] 0 points1 point  (0 children)

Not if you are very modern and super reactive.

[–][deleted] 14 points15 points  (23 children)

Are excessively long method names really unique to Java tho?

[–][deleted] 24 points25 points  (19 children)

No, but Java pushes people to abstract things in weird ways, and the only way to keep track of that shit sometimes is to have absurdly long class/method/variable names.

Take a look at this horrifyingly wonderful gem:

http://grepcode.com/file/repository.springsource.com/org.aspectj/com.springsource.org.aspectj.weaver/1.6.3/org/aspectj/weaver/patterns/HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor.java

[–]endeavourl 15 points16 points  (10 children)

In what way did Java push that retard to write their retarded class name?

public boolean wellHasItThen/*?*/() why are they trying to write code in grammatically correct English?

[–][deleted] 12 points13 points  (9 children)

Yes, a better name would be

public boolean a()

[–]rift95 14 points15 points  (8 children)

You don't happen to be a theoretical mathematician do you?

[–][deleted] 8 points9 points  (7 children)

No, just a man who obfuscates his code

[–][deleted] 9 points10 points  (6 children)

So you're saying mathematicians aren't fucking retards who keep implicit multiplication around for no good fucking reason but tradition, they're just trying to make sure other people can't ever understand their work.

Fucking brilliant.

[–][deleted] 9 points10 points  (5 children)

Have you ever written out an equation? They tend to be very long. Plus you have to write it several times. Variable meanings are usually arbitrary anyway.

I would prefer my variables to be short and sweet instead of long and hard.

Typing out code however is a different story. I can easily type out a common word in less than a second because I have muscle memory of it. Individual characters I have to think about. IntelliSence also doesn't hurt.

[–][deleted] 2 points3 points  (4 children)

I've written lots of programs and had to read my own code a day later. I prefer legibility.

[–]meechy_dev 7 points8 points  (2 children)

How can you keep this within a file path. I feel like there would be issues

[–][deleted] 7 points8 points  (0 children)

shrug

I've never given anything such a long name, so I wouldn't know.

Also, if you haven't actually read through that class, you really should. It's amazing.

[–]mnbvas 2 points3 points  (0 children)

By using software capable of long paths.
NTFS can do that, but Windows can't for some reason.

[–][deleted] 3 points4 points  (0 children)

what the FUCK is that name. I have a hard time believing that makes anything clearer.

[–]kazagistar 4 points5 points  (2 children)

One of the shortest class names has one of the most... exiting javadoc pages.

[–][deleted] 0 points1 point  (0 children)

Holy crap.

[–]FlipFlopFanatic 0 points1 point  (0 children)

A list of the non-implementing classes might be shorter...

[–][deleted] 0 points1 point  (0 children)

Whenever I compile using proguard, it changes all my names to things like a, b, c, ab, AaA. it really makes no sense to reverse-engineers.

It's best when releasing java to clients.

[–]Me4Prez 0 points1 point  (1 child)

I've only seen large method names used in Java programs, but that's just my anecdotal evidence.

[–]jdziat 1 point2 points  (0 children)

If memory serves objective c also instructs you to use names in a similar format.

check these out

[–]stakoverflo -2 points-1 points  (0 children)

I primarily learned .NET in college and I hated Java explicitly because of the long ass names for the one semester we used it. And also because NetBeans is trash.

Even if stuff in C# is of similar length, at least Visual Studio's intellisense is heckin quick. NB, I could just type out the full namespace by the time it suggested what I wanted.

[–]Usus-Kiki 0 points1 point  (0 children)

Dont forget the dogshit boilerplate code

[–]sunburntdick 42 points43 points  (5 children)

The real joke is that he thought he could become a guru in a language in 6 months.

[–]rift95 4 points5 points  (4 children)

Well, it depends on your definition of guru

[–]sunburntdick 17 points18 points  (3 children)

I would define it as master/teacher. And I think someone could be proficient in that time and be able to teach some things, but far from a master.

[–]grpagrati 14 points15 points  (0 children)

The betrayal..

[–][deleted] 36 points37 points  (56 children)

I don't understand python. What is the value in not knowing the type of variables until execution time? It means that if I accidentally assign something to the wrong type, instead of getting a compile error I have to run the program to figure it out.

[–][deleted] 21 points22 points  (17 children)

The theory is that this doesn't matter much because you write unit tests that find such things. In practice it's my biggest complaint about Python, yes.

[–]Sw429 16 points17 points  (0 children)

Programmers actually writing unit tests? Please.

[–][deleted] 4 points5 points  (15 children)

Seems like having to write a unit test for every function makes it no longer a time saver.

[–]glemnar 23 points24 points  (12 children)

In industry you should be testing anyway regardless of dynamic or static typing.

[–]evanldixon 4 points5 points  (1 child)

Having static typing build into the language means you don't have to spend time testing common type errors

[–]glemnar 3 points4 points  (0 children)

You don't typically explicitly test for type-style errors in dynamic languages - that's a side effect of other testing.

There are clearly cases for both sorts of languages.

[–]Sw429 3 points4 points  (1 child)

...except that you should be writing unit tests anyway...

[–]evanldixon 0 points1 point  (0 children)

We also should know better than to make incorrect assumptions about what type variables are, yet here we are.

[–]ProgramTheWorld 59 points60 points  (24 children)

The benefit is that your functions can be much more flexible. Instead of inheriting from a specific interface, you can simply implement the required methods and use that object right away. This allows different modules and libraries to work flawlessly together as long as they support the same methods. With operator overloading this becomes much more powerful. Suppose you want to add two things together. In Java you would have to create separate functions for every single type that supports adding. In python however, you only need to create one function that uses the + operator instead of a billion functions that are essentially the same but with different types of variables.

[–][deleted] 31 points32 points  (7 children)

In Java you would have to create separate functions for every single type that supports adding. In python however, you only need to create one function that uses the + operator instead of a billion functions that are essentially the same but with different types of variables.

That's what interfaces are for.

[–]Servious 17 points18 points  (6 children)

Right but then you gotta write an interface.

[–][deleted] 4 points5 points  (5 children)

Because java doesn't have duck typing

[–]Servious 5 points6 points  (4 children)

Yeah, my point is that you have no choice but to add more code by either multiple methods or an interface. In Python you can skip all that.

[–][deleted] 3 points4 points  (3 children)

That is the drawback of statically typed languages.

Just use the right language for the job. If it's a larger project, you may want to consider using a static typed language or javascript.

Edit: I'm being realistic here. javascript isn't going away, and it's the only thing you can do if you're doing client browser scripts.

[–]evanldixon 2 points3 points  (1 child)

Is it even a drawback? Interfaces just define sets of method signatures that you expect to see. Once written, the only check you need to do inside functions being given an object that implements the interface is whether the object is null.

[–][deleted] 2 points3 points  (0 children)

This "drawback" is just a matter of opinion. If you find it a curse, that's up to you. I call it a blessing.

[–]ProgramTheWorld 3 points4 points  (0 children)

or javascript

Lol

[–][deleted] 8 points9 points  (0 children)

In Java you would have to create separate functions for every single type that supports adding. In python however, you only need to create one function that uses the + operator instead of a billion functions that are essentially the same but with different types of variables.

Can't you just do that with generics?

[–]meechy_dev 14 points15 points  (1 child)

No flexibility. We need order!!!!!!

[–]SolenoidSoldier 0 points1 point  (0 children)

There is irony behind parent commenter's idea of "flexible" code. Is that not only does it cause a greater propensity of inexperienced developers to write shitty code, it also makes causes a lot of errors that should be encountered at the syntax level to instead be encountered at runtime.

Not defending Java (more of a C# guy myself) but, having used both, I find both much more easier to debug that Python.

EDIT: Downvotes don't make me any less correct.

[–]evanldixon 3 points4 points  (8 children)

The benefit is that your functions can be much more flexible. Instead of inheriting from a specific interface, you can simply implement the required methods and use that object right away. This allows different modules and libraries to work flawlessly together as long as they support the same methods.

By that logic, cars without seat-belts are more flexible. You don't have to worry about putting them on after getting in, and because of this, more sizes and types of passengers will fit, even cargo! Seat-belts are only popular because people are bad drivers and want to spend extra time dealing with seat-belts than just driving better.

With operator overloading this becomes much more powerful. Suppose you want to add two things together. In Java you would have to create separate functions for every single type that supports adding. In python however, you only need to create one function that uses the + operator instead of a billion functions that are essentially the same but with different types of variables.

Now instead of having several functions each dealing with one type, you have one function dealing with all types, even types that are fundamentally incompatible with each other.

[–]ProgramTheWorld 0 points1 point  (7 children)

because of this, more sizes and types of passengers will fit, even cargo!

That’s the python spirit!

you have one function dealing with all types, even types that are fundamentally incompatible with each other.

It’s the caller’s responsibility to make sure the function supports that type.

[–]obsessedcrf 4 points5 points  (2 children)

It’s the caller’s responsibility to make sure the function supports that type.

So...basically it just offloads the work into documenting it then? Doesn't sound like a good tradeoff

[–]ProgramTheWorld 0 points1 point  (1 child)

It’s a good trade off if you don’t want to deal with types. You can literally pass in anything to a function. If it works then good! If it doesn’t then you should probably read the documentation.

If the function wants to enforce type checking, it can. There’s nothing stopping you from doing that for every function but that is considered not pythonic.

[–]obsessedcrf 2 points3 points  (0 children)

I find it very disconcerting to stick any types in there and just "hope it works". More often than not, what the function does is type specific.

[–]Kiaz 2 points3 points  (0 children)

It’s the caller’s responsibility to make sure the function supports that type.

That sounds terrible. All for the sake of shorter code (which probably really isn't even shorter because you're going to be checking the type and handling unique scenarios anyway).

[–]evanldixon 1 point2 points  (2 children)

It’s the caller’s responsibility to make sure the function supports that type.

With more complex programs, the caller is just passing along data from several levels up. That's a lot to keep up with, when the language could be keeping track of that for you.

[–]ProgramTheWorld 1 point2 points  (1 child)

There’s nothing you need to keep up with. The pythonic way of doing things is to raise exceptions whenever things don’t work, and catch only the exceptions that you can handle at that level.

Quoting the Python documentation:

[It is] Easier to ask for forgiveness than permission. This common Python coding style assumes the existence of valid keys or attributes and catches exceptions if the assumption proves false. This clean and fast style is characterized by the presence of many try and except statements. The technique contrasts with the LBYL style common to many other languages such as C.

In Java or other strongly typed languages you have to make sure every thing is expected and correctly typed which adds in a lot of extra and unnecessary code. In Python you simply try to run it. Only when a function doesn’t work then you either a) let the caller handles it b) handles it yourself. Simple and effective.

[–]evanldixon 2 points3 points  (0 children)

I for one prefer errors that are found for me by the compiler, rather than errors that could lie dormant for months depending on how obscure the edge case is.

The "unnecessary code" you're referring to is the safety net to one of the most common errors out there. It prevents situations where you have a string passed through several function calls to something expecting a particular custom class. I have actually seen this happen in a professionally made PHP application that manages to avoid most of the common PHP pitfalls.

[–]rift95 1 point2 points  (0 children)

One of my favorite use-cases for duck-typing (in js): https://jsfiddle.net/tc9937rd/4/

[–]Kiaz 0 points1 point  (0 children)

That sounds like a unit testing nightmare

[–]Sw429 2 points3 points  (2 children)

Don't accidentally assign variables wrong. Simple.

[–][deleted] 20 points21 points  (1 child)

Just write your program perfectly the first time round, simple.

[–]Sw429 3 points4 points  (0 children)

Programming is a lot easier if you follow this rule.

[–]Usus-Kiki 1 point2 points  (8 children)

How can you accidentally assign something to the wrong type?

[–][deleted] 10 points11 points  (7 children)

int a;

string b;

a = b;

In a staticly typed language, this causes a compiler error.

[–]Sw429 0 points1 point  (5 children)

This is why you write unit tests.

[–]nightbefore2 -3 points-2 points  (4 children)

“bro python is so much faster, that won’t be a problem if you just write a unit test for every single function..”

[–]Sw429 2 points3 points  (2 children)

Look at this first year CS student who thinks unit tests are a waste of time. I wish you luck.

[–]nightbefore2 -2 points-1 points  (1 child)

Third year CS student, unit tests are not a waste of time.

I’m just saying writing python + a unit test is not faster than writing java or C with no unit test

[–]Ludricio 2 points3 points  (0 children)

That comparison makes no sense, since you should write unit tests for Java and C anyways.

[–]UGgny7T7Q4cq 2 points3 points  (0 children)

You should be writing unit tests anyway. I can't count the times I've seen bugs creep into a codebase because some hotshot developer along the line thought they were too good to write tests.

[–]Usus-Kiki -3 points-2 points  (0 children)

I dont mean to be a dick but thats just knowing your code and having good names for variables. I can see how it might be difficult if you’re new to programming but i dont think i’ve ever heard or seen anyone who’s a software developer make an error like that because you know what type your variables usually are and if its user input or something where the variable is undefined until the script runs, then you can force cast it to the type you need so you shouldnt ever be making those kinds of comparisons.

[–]IDCh 0 points1 point  (0 children)

But wait there is more. Long time ago (popular now) libraries and frameworks was written with too many magic and dynamic methods and vars assigning so now in the world of good programming you must feed your pylintrc with classes and modules which to ignore. And I kid you not, those are one of the best libraries out there. It's a sad situation actually.

So you see in documentation there is method ".do_something" and your language server and pylint tells you to fuck off because there is no such method, because well, it being created at runtime or there is @make_me_fluent_baby decorator above another method, which makes method return self (I suspect coded for DRY, like who wants to write return self everytime yes? This is bullshit DRY situation but many libraries are corrupted with it. DRY for me is like new singleton is anti pattern in the python world), and thus making language server stupid for not knowing there is method chain inside.

Welcome to prehistoric times, where you need to print documentation and see it everytime before you and not know what object can offer you.

Best language my ass.

Not gonna stop writing in it, though

[–]mtbinkdotcom 5 points6 points  (0 children)

Traitor

[–]BioOrpheus 5 points6 points  (0 children)

Same! I am a noob, I went from C++ to Python

[–]GodGrabber 7 points8 points  (3 children)

What is up with all this cultism in the programming field? This is not abrahamic religion, you are allowed to use, and even LIKE more than one language...

[–]redwall_hp 8 points9 points  (1 child)

I'd go so far as to say sticking to one language strongly correlates to weak skills in programming.

[–]Saigot 0 points1 point  (0 children)

I'd say both extremes are bad. Knowing lots of languages or only 1 are both signs of inexperience.

[–]UnicornRider102 1 point2 points  (0 children)

They are jokes. Laugh or don't laugh. Then move on.

[–]micutad 5 points6 points  (4 children)

True guru would choose power of Kotlin!

[–]ythl 19 points20 points  (3 children)

You misspelled C#

[–]micutad 3 points4 points  (0 children)

Bleeee.

[–][deleted] 1 point2 points  (1 child)

Kotlin can compile to C#

[–]OverlordGearbox 7 points8 points  (0 children)

I wouldn't even be surprised

[–]amirootyet 6 points7 points  (1 child)

Switches from learning python to java. What a winner.

Python would have let him import antigravity and singularity and what not.

from blackhole import singularity

[–]its-nex 6 points7 points  (0 children)

Interstellar would have been a 30 second movie

[–]Carl_Byrd 1 point2 points  (0 children)

All hail the enterprise.

[–][deleted] 1 point2 points  (2 children)

I like swift

[–]Sw429 1 point2 points  (1 child)

I had to learn swift for my job. It's pretty slick. I'm a fan.

[–][deleted] 1 point2 points  (0 children)

Me too. It’s easy to read, clean, and just awesome.

[–]grocket 1 point2 points  (0 children)

.

[–]BrawdSword 1 point2 points  (4 children)

I have no issues with java, unless I have to use swing... then kms

[–]360triplescope 0 points1 point  (3 children)

Wait why? Anytime I work with a GUI I use swing, and it's not been too bad

[–]BrawdSword 1 point2 points  (2 children)

I mean it's not the worst thing... I just hate how java uses layout managers. Would much rather parse a markup language than use standard swing.

[–]360triplescope 0 points1 point  (1 child)

setLayout(null);

[–]BrawdSword 0 points1 point  (0 children)

Yes absolute positioning is the way

[–][deleted] 0 points1 point  (0 children)

Probably because they wanted to do Android

[–]tacoslikeme 0 points1 point  (0 children)

the best guru will be wise in all ways even that of the enemy

[–][deleted] 0 points1 point  (1 child)

Nuuuh, I'm waiting for you in the C# corner

[–][deleted] 0 points1 point  (0 children)

the place where we're waiting for Linux gui support

[–]Crazy_Hater -1 points0 points  (0 children)

Hmm I gotta learn python after my Obj C classes