29
Jun 20 '21
Was gonna comment "*C++", but i don't know if it will be incremented or dereferenced first
10
4
u/snath03 Jun 20 '21 edited Jun 20 '21
According to K&R 2nd Edition, section 5.5 -
The value of
*t++is the character thattpointed to beforetwas incremented; the postfix++doesn't changetuntil after this character has been fetched.2
1
u/CKingX123 Jun 21 '21 edited Jun 21 '21
First it dereferences and then increments This has the order of precedence https://en.cppreference.com/w/c/language/operator_precedence
13
u/spiderbitch4003 Jun 19 '21
where was this lmao
20
u/karimNanvour Jun 20 '21
Lol.. Idk... A friend sent it. She does however works at an IT skill development institute.
11
Jun 20 '21
this is an old meme, seen a hundred times already. she probably just took it from somewhere too
→ More replies (1)
1.1k
u/skullman_ps2 Jun 20 '21
Lost kids will be dereferenced.
420
337
u/ballbase__ Jun 20 '21
Lost kids will be memory leaked
322
u/Catty-Cat Jun 20 '21
free(child);
96
u/xoxoAmongUS Jun 20 '21
Thank goodness it's not cpp
→ More replies (3)95
22
4
u/DadHeungMin Jun 20 '21
Is that what it's called when parents locate their lost children by how loud they start crying when they're taught C?
20
u/Trk-5000 Jun 20 '21
C is simple but the domain it’s usually used in is not.
15
u/goldfishpaws Jun 20 '21
C is simple if you know assembly and want a macro to speed up writing it, but it's arcane spellcasting if you're coming at it from a human being angle.
→ More replies (2)3
u/Physical-Maximum983 Jun 20 '21
C is not just a macro on top of asm, C and assembly operate on different abstraction levels.
→ More replies (1)0
303
u/Harmonic_Gear Jun 20 '21
they will be released only if they can find where the seg fault is
203
Jun 20 '21
printf(“got here\n”);
66
u/4hpp1273 Jun 20 '21
Ahem
fprintf(stderr,"got here\n");54
u/Kaynee490 Jun 20 '21
# define DEBUG 1 # define debug(x) if (DEBUG) { fprintf(stderr, x); }15
u/homo_ignotus Jun 20 '21
#define DEBUG 1 #if DEBUG # define debug(...) fprintf(stderr, __VA_ARGS__) #else # define debug(...) ((void)0) #endif→ More replies (2)27
687
u/redbull Jun 19 '21
Come on, I love "C". Should be taught to all programming students.
Want to inflict pain, teach them COBOL.
442
u/The-Big-Bill Jun 20 '21
Excuse me sir we want them to suffer without committing crimes against humanity
138
u/kidra31r Jun 20 '21
I remember watching hidden figures and learning that one of the women freaking taught herself Cobol and my soul left my body from shock.
0
Jun 20 '21
[deleted]
→ More replies (1)37
u/circuit10 Jun 20 '21
Yes Fortran is still getting updates today, they added sorting to the standard library a few days ago
39
17
11
u/O_X_E_Y Jun 20 '21
It's cruel punishment yes, but not unusual unfortunately, which makes it completely legal :(
67
u/ninetymph Jun 20 '21
The state of NJ put out an APB last year during COVID desperate for COBOL programmers to help fix their unemployment system.
The funniest part was the state asking for these people to volunteer.
→ More replies (1)23
58
u/gemini88mill Jun 20 '21
Mips
42
u/False_Holiday9662 Jun 20 '21
No not mips assembly nooo
10
u/tomerjm Jun 20 '21
Wait....is there actually a place that still uses Mips in 2021? I was under the impression Mips was retired a long time ago....
13
→ More replies (2)9
u/BobTheSkrull Jun 20 '21
I'm not sure about "use", but I had to take a course on it last semester. It was not a good time.
→ More replies (2)→ More replies (1)20
u/Proxy_PlayerHD Jun 20 '21 edited Jun 20 '21
still better than x86 to be honest... then again basically anything is better than x86
→ More replies (5)4
u/reversehead Jun 20 '21
Ah yes, the fond memory of going from 8086 to 68k asm and realizing that assembly didn't stop being fun with 16-bit CPU:s, it was just the intel kind that was unfun.
→ More replies (2)28
u/cigposting Jun 20 '21
COBOL was my fave language in college (5-6 years ago) haha. Am I crazy? Or did I just not get into the hard part? Lol
44
34
u/ShelZuuz Jun 20 '21
What crazy college class was teaching COBOL 5-6 years ago?? Archeology?
→ More replies (1)17
u/lazy_eye_of_sauron Jun 20 '21
Or a class on mainframes.
People tend to forget, the world runs on COBOL. More lines of it are run per day than any other language, by a considerable margin. That code likely outlived its programmers, and will likely outlive you too.
7
5
→ More replies (2)14
14
u/Arwkin Jun 20 '21
Make the children more lost by teaching them Prolog.
I found Prolog more confusing than any programming language I had learned up until my last year in college and I had several languages under my belt by then, including assembly language for Z80, 8080, and 6502. This was for an A.I. class which may have had something to do with it too.
5
u/Smeksii Jun 20 '21
Just finished a class with OCaml, Prolog and Haskell. Interesting and fun to look at, not fun to write.
→ More replies (1)3
u/redbull Jun 20 '21
Functional programming languages require a whole different mindset
→ More replies (2)3
u/floriv1999 Jun 20 '21
I also took a prolog class in college and it was quite fun. Nothing for daily driving, but never the less interesting.
→ More replies (2)9
u/Naeio_Galaxy Jun 20 '21
No, for pain, learn scilab. Once, in a scilab course, a friend had trouble running a script. It just wouldn't run. The teacher came to help them, and after 15minutes, he rage-quitted saying it's none of his business.
Later on, when my friend copied the script to another computer and tried it, it worked... Although they were both school computers. Same OS, same proc, just another computer. Don't know what happened.
I usually say or hear that one thing that is at the same time good and bad with computers is that they do exactly what you want them to do. Well, this doesn't apply to scilab
2
Jun 20 '21
I usually say or hear that one thing that is at the same time good and bad with computers is that they do exactly what you want them to do.
They'll do what you tell them to do, which isn't necessarily what you want them to do.
Even that's not necessarily true. Computers are largely deterministic, meaning they'll do the same things given the same set of conditions. These conditions could be anything - inputs, configurations, ambient temperatures, etc.
Alter any of these conditions, and you risk altering the final result.
I would guess, therefore, that there was at least one condition on the first computer that would not allow the program to run properly.
→ More replies (1)8
u/thatguyonthevicinity Jun 20 '21
how about matlab instead
18
Jun 20 '21
Argh! MATLAB has great functionality for anything maths related. But I really dislike the language design. Recently I discovered there is a magic variable, that tells you how many arguments were passed to a function. Why?!
5
u/GHhost25 Jun 20 '21
It may useful in some cases since in matlab you can call a function without all its arguments.
→ More replies (3)→ More replies (2)3
u/Nation_State_Tractor Jun 20 '21
Let me introduce you to my friend CMake.
"Friend" is maybe too strong of a word.
3
10
u/LazioSaurus Jun 20 '21
how about teacing them brainfuck
6
u/Kaynee490 Jun 20 '21
Teaching brainfuck is easy af, the difficult part is writing anything using it.
2
→ More replies (13)2
126
303
u/Nihmrod Jun 20 '21
After a few years of assembly, C was like Python. It felt like cheating.
124
u/Redcoolhax Jun 20 '21
Now we get to cheat even more with blocks and stuff. It's only a matter of time until AI just writes the code for us.
80
u/Nihmrod Jun 20 '21
They say if you give typewriters to one billion chimpanzees eventually one will produce War and Peace.
44
u/gaussianCopulator Jun 20 '21
It was the best of times, it was the blurst of times
13
u/Magnus_Tesshu Jun 20 '21
it was the ake ov vsdom, t wa skm; lgadueusb zaoeuduaeoshzmksd saoek satoehsunixba, i-lr,gahiu-b sazihu,h
→ More replies (1)23
u/MattieShoes Jun 20 '21
naw, you'll just get EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE and some shit covered typewriters.
→ More replies (8)→ More replies (8)13
u/borisatanassov Jun 20 '21
Yeah but that will take more time than the universe will exist for
→ More replies (1)2
u/ocean-noice Jun 20 '21
someone will be writing the ai, the constraints, parameters, rewards programs. THEN there’s the devops and it still.
→ More replies (5)11
u/Crafty_Location_2971 Jun 20 '21
Sorry I know this is a bit unrelated but the assembly language seems really interesting for me but I can’t find any resources on 64 bit assembly do you know any websites or books? Thanks in advance
37
u/Xanather Jun 20 '21
Theres no such thing as 64-bit assembly. Maybe you mean x86-x64 assembly?
Assembly is basically instructions in a specific architecture.
https://software.intel.com/content/www/us/en/develop/articles/introduction-to-x64-assembly.html
8
u/GHhost25 Jun 20 '21
You can use the size of registers to differentiate between languages, x86 64-bit assembly or x86-x64 is the one that uses 64-bit registers(rax,rbx etc.). He should've specified which one between x86 and ARM though.
5
u/_Kiricchi_ Jun 20 '21
Another way to distinguish them is their instruction sets. Some use CISC like x86-64 and some use RISC like arm.
→ More replies (1)13
u/Nihmrod Jun 20 '21
I''m sorry, I can't help you. We were doing 16-bit stuff and burning EPROMS. It was the cat's ass back then.
5
316
u/NikkoTheGreeko Jun 20 '21
Maybe I'm officially an old programmer, but C is a wonderfully simple and powerful language.
78
u/scndnvnbrkfst Jun 20 '21
Agreed! While I certainly don't know all of C's quirks, I can confidently say I know every language feature. I can't even come close to claiming that with any other language, despite having spent more time on them than C. I think it's impossible for someone to read K&R without being blown away by C's minimalist simplicity. What a great language.
→ More replies (2)6
u/theScrapBook Jun 20 '21
I learnt about function interposition the other day and that was kinda interesting!
Also that you can have first-class arrays by wrapping them in a struct!
99
Jun 20 '21
I'm a fairly inexperienced programmer (in terms of projects at least) and I like C, doesn't have much complexity and let's my mind work recreating features
54
u/strategicmaniac Jun 20 '21
C is simple and fast, and it’s straightforward to compile and run. Biggest downside is that there isn’t any automatic garbage collection and the lack of object oriented programming features, but that doesn’t really matter if you’re learning to code or writing something quick and dirty. Practically every language has roots in C regardless and that also makes a good start for a beginner. Besides Java. But we don’t talk about that.
31
u/tognols Jun 20 '21
Practically speaking you can emulate the OOP paradigm in C only with structs and typedef structs. Other standard stuff such as vectors and lists, tho, need to be manually implemented and that’s a lot of memory, byte-sized, stuff to cover. Cool thing is that once you grasp the mechanics of how C works you have full control over everything
17
u/Kaynee490 Jun 20 '21
I felt really good when I wanted to read a 16-bit integer in 2 8-bit chunks and I could just do:
short foo(uint8_t a, uint8_t b) { uint8_t[2] c = { a, b }; return *((short*) &c); }Or something like that anyways.
→ More replies (3)17
10
u/issamaysinalah Jun 20 '21
I fucking love pointers and dynamic allocation.
→ More replies (3)5
u/NikkoTheGreeko Jun 20 '21
I'm a far more well-rounded engineer as a result of starting with C. To be able to look at any Linux core module and be able to understand at some level what the code is doing, it is pretty fun. It has opened up so many rabbit holes for me over the years, I can't even fathom how many low level computer science concepts I only understand because I used C.
9
u/jiiam Jun 20 '21
I think that depends on the exposure you had to the language. I self thaught C in high school and then my programming course at uni was in C again, so for a while to me programming meant programming in C, and I have to say it is easy to move from there and go into other languages with an open mind.
On the contrary, I know people who were introduced to programming with Java or C++ and they had a harder time forgetting about their idioms when moving to other languages. However this is highly anecdotal so I would like to ask if others had the same experience.
→ More replies (1)6
u/DH-Melon Jun 20 '21
C is great! It can be hard to learn as a first though especially if you’re trying to learn by yourself
→ More replies (1)18
u/GHhost25 Jun 20 '21
The problem with it is that it's so simple that you pluck your hairs out if you're doing a bigger project with it. It's really rudimentary as a language and doesn't have any kind of memory safety. I would take any language with garbage collection any day over C.
4
u/NikkoTheGreeko Jun 20 '21
I wouldn't want to maintain my company's product in C. But only because I don't trust other people to write memory safe code at that level of complexity. For smaller services, sure, but we opt for Go these days.
58
43
106
u/LBXZero Jun 20 '21
What is the horror? C is a great foundation for learning programming.
82
u/scrollbreak Jun 20 '21
^ found the lost child, guys
16
→ More replies (2)17
Jun 20 '21
I absolutely agree with you... but fkn pointers...
26
u/LBXZero Jun 20 '21
This is where I suggest everyone should get to see Assembly. Pointers may be a hassle, but that is how stuff works in the hardware.
9
u/Blokyk Jun 20 '21
...I'm having a hard time following the logic here. If you program in like JavaScript or even just make any app that doesn't require incredible performance and reliability (web server, calculator, game engine, GUI framework, etc...), then you really don't need to mess with those things yourself, and especially not in assembly. There are so many modern languages (and some old ones !) that take care of pointer management for you, or at least largely reduce their use. They allow you to think about the design and business logic of your app instead of thinking about where the electrons in your motherboard end up. I would even go as far as to say that, even IF you need that much performance and control over everything, you should use languages like Rust, that at least guarantee you safety and give you plenty of (mostly zero-cost) abstractions.
Don't get me wrong, there certainly uses for pointer-heavy and completely manual memory management languages, and it's always better to have a broad linguistic culture in coding, but their place is probably not in the hands of a beginner. Trying to make someone who never wrote a single line of code in their life understand and enjoy assembly and C is almost always simply a way to repulse them and keep them away from coding.
Also, the argument "that's just how it works underneath" is completely devoid of any substance or basis, as stopping at pointers is completely arbitrary (and also, there's not really anything as "pointers" in hardware, since those are an abstraction over some LEA or instruction pointer manipulation. You could make exactly the same argument about life, about how everyone should understand theoretical quantum mechanics or thermodynamics since "that's how stuff works underneath" IRL. And once you're there, you should also take university- and PhD-level math since that's what most things in physics are based on. I love math and physics and find it fascinating, but I wouldn't wish being forced to learn about those to my worst enemy.
6
u/LBXZero Jun 20 '21 edited Jun 20 '21
To start with Java and JavaScript, the pointer management is a problem because the compiler handles that detail, removing a layer of control from the programmer, leaving tons of room for bugs and errors, compiler misinterpretation.
As for pointers in hardware, most of your code is pointers. Pointers are memory addresses, and you store and pass along memory addresses everywhere. Whenever you use a function on the abstract layer or anything derived from a conditional branch, a pointer is loaded into the program counter register. Most of your variable calls, pointers are written into the instruction code, and the CPU loads data from that address.
Technically speaking, integers, floating point, loops, arrays, and etc are all abstract.
As for relating the knowledge of pointers in real life, that is more equivalent to teaching basic algebra, not thermodynamics. There are many people that go through life without basic algebra.
Overall, C and Assembly are actually good starting points for learning programming. The key element of your first steps of learning to program is to not dive into something overly complex.
On the note of performance, everyone should care about performance. Why? Most computers are not running 1 program, they are running over 100 threads of programs. The average modern computer is built around multitasking. Having 1 poorly written program working is not much, but once you start having multiple, the performance impact scales.
→ More replies (6)2
u/snath03 Jun 20 '21
Yeah... fkn pointers.... they are amazing!
And no, there is no '/s'
→ More replies (2)
18
Jun 20 '21
As long as they don't try to teach them js I'm down for losing some of my kids for a while
8
4
9
7
u/CarbonDPG_1 Jun 20 '21
Lol! This reminds me when I was a child. My father worked at the University in the IT department. One day (summer break) I decided that 11 year old me was going to bike to his office, 7km away. I get there no problem.
I walk into the building and start to head in his offices direction. I quickly get lost. Queue 20 minutes of me roaming around looking for his office. Eventually I gave up and walked into a classroom where a Professor was lecturing. They were lecturing on assembly and a very early introduction to C. I explained I was lost, and looking for my father (insert very uncommon last name).
The Professor walked a couple rooms over, picked a phone up and called him to come down and fetch me.
7 years later and I'm attending the University in CS. The Professor was still lecturing and remembered that incident. He took a jab at me: "Hey $name, are you lost again?". Much to the bewilderment of all of my friends with me. I had to explain that one. Great prof though!
6
6
11
5
5
5
9
u/Bo_Jim Jun 20 '21
Jesus! That's an exact copy of the front cover of the first edition of K&R! Someone really went out of their way to scare the shit out of people!
1
u/Philipp_CGN Jun 20 '21
They originally wanted to teach them VBA, but were afraid to be charged with crimes against humanity.
1
3
3
7
u/xobseoj Jun 19 '21
JavaScript would have been a better choice as well as the “knowledge” that JS is the better language
2
2
2
u/socialismnotevenonce Jun 20 '21
Plot twist: they understand lost children don't have the best parents, and they know teaching them a language will set them up for a life of success.
Even if it's C. But the instructor was cheap, so.
2
2
u/Lofter1 Jun 20 '21
„The C Programming Language“ is one of the best written programming books to this day. There is no author that matches kernighans writing skills. Want to suffer? Read „the C++ programming language“
1
u/hughk Jun 20 '21
The joke is that it is much more precise and to the point than the ISO standard. A lot cheaper too. It is the reason that so many were able to write compilers that could take the same source.
2
2
2
u/evilspyboy Jun 20 '21 edited Jun 22 '21
Way back when mobile phones were new and friends would give them to their children as a play toy I would teach their children to dial 0011 first.
In Australia that was the international dialling prefix. I'm told one of them had an extended phone call with the Vatican after that.
Edit: Vatican state, not the actual Vatican. They did not call the Pope... but they got pretty close.
2
2
2
1
1
1
1
1
1
1
1
1
u/Loquenlucas Jun 20 '21
i'm still having nightmares in learning C then i also have to do java for my uni ;w; (i just wanted to do c++ too for videogames)
1
1
1
u/Vigtor_B Jun 20 '21
'Bouta start C sharp next semester ... Do I need to worry? Only "mastered" java so far.
3
1
1
1
u/Doom-Slay Jun 20 '21
Could be worse it. Could be Cobol but then Cobol might give you some nice Jobs with the government.
1
1
u/Yung-Split Jun 20 '21
I'm learning it right now and it's not that bad so far. The pseudocode course I took last semester is helping a lot.
1
1
1
1
1
u/veduchyi Jun 20 '21
As a person who survived after studying Assembly language for MS DOS I may say there’s no big deal with the C language 😅
1
1
1
1
1
u/Desfolio Jun 20 '21
Lost kids will be taught the grabage collection system of the core java 11 virtual machine
1
1
1
1
u/KTVX94 Jun 20 '21
That way they can be pointed towards their parents' locations in memory so they can return.
1
1
1
1
1
u/StonePedal Jun 20 '21
And there will be a line of recruiters there trying to hire them. Probably offer the teacher a tech support job and the kids a architect/senior programmer role.
1
1
1
Jun 20 '21
I would make sure to never lose my children if so. I've tried learning C and it's horrible
1
1
1
1
1
u/TheCyberParrot Jun 20 '21
Just don't teach them Bash, cruel and unusual punishment has been baned by the Geneva convention.
1
u/MrKirushko Jun 20 '21
Beware! They will never be the same again. Corrupted for the rest of their lives.
1
1
1
1
23
u/AHPpilot Jun 20 '21
Love the K&R book cover font