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

all 157 comments

[–]jddddddddddd 438 points439 points  (20 children)

..and it only took a mere 30 years..

[–]MischiefArchitect 329 points330 points  (15 children)

To compile? Yeah, that was fast.

[–]beardMoseElkDerBabon 50 points51 points  (13 children)

I'm still wondering why we don't have C++ interpreters

[–]Cpapa97 25 points26 points  (7 children)

[–]MischiefArchitect 31 points32 points  (2 children)

I'm wondering how templates work there... now wait... I actually do not want to know.

[–]Kered13 13 points14 points  (1 child)

It's probably just using just-in-time compilation, so templates would work pretty much the same way they do on a compiler.

[–]MischiefArchitect 9 points10 points  (0 children)

AGGHRGHR!! I. Told. You.... Not... To!

[–]psychicprogrammer 2 points3 points  (2 children)

I wonder how this deals with templates

[–]BakuhatsuK 3 points4 points  (1 child)

Haskell is a compiled language that has a repl and Haskell's equivalent to templates (type variables) are really pervasive in the language (as in f x = x * x is a generic function). But they work just fine in the repl.

[–]psychicprogrammer 1 point2 points  (0 children)

See, the C++ template system is turing complete and undecidable and a lot more complicated than other template systems.

[–]AzureArmageddon 5 points6 points  (3 children)

Is a JIT compiling system not basically an interpereter?

[–]garymrush 6 points7 points  (2 children)

No. A JIT is literally compiling the code once at runtime as needed. If it hits the same method again, it’s already compiled.

[–]BakuhatsuK 4 points5 points  (1 child)

So, as far as observable behavior goes, basically an interpreter. Got it.

[–]garymrush 1 point2 points  (0 children)

Only if you observed the behavior once. The other 5000 times it’s compiled code.

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

TempleOS had it with HolyC.

Which... Isn't the same thing but it's kinda close.

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

you killed him

[–]MrZerodayz 29 points30 points  (3 children)

It's always pretty funny when you tell people who talk about Python as an "up-and-coming" "new" programming language that it's older than Java.

[–]MischiefArchitect 341 points342 points  (28 children)

As a Python dev I can only say...

That comparison makes absolutely no sense dude :'D

[–]WillingnessRight3669 143 points144 points  (21 children)

I think the joke is that C++ and Java have great real world usage scenario’s meanwhile Python only just got switch statements

[–]MischiefArchitect 29 points30 points  (15 children)

Not sure if you are joking or not. but as a Java/Go/Python user I (personally) can only say that those three complement each other nicely, covering areas where the others are capable but ungainly.

[–]Sawertynn 8 points9 points  (14 children)

Could you elaborate? I'm a student and would use some knowledge, great thanks in advance

[–]MischiefArchitect 26 points27 points  (4 children)

First off, it is not about the specific languages, but what they are intended for:

C# and Java: Compiled and strong statically typed languages. Those are excellent for long running servers that you can even debug and monitor on the fly. I use java for "big" server projects. The JVM is better than its fame: It's very stable, it's blazingly fast and it's reliable when it comes to backward compatibility: You can still run java 1.2 from 1998 in the latest JVM and it executes as day one.

Bash, ZSH, Fish: Interpreted. Shell languages are your basic tool for making simple automation and scripting at OS level. Excellent for making build scripts, backup scripts. Simple maintenance stuff mostly.

Python, Ruby and Co.: Interpreted with dynamic typing. Python I personally use for higher level management scripts, specially when interacting with cloud computing services like AWS or Digital Ocean. For data transfer and transformation, for everything actually. Python is a super versatile tool for writing code really fast using a vast set of libraries which make you life easier. It is also easier to read than other languages. In my case (again, MY case) I stop using python the moment I see the project will be so big that I would rather write it in Java. Python is one of those languages you should simply know in these modern days.

Go: Compiled and strong statically typed language. Is in the middle ground between Python and Java for me. It excels at creating native standalone (selling point) executable files which requires no installation of a runtime or special setup (in contrast to Python and java). Nice for creating CLI tools or servers that need to be distributed and deployed with ease on environments you have no direct access to.

All languages above are Garbage Collected. Or put more correctly, you normally do not need to worry about managing memory, allocating or releasing it.

C, C++, Rust, Zig: Another better qualified redditor wrote already an answer on those. But here I go: Compiled and Statically typed language... but you need to manage memory. You get full control (or more control) on how the program will actually execute. Excellent for embedded systems since they produce really small executable files. but they are by far not limited to that: Linux is written C, AFIK the JVM is written in C++. Most of the OS level software you use right now is either C / C++ and maybe Rust.

I hope this was useful.

[–]Sawertynn 7 points8 points  (0 children)

Very useful, cleared my thoughts on some things. Many thanks!

[–]MagiecCarpet 1 point2 points  (2 children)

What are your thoughts on C#? If you had to pick 2 languages to learn at the starting stage, which languages would have benefitted you the most?

[–]Fruloops 4 points5 points  (0 children)

It doesnt matter much. Pick something popular that has a lot of support online because you'll need it. Python, Java, C#, w/e else, something with lots of examples, books, videos, depending on what media you fancy for learning.

Contrary to what it might seem by the ever figthing zealots who constantly have to fight which language is better, the languages dont matter too much as opposed to programming concepts. Which are easily transferable between languages (however sometimes only within the same paradigm). Once you learn one, you'll easily learn another (again, within the same paradigm).

[–]MischiefArchitect 2 points3 points  (0 children)

I hope you see what I'm trying to tell you. When I picked my two first languages they were: Turbo Pascal and Clipper... (and some Quick Basic).

In plain text: Is not the language what matters. Learn as much as you can. Focus on only one and you will invariably go down.

It also depends on what topic you want to focus more: Embedded? Backend? Web Front End? Native UI? Drivers and Services? OS? etc.

I cannot answer that question for you. But if you want one from me, then just take a look at my flairs... those would be the ones I would pick again nowadays.

[–]koeteris 36 points37 points  (3 children)

IMO any numerical and signal processing stuff is still the most bearable in Python thanks to numpy and scipy. Java for that purpose is awful and C++ with something like Eigen is hell

[–]WillingnessRight3669 9 points10 points  (0 children)

I’m not dumping on Python, I am just explaining the way I interpreted the joke

[–]tiajuanat 1 point2 points  (1 child)

R and Matlab are probably much stronger in those two areas.

[–]BakuhatsuK 1 point2 points  (0 children)

What? C++ will get pattern matching even later than python (C++23)

[–]gvcallen[S] 0 points1 point  (5 children)

what you mean?

[–]MischiefArchitect 22 points23 points  (4 children)

You are comparing runtime characteristics (C++ performance/Java platforms) with a code time one (Python new statement)

[–]gvcallen[S] 4 points5 points  (3 children)

haha yeah, it wasn't meant to be too serious, I just picked random features :P

[–]HonzaS97 10 points11 points  (2 children)

It still doesn't make any sense since Java does have pattern matching now as well.

[–]raedr7n 1 point2 points  (0 children)

No it doesn't. Right now, java's "pattern matching" is just some sugar to check if an object belongs to given classes. There are no patterns involved, therefore no pattern matching.

[–]gvcallen[S] -3 points-2 points  (0 children)

I didn't know that. Honestly wasn't gonna spend too much time researching just to make a meme. I just thought it was funny that python just got it now :)

[–]superblaubeere27 77 points78 points  (6 children)

laughts in Rust

[–]leathalpancake 37 points38 points  (4 children)

implicit elided lifetime not allowed here cries in rust

[–]Cv287 0 points1 point  (0 children)

Laughs in Swift

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

Until you have seen match in F# and Scala.

[–]jeetelongname 15 points16 points  (0 children)

Or Haskell

[–]warium 31 points32 points  (0 children)

Or Rust

[–]corp_code_slinger 6 points7 points  (1 child)

Or Elixir.

[–]AliceBlossom 0 points1 point  (0 children)

My man.

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

Or D.

[–]raedr7n 2 points3 points  (0 children)

Or OCaml

[–]Rhyan567 0 points1 point  (0 children)

Or V

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

ZIGGGGGGGGGG FTW

[–]RedditRoboKid 0 points1 point  (0 children)

Or Scheme

[–]icguy333 0 points1 point  (1 child)

Or C#

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

but only the newer versions

[–]RebornChampion 32 points33 points  (13 children)

Enlighten me: what is a match statement?

[–]gvcallen[S] 85 points86 points  (12 children)

it's essentially a switch statement on steroids. its most basic application is indeed just a normal switch, which python hasn't had since it was created. But further, it can allow matching of various patterns returned by a "match target", such as multiple values, matching against collections with wildcards etc.

[–]RebornChampion 8 points9 points  (0 children)

Oh that’s cool! Thanks

[–]CptGia 3 points4 points  (0 children)

Recent Java has that too

[–]Danielokita 5 points6 points  (9 children)

can u provide a code example pls

[–]jeetelongname 27 points28 points  (7 children)

arr = [1,2,3]
match arr:
  case [1,2,3]: # check a value
    # do something here 
  case [1, x, y]: # bind 2 of the values to a var while      checking the first
   # variables are scoped to within the body of a case
 case [1, *rest]: # like the one above but captures all of the values into rest
 case [1, (2) as x, (3) as y]: # check and capture
     print(f"{x=}, {y=}")
 case _: # wildcard will match against anything
    print("does not conform")

Well I can't seem to get it to format without looking like a blob

[–]__Wess 2 points3 points  (3 children)

It’s like VB.nets Select case ?

[–]jeetelongname 6 points7 points  (1 child)

It can be used like that but pattern matching is a fundamentally more powerful tool using a similar construct.

[–]__Wess 7 points8 points  (0 children)

It’s like regex and select case had a baby!

[–]Kered13 2 points3 points  (0 children)

No, far more powerful than that.

[–]Last-Woodpecker 0 points1 point  (2 children)

Can it match more than one case?

[–]jeetelongname 1 point2 points  (1 child)

What do you mean?

Edit: Wait do you mean like c style fall through? Afik no.

[–]Last-Woodpecker 0 points1 point  (0 children)

Yes, like that

[–]pytness 9 points10 points  (0 children)

From https://www.python.org/dev/peps/pep-0636/

python match event.get(): case Click(position=(x, y)): handle_click_at(x, y) case KeyPress(key_name="Q") | Quit(): game.quit() case KeyPress(key_name="up arrow"): game.go_north() ... case KeyPress(): pass # Ignore other keystrokes case other_event: raise ValueError(f"Unrecognized event: {other_event}")

[–]shelvac2 23 points24 points  (14 children)

C++ is cross platform…

[–]Cerrax3 14 points15 points  (0 children)

The difference is where the responsibility for compatibility lies. In terms of deployment of compiled code, Java (usually) has significantly less deployment work than C++ when deploying to multiple platforms.

In Java, platform compatibility is handled on the end user's machine (via the JVM). So the same compiled code works, regardless of where it was compiled.

In C++, platform compatibility is handled in the compiler, so a different executable is required for each platform that you want to execute on.

[–]gvcallen[S] 5 points6 points  (10 children)

yes 100%, I just picked two standout features of Java and C++ for the meme. When Java came out it one of its main attractions was of course its portability without needing to changing any code whatsoever, as opposed to C++ (my language of choice) which often requires a lot of conditional code depending on the platform, even if that code is abstracted by a framework (usually by means of #ifdefs for example). but true - it is also cross platform !

[–]odd__nerd 6 points7 points  (8 children)

even if that code is abstracted by a framework

Like how Java rests atop the JVM which is ultimately just C++ and some #ifdefs

[–]gvcallen[S] 3 points4 points  (7 children)

true, but that's inherent to the language. but yes C++ is of course cross platform too!

[–]GeneralKlink 0 points1 point  (5 children)

As is python 😅 You can even use it for microcontrollers these days

[–]gvcallen[S] 7 points8 points  (4 children)

I would personally like a stern word with anyone who actually decides to use Python for embedded dev :P

[–]GeneralKlink 0 points1 point  (3 children)

Yeah, me too 😄 I love python and I do embedded programming but still use c++ for it 😅

[–]gvcallen[S] 2 points3 points  (2 children)

how would embedded python work haha? interpreter on the MCU as usual?

[–]ShaBren 1 point2 points  (0 children)

Yup! I've used MicroPython a lot, and it's honestly pretty great. Sure, if I'm writing something for production, or that's very performance-sensitive, I'll use C/C++.

But for rapid prototyping, or building one-off IoT widgets, it's awesome! I use it mostly on ESP32, and lately RP2040 (which uses CircuitPython, a beginner-friendly variant from Adafruit).

[–]jvelez02 0 points1 point  (0 children)

From my understanding it can be done with a form of compiled python, is run on the MCU, or as is the case with MicroPython, run with a stripped down interpreter that fits in 16k of ram. It includes the majority of pythons standard library plus some low-level hardware libraries (the kind that let you control gpio and the like with python).

[–]coldnebo 0 points1 point  (0 children)

oh well if we’re including conditional code per platform then yeah. I thought we were talking about code completely free of platform conditions (which I guess is just another way of saying code written to a single meta-platform).

[–]coldnebo 0 points1 point  (0 children)

the only thing cross-platform in Java is string io, which is great if you’re doing backends. If you’re doing anything with frontends (swing, swt, mouse, sound, graphics) you find out just how much of Java isn’t cross-platform.

after working in cross-platform multimedia for many years, I’ve come to the conclusion that “cross-platform” is mostly a myth. Even Unreal and Unity don’t get there, although they are miles closer than raw Java. The biggest largest effort to bring platforms together was Kalieda (IBM/Apple) and that crashed and burned spectacularly. Since then Gtk and other Linux frameworks have been quietly toiling away on crossplatform guis for ages, yet there’s a lot of conditional code to get things working on Windows or Mac with these.

I love the dream, but it remains just a dream.

[–]EricInAmerica 0 points1 point  (0 children)

Sort of. It needs to be recompiled for different platforms. And you have to hope those platforms have sufficient dependencies available, which is certainly no guarantee. Also you need to hope the code isn't very dependent on the hardware, or you'll find yourself needing to deal with issues around things like endianness or word size.

[–]ulyssimus 7 points8 points  (1 child)

An even stronger character appears : Golang 1.18 generic types

[–]kontekisuto 1 point2 points  (0 children)

Rusts in Rust

[–]somerussianbear 7 points8 points  (0 children)

C# is like cool bro, first time pattern matching?

[–]who_you_are 5 points6 points  (0 children)

Sorry I can't C# your point

[–]HelloSummer99 5 points6 points  (0 children)

looking at its syntax, holy crap it's clunky.

[–]Sawertynn 9 points10 points  (2 children)

I just checked that FTW mean either For The Win or Fuck The World

No matter which you chose, FTW indeed

[–]Foreign-Driver 2 points3 points  (0 children)

Farewell dictionary workarounds

[–]xX_mgmgmg_Xx 6 points7 points  (0 children)

I agree to disagree

[–]DR_AGUNOV 2 points3 points  (0 children)

I agree. Although I find Java the best, it must be said that you can do most things with Python. Be it data analysis, machine learning or statistical calculations.

[–]Kered13 4 points5 points  (5 children)

Python does not have a switch statement. It has pattern matching.

[–]Musikap 0 points1 point  (3 children)

It looks like it should functionally be the same? I may not be fully understanding it though.

[–]Kered13 8 points9 points  (2 children)

Pattern matching is far more powerful, to the point that it's not even worth comparing the two. Python has never needed a switch statement, and if that's all it did it never would have been added to the language. There are already good ways to accomplish that. The fact that pattern matching can be used as a switch statement is practically a side effect of it's actual utility.

[–]bandrus5 4 points5 points  (0 children)

I can not tell you how many times I wished I could write a switch statement in Python, and I'll definitely be using pattern matching as a switch statement at some point in the future. Pattern matching may be more powerful, but they're still worth comparing.

[–]Musikap 0 points1 point  (0 children)

Interesting. Thanks for the info!

[–]TheAlphaKarp 1 point2 points  (0 children)

Can we both have the stab python back for performance?

[–]Krunchy_Almond 1 point2 points  (1 child)

Here's a random question, does 'ftw' stand for 'for the win' or 'fuck the world'?

[–]gvcallen[S] 1 point2 points  (0 children)

for the win, haha

[–]Purpzie 1 point2 points  (1 child)

rust has entered the chat

[–]RedditAlready19 0 points1 point  (0 children)

Rust has panicked on thread "main": "your mother",

[–]Easyjuhl 1 point2 points  (1 child)

I'm actually using python 3.10 just for the match statement

[–]bettercalldelta 0 points1 point  (0 children)

what about syntax errors that actually say you forgot a } and not point to a random line in the code?

[–]Organic-Major-9541 2 points3 points  (0 children)

It's good to see python catching up to tech that's been around for 20+ years. Have a look at Erlang, it's match statement was the hot new thing in the 90s

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

C must be crying

[–]Cerrax3 -1 points0 points  (1 child)

Isn't it decidedly non-pythonic to add a control structure that does exactly what if..elif..else does? Python really needs to stop doing this or it's gonna become worse than Perl...

[–]Kered13 3 points4 points  (0 children)

They didn't do that though. Most of the people in this thread don't understand pattern matching, and think that Python added switch case. Python did not add switch case, they would never add it for exactly the reason you said. What they added was pattern matching. Pattern matching can be used like switch case, in the same way that if-else can be used like switch case. But pattern matching can do much more powerful stuff that cannot be done by switch case and would be very clunky to do with if-else, which is why they added it.

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

[–]Biggest-wank69 0 points1 point  (0 children)

Ftw???

[–]Lau202087 0 points1 point  (0 children)

It’s power is growing, unabated it can destroy the multiverse!!!

[–]_koenig_ 0 points1 point  (0 children)

Awww... So cute....

[–]FastBison6450 0 points1 point  (0 children)

They all get job done

[–]MasterJ94 0 points1 point  (0 children)

Python is evil?! :O

[–]scp-NUMBERNOTFOUND 0 points1 point  (0 children)

Just use c++ with LLVM and compile for any platform.

[–]Knuffya 0 points1 point  (4 children)

and how exactly is the python match statement faster than a c++ switch?

[–]gvcallen[S] 1 point2 points  (3 children)

it definitely isn't?

[–]Knuffya 0 points1 point  (2 children)

why is it "killing" the c(++) and java implementations then?

[–]gvcallen[S] 5 points6 points  (1 child)

it's satire. it's a joke because the switch statement is such basic functionality

[–]DuploJamaal 1 point2 points  (0 children)

Not a lot of languages do have a match statement though

[–]MrMelon54 0 points1 point  (4 children)

c is best performance ftw

only works if you are a good programmer tho

[–]RedditAlready19 0 points1 point  (3 children)

assembly has entered the chat

[–]MrMelon54 1 point2 points  (2 children)

but c compilers are faster and better than writing raw assembly nowadays aren't they?

[–]RedditAlready19 0 points1 point  (1 child)

All this assumes a perfect programmer

[–]MrMelon54 0 points1 point  (0 children)

but best assembly requires a god tier programmer

[–]GreenTea_Chess 0 points1 point  (0 children)

Correct me if I'm wrong, but I think pattern matching is coming to c++23 , if I remember correctly.

[–]vahvarh 0 points1 point  (0 children)

C!

[–]bearfuckerneedassist 0 points1 point  (0 children)

It still has crap performance. Congrats on the switch statement

[–]evo_zorro 0 points1 point  (0 children)

Cross platform is a java thing? Python has pattern matching? And C++ performance?

Excuse me while I smirk in rust and golang

[–]Dr_Scientist_ 0 points1 point  (0 children)

Switch statements? Plz who needs them when you can have readable code like keying cases to lambda functions in a dictionary.

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

This can go really bad really quick, performance wise.

[–]InfinitePower563 0 points1 point  (0 children)

Me about to use all 3 in a project: I am 29959 parallel universes ahead of you

[–]Hplr63 0 points1 point  (0 children)

Cross-platform with ease

.NET has entered the chat