[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
C considered harmful
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 228
Thread images: 14
File: blue-c-language-icon-256-x-256.gif (16 KB, 280x280) Image search: [Google]
blue-c-language-icon-256-x-256.gif
16 KB, 280x280
Let's be honest: this is the most harmful shit of all. Nobody really knows it as much as he really thinks he does, which is why anything written in it is so leaky and barely clanking along. That's why we're STILL finding errors in tiny-ass coreutil programs even now.

Let's do ourselves a collective favor and drop this shit already.
>>
>>52489065
>>listen to my uninformed opinion from im a guy who only programs in python and javascript
>>
>>52489100
Scheme and Haskell mostly.
>>
>>52489100
>python
Do people use this outside hobby/school projects?
>>
>>52489065
>considered harmfu

into the trash you go
>>
File: 1452665413459.png (706 KB, 960x954) Image search: [Google]
1452665413459.png
706 KB, 960x954
>>52489065
with C >95% of the debugging effort is done by the compiler, it needs to be able to statically detect problems well before runtime so once you write you program and it compiles it should just werk(tm).

heres where the problem lies, any it's squarely GCC's fault. just about every other hobbyist C99 compiler has a swarm of features for detecting memory leaks and bad practices. GCC is the one and only exception, and happens to be the most popular compiler outside windows environments.

tl;dr go install clang and stop using harmful compilers.
>>
>>52489136
My Torrent client and package manager uses it. And I use it to quickly make a program if need be.
>>
>>52489065
The only harmful thing here are shitty programmers
>>
>>52489065
Except we have no better non meme alternative
>>
>>52489165
Stallman really is a piece of shit.
Anything GNU related is just pure ass.
Can't wait for it all to depreciate. It's slowly happening already.
>>
>>52489521
Stallman is a nice guy
He invented C programming language and wrote linux with it
>>
use Go ;^)
>>
>>52489065
>Nobody really knows it
looks like you haven't met the big dick C playa
>>
>>52489521
>depreciate
can you even into?
>>
>>52489065
>Nobody really knows it as much as he really thinks he does
If you don't know the C spec by heart, you shouldn't be posting here. It's not like C++ or anything, it's perfectly reasonable to be expected to know all of C.

>which is why anything written in it is so leaky and barely clanking along
No, that's poor programmers and poor programming practices. You can do a lot worse things in PHP or C++.
>>
>>52490532
>poor programming practices
b-but muh patterns, muh tdd, muh agile, muh scrum
>>
>>52489165
If you actually made something that detected memory leaks reliably during compile time, you would be rich and famous.

i.e., stop lying out of your anus
>>
>>52490544
Those are "management practices", not programming practices.

Programming practices means things like don't malloc() like a slut, don't pass stack pointers out of functions, etc.

You can in fact write any program without using malloc() and using only stack allocated memory (provided you have enough stack space, of course), giving you free memory management.
>>
>>52489065
>let's write firmware, kernels, drivers and system tools in python or javascript hurr

OP considered harmful
>>
>>52490572
>Those are literal meme "practices" to impress upper management, shareholders and customers
Fixed.
>>
>>52490572
>write any program without using malloc()
>any program
>any
m8
>>
>>52489136
Hahaha
Scientific computing, scripting infrastructure, even game server back ends sometimes use Python
>>
>>52489136
Remove python libraries and look at the dependencies they have.
>>
File: 4chan hobbies.jpg (41 KB, 420x250) Image search: [Google]
4chan hobbies.jpg
41 KB, 420x250
C is 4chan friendly. See pic.
>>
>>52490572
>You can in fact write any program without using malloc() and using only stack allocated memory
you can also write any program using only page faults on x86, but nobody sane does that
>>
>>52490658
That is common when you program for mcus
>>
>>52490831
>mcus
>any program
inb4 pretending
>>
>>52489123
>doesn't know c
do you suck dicks?
>>
Size of any object should be built into the data structure. Most of these major bugs the last year has been because the size of a message is sent as a separate variable and that is not checked.
That and enabling features by default when they are not essential is bad practices.
>>
>>52490860
program has a very general definition
I don't see how it doesn't apply to MCUs
>>
>>52490925
"any", you fucking idiot, "any"! not "these hand picked examples of programs". ANY
>>
>>52490876
>I don't know what the fuck I'm talking about
>>
>>52489065
C lets you get near the metal. With great power comes great responsibility, and C will not protect you from your own stupidity. Learn how the hardware works, stupid.
>>
>>52489136
> doesn't know about Numpy, Scipy and Pandas
> doesn't know that whole scientific community uses Python most of the time
>>
>>52490989
Oh, I should've read what you responded to.
The way you quoted it sounds like you're saying "any program without malloc is bad/stupid".
>>
>>52491176
this

it's also used a lot in IB, data analytics and
machine learning. not on the same level as R but I'd say it's the nearest competitor.
>>
The problem with C isn't the language, it's that it forces you as a developer to be an absolute expert at undefined behavior to have even the slightest hope of not fucking things up for any non-trivial software. This kind of understanding is quite hard to come by and generally is only seen in really old greybeards.
http://blog.regehr.org/archives/213

This is why C is vanishing into ever more niche areas in todays world. C++ will take it's place eventually in basically every area C once dominated.
>>
>>52491176
Everyone and their granny knows about fucking numpy because you need it to do the most fucking inane things.
Adding two numbers? Please include numpy. Oh, wait, no, not that version, you need this version. Oh it doesn't work with your other libraries? Too bad, please compile it yourself.

Worked at a university and ended up fixing stupid python problems for idiots a lot of the time. The whole system is broken, library dependencies are all over the place there is no solid structure from one version to the next. Some don't run on Linux, some arent available on windows, etc etc. It's a total shit fest.
The amount of time wasted setting up the environment could be used to learn a proper language where you are expected to write software yourself rather than import everything then give up when the environment shites the bed.

Anyone I know doing scripting for analysis uses matlab. At least you can put an idiot down in front of it and know if there is a problem it's the user not the ide. Unless it is the ide because java.

Never had an issue with c. Don't see what all the fuss is about. You never hear builders complaining they should build with bubble wrap instead of bricks so they don't break their toes when they drop them.
Just be more careful when you write
>>
>>52491394
>expert at undefined behavior
>C++ will take it's place eventually
that's funny since C++ has all the undefined behavior of C plus its own corner cases and gotchas
>>
>>52491399
>amount of time wasted setting up the environment
just pip install in a virtualenv, bro
>>
File: laughing_links.jpg (8 KB, 200x223) Image search: [Google]
laughing_links.jpg
8 KB, 200x223
Threads like this are always hilarious. There's the standard response by tards who don't know that there are viable systems language alternatives to C. There are the tards who think "lel just don't make mistakes" despite ample evidence that even experts slip up. There's this >>52489165 dude, who somehow thinks C is even remotely suitable for detecting errors at compile time. All sorts of fun.

OP is right btw.
>>
>>52489136
>what is Google
>they even hired Guido
lel
>>
>>52491435
Not really. If you want to be pedantic and claim all C is valid C++, then just stick with C.

The committee is working vigorously to route undefined behavior out of the standard. For the parts where compatibility with C won't allow for it, then the adoption of the C++ Core Guidelines by big shops will go the rest of the way.

C++ is a much safer language to program in than C (always has been because of it's stronger type-checking), and especially modern C++ and the direction it's going in.

And at the same time it's still very, very fast as a runtime language. C's days are numbered, and it's use in opensource is already cratering.
>>
>>52491465
>who don't know that there are viable systems language alternatives to C
spotted the Go tard
>>
>>52491501
>C++ committee
I still find it funny in a sad sort of way that everyone is so desperately trying to reinvent Ada except with C-style syntax. And they still have quite a ways to go yet.
>>
File: PPE4tongue.png (260 KB, 640x360) Image search: [Google]
PPE4tongue.png
260 KB, 640x360
>>52489065
You can't deprecate C if you don't have an alternative
>>
>>52491549
Yea, I understand. C's terse syntax (and the fact the government wasn't inolved, and the fact it actually LET you do stupid [but appropriate] things) won the day heh.

Ada is just too verbose for my tastes, but ofc that's intentional.

also
>reinvent
. . .
>>
>>52491571
C++ is a sane alternative

>Five Popular Myths about C++
>by Bjarne Stroustrup

>1. “To understand C++, you must first learn C”
>2. “C++ is an Object-Oriented Language”
>3. “For reliable software, you need Garbage Collection”
>4. “For efficiency, you must write low-level code”
>5. “C++ is for large, complicated, programs only”

https://isocpp.org/blog/2014/12/myths-1
https://isocpp.org/blog/2014/12/myths-2
https://isocpp.org/blog/2014/12/myths-3
>>
>>52489136
what is django?
>>
>>52491501
>want to be pedantic and claim all C is valid C++
that's what an idiot would claim, not a pedant
>committee is working vigorously to route undefined behavior out of the standard
can't do that and still offer same performance as C
>For the parts where compatibility with C won't allow for it
and that's the biggest problem for C++
>adoption of the C++ Core Guidelines by big shops will go the rest of the way
how does the "C++ Meme Guidelines" protect you from signed integer overflow?
>C's days are numbered
most likely you won't live long enough to see C gone
>>
>>52491636
bro, can you even flask?
>>
>>52491615
And Ada is an even saner alternative, but that won't stop the retards claiming C to be the one and only true way.
>>
>>52491690
>saner alternative
hey, kid, I got this fresh new "systems programming language" for you! yeah, you can write a TCP echo server in no time!
>>
>>52491674
actually there are a few cases where C++ literally blows every other language out of the water.

>most likely you won't live long enough to see C gone
Neither will you, haha.

But as the huge language it is today (in the few areas left it is), that will probably swing mostly in C++'s direction within 10 years I'd imagine.
>>
>>52490783
Not even that faggot, but I feel that isn't a good case for python.

> scientific computing
Mostly throwaway shit-code, glued together.
> scripting infrastructure
same thing
>game server backends
in case you mean EVE, that's shit

The only thing that Python is really glorious at is involving ffmpeg to download and convert video to muh PC.
>>
>>52491710
>Ada
>new
The language is probably older than you are.
>>
>>52491674
see
>>52491615
All your points are shit except for the last one, which is fact we all have to live with

>>52491690
I've heard that too and with the features offered by the language seems to be true. But apparently C has lower learning curve, which allows shitastic things to be developed at nearly the speed of light. Plus the old hacker mantras of getting things done rather than doing things right.
>>
>>52491687
Flask is dead as fuck Anon, it recieves like a minor commit every month.
>>
>>52491734
what is Go
>>
>>52491739
>But apparently C has lower learning curve, which allows shitastic things to be developed at nearly the speed of light.
Bullshit. Learning babby-tier is quick, because the language has a small set of keywords.

Learning how to master it takes literally decades, and even then the code reliability is only provisional with few proofs available.
>>52491394
>>
>>52491739
>All your points are shit
ask me how I know you don't have a clue about C nor C++
>>
>>52491739
>C has lower learning curve
It only seems this way because it defers whole classes of errors to only be picked up during runtime, while Ada tries to find as many as possible at compile time. University students, for example, have an easier time learning Ada and a much easier time getting any embedded shit done with it.

>>52491751
Not a systems language.
>>
>>52491751
>what is Go
The new Node/Ruby
>>
>>52491775
>>52491794
My first language was Pascal, learned 15 years ago. It was easier to debug but required a more disciplined mind. When I learned C, about 13 years ago, I really liked that it allowed for things to be declared left an d right and cool shit like casting types to fit needs. They were noticeable harder to debug.
Given that Ada is strongly typed I assume that shit goes the same way as Pascal. But I agree that learning a language it's just a matter of learning the keywords. Mastering is another beast on itself

>>52491781
Because you're full of shit.
>>
>>52491744
>minor commit every month
These fucking webfags! If it doesn't have 300 breaking commits per day a la memejs because it's utter shit, it must be unmaintained and dead. Does it ever cross your mind that it's done?
Quick, let's find an alternative to echo from coreutils! Last commit was in september 2014! Clearly dead! zomg! Better whip out something quick and throw it on npm and commit daily.
>>
>>52489065
Too bad the alternatives are exactly as shitty (C++) since derived from it, don't have a non-GPL compiler and tons of libraries (Ada), non-standardized (FreePascal) or simply are not ready(D, Rust, whatever Jon Blow is creating) (yet).
>>
>>52491849
>cool shit like casting types to fit needs
confirmed clueless idiot
>>
>>52491887
>tfw comments like this is the reason why people hate us Pythonistas

Flask barely even supports Python 3.
>>
>>52491849
>I don't know C++
gtfo to /wdg/
>>
File: typical_g.jpg (25 KB, 398x328) Image search: [Google]
typical_g.jpg
25 KB, 398x328
>>52491912
>>
>>52489136
Python is a pretty decent language, a lot of people use it.

>>52489065
You can't use anything but C i when you're dealing with embedded devices. C is a great language because it's so logical and its relatively strict syntax keeps the program code clean. Plus it has compilers for everything do from x86 to ARM to your grandma's pie
>>
>>52491898
The FSF version of GNAT is licensed with the runtime library exception. Yeah, the versions are confusing. The lack of libraries is a bit of a problem, but Ada has a great FFI so it's not as bad as you'd think.
>>
>>52491943
>You can't use anything but C i when you're dealing with embedded devices
this desu
If I moved up to C++ I'd only be using the C parts of it anyway.
>>
>>52491923
>barely even supports
Flask works on python3 the same as on python2, you muppet! Oh, the hundred extension you use are not all ported to python 3? Sure, that's flask's fault, and they should make daily commits to the flask repo for that!
Fucking retard.
>>
>>52491923
>us Pythonistas
how's the coffee, hipstertrash?
>>
>>52491943
>you can't use anything but C blah blah blah
lel, such ignorance. The only legit point you've got there is that C has compilers for more architectures.
>>
>>52491977
>The lack of libraries is a bit of a problem, but Ada has a great FFI so it's not as bad as you'd think.
Dude, most languages have an FFI that's not complete shit, so I take that for granted.

Actually, the only example I remember with a shit FFI where you have to use assembly to fix calling conventions was FreePascal and I looked that up years ago, so it might have changed.
>>
>>52492130
>muh nodejs for PIC16
webfag confirmed
>>
>>52492186
And he doubles down with the not-knowing-shit-about-what-he's-talking-about! Can he get the hat trick? Stay tuned!
>>
>>52492252
>muh npm
>muh v8
>muh memescript
>>
>>52491739
>All your points are shit
>I can't dispute them because I have no knowledge so I'll call them shit and run away
>muh ebin damage control
>>
>>52489065
>Nobody really knows
I bet you can't even average 2 ints!
>>
File: 1432235713064.png (72 KB, 202x202) Image search: [Google]
1432235713064.png
72 KB, 202x202
>C
Great for low level stuff (OS, drivers, embedded), small projects, and speeeeeeeeeeeed.
Lawd help you if you have to deal with security and its painfully awkward string handling.
>C++ and other midlevel language
Great tools and poor controls combine to let people tie themselves into knots if they don't plan ahead or aren't will to allocate time to refactor. Usable for larger projects, but strong coding and project guidelines are a must.
>Java
Lots of good ideas, not so great implementation. Higher level abstraction and standardized data take away a lot of the system interop issues that plague lower level languages. Oracle/Sun needs to be their Design Pattern dipwads with a stick
>C#
Essentially Microsoft Java. Would be perfect if it weren't for neo-MS constantly screwing around with library support, especially with their GUI code.
>>
>>52492453
>especially with their GUI code
haven't you heard? html5-es6-angular-react-meteor-backbone-vue is the new GUI!
>>
What language should i learn as a complete noob


what was your first language
>>
>>52492529
C
>>
>>52492453
>especially with their GUI code
What? WPF and Winforms are still supported.
>>
The maker of C was born one town over from me
>>
>>52492529
java

the rest are useless meme languages
>>
>>52492561
just like MFC
>>
>>52492587
java confirmed the one true meme
>>
>>52492596
>MFC
>C#
Huh?
>>
>>52492529
html5+css3 and you can do anything!
>>
>>52492612
this faggot can't even p/invoke!
>>
C was made for a different kind of programmer

Not the self proclaimed genius hobbyist
Not the trained employee

It was made for, and by, the genuinely intelligent academic with a heavy background in math and even some actual hardware design.

If you are not that person or lack the mental ability to ever become that person, it's really no surprise that you can't use C without fucking up.

>>52489136
Yes, sadly. Slow shit everywhere.
>>
>>52492529
Python is great for beginners
>>
>>52490658
>>52490809

Try Quake III retards.

Re: >>52490572
>>
>>52492562
very impressive, keep it up
>>
>>52492545
>>52492587
>>52492625
>>52492703
?

so which one do i choose
>>
>>52492562
this is the DMR bot displaying the horrible "off by one" error

at least he didn't say "the maker of C was born BUFFER OVERFLOW BITCHES ASSUMING DIRECT CONTROL MEMES MEMES MEMES MEMES"
>>
>>52492712
Q3 uses malloc, you muppet!
>>
>>52489521
I'd just like to interject for a moment. What you're referring to asLinux, is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plusLinux.Linuxis not anoperating systemunto itself, but rather another free component of a fully functioning GNU system made useful by the GNUcorelibs, shell utilities and vital system components comprising a full OS as defined byPOSIX.

Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called Linux, and many of its users are not aware that it is basically the GNU system, developed by theGNU Project.

There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux.
>>
>>52492746
There is literally no such thing as a good beginner language

Just learn the basic concepts of CS and read your SICP or something

>but muh unemployable meme language
Learning a language is trivial. Fucking trivial. It takes a week at most. Who fucking cares. And who says all programmers want to work in the godawful software industry? Fucking idiot. Fucking java pig. Fuck you.
>>
>>52492799
>It takes a week at most.
not C
>>
>>52492799
>SICP

whats that
>>
>>52492786
I'm terribly sorry for interjecting another moment, but what I just told you is GNU/Linux is, in fact, just Linux, or as I've just now taken to calling it, Just.Linux. Linux apparently does happen to be a whole operating system unto itself and comprises a full OS as defined by POSIX.

Most computer users who run the entire Linux system every day already realize it. Through a peculiar turn of events, I was misled into calling the system "GNU/Linux", and until now, I was unaware that it is basically the Linux system, developed by the Linux project.

There really isn't a GNU/Linux, and I really wasn't using it; it is an extraneous misrepresentation of the system that's being used. Linux is the operating system: the entire system made useful by its included corelibs, shell utilities, and other vital system components. The kernel is already an integral part of the Linux operating system, never confined useless by itself; it functions coherently within the context of the complete Linux operating system. Linux is never used in combination with GNU accessories: the whole system is basically Linux without any GNU added, or Just.Linux. All the so-called "GNU/Linux" distributions are really distributions of Linux.
>>
>>52492815
Yes, C takes a day or two to learn. It's a dead simple language. You learn how the syntax works and that's it, you just think of how to represent programs in it. Assuming you are a non-autist that just does shit instead of wasting weeks thinking of clever ways to reduce SLOC while maintaining good formatting.

Now, java...well, that's not actually a programming language, it's more like the lost speech of r'lyeh.
>>
>>52492880
>C takes a day or two to learn
false
>You learn how the syntax works and that's it
not even close
>>
>>52492910
Looks like someone didn't read their SICP first.
>>
>>52492949
looks like someone doesn't know C
>>
>be Nooby Noobson
>expert JavaScript programmer
>can't into babby C tutorial
>every "Hello World" program segfaults
>spend rest of your life spreading FUD about C on /r/programming and HN
>>
>>52489136

Good scripting or prototyping. Also as people have noted the mathematical libraries are fantastic especially mixed with some basic scripting.

Python is good its just not the same type of tool C is.
>>
>>52493010
>expert
>JavaScript
hahahahahaha
>>
>>52491571


Hold on. Wait. People are still posting after this!!?
>>
File: 1452922099781.gif (993 KB, 250x250) Image search: [Google]
1452922099781.gif
993 KB, 250x250
>>52493010
>segfaulting a Hello World
>>
>>52489065
> ctrl-f array decay
> 0 results

/g/ never fails to disappoint
>>
>>52493102
why would you search for random combinations of words?
>>
>>52493102
There has been at least one oblique reference to the problem with >>52490876, but you're right that most of /g/ has no idea what the fuck that is and why it means C is shit.
>>
>>52493102
>>52493180
confirmed idiots
>>
>>52489065
We really need to just start making C++ compilers better so it can be used in embedded apps.
>>
>>52493285
>We
m8, you have no idea what a compiler is
>>
>>52493294
It's something that takes liney-wineys and then a bin comes out.
>>
>>52493334
confirmed C++ compiler developer
>>
>>52493285
You mean lisp compilers.
>>
>>52493373
You mean nodejs compilers.
>>
>>52493393
You mean mongo compilers.
>>
>>52493373
No. Lisp is slower and uglier than C++.

>>52493393
It would really be a good idea to have embedded things just use JS though.
>>
>>52493403
You mean HTML compilers
>>
>>52493406
>just use JS though
don't forget CSS3!
>>
>>52489065
this
>using c
>ever
enjoy being pwned>>52489065
>>
>>52493236
go home kid.
it's easily C's most glaring flaw, and it had no reason to exist except for Dennis Ritchie's lack of sophistication and foresight at the time.

// would making array parameters implicit tuples have really been that fucking hard?
int foo(int buf[]) {
for (int i = 0; i < countof(buf); ++i) { /* ... */ }
}
>>
>>52493429
>countof(buf)
countof pointer? are you this retarded?
>>
>>52493417
What?
>>
>>52493450
how are you going to make cool animations on that 8 segment LCD without it, faggot?
>>
>>52493441
the point is that utility of complete array/ptr equivalence breaks as soon as you try to pass an array to a subroutine.

in the hypothetical example, 'buf' would be a ptr/len pair.
>>
>>52493468
>complete array/ptr equivalence
there's no such equivalence in C
>breaks as soon as you try to pass an array to a subroutine
functions in C can't have array type parameters
>>
>>52492799
This
>>52492746
Just roll a dice
1 C
2 Java
3 Python
4 Haskell
5 Scheme
6 Ruby
>>
>>52491153
Dude C is so metal right?
>>
>>52493515
In C, arrays are only sized entities in the context of statically arranging members of a struct or variables in a stack frame.
Everywhere else they are just syntactic sugar for doing offsetted pointer access, with buffer members counts needing to be tracked/checked separately in an ad-hoc manner.

>>52493515
>functions in C can't have array type parameters
are you retarded? all the following are valid:
int foo(int x[6]); // seldom useful
int bar(int y[]); // probably not smart
int baz(int z[], int cnt); // what 99+% of use cases really are

I don't understand how you can deny ptr/array equivalence AND say that you can't have array type parameters, when the language grammar explicitly allows you to do shit like above.
>>
>>52493663
>arrays are only sized entities in the context
all objects have a size, including arrays
>all the following are valid
yes, but those are not arrays, those are pointers
>how you can deny ptr/array equivalence
because arrays and pointers are not equivalent
>say that you can't have array type parameters
you can't, they're pointers even if you declare them using that syntax, learn the language
>>
>>52493429
I always though C "arrays" where only syntactic sugar for memory offsets.
>>
>>52493917
you thought wrong
>>
>>52490572
You can't even accept a user inputted string without malloc.
>>
>>52493927
So it's either make good working arrays like Ada's or just don't? Then again you would need to change the grammar for declarations of memory allocated on .rodata or .bss
>>
>>52493917
sort of.

this guy is correct in a sense so technical pedantic as to be hardly useful:
>>52493901
all C objects have a static size, and since unsized arrays don't, they don't really exist except as syntactic sugar.
things like malloc just return pointers, and functions can have parameters that LOOK like arrays but really aren't, etc.

only statically sized buffers are "real" arrays by some people's consideration, even though heap-allocated contiguous blocks meant for linear storage are used all the time.
>>
>>52493958
Dude. Malloc isn't voodoo magic. An allocator's job is just to take care of segmenting your memory so you don't have to. You give it a big memory pool, and each time you need a small chunck, it tells you where you can have it. Here is a good exercise : have this uint8_t stack[1024] and give me where I can store efficiently a structure of 42 bytes
>>
>>52494166
>since unsized arrays don't
no such thing as unsized arrays
>only statically sized buffers are "real" arrays by some people's consideration
no, only arrays are arrays, regardless if they are statically or dynamically sized
>>52494169
>have this uint8_t stack[1024] and give me where I can store efficiently a structure of 42 bytes
not as easy as you might think
>>
>>52489065
C is OK (or at least salvageable) except for its shit treatment of arrays, including strings with their in-band termination.

// fuck you Ritchie that you thought this was worth it
void strcpy(char *s, char *t) {
while (*s++ = *t++);
}


the inability to accept arbitrarily sized arrays in function parameters and that the language just fucking punts by letting you do [] subscripting on any pointer is by far the biggest mistake in hindsight.

C strings and all their problems are a direct result of the array parameter problem and the desire to save a handful of bytes on collections of short strings on PDP-8s or whatever.
>>
>>52494757
> C
> dynamically sized array

do you mean VLAs?
>>
File: Aspect-Emperor.jpg (518 KB, 1440x792) Image search: [Google]
Aspect-Emperor.jpg
518 KB, 1440x792
>>52489065
With C you can program closer to the hardware than you can do in C#.

One argument against learing C is that it's included in C++. But most people realize sooner or later that you must know C to be good in the derivative languages.

C is pure power.
>>
>>52494775
>letting you do [] subscripting on any pointer is by far the biggest mistake in hindsight
that's what happens when you learn C from online tutorials instead of reading a book; if you'd do the latter, you'd know subscripting is just syntactic sugar for addition followed by dereference and you wouldn't be surprised by anything
>C strings and all their problems are a direct result of the array parameter problem
first, there's no problem with C strings; second, there are no array parameters hence no problem with array parameters
>>
>>52494900
>there's no problem with C strings
kek'd pretty hard
>>
>>52494932
of course, it's a characteristic of brain damaged individuals to just laugh when they don't understand something; it's a defense mechanism
>>
File: 1436141986738.jpg (120 KB, 700x774) Image search: [Google]
1436141986738.jpg
120 KB, 700x774
>>52492561
>Winforms
https://social.msdn.microsoft.com/Forums/windows/en-US/c4277a4e-9146-4dae-9eaa-773ef2802fe2/when-microsoft-will-stop-to-offer-support-for-windows-forms?forum=winforms
Off extended support in April.

WPF is the new hotness until MS decides to push something else.

>>52492506
You say that in jest, but MS really did lose an entire generation of code grunts to Google and web tech. Shame web tech is such a mess.

>>52492596
>>52492612
>MFC
It actually used to be a wonky, but powerful framework until they started making a massive shitmess out of it. Forced Unicode means having to trawl an entire codebase and escape every string literal the compiler feels like throwing a bitchfit over. The Feature Pack integration is disgustingly buggy, incompatible with half the framework, and requires rewriting large portions of the UI to leverage it. They chose to hold framework fixes hostage in newer versions of Visual Studio.
>>
>>52494872
If that's your logic then why not learn Algol 60/68 before learning C?
>>
>>52494900
nice ad hominem, kiddo, but I learned C from K&R years ago but am not such a raging neckbeard wannabe that I can't see the faults in the language for what they are.

>second, there are no array parameters hence no problem with array parameters
the same way that a starving person doesn't have a problem with food?

>first, there's no problem with C strings;
max kekkles.
in-band buffer termination is complete shit and slows down string parsing wherever it is used, in any form.
that's before you even consider all the millions of bugs and exploits it's induced in the last 50 years.

what are you going to try to sell us next, that unhygenic macros are also a net plus?
>>
>>52494997
Nigga I work with C every day, you're lying to yourself if you think C strings have no flaws.
>>
>>52495012
>web tech
please don't say those words together
anyway, ms lost because they had no fucking direction/coherency; they pumped technology after technology abandoning stuff at an incredible rate; who the fuck can take them seriously when they go "MFC is the design framework for GUI", "now, it's WinForms", "scratch that, it's WPF", "nah, WPF is obsolete, Silverlight is the new shit, Silverlight everywhere", "meh, Silverlight is dead now that flash is going away, so WPF is the good stuff again", "hey, Metro stuff is all about javascript and HTML5"
and it boggles the mind when all these UI "technologies" can't even hold a candle to the 1999-era VCL.
>>
File: big_bait.jpg (83 KB, 1024x768) Image search: [Google]
big_bait.jpg
83 KB, 1024x768
>>52494900
>first, there's no problem with C strings;
>>
>>52495044
C is more used than Algol 60/68.
>>
>>52495144
>I learned C from K&R years ago
it doesn't show; maybe you just skimmed?
>the same way that a starving person doesn't have a problem with food?
the same way it doesn't have a problem with move constructors and virtual destructors
>slows down string parsing wherever it is used
how?
>millions of bugs and exploits it's induced in the last 50 years
writing sloppy code is the programmers' fault
>>52495172
>I work with C every day
if you work with C every day and you struggle with strings, I have bad news for you
>>
>>52495304
>how?
think for a minute how frequent tight element-by-element loops affect BTBs and keeping pipelines filled, and get back to me whenever you figure it out.

do you think, for example, that strcpy is as efficiently implemented as memcpy?
>>
>>52495304
Never said I struggled, m8
>>
>>52489065
god, /g/ is such a pile of shit.

the one person who's capable of using terminology precisely is doing it just to troll and maintain pretentious but completely shit opinions.

C is sadly about the best language for its target space, but that's only because it was first and choked out would-be competitors, not because it's structurally perfect.

all the following could have been better with no penalty:
> unhygenic preprocessor macros
> pointer decay
> C-strings (in-band termination)
> pass by value semantics (default const reference w/ copy passing optimization in ABIs for small types would have been better)
> in-band error reporting (ret < 0) and even worse, global error flags (fuck you errno)
> entire <signal.h> API, especially all the reentrant/async-safe hoop jumping bullshit for handlers

of course experienced C programmers learn to deal with all these, but they're huge mistakes no reasonable new language would include.
>>
>>52489065
>C considered harmful
Citation needed.
>this is the most harmful shit of all
Citation needed.
>Nobody really knows it as much as he really thinks he does
Deepity, citation needed, forgot the /she.
>which is why anything written in it is so leaky and barely clanking along
Oh, so you mean they're just not as great as programming as they may think?
>That's why we're STILL finding errors in tiny-ass coreutil programs even now
Is it a problem with C? Or is it a problem with GNU/Linux in general?
>Let's do ourselves a collective favor and drop this shit already
Yes, let's collectively stop using the one language that lies at the helm of every single modern operating system.

Nice b8, m8.
>>
>>52490872
They mentioned the programming languages he frequently uses, not all of the ones they are proficient in. You are on an awfully high horse for someone with the deduction and logic skills of a brick.
>>
We were given a chance to have a safe, expressive language backed by the DoD, but Ada never killed C.

Now we face a future of the only viable C replacement being Rust, backed by a bunch of smug leftists. Is this what we deserve?
>>
>>52489136
>Delunge
>EVE Online
>Bittorrent
Enough said
>>
>>52491733
lmao you should look up a machine learning platform called TensorFlow released by google.

it's written in python.

google search, at least the neural network part that does the core feature, is written in python
>>
>>52496884
don't worry, as soon as they started paying more attention to gendered pronouns in the documentation than towards making it more performant and attracting serious developers, it was effectively dead.
>>
>>52496899
>EVE Online
mah nigga
>>
>>52496916
Anything non-trivial you do in python is done by calling out to C or fortran libraries. Nice try though.
>>
>>52496944
that's literally saying the same thing as the OP: "Scheme, because it is implemented in C, is shit because it is written in C."
>>
>>52496957
no it's not you spaz. It's python code wrapped around massive amounts of C. We're talking about replacing C.
>>
>>52497028
if you replaced the C-backend in TensorFlow with something else, it'd still be written in Python :)
>>
>>52491435
>>52491501
what are you people even discussing here? i began learning C. a simple book with 700~ pages. it teaches me the syntax and how to use / when to use C. isnt that all you need? maybe a bit creativity/problem solving in addition
>>
>>52492130
are you stupid anon? Sure, if you don't want to write C code for embedded devices, you could write assembly.
>>
>>52494757
>not as easy as you might think
And it's not as hard as you might think either.
>>
>>52493102
>array decay
Lol no such thing.
>>
Python/Javascript fags who claim C to be dead and "useless", noggers who shout "kill all whitey", and a man sawing off the tree branch he is sitting on are all doing literally the same thing.
>>
>>52497304
An array passed to a function "decays" to a pointer to its first element. That's why, instead of writing
int main(int argc, char* argv[])

you can write just as well
int main(int argc, char** argv)
because the whole array will not be passed by value, but rather "decay" to a pointer (still the former notation is preferred as it make clear that there is an array outside the given function and not just a pointer).
>>
>>52497373
Whoops, forgot a [/code]. Whatever, it's readable anywa.
>>
>>52497373
>decays to pointer
It is a fucking pointer.
int v[3] = {1, 2, 3};
*(v + 1) = -1;
>>
>>52489926
lel
>>
>>52489065
>http://meyerweb.com/eric/comment/chech.html

I would also love to see your flawless coreutils
>>
>>52497560
>pointer arithmetic works with arrays therefore arrays are the same as pointers

No, Pajeet.
>>
>>52497304
nice try, pajeet
>>
>>52492786
I have no idea why, but this never gets old.
>>
Oh cool, this thread is still around. I'll just add a little something. Y'know how you need to pass around a second variable to keep track of the size of dynamically allocated arrays? This should be completely unnecessary, because malloc keeps track of the size anyway. But you can't access that.
>>
>>52498035
>this never gets old
Neither does
install gentoo
>>
File: 1452837125137.png (11 KB, 590x407) Image search: [Google]
1452837125137.png
11 KB, 590x407
>>52489065

Everything still runs off C, most other languages including Java, Python, and most languages run off C based APIs

>hurr durr this language is terrible to do stuff in

of course it is you stupid fucks, it's low level.

All you idiots who sit here deciding what language to pick don't realize that nearly all of them are built on C or C++

The only ones that can largely lay claim to being their own languages are the oldies, FORTRAN, COBOL, Lisp, and a handful of others than basically turned out to be trash. C largely took BASIC and put it on steroids

Everything you're running on your C based operating system is using a C based API

>people in this thread think it's replaceable
let me know when you've finished writing that operating system kernel in whatever language you've chosen to do it in, good luck
>>
>>52499055
That's not a problem with C, the Linux/UNIX system call does that. You have no way of accessing it without kernel access, and I'm guessing even you aren't stupid enough to demand every program have access to kernel internals.
>>
>>52499055
the heap isn't guaranteed to have an implementation with O(1) access to an allocation's size, anon.
you also have issues with alloca() and VLAs, which are free to be allocated in stack or heap space.

nonetheless, the real issue is the paucity of C's type system, not runtime implementations.
>>
>>52499479

why would it not be O(1)?
>>
>>52499511
Why would it be? It might be in a linked list or something.
>>
>>52499511
this:
>>52499528

and the fact that some heap designs intentionally keep the internal allocation tracking away from the buffer to prevent overflow and spraying attacks.
>>
>>52499528

but we're looking for an allocation's total size, even if there were multiple allocations you could keep track of the total somewhere else

all you have to do is keep track of that value somewhere and then accessing it is O(1) regardless of the data type

i could be wrong on this but it from an outside perspective as someone who's not big into C it's presumably possible to keep track of a memory allocation with an O(1) function
>>
>>52499724
>all you have to do is keep track of that value somewhere and then accessing it is O(1) regardless of the data type
that is the entire problem you dumb fuck
>>
>>52499901
>>52489950
"go" is ugly as shit
>>
Daily reminder that considered harmful is considered harmful.

http://meyerweb.com/eric/comment/chech.html
>>
>>52499055
>>52499479
another significant issue not already discussed is that the heap isn't required to return a block of memory of exactly N bytes, just at least N bytes.

if you malloc 21B, you might get a pointer to a buffer that's actually 24B or 32B as far as the heap is concerned.
tracking the exact length would be just something extra for the heap to deal with that wouldn't be of use in most cases.
>>
>>52501642
>wouldn't be of use in most cases
Aside from, y'know, helping to prevent all those buffer overflow bugs. Nope, no use at all.
>>
>>52501869
the heap doesn't know whether any individual request is for a single object or an array, and tracking the size of every individually allocated object would just waste memory.

obviously buffers need to have their sizes tracked, but the free store is Not It for multiple very good reasons.
>>
>Considered harmful
>Every other bounds checking language just uses pointers on a lower level, most likely written in C
>>
>>52499055
You're completely free, and often encouraged in high performance scenarios, to write your own allocation framework. Feel free to implement whatever features you want.
>>
>>52502277
only a pleb would consider C's lack of random access checking a real problem, anon.

there are a lot of more glaring issues that don't even have speed/safety tradeoffs.
>>
>>52492679
yea. it was defined buy guys hand writing code and math functions for some really cumbersome machines; C was like a driving a caddilac for them at that point. also C's initial claim to fame was not speed or simplicity of implementation, it was portability. Write once, run on all 4 of the types of machines that existed at the time. hence is admittedly waning ubiquity. if there's a c compiler for the architecture and a sane I/O model, then you can write literally any piece of software for it.
>>
>>52491467
>implying Google isn't a Java company.
>>
198 void
199 resend_bytes(int fd, u_int64_t *offset)
200 {
201 size_t available, needed;
202
203 if (out_start < out_last)
204 available = out_last - out_start;
205 else
206 available = out_buf_size;
207 needed = write_bytes - *offset;
208 debug3("resend_bytes: resend %lu bytes from %llu",
209 (unsigned long)needed, (unsigned long long)*offset);
210 if (needed > available)
211 fatal("Needed to resend more data than in the cache");
212 if (out_last < needed) {
213 int chunkend = needed - out_last;
214 atomicio(vwrite, fd, out_buf + out_buf_size - chunkend,
215 chunkend);
216 atomicio(vwrite, fd, out_buf, out_last);
217 } else {
218 atomicio(vwrite, fd, out_buf + (out_last - needed), needed);
219 }
220 }
>>
>>52489065
Wow and I thought /k/ was easy to bait.
>>
>>52491176
That's because scientists don't know how to program.
>>
>>52503685
OP is a baiting faggot, but it's good bait, since the core complaint about C having some glaring flaws is actually true.

The bait is even better since 99% of /g/ isn't really qualified to make insightful commentary on programming languages, but everyone feels like they have a stake in the game for their pet languages.
>>
>>52490572
>what is 'new'
>>
>>52490572
>You can in fact write any program without using malloc() and using only stack allocated memory (provided you have enough stack space, of course), giving you free memory management.

i can't tell whether this is genuinely retarded or just horribly deceptive.
what it really means is that you can write programs with statically bound input sizes and internal complexity levels and that the program will fail when those limits are reached.

heap management is slower than linear stack allocations, but at least internal memory consumption is fungible and you can grow to the extend of the process ulimit or the address space limit (i.e., usually ~3GB on most 32b platforms).

32b programs written like anon suggests can trivially have their entire address spaces filled by overly cautious allocations in each stack frame.
>>
>>52489123
> haskell

Ah, do you think people use this outside of hobby projects?

https://storify.com/realtalktech
>>
>>52489065
you're right.
>>
>>52489145
>not knowing harmfu
>>
>>52500746
>"go" is ugly as shit
judging by your taste you'll beat it to BBW and black tranny porn as well
>>
>>52490789
>
what does it mean?
>>
>>52491674
>>52491713
most likely you won't live long enough to learn C++ properly
>>
>>52489521
What's wrong with coreutils? And pretty much every other dtandard linux program there is?
>>
>>52491465
>There's the standard response by tards who don't know that there are viable systems language alternatives to C.
Do tell
>>
>>52507773
The best is Ada and the most prominent is C++.
>>
>>52508070
this, basically.
>>
>>52508070
Ada is a pain to write in
and C++ is a mess
>>
>>52507161
>or C, for that matter.

http://blog.regehr.org/archives/213
http://blog.regehr.org/archives/226
http://blog.regehr.org/archives/232
>>
>>52508670
funny, just the words i would use to describe systems programming in C anon.
>>
>>52489165
You've either barely used GCC or you're an idiot. GCC has some of the best debugging tools around. Debugging tools will never replace good practices and safe design, anyone who does this would have been a bad programmer regardless.
Thread replies: 228
Thread images: 14

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.