r/ProgrammerHumor May 27 '22

Meme Welcome to hassle free coding

Post image
2.3k Upvotes

305 comments sorted by

355

u/Bomaruto May 27 '22

Bye main, hello __main__

144

u/Faustens May 27 '22

hello

if __main__ =="__main__": main()

66

u/[deleted] May 27 '22

[deleted]

32

u/[deleted] May 28 '22

[removed] — view removed comment

35

u/Icy_Perspective7313 May 28 '22

you fell in to the trap. Strings ARE objects!!!!

7

u/yiip87 May 28 '22
if __name__ == "__main__":
    raise SystemExit(main())

9

u/BobQuixote May 27 '22

Hey main, my main main!

14

u/[deleted] May 27 '22

[deleted]

20

u/22draynor May 27 '22

8

u/[deleted] May 27 '22

[deleted]

18

u/[deleted] May 27 '22

Unless I’m mistaken (I’m not a python dev) that page is saying that there’s a variable python generates called “name” that will be the name of the module (file) where the code is executing. However, if the module is the entry point for the program (ie the script you ran to start the code executing) then that name variable will contain the value “main” instead.

Edit: Disclaimer: reddit has taken the two underscores before and after to mean I want to bold “main” and “name”, and I’m not going to bother to figure out how to correct that.

13

u/[deleted] May 27 '22

[removed] — view removed comment

2

u/[deleted] May 27 '22

Nice, and I should have known

4

u/[deleted] May 27 '22

Unless I’m mistaken (I’m not a python dev) that page is saying that there’s a variable python generates called “__name__” that will be the name of the module (file) where the code is executing. However, if the module is the entry point for the program (ie the script you ran to start the code executing) then that __name__ variable will contain the value “__main__” instead.

Edit: Disclaimer: reddit has taken the two underscores before and after to mean I want to bold “main” and “name”, and I’m not going to bother to figure out how to correct that.

Edit 2: Fixed, thanks u/nukedkaltak

3

u/DeKokikoki May 28 '22

And to finish the explanation so that people don't have to open the link: if you want to import a function or a class or something from a module, python needs to run that module. If you haven't used the "if __name__ == '__main__': main()" construct, that means the main code of that imported module will also be run which is almost never what you want.

→ More replies (2)

5

u/22draynor May 27 '22

There are also lots of videos on the subject. best way to learn is to implement it yourself on a small scale and then explore uses for your new found knowledge.

3

u/coloredgreyscale May 28 '22

have you tried turning it off and back on?

(sleeping?)

→ More replies (1)

2

u/Amidus May 28 '22

Oh, no, it's okay, it says it's easy.

...

What did it say? Lol

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

369

u/[deleted] May 27 '22

Python doesn't feel like a programming language if your first language is C++.

170

u/oddmerlin373 May 27 '22

Honestly I prefer to call it a scripting language because that’s what it’s good at

102

u/ashum048 May 27 '22

Yes, yes, yes.

Automating stuff with python and creating small apps is a blessing.

Debugging large scale applications in python is pain.

59

u/prescod May 28 '22

Debugging large scale applications is a pain...period.

43

u/[deleted] May 28 '22

Strictly typed languages are much easier to debug though IMO. Python and JS will let you do extremely weird stuff that’s hard to pick out in debugging, where in a C-based language it would just give you a compiler error

4

u/HgnX May 28 '22

Man needs a bit of PyLance in his life

7

u/juhotuho10 May 28 '22

Python can be turned to strictly typed with type hints and mypy

13

u/prescod May 28 '22

And C will let you do bad things with memory where Python would just give you a runtime error.

If you want tons of compile time errors, Python's type system is vastly more powerful and precise than C's:

https://mypy.readthedocs.io/en/latest/

5

u/ShelZuuz May 28 '22 edited May 28 '22

That’s the old “chainsaws are dangerous so let’s use a nail file to chop off the tree” argument.

Also the common set of libraries you use in python are almost never statically types so the linter doesn’t really help.

2

u/prescod May 28 '22 edited May 28 '22

That’s the old “chainsaws are dangerous so let’s use a nail file to chop off the tree” argument.

Not at all. It's "axes (C) and chainsaws (Python) are both dangerous and let's not BS ourselves about that."

If you have a high standard for static correctness then you use Rust or Haskell, not C or Python. C is MUCH more dangerous than Python, as the thousands of "use after free" and "buffer overflow" security vulnerabilities show.

https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=buffer+overflow

https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=use+after+free

https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=null+pointer

It's ridiculous to point to C as an example of a "safer" language in the face of enormous real-world evidence that it is not.

Also the common set of libraries you use in python are almost never statically types so the linter doesn’t really help.

What's your favorite Python library that is not typed?

Django: https://github.com/typeddjango/django-stubs

LXML: https://github.com/lxml/lxml-stubs

Numpy: https://numpy.org/devdocs/reference/typing.html

SQL Alchemy: https://github.com/dropbox/sqlalchemy-stubs

The whole Python Standard Library: https://github.com/python/typeshed/tree/master/stdlib

Tons and tons of other third party libraries: https://github.com/python/typeshed/tree/master/stubs

And if you find something missing, you can add a type stub to your own project or contribute it to typeshed or make a new project for it.

→ More replies (1)

0

u/unknowntillnow23 May 28 '22

Are you building large systems in python alone. Someone doing some voodoo shit in python would be picked up by the commit hooks or in a code review at the very least.

6

u/AltAccountMfer May 28 '22

I always hear this response and my rebuttal is that it shouldn’t have to get that far.

→ More replies (1)

3

u/LEGOL2 May 28 '22

That's... my job. My work is debugging drivers 24/7 <pain>

11

u/[deleted] May 27 '22

I heard it's pretty good at data

13

u/0430ke May 28 '22

Yeah I primarily use it for data and database shit. It's much faster to write and run something quick that manipulates a lot of data quickly.

It's also incredibly nice due the fact that almost EVERYTHING has an API for Python. So you can gather data from many sources all in one place, easy to write, quick to run.

Edit: To add on to this, it's also easy to manipulate data types since it's easy to cast data to other types. JSON is super easy to use, etc. Using other languages you have to really mess around with getting the data type you want. Python just makes it easier.

6

u/ashum048 May 28 '22

Agree. Data is another place where python really shines.

Create a simple data pipe or a NN in python is fun.

4

u/Thathitmann May 27 '22

It's got some nice built in functions to quickly save and load to/from JSON files, and with addons it can handle about any file types.

It takes about 2 lines of very easy to read code to import/export data.

8

u/prescod May 28 '22

Yes and it is also very good at doing gigantic matrix multiplies spread over multiple computers in a cluster. I think that's actually what's meant by "good at data."

4

u/[deleted] May 28 '22

I'm studying python in school but not real world applications

From what I've seen and from what I've heard from better programmers it's good for data analysis

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

5

u/ddtfrog May 28 '22

I like it for front end automation and web scraping, too.

2

u/ashum048 May 28 '22

true. Any automation in python becomes so much clearer than a bunch of shell scripts all over the place. Not against shell scripts. Don't want to start a war)

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

18

u/[deleted] May 27 '22

are we not calling it a scripting language anymore?

9

u/mooscimol May 28 '22

Scripting is one of the purposes, but really not the biggest one IMO. It is interpreted, dynamically typed language, opposite to eg. complied, statically typed languages like C.

1

u/oddmerlin373 May 27 '22

Apparently, even on the python site they call it a programming language. Even though I don’t think it was ever meant as one

11

u/banmedaddy12345 May 28 '22

4

u/LightRefrac May 28 '22

And YouTube

3

u/Hlorri May 28 '22

Hence, the buggy copy&paste?

10

u/[deleted] May 27 '22

[removed] — view removed comment

5

u/teastain May 27 '22

Wisdom of Solomon.

3

u/[deleted] May 27 '22

Be nice or Ill split C++ into C+, Python+ and Java-

3

u/Hayden2332 May 28 '22

Scripting languages are a subset of programming languages. Just like compiled languages are a subset of programming languages

13

u/prescod May 28 '22

Yeah it's good at scripting.

And machine learning.

And data science.

And teaching.

And Web development.

And biological computing.

And...

But let's just call it a "scripting language".

8

u/nickwcy May 28 '22

Machine learning: CUDA / Tensorflow is written in C

Data Science: Numpy is written in C

Web development: Absolutely not. Python is good for POC/classwork, but never highly maintainable for enterprise use.

What Python is really good at is small pieces of code like CI/CD scripts, or serverless functions.

16

u/prescod May 28 '22 edited May 28 '22

Nick: do they machine learning folks mostly write C or Python?

I’m not asking what language their runtime is implemented in. I’m asking what language the programmers program in.

With respect to web apps. Let me list a few startups that were written in Python at the time they got famous (before being refactored into dozens of microservices written in a hodgepodge of languages).

Youtube. Reddit. Instagram, D-wave. To name a few.

Have you built an app that succeeded to that extent?

If not, what is your evidence that Python cannot be used for web apps given that clear evidence of success?

3

u/nickwcy May 28 '22

Depends on what you meant by machine learning folks. They program the logic in C, you don’t see back propagations for MLP nor need to write the bagging logic for random forest.

Calling a library does not mean you engineered it.

And having business success does not mean they have chosen the right language for web development. Nor it has anything to do with maintainability. They will be successful even if they have chosen Java, C# or other languages, because of their brillient ideas, not because they are using Python.

12

u/prescod May 28 '22 edited May 28 '22

Most data scientist know Python. A smaller percentage know C.

This is also true (though to a lesser degree) for machine learning programmers. More work in Python than C.

Calling libraries to solve problems does make you an engineer. Solving the problem is the defining characteristic of engineers. C programmers call a lot of libraries too.

Business success is the ultimate result of technical success. Am I saying they would have failed in another language? No. But you implied that they should have failed in Python. They didn’t.

Python solves the problems that dynamic businesses need to solve. That’s really all there is to it. You have a distaste for it and therefore you want to make a fact-free claim that it’s the wrong tool. But reality and evidence are against you.

2

u/BeanieTheTechie May 27 '22

its really multipurpose

-5

u/jamcdonald120 May 27 '22

Its an excelent scripting language. Just the tthing if you want to write a basic commandline utility for some repetative task.

And then people try to use it as a web backend

20

u/prescod May 28 '22

Yeah, dumb people making useless products like YouTube, Reddit, Dropbox and Instagram. I guess your startups have had more success with "real" programming languages.

-7

u/jamcdonald120 May 28 '22

hey look, someone who doesnt know what micro services are and equates good coding practice with good business practices.

11

u/prescod May 28 '22

WTF are you even talking about?

I didn’t say anything about microservices/monoliths at all.

13

u/tripledjr May 28 '22

hey look, a gate-keeping elitist that doesn't understand trade offs and using different programming languages in different scenarios.

Also what the hell does the chosen language have to do with micro services vs monolith?

6

u/Hayden2332 May 28 '22

Hey look, someone who’s never programmed in the real world since they were born

→ More replies (1)
→ More replies (1)

7

u/[deleted] May 27 '22

You just write pseudo code and it runs!

4

u/KendrickEqualsBooty May 27 '22

Is Python written in C or C++

11

u/[deleted] May 27 '22

C

3

u/m__a__s May 27 '22

I believe that Python (aka CPython) was originally written in C and is now a combination of C and Python. Other "pythons" are written in other languages (e.g. IronPython is written in C#)

14

u/AlbertChomskystein May 27 '22

HTML and Python have some similarities to be fair, like not being able to declare variable types.

20

u/[deleted] May 27 '22

You can declare variable types in Python. But for the most part you don't really need to unless you want to.

2

u/nickwcy May 28 '22

And it doesn’t check the type when it runs

6

u/Suahil May 28 '22

If a variable has a type defined, but nobody checks it. Does it even matter?

3

u/Hlorri May 28 '22

Well, if someone writes documentation in the forest but noone is around to read it, was it really written?

12

u/Affectionate_Fly3313 May 27 '22

Pre CSS HTML was just like LUA.

Everything is a table.

7

u/OutrageousPudding450 May 27 '22

And now thanks to PyScript, the cycle is complete.

2

u/Psychological_Fox776 May 27 '22

Explain? (I’ve only just started Python and know nothing)

6

u/OutrageousPudding450 May 27 '22

Basically, PyScript allows you to use Python code in web pages the same way you'd use JavaScript.

1

u/Psychological_Fox776 May 27 '22

So they coded JavaScript in Python(?)

→ More replies (2)

2

u/prescod May 28 '22

2

u/nickwcy May 28 '22

Type hint is a hint for human (or IDE) only. You can write

x: int = “foo”

However the interpretor shows no error. Python should implement a script mode similar to TypeScript along with it’s Type Hints. Otherwise it is nearly pointless to adopt type hint as modern IDE can infer most types, except those integrates external systems.

4

u/prescod May 28 '22

Poke around the link I shared with you. It’s a tool that will give you type errors exactly like a Java or C++ compiler.

If you want to delay them to runtime there are also tools for that.

→ More replies (1)

3

u/0x7ff04001 May 27 '22

C++ is for real men.

→ More replies (2)

47

u/00PT May 27 '22

main() is very much still standard.

33

u/LavenderDay3544 May 28 '22

They forgot to put performance in the bottom panel.

-1

u/BitterAndJaded120 May 28 '22

Better, because C++ "programmers" are nowhere nearly as good at optimization as they think they are

→ More replies (2)

52

u/[deleted] May 27 '22

Me switching from python to C++

"WHAT THE FUCK DO YOU EVEN DO?!?"

20

u/Claymourn May 28 '22

Well in short everything.

34

u/thebaconator136 May 28 '22

No no, shorts only go to 32,767.

2

u/TheDownvotesFarmer May 28 '22

This is the way

2

u/MatsRivel May 28 '22

Doing the same thing atm. I've got the basics down ok-ish, but I've never been so annoyed setting up the "must have" addons for VSCode before...

2

u/[deleted] May 28 '22

[deleted]

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

110

u/mbardeen May 27 '22

Welcome to "why the hell is this function returning a string and not an object like it's supposed to?"

41

u/MarchColorDrink May 27 '22

Tbf, a string is an object. A function is an object. A class instance is an object. It's all objects.

28

u/Dolner May 27 '22

Some would even say object oriented

0

u/mbardeen May 27 '22

True.. however that one function can return different type objects than one expects is annoying at best, and dangerous at worst.

→ More replies (2)

82

u/Farenheit514 May 27 '22

You will miss the ++ and safe types

22

u/AndreaCicca May 27 '22

❤️++

22

u/Affectionate_Fly3313 May 27 '22

And the Grinch's heart returned its size and incremented one time that day.

-5

u/SkezzaB May 27 '22

Why will they miss the ++?

It's hardly ever used in Python, is one extra character, and if you want to change the increment by 2 instead of 1, you have to write that bit anyway, moreover Python's loops don't use it, so it's not used there, what else is there to miss?

Also, the walrus operator works in a similar way to some use cases as well, making it even less useful

7

u/Torebbjorn May 27 '22

Well, both the post- and pre increment/decrement are useful in making the code a few lines shorter, and sometimes more readable.

Without it,

int i = len; while (--i >= start) { /* do something */ } // use the value of i for something.

Would become

int i = len - 1; while (i >= start) { /* do something */ i = i - 1; } // use the value of i for something.

Assuming the while loop could exit some other way than i becoming exactly equal to start - 1. Though again, it isn't really that much harder to read at all, and you could change the while to a for, to keep all the loop specific code in one place.

for (; i >= start; i = i - 1;)

8

u/_PM_ME_PANGOLINS_ May 28 '22

It’s very rare that you ever iterate like that in Python. If you need indexes then it’s range or enumerate.

6

u/mar00n May 28 '22 edited May 28 '22

I honestly miss the ++, but you gotta agree that this is much simpler:

for i in range(10,0,-1) :    

    # do something

6

u/wanderingmadlad May 28 '22

There is range based loops in c++ as well

1

u/Droidatopia May 28 '22

Shorter yes.

More readable, not likely.

If you are reading code, and you encounter either a ++ or a -- that is not:

A) The loop increment at the end of a for statement, or B) A stand-alone statement incrementing a variable,

Then you need to stop and mentally breakdown the single statement into two statements in order to continue reasoning about the code.

In fairness, I'm talking about readability in terms of being able to scan a piece of code and quickly ascertain what it is doing, and I will concede that pre and post increment might communicate intent, which could also be considered part of readability.

For myself, one of the first things I do when I take over code is to remove all the ++ and -- that are not in loop counters. They all get replaced by += 1. The only reason I leave them in the loop counters is a nod to tradition.

-4

u/prescod May 28 '22

So you basically just proved that you don't need it...

5

u/Torebbjorn May 28 '22

Of course you don't need it. There is basically nothing you need. A language that only supports:

Load from memory
Store to memory
Add
Jump
Checking for 0
Checking for negative

is most certainly Turing complete, and could probably actually be used.

Everything else added on top just makes certain things easier to do, and reduces how much code you have to write and how many clock cycles the CPU needs to execute a certain instruction.

2

u/CdRReddit May 28 '22

thats not even all you need

subtract and branch if less or equal is turing complete

→ More replies (5)
→ More replies (1)
→ More replies (1)

74

u/O_to_the_o May 27 '22

Inconsistent use of tabs and spaces ....

10

u/A_man_of_culture_cx May 27 '22

I have been using spaces in C++ but I never understood what they actually do. Like i knew that c++ strings etc doesn’t work when you don’t do std:: or using namespace std

12

u/SyrupOnWaffle_ May 27 '22

they meant like the spacebar not namespaces. to answer your question though namespaces just organize large groups of things together to avoid naming conflicts. ex if two unrelated libraries had “functionA” library1::functionA and library2::functionA can be called seperate no problem

1

u/[deleted] May 27 '22

in most scenarios it's literally just formatting. outside of that, the only functional difference you have is when you have no space at all, or any space at all.

18

u/ffs_give_me_name May 27 '22

Tabs > spaces

11

u/[deleted] May 27 '22

I usually just press enter and let my IDE format for me, but if I’m manually inputting spaces, I always use tab.

10

u/Mahrkeenerh May 27 '22

and your ide converts it to spaces. The question is not what you press (did you think someone is out there pushing space 4 times?), it's what the editor converts your tab to.

4

u/engelthehyp May 28 '22

I press tab, and always make sure my IDE uses tabs. It makes it only one character to move instead of 4 when navigating indentation. Besides, I can always change the size of tabs (although I don't). For spaces it's not so easy.

1

u/martmists May 28 '22

I hope you don't actively publish your code to GitHub which uses width 8 for tabs and makes code unreadable as result

3

u/[deleted] May 28 '22

?ts=4 thank me later.

→ More replies (1)
→ More replies (1)
→ More replies (1)

12

u/JADW27 May 28 '22

I'm not a fan of semicolon-optional coding. I can't explain it other than it "just doesn't feel right." Perhaps a little bit of "I spent hours of my life searching for missing semicolons, so you should have to as well."

It's probably not healthy...

3

u/-Redstoneboi- May 28 '22

python is semicolon-burn-it-in-flames, not semicolon-optional

you can use them, but then you'd have to deal with witch hunters

8

u/[deleted] May 27 '22

Or you can just know when to use both.

3

u/frogking May 28 '22

Exactly. And there are several other languages that could be in a developers toolbox too.

Only junior developers, students or children think that there is one language to rule them all.. and that THAT language is the one they happen to know the name of.

→ More replies (1)

8

u/[deleted] May 28 '22

There was a better version of this meme ages ago which included "speed" as a thing being left behind

38

u/pensiveChatter May 27 '22

Well, you're also saying goodbye to comprehensive compile time checks, proper post-mortem debugging, on demand debugger attaching, etc...

3

u/Akai_Yun May 27 '22

Just a noob question: is it a good idea to do C++ here and there to keep it as viable option and in recent memory while still practicing Python?

8

u/pensiveChatter May 27 '22 edited May 27 '22

You mean for job interviews? Depending on the job, it can look good on your resume. Life is full of opportunity cost. That time you spend keeping up with C++ could just as easily be spent learning more design patterns or other things in pure python.

it probably also wouldn't hurt to know that ;, main and {} are part of python

eg: "import pdb;pdb.set_trace()" and while pointers, for the most part, aren't part of python, you'll eventually have to call native code from python and/or parse files with relative offsets when writing your own unpickle code.

Also, seriously? The big thing about switching to python from C is the syntax used for scoping?

→ More replies (1)

15

u/Torebbjorn May 27 '22

If you are doing Python correctly, main() is staying...

15

u/lieddersturme May 28 '22

I switched back immediately to C++.

8

u/frogking May 28 '22

Why?

There is a whole class of problems that Python is better suited for, because the turn around time is shorter.

Besides.. there is nothing wrong with knowing several languages. It’s like having more tools in the shed, than just the tractor used to pull heavy things.

→ More replies (2)

6

u/Farren246 May 27 '22

Honestly I miss semicolons and ++

25

u/CmdCyrious11 May 27 '22

welcome to package hell, where there's 99 existing solutions and all of them are deprecated or only exist for a different version of python to each other =)

11

u/m__a__s May 27 '22

Welcome to dependency hell.

3

u/BobQuixote May 27 '22

Is there any language that doesn't have that problem, without responsible dependency management? I'm learning Rust this very moment and they put a lot of work into managing that problem, because it is still an issue.

9

u/NearbyWish May 27 '22

No no, your language is a horrible mess with terrible dependency management, mine is the paragon of excellency with no dependency issues whatsoever. I use C by the way, also why do people keep asking me about libraries I don't even read books.

5

u/CaitaXD May 28 '22

Goodbye curly braces hello runtimeache

4

u/coloredgreyscale May 28 '22

you will still use {} for dictionaries

4

u/therealbeeblevrox May 28 '22

What? Everything is a pointer in Python!

5

u/virouz98 May 28 '22

Lack of all the things listed in there isn't a good thing

→ More replies (1)

12

u/DaniilBSD May 27 '22

C# is a hustle free C++

Python is too limiting if you are used to C++

21

u/AlbertChomskystein May 27 '22

c# is microsoft java

15

u/ALJSM9889 May 27 '22

Java is also good despite the memes

→ More replies (1)

3

u/BobQuixote May 27 '22

C# is MS Java with a radically different policy about new features. Java resists changes a lot more, C# has pretty strict criteria but is also pretty aggressive about developing the language, but not as much as C++ which at this point is like 3 or 4 languages mashed together.

2

u/Droidatopia May 28 '22

How much more divergence from Java will be needed before we can declare the original similarity gone?

I learned Java in school, took nine years off to do other stuff, then switched entirely to C# when I started an actual engineering job. Last year, I had my first chance to program in Java again in over 20 years and, all I can say is the years have not been kind.

It's weird too with all the C# features that Java has recently tried to start copying, but in a less useful way.

2

u/m__a__s May 27 '22

Yes...and no.

→ More replies (1)

3

u/citizen005 May 27 '22

I couldn’t deal with the absence of brackets.

10

u/jamcdonald120 May 27 '22

You will miss pointers soon enough

I dont know why you are complaining about ++

; allows multiple commands to share a li e

I would rather have {} than syntax dependent tabs

i would rather have int main(int argc, char** argv) than

import sys
if __name__ == "__main__":
   argc=len(sys.argv)

and thats not even mentioning the none type errors

-8

u/therapy_seal May 27 '22

I dont know why you are complaining about ++

It's the only thing there actually worth complaining about. It's a harmful feature. It leads to programmers making mistakes that are never made in other languages.

8

u/jamcdonald120 May 27 '22

er most langusges have ++ and its not particularaly harmful....

Are you meaning pythons lack of ++ is harmfull?

1

u/therapy_seal May 28 '22 edited May 28 '22

Most languages do not have pre/post-increment operator. It's inclusion in the languages which do support it has resulted in numerous bugs which would not have occurred if they had simply used +=1 instead. It literally only saves 1 character. It's time to stop defending it.

1

u/jamcdonald120 May 28 '22

I dont know what you are smoking.

I cant think of any bugs caused by having ++, but I can think of lots caused by using +=1 instead.

As for your statement about most languages, since the set of all programming languages is ill defined, I used the ones on https://madnight.github.io/githut/#/pull_requests/2021/4. Fully 2/3rds (both by number and usage) have increment and decrement operators.

Of the languages in the top 10 only python and ruby dont have it.

I dont know what your beef with increment is, but it isnt widely shared.

→ More replies (4)
→ More replies (3)

8

u/ILoveSimulation20 May 27 '22

and say goodbye to optimisation as well while you're at it

20

u/[deleted] May 27 '22

Optimization still exists, the solution is not to use Python and let C handle everything!

3

u/CmdCyrious11 May 27 '22

Extend not embed.

What does that mean? Just that 70% of our production source code is written in C.

2

u/BeanieTheTechie May 27 '22

actually using a main function in python is recommended because it allows for interactively teating functions declared in your main file

2

u/Loose_Crow_6871 May 28 '22

All of those (yes even pointers) exist with the right library

2

u/akaBigWurm May 28 '22

Is Python even coding or just scripting?

→ More replies (6)

2

u/John_Fx May 28 '22

I kinda miss pointers. Hard to understand at first but they make your brain evolve in ways that pay off for your whole career

2

u/Zuka101 May 28 '22

Hassle free?

2

u/frogking May 28 '22

There is a time and a place for both Python and C++.

The overlap of tasks where you’d be free to choose is somewhat limited, isn’t it?

2

u/[deleted] May 28 '22

Just curious, but are you supposed to switch to Python eventually? I've been seeing a lot of C++ to Python posts lately, and I dont know if that's just a meme or if C++ people are just eventually supposed to switch to Python.

2

u/-Redstoneboi- May 28 '22

they are polar opposites in terms of purpose. you use one for one thing, the other for another.

2

u/[deleted] May 28 '22

Ah. Thank you!

2

u/GKP_light May 28 '22

python has pointer, it is just that they are hidden.

a list is like a pointer in C, and you can make a list of length 1.

2

u/MythrandirRF May 28 '22

Started off programming by learning C++. For about 3 years I went out of my way to learn the best practices and the "advanced" techniques which got me my first pretty decent job.

Turned out that the money-maker microservices that were owned by my team were mostly written in Python so I had to switch gear. Honestly, Python is such a relief. I love the "care free" coding.

I still occasionally write C++ code but I now find it somewhat less enjoyable.

4

u/Ambitious_Ad8841 May 27 '22
if __name__ == "__main__":

2

u/[deleted] May 28 '22

Not gonna lie, but It's so f#*king ugly.

5

u/TheFlyingAvocado May 27 '22

Python 2 or Python 3? There’s no such thing as hassle free coding. Speed, for one, may be a major hassle.

1

u/Frapzo May 27 '22

Had to rewrite legacy testing code for OS class in Uni ,a few weeks ago, from python 2 to python 3. The amount of bullshit I had to deal with was astounding. Legacy shell commands it expected the OS to support, objectively wrong syntax for some commands. And worst of all. A bunch of the included libraries had changed syntax as well from python2 to python3 with basically no documentation for it. Honestly, fuck python after that

→ More replies (1)

2

u/xXx_Lizzy_xXx May 27 '22

hello tab

6

u/-Redstoneboi- May 28 '22

PEP8: 4 space*

2

u/DoubleTriple14 May 28 '22

Python may be more convenient, but it is a lot slower.

2

u/ltrayeetlord May 27 '22

Of course you can ditch the ++, Python is written in C.

This is a joke, of course.

1

u/UrSeneschal May 27 '22

Python is certainly not hassle free

1

u/MasterFubar May 27 '22

So long pointers, so long code blocks, hello mysterious bugs!

4

u/prescod May 28 '22 edited May 28 '22

Oh yeah, nobody has ever had "mysterious bugs" in C++.

-1

u/Possibility_Antique May 28 '22

If C++ compiles with bugs, you're using it wrong. Use constexpr, static_assert, concepts, templates, and other compile-time features to prevent bugs from entering production. Oh, and since they're done at compile-time, runtime execution of those code blocks is free.

3

u/prescod May 28 '22

I hope you're joking. That isn't even true for Haskell or Rust, much less C++. All languages allow bugs and C++ is not even formally type-safe or pointer-safe.

C++'s type system: C++ (among other unsafe languages) has a type system that does many local checks of a programs's source code. However, passing these checks does not establish anything definite about a program's behaviour: many C++ programs pass all of the compiler's type checking, and yet exhibit use-after-free errors, memory corruption, and arbitrary behaviour when run.

You can claim that these people are just using C++ wrong. I can say the same of those that ship buggy Python or Visual Basic programs. It's just a No True Scotsman argument.

2

u/Possibility_Antique May 28 '22

C++ is far from perfect. All I'm saying is, Python could never be a replacement for compiled languages, simply because it is not compiled. You're correct, I could have made the same argument about Rust. But you're missing the point if you think my claim was meant to elevate C++. My point was that the compiler is your friend, and defensive programming in compiled languages is overlooked in conversations about language choice.

→ More replies (6)
→ More replies (3)

1

u/[deleted] May 27 '22

[deleted]

4

u/-Redstoneboi- May 28 '22

hey at least it's "for code to run" and not "for code to compile with errors"

2

u/gxy1 May 28 '22

For code to run into runtime errors because there is no compile time checking

→ More replies (1)

1

u/[deleted] May 28 '22

Give a hello to the slowest language ever

0

u/Neutraali May 27 '22

Welcome to unemployment.

5

u/-Redstoneboi- May 28 '22

???

python has like 200 million jobs

→ More replies (1)

0

u/tigable May 27 '22

Forgot to label Slinky 'Speed'.

0

u/ANewTryMaiiin May 28 '22

Python is a kiddie language.

0

u/PyMaster22 May 27 '22

Does anyone talk about quad-* (****)?

0

u/Helilo129 May 27 '22

I started with C++ and because of it every time python is used i keep thinking its pseudo coding. anyone mind telling me if python(i don't use it so asking) has this or if its just dumbed down code.

0

u/RainbowCatastrophe May 27 '22

!RemindMe 1 year to check back and see if OP realizes how terribly mistaken he was

→ More replies (1)

0

u/burncushlikewood May 28 '22

Man I prefer c++ over python, it's much more powerful and it's more linear for my style of coding. I love the language I would rather do my projects completely in c++ it's the ultimate language

0

u/[deleted] May 28 '22

[deleted]

0

u/-Redstoneboi- May 28 '22

that says a lot more about your C++ code than it does about python

→ More replies (1)

-1

u/Tfsr92 May 27 '22

Go ahead and make an enterprise application in python.

→ More replies (2)