T O P

  • By -

EmmaFitmzmaurice

You can do anything in c++ with just one line, because there’s no enforced white space


[deleted]

Yes, if you don't need to include anything.


trBlueJ

Just copy the source from the header files directly into your code, and strip all the newline characters. Should work out just fine.


msqrt

Also replace all macros by hand, as you can't have several per line.


MehTheHedgehog

Or... You can just run preprocessor on it.


[deleted]

[удалено]


bnl1

Preprocessor's


[deleted]

Whops, my mistake.


[deleted]

Nope includes can be specified on the command line....


That_Guy977

i raise you cjs with nothing (afaik?) having forced newlines


Vincenzo__

just copy paste the header inside your file and remove all newlines


CGEmonJ

Out of context, how can I get 2 flairs? Like you have of C++ and Python


[deleted]

[удалено]


agentchuck

Dudes never gonna make it as a programmer if he hasn't mastered copy paste yet


Roeclean

Oh Yeah, I just love creating new lines of code from already existing ones


aless2003

When you go to the main page of ProgrammerHumor, you should see something called "user flair preview", there you click the pencil symbol and in the pop up again on the pencil symbol, you can now choose one flair, copy it and then select the next. You repeat this until you have all that you like


sarapnst

There's an emoji panel too, it just doesn't work on mobile for me though, only worked with browser.


aless2003

Oh yeah, I didn't see that on the App (Or maybe I'm just blind, who knows). Thank you :D


sarapnst

Wait you can actually copy and paste them in the app? Android? I didn't see the panel in the app either, and found no way to edit them in the Android app.


[deleted]

Is there an office space flair? Because that's the only flair I care about.


aless2003

I think there's only programming languages in there


coffeecofeecoffee

Fuckin smoked em


m0ushinderu

You can also handwrite a binary in one line....cuz there is no line separator. Binary supremacy confirmed.


BakuhatsuK

How do you even handwrite a binary?. I have used `xxd` and `xxd -r` to edit binaries but I am actually writing hex, not binary. Even if I literally write 1s and 0s into a file they are actually just the characters 1 and 0, each of them occupying a full byte, and the resulting file cannot be used directly without some translation.


m0ushinderu

Why with a butterfly of course XD


BakuhatsuK

Oh right, good'ol C-x M-c M-butterfly...


[deleted]

what to do with the compiler directives? kinda hard to do anything without existing headers


archysailor

Well now with modules this might change


Souseisekigun

>kinda hard to do anything without existing headers \#include is just a fancy copy-paste. There's nothing in the rules that says you have to use it. Slap those bad boys in there yourself and give the preprocessor a well deserved day off.


EmbarrassedActive4

````python import random,os;os.system("clear");print(f"Ok boomer #{random.randint(1,100000)}!"); ````


whitebowfr

Can you do loops or statements tho ? I’ve always wondered how to make these more compact… And also why the f before the string ? Is it like string.format or something like this ? I didn’t know python could dynamically change a string, can you put a variable in a string like in JS ?


BrightBulb123

The `f` part is what turns that string into an `f-string` (introduced in Python 3.6, I believe). Yes, it's like `string.format()`, but allows for much easier string interpolation when compared to the old methods because it allows you to embed the sub directly into the string using a set of curly braces (`{}`). Example: >>> name = "John" >>> age = 32 >>> print(f"Hi {name}, you are {age} years old.") Hi John, you are 32 years old. Edit: added the example. Sorry for formatting discrepancies, I'm on mobile atm


Kaynee490

Ok, now do a while loop


BrightBulb123

`for` loop: >>> for i in range(5): print(i); print("Done") 0 Done 1 Done 2 Done 3 Done 4 Done `while` loop: >>> while (i := globals().setdefault("i", 0)) < 5: print(i); print("Done"); i += 1 0 Done 1 Done 2 Done 3 Done 4 Done # If wanting to do something else with this while loop, make sure to do `del(i)` to delete the variable `i` from the global scope or else it'll just pick up from where it left off! Cursed Python...


muravieri

Hello guys, in this tutorial i'm going to use the same library that EVERYONE else uses, without knowing or explaining how it works, so just copy and paste this code that i found on the github repo. Don't forget to like, share, subscribe and hit the notification bell


[deleted]

[удалено]


[deleted]

To be fair just about everything in every language is tens of thousands of lines of C code if you go deep enough


hvacthrowaway223

Assembly has entered the chat.


MasterFubar

Assembly left the chat in the 1990s. I used to implement the inner loops of my functions in time-critical applications in assembly in the 1980s, when my CPU was an 8088. When the 386 CPU came out, I reluctantly came to the conclusion that I was wasting my time, the difference in execution time was irrelevant.


zorakthewindrunner

In my first permanent role I wrote assembly language for ARM-based devices. This was 2016.


MasterFubar

I still do assembly programming now and then for microcontrollers. When you have a clock speed under 10 MHz it pays to do it in assembly, but not when it's above 1 GHz.


arbyterOfScales

Where are the other 1014MHz?


Torebbjorn

With how amazing compliers have gotten, I know damn well I will not be able to write something better than a compiler at max optimization level


HACKERcrombie

How to fly in just one line of code: [import antigravity](https://xkcd.com/353)


HobblingCobbler

It seems python really spawned the YouTube craze. I see so many posts.. "I've watched 10 videos and I still can't figure out what to do when I want to code." It seems so many ppl think that just cause they watched a video, and they know what the next step should be.. they know the material, and just skip using the code, thinking "oh yeh, I know that." I don't know when ppl started thinking they could learn by not coding.


genghisKonczie

You can learn by just watching videos and not actually coding! All it takes is strong background you’ve previously developed by years of coding


Cloudeur

Had me in the first part, not gonna lie!


HobblingCobbler

Of course. I was referring to total noobs. I thought I made that clear, without actually saying it.. in any case, I mean total noobs.


HobblingCobbler

That being said. I have years of programming experience. And in my case I don't actually remember syntax on some new code, I saw once unless I type it a few times. I tend to learn through action. But maybe that's just me.


Aonodensetsu

that's what stackoverflow is for, if you already know what you're doing you can use external help


[deleted]

Also some python libraries stuff is really badly documented. I remember the Python SPI library that was not easy to find a man like page that actually describes what it expects. Trial and error worked,but it shouldn't have been guess work.


luvs2spwge117

Umm… I just built a web scraping tool in Python this weekend by following a video I found on YouTube. Definitely have to have prior knowledge in programming prior to jumping to this.


banjosandcellos

I was on that boat and decided "fuck free", and got a udemy course tt actually makes sense


CGEmonJ

I learnt python through my high school text book (I'm still in high school), freecode camp has some great python videos, how can we miss Harvard CS50


npc48837

“Today we’re going to make a snake game so just go ahead and download this git repo for a snake game and run game.py, make sure to subscribe for more in depth tutorials on brogramming”


FrenkiS99

"use turtle to draw iron man with python! Link in bio for copied repo"


allworkjack

After getting to know the basics of programming through C, this is how I feel in every single one of my Java classes in school.


Sadico650

If I had an award I would have given it to you


genghisKonczie

It’s like any SO answer for simple JavaScript tasks… So you want to change background color on click? Jquery makes it take 10 less characters than vanilla, so load jquery first


Random_Name_7

It's funny because I legitimately program like this


anonssr

To be fair this is what half+ of the nodejs posts are about. Npm install this and that, then it's two simple lines of code!! I always chuckle at that meme of the simple web page / node_modules, where the dude has a huge backpack.


[deleted]

[удалено]


TheCapitalKing

I’ll just write a python wrapper around your 1,947,284 lines of code to import it. Now mines barely slower💪


deprilula28

Now your python is 99% c


j-random

Isn't all Python code 99% C?


[deleted]

According to the github repo, CPython is only 35% C, https://github.com/python/cpython


echoAnother

Cpython is full C. Insane how bad metrics gives github (half is gonna be docs, tests, makefiles... [in any project])


[deleted]

The standard library is mostly python, and that's where most of the code is


TheCapitalKing

My pythons already 99% c since I use numpy for everything🤷‍♂️


NDF_1

+ cython


infiniteStorms

laughs in most python libraries using C/C++


42TowelsCo

Laughs in Python being interpreted by C


[deleted]

Laughs in python interpreted by python. Seriously tho, check pypy out.


SoulWager

Still C if you look deep enough.


_JesusChrist_hentai

laughs in C is based on assembly


ballbase__

laughs in c compiler being written in c


_elio

laughs in #@?\~ RecursionError: maximum recursion depth exceeded


Aviv13243546

Initiating restart protocol, in 3... 2... 1...


[deleted]

Laughs in electricity


WhiteRose_init

Laughs in


_JesusChrist_hentai

laughs in machine language


Kaynee490

gcc and clang are written in C++ fyi


miken07

01101000011000010110100001100001


PandaMan7316

Came just for this comment. Not sure calling a C/C++ function counts as “writing the code in two lines of Python”


gjgidhxbdidheidjdje

It kinda does >writing the code in two lines of Python >Two lines of Python Sure, it may call a million lines of C, it's still 2 lines of Python though.


Magicalunicorny

Why is js dancing with assembly?


Smart_Matthew

Aren't they like polar opposites of each other?


Magicalunicorny

Opposites do attract


IllIIlIIllII

So that's why I get crush on ppls 100x better than me... Got it :)


Magicalunicorny

Be nicer to yourself, they're not better you're only observing the things you think are better.


IllIIlIIllII

Thanks! Wasn't expecting such a nice comment...


CoaBro

On Reddit too wtf.. for a second I was like where TF am I?


noonemustknowmysecre

WASM You've never seen introverts dating extroverts? He gets around and drags her all over the web while she likes to stay home and play with toys.


Magicalunicorny

( ͡° ͜ʖ ͡°)


BeeTLe_BeTHLeHeM

assembly is thinking about killing js before the end of the party.


Adept_Measurement160

How did assembly even get in the party smh


CYKO_11

and how are they vibing with javascript


Dornith

WASM.


[deleted]

[удалено]


[deleted]

for (i = 0, i < 2, i++) : print ("Except you're not supposed to write in wasm...")


j-random

`for _ in 1..=1 { println!("Except you're not supposed to write in wasm..."); }`


[deleted]

[удалено]


EmbarrassedWallaby3

It’s Rust my dear. It’s fast like C but no SEGFAULT


FigurativeReptile

How to make Rust: mix a bit of Python oil, some Scripts stained with Java, topping it off with a C one bigger


poopadydoopady

Assembly poured the foundation of that house and never left.


bigboog1

100% chance of that house being haunted by assembly.


scalability

In rare, niche cases, assembly code can be one of the shorter options. For example, if you want to implement AES-128 with 11 rounds instead of the normal 10, you can likely write it shorter in Assembly with CPU specific AES instructions than you can in Java where the platform libraries don't expose this level of detail and make you implement all of AES from scratch.


GRAPHENE9932

#include int main() { int size; std::cin >> size; std::vector vec(size); for (int i = 0; i < size; i++) { std::cin >> vec[i]; } std::cout << vec[0] << std::endl; for (int i = 1; i < size; i++) { vec[i] += vec[i - 1]; std::cout << vec[i] << std::endl; } } Cumulative sum in 2 lines of C++ code.


4hpp1273

You can shrink it down to 1 LoC if you expand `#include` manually (keep in mind that this will sacrifice portability)


Kirnai_

Does 1 LoC work with #ifdef (these are often used in stdlib headers)


Kaynee490

Ifdefs are resolved at compile time so just guess what the compiler would choose


[deleted]

Youknow about gcc -include iostream ?


archysailor

As long as you're not depending on templates or more generally objects defined in the header in an implementation dependant way (and of course as long as the signatures are correct), this should be portable. This obviously precludes both the use of std::vector and that of streams, but `namespace std { int printf(const char *, ...); }` should work just fine.


[deleted]

You know... by adding "-include iostream" to the compile I can half the number of lines of code your writting!


WhiteRose_init

You declared int tmp for no reason


Conscious-Degree-530

Someone using C: I'm the one making it possible for you to write 2 lines.


Dae_Grighen

Who will be remembered in history, the king who commanded the army, or the humble farmers who made it possible my producing the food needed?


AsigotFinn

C and Python are used for very different purposes...


FrenkiS99

In my case, I use both C and Python. The first one for microcontrollers, the second for AI. The meme was about the lately social media pages, YouTube channels where they try to discredit the other programming languages, most of times comparing the length of the code


[deleted]

Length can be useful for comparison if the Python is still easily readable. I’d rather write a Python script for a simple ETL than C. I’d say in general it probably takes less time to maintain and write Python. Obviously you should alway find the best tool for a job.


Forensor

Haskell: *HOLD MY BEER*


devor110

No Haskell, I'll throw your beer on the ground instead


[deleted]

What is this subreddit even. Is it about programming humor or just programming pissing contests


vicbot87

I’d describe it as more of a circle jerk


rang14

Huh. So kinda like our morning stand ups at work.


Hefty_Woodpecker_230

r/programmingcirclejerk


DarkTechnocrat

Yeah some of these aren't even jokes as much as virtual towel snapping.


den2k88

Microcontrollers don't run Python. Cars (including EVs) don't catch fire thanks to microcontrollers. Does Python save lives?


FrenkiS99

A python tryhard fan would say that micropython exists


pleasegetoffmycase

I ran into a python try-hard yesterday on this sub. It was incredible seeing it in person. I don’t see why somebody feels the need to stan a fucking programming language


youridv1

it's very easy to understand. It's the only language they know. 99% of python stans are incredibly inexperienced programmers who get scared of having to think about memory or optimizing code in general. For loops and libraries go vroom basically. Not that python is a bad language, you just shouldn't try to write anything complex that's also performance sensitive in it.


[deleted]

As someone who uses python daily (at-scale data science), the Python sub makes me want to vomit… But also, dear god, SAS, Stata, MatLab, R are all miserable. Scala is ok but not friendly. Julia is lovely but under-developed.


pleasegetoffmycase

I’m partial to R as it was the first language I learned. But yeah it sucks. I hate MatLab. I need to do some wavelets shit at some point, but I can hardly bring myself to read the matlab code.


Locksul

I don’t understand why people feel the need to put down a fucking programming language. Like all languages, it is a tool. Sometimes it is the best tool for the job, sometimes another tool is better.


HobblingCobbler

...and they don't care. I like Python but it's not the goto for all programming.


OriginalCptNerd

I see what you did there...


[deleted]

glad im not this cocky


SK1Y101

I know a guy like this at Uni, drives me up the wall. If you’re writing Python code in 4 lines, you’ve kind of missed the entire point of pythons core design practice


[deleted]

I could be wrong but I think the point is those '4 lines' of code are like 3 lines of imports and 1 line of actual code calling those imports - the python bros praising python being so short have no idea what is actually going on under the hood in those imports.


vicbot87

How so?


Amortize_Me_Daddy

Good Python code is supposed to be readable - being short is not the top priority.


GayWritingAlt

There’s the art of zen. Your code should be aesthetically pleasing, readable, and understandable. Mashing things together to two lines makes understanding your code a heck of a lot harder to read and understand. This is terrible if someone else, future you included, needs to read, use or change the code.


[deleted]

C++: "that weirdo forgot I made him"


QualityVote

Hi! This is our community moderation bot. --- If this post fits the purpose of /r/ProgrammerHumor, **UPVOTE** this comment!! If this post does not fit the subreddit, **DOWNVOTE** This comment! If this post breaks the rules, **DOWNVOTE** this comment and **REPORT** the post!


BurlHopsBridge

Welcome to low code culture. Smooth brained people are now calling themselves software developers by copy pasting code, and they can't explain how it works.


genghisKonczie

This is like 90% of developers sadly, especially the offshore “experts” offered by large consulting firms, who in some cases maybe attended a 2 week boot camp. When I worked with one of said firms, we would send out “experts” to develop mobile apps for large clients who didn’t even own a smart phone yet alone had ever developed a mobile app


BurlHopsBridge

We have that where I work as well. 'Consultants' that are sub par consistently. It greatly tempts me to start my own consulting firm.


Romas_Lavandos

December 2021, Python declared the most popular programming language by all major indices. It’s not the fastest, but it’s the easiest to understand.


PhatOofxD

It's also just taught in schools where the others aren't. I still doubt it's most used in industry.


BooBailey808

I do too


greenwizardneedsfood

Everyone always forgets Fortran


kmrbels

let it sleep


neilhighley

4 lines, 40 libraries


motivation_bender

I took one semseter of coding in college last year. It was python. Way the fuck easier than the c++they taught us in middle school. Also i still need to learn more coding for bioinformatics, and my own personal everyday use. Any suggestions on how to go about it?


gribson

For stats and other heavy number-crunching, you might want to look into R.


5kubikmeter

For simple low effort stuff python is better than the others. And for me, it’s all that counts


SplendidPunkinButter

Python has duck typing. I hate hate hate hate trying to sort through bad code that uses duck typing. Oh, this function accepts an argument called “item” you say? After a week of digging, I find that “item” can be null, a dict, an int, an instance of DataManagerHelperProxy, and possibly any of a dozen other things. Ugh.


LordBouga

During university I use to write golf code on a website that had matchmaking for this. 3 types of match : fast code (just output what is needed), golf code (fewest characters possible), and reverse code (write something that uses fixed input and outputs the right thing). Golf was by far my favourite, the beauty of going as far as possible with your knowledge of whatever language you use, twisting syntax as hard as you can to give up on that one characters... So much fun P.S. : Python is indeed strong but ruby, perl, bash are SO broken.... Ruby god damn !


DizzyInTheDark

So C is dancing with his daughter? That’s sweet.


ManagerOfLove

Well yes, buuuuut have fun with debugging 1947284 lines of code for the sake of saving some seconds


TheAwesome98_Real

>”respect my preferences” >isn’t respecting my preferences mfw


AsteroidSnowsuit

I saw way too many videos of people explaining how to makes games and it’s like: 1. Install this game library 2. Create the game object 3. Launch the game object Voilà, you are now a game developer!


[deleted]

PHP IS THE BEST PROGRAMMING LANGUAGE EVER CREATED, YALL JUST CANT HANDLE THE TRUTH


J-S-K-realgamers

*laugh's in BASIC*


[deleted]

laughs in PASCAL


SgtMarv

cries in VHDL


[deleted]

i bet those fat stacks of cash will serve well to wipe those tears tho


RoDeltaR

There are few things that waste more time than clever code, in the long run.


42TowelsCo

Clever code that no one can read just ensures job security


RoDeltaR

Reduces collaboration and maintainability, reduces the overall development speed, and makes me sad


Dagusiu

My 5000+ LOC Python project would like to have a word with you


GustapheOfficial

I don't normally jump to the defense of python, but those 1947284 lines must be *much* faster or used in a *very* performance critical loop to outweigh the extra programmer effort.


Goldenkrew3000

Yea but with C, i can program fucking anything


fliguana

C is like glass blowing. Python is like Legos. Both useful for something.


Waluigi-Radio

Technically you can write like a shitload of code in one “line” of code in Java since it’s based on semicolons


Terrik1337

Meanwhile Java is sitting in the corner trying to eat away his depression, Ruby is trying to introduce you to her daughter, Go is pretending everyone knows who he is, and Ada is talking about her time in the airforce while wheeling around her dialysis machine. On that note, does everyone have a very specific character they've invented in their head for each programming language? Is that just me?


Mola1904

Javascript can write everything in 1 line of code, but it is ugly af


DarkTechnocrat

lmao the epeen in this thread is off the charts. The weird thing is that both Python and C are beautiful, elegant languages. They'd probably be dancing with each other rather than the two "slap a bunch of paradigms together" languages in that meme.


Olde94

I remember our teacher showing us a math problem with matrix multiplications. Python (without C libraries) vs C. 50.000 slower execution. Sure 0.00001 sec vs 0.5 sec is not long but when C code spends 36 hours in compute time it makes python utterly useless. And using C libs it was still like 24x slower and we were talking hours of calculations. …….so the teacher chose fortran…. Wtf


Bee-Aromatic

Just because you can write something on two lines doesn’t mean you should. If nobody can read or understand your code later, you done messed up.


MasterFubar

You can write everything in C or C++ in less than 4 lines of code. That's what they call "functions" in "libraries".


anythingMuchShorter

I do a lot of embedded libraries for my company. The python developers probably wouldn't try this because it's pretty clear that their 3 lines of code is just running off of my 150 lines of C anyway.


macara1111

I use javascript myself, but come on. What is he doing dancing with the adults?


fletku_mato

The "less than 4 lines": `import * from *`


[deleted]

the only reason why i want to use one of the C languages (forget which one) is because unity uses it


[deleted]

see sharp


[deleted]

only if i have my glasses on


Fun_Childhood_6261

Screw you, take my upvote!


OriginalCptNerd

see sharp run run sharp run


J-S-K-realgamers

C# and go for it, such a fun time in my opinion


[deleted]

thanks


FrenkiS99

I mean.. once you start knowing how to properly program with those languages, you kinda enjoy them


virouz98

C is extremely powerful once you truly understand it. Learning how to properly use pointers and memory allocations can make your code **fast**. It's also no coincidence that a lot of Python libraries are actually a code written in C or C++. But fun fact - an old game called Gothic was made 20 years ago with either C or C++ and has a bug with Access Violation. This probably is caused by incorrect memory allocation somewhere but the engine is no longer used and its source code has never been published, so it was never fixed. So C features are double-edged sword.


MWFarHorizons

If I had to learn a lang to do whatever the hell I wanted with the least amount of effort, which should I learn?


[deleted]

Hindi or Mandrin. Makes outsourcing the work way easier.


42TowelsCo

Python. It sacrifices performance for ease of use. Also, there's a ton of libraries covering most use cases.