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

C vs C++

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 307
Thread images: 11

File: c_cxx_venn_diagram.001.png (41KB, 488x441px) Image search: [Google]
c_cxx_venn_diagram.001.png
41KB, 488x441px
I'm obsessed with the idea of finding out the best general propose language for me, to use as a hobby, and eventually professionally.
I cannot decide between C++ and C.
I come from 6 years in which I've been working in C++ both at my job, and as a hobby.
I recently came across some wonderfully written C code, and now I'm questioning if I should change my "favorite language" and try to excel in the C techniques that actually make the difference.

It just looks more minimal, straight forward, easier to debug, portable, compatible, probably even better performance-wise (don't quote me on this one, though).
I also realized that with function pointers I can even do object oriented and polymorphic stuff, and there are procedures to "sanitize" void pointers, in order to make them kinda memory safe.

In this moment I fail to see any good reason to actually use C++14/17 over C11.

Do some of you prefer C++ over C?
What are your reasons?

Please restrain from using arguments that sounds like: "I'm super smart and if other people can't maintain my code it's because they are stupid"
>>
>>55999615

Ada or you're a pleb.
>>
All of them. It doesn't really matter where you start. Learn all of them. No I don't mean go from language to language reading documentation I mean learn to program in every fashion currently presented and then master whatever language you need at any given moment.
>>
>>55999615
Rust is the only solution.
>>
>>55999641
As in "If you don't use Ada, you are actually a pleb"?
Or as in "you, saying C is better then C++, which is more feature-rich and modern, sound as dumb, edgy and memey as a guy who would suggest Ada, sentencing you to be a pleb if you choose otherwise"?

>>55999678
Rust looks pretty damn solid and cool to me. On the other hand, the Mozilla foundation has really turned into an SJW headquarter.
Now: while I don't care if Rust is associated with fat feminists, I also enjoy the idea of a language that is maintained by a competent team, on the long run.
>>
I've worked for a few start ups in software development before getting a more stable position as a systems admin for a company that offers server hosting for various gaming platforms, as well as a larger separate corporate division.

>general purpose hobby language
Java or Python/Lua. Both very easy to learn and very easy to work cross-platform. Java has tons of libraries.

>professional language
When it comes to getting an entry level job, nobody cares what language you know. Programming is constantly innovating and revolutionizing. This fancy Java library may be what's hot right now, but 7 months from now you may need to learn C# because a new popular device came out that uses C# to make third party apps for. As long as you understand Linux CLI and have a portfolio of real experience showing the ability that you can learn multiple languages, you should be able to get hired. it doesn't matter what those languages are.
>>
>>55999615
>Do some of you prefer C++ over C?
C++, simply because most C libraries work in C++ as well but not the other way around.

Also: What stops you from trying "to excel in the C techniques that actually make the difference" in C++?

Also: I'm super smart and if other people can't maintain my code it's because they're stupid.

Also: Check more meme languages, like Loci or Zig
>>
>>55999615
>and there are procedures to "sanitize" void pointers, in order to make them kinda memory safe.
That sounds like some extremely shuddy hack, similar to some macro based test framework and RAII thing I came across at some time.
>>
Another anon here: i started learning c++ for fun, mainly because i can make cross platform applications with qt. Is there such a thing for c? I know there's gtk, but it doesn't look very outside of gnome
>>
>>56000854
*Doesn't look very good
>>
>>56000769
>Also: What stops you from trying "to excel in the C techniques that actually make the difference" in C++?

A well written C code, using the edgiest, most secret techniques, it's still really easy to pick up, to understand, and to maintain.

A well written C++ code is impossible to read and to maintain.
I've been working in C++ the last 6 years, and when I recently come across some source code from the boost library (which is praised as the best C++ code ever written) it looked like a whole new language.
I could not understand anything without consulting a stack overflow article for every line. And even when I started to understand the whole structure, I realized that at the end of the day everything it's just extremely convoluted.
>>
>>56000876
Theres libgui...
Unfortunately it uses Gtk on Linux.
>>
>>55999615
>I cannot decide between C++ and C.

Java is the best general purpose language. C# is a better language, but Java is actively used across a wider variety of platforms and devices.

C++ is the worst language to learn. C teaches you about fundamentals, almost as well as assembly would. C++ is a waste of time.

Seriously, the only reason you see C++ pushed so hard on /g/ is because it's full of students and NEETs who think anything vaguely difficult makes them 1337. If you want challenging, learn Lisp or Haskell. Don't dick around with C++.
>>
>>56000915
>A well written C code, using the edgiest, most secret techniques, it's still really easy to pick up, to understand, and to maintain.

But as long as it compiles with a c++ compiler like MSCC, it's still c++, even if it looks like c.

It's not like there is actually idiomatic code, that's cancer for cancerfags and cancer langs that need cancer workarounds to actually make sense.
>>
>>55999615
Consider C#.
>>
>>55999615
>What are your reasons?
1. STL containers
2. Smart pointers and RAII in general
3. Stronger typing than C
4. Built in regex
5. Templates and constexprs
6. Lambdas, closures, functors, std::function and other syntactic sugar allowing me to program functionally
>>
>>55999615
Maybe try something like Nim or D?
Or Rust tho /g/ seems to hates its guts(well it's community).
>>
>>56001131
>Maybe try [clusterfuck to C compiler with semantical leaks] or [language that killed its chance multiple times]
> /g/ seems to hates its guts
That means it's a good one, morty.
>>
>>56001076
>program functionally
Kill yourself, faggot.
>>
>>56001360
Butthurt imperative pleb detected
>>
>>56001373
Pleb with a job. You can stay a jobless patrician, cumguzzling faggot. I don't give a fuck.
>>
>>56001429
Not the same anon.
Are you stating that there are more jobs for imperative languages?

Do you program for embedded systems?
Is it really a big job market slice, or just a niche?
>>
>>56001429
Anon, I do have a job. As a C++ developer. If you don't know multiple programming paradigms, how can you call yourself a programmer?

All modern languages are multiparadigm languages, so why limit yourself to only using one, outdated, paradigm?
>>
>>55999615
>I'm obsessed with the idea of finding out the best general propose language for me
I would start with English.
>>
check out glib, which is used by gtk and plenty of other C libs. it literally recreates C++'s object and inheritance system in C, and it's ugly as fuck. for instance, a line of C++ code that looks like this:
file.zoom-level = 5;

ends up looking like this in C, because C has no such things as "objects":
g_object_set_property(G_OBJECT(file), "zoom-level", 5);
>>
>>56001474
>Are you stating that there are more jobs for imperative languages?
Is this bait? I can't tell.
>>
>>56001566
Considering that there are objectively more jobs in Java, C#, Python, JavaScript, PHP etc, all languages that draw heavily from multiple paradigms, as opposed to languages such as Smalltalk, Objective-C, C, etc aka """pure""" imperative languages.
>>
>>56001520
Does it sound weird, or did I make some actual grammar errors?
I honestly can't tell.
>>
>>56001649
i'm not the guy you were replying to but I suspect it was your misspelling of "purpose"
>>
>>56001590
>all languages that draw heavily from multiple paradigms
Nobody uses functional shit in any serious project, it's your own business if you want to fuck with lambdas or closures, might as well write in Haskell.
>>
>>56001731
>Nobody uses functional shit in any serious projec
But they do, you fucking moron. Even fucking jQuery uses map and reduce.

> it's your own business if you want to fuck with lambdas or closures, might as well write in Haskell.
There's a huge difference between using functional programming where it makes sense, and using imperative constructs other places, than to use only one single paradigm and refuse even to use basic I/O because it has side effects.
>>
>>56001731
>Nobody uses functional shit in any serious project
Sure, nobody uses Boost, React, .NET, or any other modern framework.
>>
>>56001753
>jquery
>serious
>>
>>55999615
>Do some of you prefer C++ over C?
>What are your reasons?
RAII is the only reason I need. You cannot do it in C therefore C is way more vulnerable to accidental leaks. And these: >>56001076

Also C++ is as portable and compatible as C, where did you get that from? C++ has many features like threads that are portable while C have them only platform depended.
>easier to debug
Explain.

When you use C++ you can use all the "minimal, straightforward" features of C just fine, but when you use C you cannot use C++ features.
And C doesn't have any OOP which makes it way less suitable for large, high-level projecte(I mean software etc. not kernels/drivers).

Anyway: Rust > C++11 > C++ > C

>>56000607
>On the other hand, the Mozilla foundation has really turned into an SJW headquarter.
>caring for company who founded a tool that anybody can use
>Rust is associated with fat feminists
Who associate Rust with fat feminists outside of 4chan? I doubt any fat feminists could ever learn Rust to begin with.

>>56000915
Maybe you just don't know C++ as much as you thought?
>>
>>56001764
It's widely used you sperg.

http://trends.builtwith.com/javascript/jQuery
>>
>>56001770
Rust is a useless meme language.
>>
>>56001770

D > *
>>
>>56001796
It was widely used in mind 2010s, not now. Get with the program, gramps.
>>
>>56001802
This is a useless meme reply.
At least provide some arguments and propose better alternative.
>>
C is more than enough. C++ so much bloated that the entire language is like a gigantic pitfalls of segfault error.

C is pure and simple. No bullshit, only the truth. You want the real truth ? C will tell ya.
>>
>>56001849
It's much easier to cause segfault errors in C than modern C++. RAII and smart pointer were created for a reason.
>>
>>56001849
Don't call it C. Call it MISTER C.
>>
>>56001867
Linux kernel is in C

Windows is in C++

That's the only argument that is needed to choose between C or C++. You have to choose your camp. Once you do, you choose the language the camp has chosen.
>>
>>56001812
React or angular or whatever the webby wobby neo-hipsters use are also relying heavily on functional concepts.
>>
>>56001770
>And C doesn't have any OOP which makes it way less suitable for large, high-level project
OOP is fundamentally flawed. It leads to shared state and overcomplicated and over-engineered designs.

>Maybe you just don't know C++ as much as you thought?
Nobody can "know" the giant mishmash of random features that is C++.

>>56001888
The Windows NT kernel is in C though.
Nobody is actually retarded enough to write a kernel in C++.
>>
>>56001888
What a retarded argument. Its already known Microsoft developers are incompetent so that doesn't really count.
>>
>>56001888
>That's the only argument that is needed to choose between C or C++. You have to choose your camp. Once you do, you choose the language the camp has chosen.
No you don't.

I used to work as a C++ developer, now I work as a C developer. You can know both. The error is to try to program C++ as if it is C and vice versa, they are really two vastly different languages.
>>
>>56000607

As in Ada is the superior language. Only being able to carry on one instruction at a time is so stuck in the 70s. If you have a processor with twelve cores, why don't you drop your cuck languages and use one that allows you to carry on twelve flows of instructions simultaneously?

>inb4 muh java has multiple subprocessing

HAHAHAHAHAHAHA not an argument. Reminder that the software that launches the nukes is written on Ada.
>>
>>56001952
>Reminder that the software that launches the nukes is written on Ada.
Pretty sure that it outdates Ada.

http://edition.cnn.com/2016/05/26/us/pentagon-floppy-disks-nuclear/
>>
>>56001969
>>56001952
https://www.theguardian.com/technology/2016/may/26/us-nuclear-arsenal-controlled-by-1970s-computers-8in-floppy-disks
>>
>>56001841
1. Anything newer than Java is a useless meme language.
2. Rust is newer than Java.
Conclusion: Rust is a useless meme language.
>>
>>56001969
>>56001983

Oh I get it, the language they're programmed in is... floppy disks? You must be seriously stupid if you don't understand the difference between hardware and software.
>>
>>56002105
They're probably programmed in Pascal or ALGOL or something like that. Actually, it wouldn't surprise me if it was written in assembly.

Ada didn't become usable until Ada 95, long after said software was written.
>>
>>55999615
JavaScript. Non-ironically.

I've worked in C, C++, C#, Java, PHP, Python, and JavaScript. I prefer JS even though I'm stuck with my current work in C++.
>>
>>56001888
Windows kernel is in C as well...

>>56002049
Great argument. I'll give you a (You) for an attempt.

>>56001907
>OOP is fundamentally flawed. It leads to shared state and overcomplicated and over-engineered designs.
But it works better. Of course you can make retarded, over-engineered OOP that will be hard to understand. But good design makes your code way more clear and modular, easy to extend and modify even for someone who is unfamiliar with whole project. Also without OOP you can't have templates, RAII, inherence which makes your code way larger, more complex and much less reusable.
I can't even imagine how would I solve most of the problems I actually do at job. Without OOP, I would have to force other devs who want to add eg. new powerup type to our game, to search and change switches and other code in at least 5 various places. It's super vulnerable for bugs and mistakes. Unless we would use some tricks to mimic vtables and inherence, but then they would probably not understand it and will surely not be able to debug it. Right now adding new powerup is literally just declaring new enum value with few parameters and/or lambdas, all in one place.

>Nobody can "know" the giant mishmash of random features that is C++.
Yes, but you just need to know the ones that are not deprecated or plain pointless. Unfortunately there is no clear way to check that, so many people focus on them instead of learning what really is useful.
>>
>>56001907
>OOP is fundamentally flawed. It leads to shared state and overcomplicated and over-engineered designs.
Unfortunately it is required for UI widgets. Every C GUI Widget library reimplements OOP poorly.
>>
>>56001907
>OOP is fundamentally flawed. It leads to shared state and overcomplicated and over-engineered designs.
C on the other hand provides no structure and any sided program made by a group results in long spaghetti trails of hacked in logic.
>>
>>56002342
You clearly have no idea what procedural programming is.
>>
>>55999615
As someone who's native language is C, I say that C++ is the best language for a program where the requirements are so far unknown. C++ makes polymorphism easier to add and adds some other useful features, while maintaining most of the useful C features (and the ones it doesn't maintain are compiler extensions in the good compilers anyway), and only adds a couple minor inconveniences. The STL is also a nice feature. Polymorphism in C isn't a huge issue to implement, but It's the kind of thing I'd never want to deal with in a team. Overall, C++ just lends itself the best to an arbitrary task.
>>
>>56000915

Thats partially because boost sells itself as the se++cond coming. And they take the time to turn readable code into the fastest code the current standard allows.
>>
>>56001807
Can you elaborate?

It could be a great language but it seems kinda all over the place currently.
>>
>>56003692
The D language would be great if anyone actually used it. No one in the industry uses it so it's terrible.
>>
>>55999615

>I'm obsessed with the idea of finding out the best general propose language for me, to use as a hobby, and eventually professionally.

It always - ALWAYS - depends on what you want to do. There is no "Silver bullet" langauge.

Generally C and Java are kinda the "basic languages" of programming, you can't really go wrong there. But honestly is Java much more power full (easy for web stuff, a lot of "ecosystem" languages).

So my advice would be get good in C and then you can kick ass in Java.


C++ is more like religion, either you think it's one of the worst and most cancerous langauges ever or you love it.


Also, sooner or later you might think about learning a scripting langauge like Python, Ruby, C# or Perl. They are slower but you can be a lot more productive with them for smaller tasks.


But first things first: start with C.
Just don't make the mistake to not learn other paradigms/langauges, a well-rouded programmer is a good programmer.
>>
>>56004181
If you look at the design patterns that have developed in Java, it seems like a lot of them are just a way to implement functional programming in Java. IMO, Java is the weird middle ground of all programming language concepts all merged.
>>
Wonderfully written C code? Pls share.

I'm slowly learning C, been looking for something like an example library of common things, like techniques, functions, famous algorithms, sort of like an index of good code.
>>
>>56004235

I'm not a Java fan. I actually think Scala is "the better Java", but it's no good to learn Scala until you know Java..

But that's a reason to learn Java, because if know it, you can easily pick up something like Scala, Groovy or Clojure - even though they are very different in their syntax, they use the Java libraries and JVM.


But there are so many nice langauges out there..
>>
>>56004495
If you're writing C, you have to figure that all out yourself. Apart from the seebs C faq and the Linux kernel conventions, there are no real standards on how to write C. If it's portable and doesn't invoke undefined behavior, that's good enough for C.
>>
File: GoDiePls.jpg (331KB, 1024x576px) Image search: [Google]
GoDiePls.jpg
331KB, 1024x576px
>>56000958
>C++ is a waste of time
>>
>>56004619
I'm not talking about standards or conventions, I'm talking about "here's a good example of merge sort" and "this way to read files has x advantage" and "oh, look at this interesting loop!"
>>
>>56005002
There's no correct way to write C, apart from code that had been benchmarked for performance.

With respect to reading a file, you either do it the way that the API intends or you do it wrong. Just look up any tutorial to find that out in C.
>>
>>55999641
>>55999678
>>56001131
>>56001952
MM EE MM EE LL AA NN GG UU AA GG EE SS

>>56001067
poo in loo, C# is MS's shitty Java/C++ knockoff
>>
>>55999641
>>56001952
What's a good Linux distro I can install in a VM to get started with Ada? I don't dare try putting the GNAT GPL toolset on my main OS
>>
>>56005133
If you don't know how to use Linux, install Ubuntu with KDE or Ubuntu with MATE. Those seem like the most idiot-proof distros, with decent DEs.
>>
>>56005059
I'm not talking about correct ways. Holy hell...
>>
>>56005317
go read K&R and seebs faq then fuck off then. It's not that hard
>>
C++ is too oldschool. Join the real world by learning a modern dynamically typed OOP language (python or ruby)
>>
>>56005373
Who said anything about hard?

You seem to have completely misinterpreted what I was after.
>>
File: wonka.jpg (67KB, 355x236px) Image search: [Google]
wonka.jpg
67KB, 355x236px
>>56005402
>the real world
you mean webdev babies?

yeah, naaah.
>>
There is literally nothing wrong with c++11
>>
>>56003709
So... the same goes with Rust?
>>
>>56003709
Facebook uses D, but that's about it. so yeah, pretty much no one
>>
>>56006505
No. Actually more people in the industry use Rust right now than D.
Dropbox, for example.
>>
>>56003709
They made too many mistakes to be taken seriously.
>>
>>55999615
C++ is useless and inconsistent. C is better
Also, learn scheme/racket/lisp.
>>
>>56008333
>C is better because it's better
>>
>>56000915
>A well written C++ code is impossible to read and to maintain.
This. And then you encounter a part with metaprogramming on templates, and cry yourself to sleep before resigning as a C++ developer and humbling yourself to learn haskell instead
>>
>>56008353
C is better because it is not trying to be what it's not designed to be. For instance: it does not have abominations bolted on top of it such as """""templates""""".
Also: you always know in C what the fuck does
 x = i * j 
mean. In C++ you also have to know what class i and j are, and if they overload the * operator, which makes your program literally the most unreadable piece of shit ever.
Quoting C++ creator, Bjarne Stroustrup :
"C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off."
>>
>>56008438
this.
>>
>>56008449
Without templates you get huge, repeating code which makes it super hard for extending. Of course you can use macros but they are unhygienic and debugging them is even worse.
You are supposed to implement operators in a way that is intuitive. You can make * operator that add but it's just stupid, it's no different from C where you have to know what functions do and name it properly to understand the program.
Overloading operators makes code more readable than using functions for the same way. Eg.
WorldPos = Matrix * (Vec.Norm().Cross(Vec2) * Constant + VecOffset)

Is way more readable than
WorldPos = mulMatVec(Matrix, addVec(mulVecScalar(crossProduct(normalize(Vec), Vec2), Constant), VecOffset))
>>
>>56001524
*(file + OFFSET_ZOOMLVL) = 5// still valid C
>>
>>56008724
That's a very clear expression because you can say what exactly it does.
>>
>>55999615
I prefer C.
I know how C works, because it’s simple.
C++ is much richer, but much more complex, and it’s way harder to know what you’re doing.

Knowing what you’re doing is way worth it.

The only thing C lacks are good containers, but Go has proven that you don’t need generic containers, so I’m sure you’ll be able to figure something out.
>>
>>55999615
>In this moment I fail to see any good reason to actually use C++14/17 over C11.

Autism. If it's not how we did it decades ago, it's not what we're going to do today.
>>
>>55999615
https://www.youtube.com/watch?v=KlPC3O1DVcg
>>
>>55999615
>It just looks more minimal,
The lack of features quickly becomes annoying. Also no one forces you to use a particular feature or write unnecessary code.

>straight forward,
I think that depends on who wrote the code

>easier to debug,
C debuggers are usually c++ debuggers in disguise.

>portable,
Some embedded architectures provide a c compiler but not a c++ compiler. If you need to target such a platform c is a reasonable choice.

>compatible,
In what way? Libraries? Interacting with other languages? Usually extern "c" is sufficient.

>probably even better performance-wise (don't quote me on this one, though).
Compile with fnoexcept and fnortti if you need soft real time guarantees

>function pointers
Use lambdas for less crufty syntax and to avoid the performance hit of going through a pointer.

>procedures to "sanitize" void pointers, in order to make them kinda memory safe.
Why not avoid void pointers all together by using a language with a proper type system?
>>
>>56000915
>boost
>good
jesus christ
>>
Anyone that can suggest a good book on c++? I already know how to program in c
>>
>>56001020
>as long as it compiles with a c++ compiler
well written C doesn't compile with a C++ compiler
>>
>>56008889
>but Go has proven that you don’t need generic containers
>>
>>56002232
>without OOP you can't have templates
retard confirmed, post discarded
>>
>>56010307
>well written C
no such thing
>>
>>56008889
Go has very clearly proven that you DO need generic containers.
>>
>>56008564
JESUS FUCKING CHRIST! THE MATRIX EXAMPLE AGAIN!
How many fucking times to you need to multiply a fucking matrix? What percentage of all written software are we talking here? Why is there a need for operator overloading for this specific use case?
Because it's useless for ANYTHING else!
>hurr durr muh iostreams
>>
>>56010393
>How many fucking times to you need to multiply a fucking matrix?
Speak for yourself, golang web fizzbuzzer.

Also, there is a lot more use cases, like complex numbers, quaternions, zillion types of coordinates, dates, etc pp.
>>
>>56010393
>Because it's useless for ANYTHING else!
You don't want to add strings? Big integers? Complex numbers? Vectors (in the linear-algebraic sense)? Polynomials? You don't like containers that behave like arrays?

>hurr durr muh iostreams
Everyone agrees that iostreams was a terrible idea.
>>
I will say one thing about Rust. It is NOT for noobs. If you go into Rust as a first language, you're gonna have a bad time.
>>
>>56008177
Dropbox uses Go not Rust you fucking maroon.
>>
>>56010444
>dates
>now() + 3
>3 what?
>I don't know, I have to check the implementation for +; if only I could find it tho...
>>
>>56010393
fuck off neckbeard shit. it's not our fault that you never got the chance to write a big project
>>
>>56010503
Mainly, but because golang isn't fast enough they have rewritten parts in Rust.

https://news.ycombinator.com/item?id=11283758
https://github.com/dropbox/rust-brotli
http://www.wired.com/2016/03/epic-story-dropboxs-exodus-amazon-cloud-empire/
>>
>>55999615
>pic
what does C have that C++ doesn't?
>>
>>56010580
>If only I didn't use notepad.
>>
>>56010626
I think compound literals...
>>
>>56010618
Then they are a bunch of language hipsters. If you need things to go fast, you use C/C++. That's just common sense.
>>
>>56010626
VLAs
restrict pointers
Designated initialisers (very useful for sparse arrays)
Compound literals.
A stable ABI (extremely important)
A lack of superfluous features
Quite a few other small things.
>>
>>56010646
Sure, kid.
>>
>>56010646
>If you need things to go bugged, you use C/C++. That's just common sense.
ftfy
>>
>>56010725
>I suck at writing C
>Therefore everybody else sucks at writing C

>>56010646
>C/C++
Why are you grouping two completely different languages together like that?
>>
>>56006505
Yes

>>56006598
Actually, they don't any more. The D guy left FB.
>>
>>56010658
>A stable ABI
How is C++'s ABI "unstable"?
>>
>>56010818
>Compiler update
>ABI changes

>Compile library with one compiler
>Can't use it with program on another compiler
>>
>>56010646
That's what everyone else is doing. But not always the most used solution is the best, - if we were doing all the same things we'd be still in the stone age.
This being said - rust is as fast (if not faster) than C++; benchmark it if you don't believe me. And, while being as fast, it's less convoluted, easier and has more readable and comprehensible abstractions.
>>
>>56010903
>rust
>less convoluted
fizzbuzzer confirmed
>>
>>56010261
I found "The C++ Programming Language" by Stroustrup to be a good read, and since C++14 barely adds anything it'll still be up to date for a while.
>>
>>56010851
>>Compiler update
>>ABI changes
isnt that a msvc issue than c++.
>>
>>56001812
JavaScript framework trends change faster than the time needed to gather and build statistics about it.
You could take one month off and come back looking like a grandpa.
>>
>>56010393
>How many fucking times to you need to multiply a fucking matrix? What percentage of all written software are we talking here?
Actually quite lot. As a game dev, I use operation like this a lot, especially when it comes to physics and graphic. Not necessary Matrix multiplications, but long vector operations are everywhere.
Also I'm currently working on fractal renderer, and majority of the code are mathematical operations on objects that represent fixed point numbers.
Also what did you expect as an example for mathematical operators overloading?

>>56010471
True. I love Rust because it solves lot's of problems from C++ and different languages without making it less secure/fast/efficient. But I'm afraid, novices probably won't be able to understand these things. Also it requires from you to think about every edge case before you will have to debug them later, which can be pretty hard for someone who doesn't used to think this way.

>>56010580
It's not language fault that your retarded time library allows for adding primitive number to an date object. It's not different from making function: Date add(Data obj, int time);
Proper libraries doesn't allow such an ambiguous operations: https://doc.rust-lang.org/time/time/struct.Tm.html

>>56010646
>this large company uses my favorite modern programming language A instead of yours B, it means it's better
>but they rewrite it from A to B
>it doesn't count, they are hipsters
My sides.
>If you need things to go fast, you use C/C++.
Rust and C are about the same when it comes to speed.

>>56010914
Rust surely isn't simple, but it's way less convoluted than modern C++.
>>
>>56010851
>compiler update
>ABI changes
Why aren't you using GCC?
>>
>>56008889
Interface{} Interface{} Interface{} InterfacE{}}}}}}}}}}}}}}}}}}}}}}}
>>
>>56010973
>isnt that a msvc issue
no, it's a c++ issue
>>
>>56001888
Linux is C because Linus himself is too full of himself to even consider that his favorite language is 40 years old and might have been replaced by something better.
>>
>>56011001
the compiler doesn't matter
>>
>>56011014
the g++ abi doesnt break with every update though afaik
>>
>>56011027
Linus' opinions about C++ are really extremely dated. The language and idioms he described were common before C++98 but aren't any more.
>>
>>56011027
>something better
no such thing
>>
>>56011034
The ABI *is* a compiler issue.
>>
>>56001888
you may have trips but you are wrong. the windows kernel is in C, C90 to be very specific.

everything else in Windows is C++ which is why you might be confused. over the past few years MS has been taking more and more things out of the kernel and moving them to userspace which is why you see many kernel-like parts of windows in c++ but the actual kernel is still pure C90 with assembly (MASM) where needed.
>>
>>56011001
>Why aren't you using GCC?
GCC has changed its C++ ABI many times. There was one not that long ago.
>>
>>56011038
nobody claimed "every", so why the strawman?
>>
>>56011027
>Something better
But there still isn't a language that is even close to being a viable replacement for C.
>>
>>56011090
>many times
No

>There was one not that long ago.
The last one was GCC version 3 something, so yes, that was a long time ago.

Also, not the language's fault. It is a compiler (aka implementation) issue.
>>
>>56011096
ok sorry g++ doesn't break in minor updates but obviously major updates will break things. that is why they continue to work on older versions of the compiler with bugfixes and some new features. They currently support 4.x, 5.x and 6.x which is a hell of a lot more than MS do with msvc
>>
>>56011110
>The last one was GCC version 3 something
The last one was version 5.1.
>Also, not the language's fault.
Yes it. The language keeps piling on more crap, and compilers have no choice but to change their ABI, so they can support it.
>>
>>56011059
you *ARE* retarded
>>ABI changes
>Why aren't you using GCC?
because the ABI changed in GCC, in MSVC, in clang, etc, due to changes in the C++ spec
again, the compiler doesn't matter in the statement "ABI changes"; they're all affected; but then again, you're retarded and can't understand
>>
>>56011151
>The last one was version 5.1.
Citation needed

>>56011161
You're obviously lying
>>
>>56011170
>Citation needed
https://gcc.gnu.org/gcc-5/changes.html
>The C++ runtime library (libstdc++) uses a new ABI by default
>>
>>56011027
Linus is an idiot, but he's not wrong about that. Why would you assume that just because something is old it must have been replaced by something better. Assembly is much older than C and it's not going anywhere.
>>
>>56011179
>The old ABI is still supported and can be used by defining the macro _GLIBCXX_USE_CXX11_ABI to 0 before including any C++ standard library headers.

>The old ABI is still supported
>>
>>56011231
I never said that the old ABI wasn't supported.
I just said that it had changed.
>>
>>56011110
>The last one was GCC version 3 something
why do you speak if you're an idiot?
>Also, not the language's fault.
>void map::erase (iterator position); // C++98
>iterator map::erase (const_iterator position); // C++11
>list::size() MUST be O(1) in C++11, so add another field to std::list
yeah, stable, not the language's fault
>>56011170
>You're obviously lying
you're obviously retarded and don't know anything about C++
>>
>>56011277
>hurr durr it changed after 13 years so it is a pile of shit
I bet you still use ALGOL-60

Btw, map::erase was a const_iterator and O(1) in C++03 as well.
>>
>>56011277
>trying to link together stuff compiled in 1998 with stuff compiled in 2011
>acts all butthurt about ABI changes
wtf
>>
>>56011318
>>56011337
>don't know what we're talking about
>we got rekt HARD
>time to damage control tho
>>
>>56011337
>stuff compiled in 1998 with stuff compiled in 2011
do you know what ABI means? do you know the purpose of it? get the fuck back to your css and stay pleb
>>
>>56011401
It means application binary interface, and surprise surprise it changes over time. You're a fucking retard if you think a 32-bit ABI and a 64-bit ABI are the same.

>>56011383
Meme overload
>>
>>56011413
>if you think a 32-bit ABI and a 32-bit ABI are the same
m8...
>>
>>56011413
>check out my new strawman tho
>>
>>56011413
>You're a fucking retard if you think a 32-bit ABI and a 64-bit ABI are the same
Those are different architectures, so that is irrelevant.
>>
>>56011436
>>56011429
>samefagging this hard
kys mememaster
>>
>>56011027
Linux is C because who the fuck wants to write an operating system in Assembly.
>inb4 Linux isn't an operating system, it's a kernel, etc.
>>
C++ tards, everyone: they don't even know the language they're shilling!
Top fucking cucks!
>>
>>56011442
>Those are different architectures, so that is irrelevant.
And C++98, 03 and 11 ARE COMPLETELY DIFFERENT SPECIFICATIONS you fucking idiot.

Use -std=c++98 if you want the 98 version of the ABI.
>>
>>56011446
>kys
You might as well kill yourself and fuck off back to YouTube.
>>
>>56011471
>"no u"
>>
>>56011464
>Use -std=c++98 if you want the 98 version of the ABI.
That's not how it works.
>>
>>56011489
Except it is.

GCC developers don't go around and randomly break the ABI. The exception is for C++0x/C++11, where the committee changed something and they had to break the 0x/11 ABI (but you can still get the old one using the macro thingy posted earlier ITT).
>>
>>56011464
>No stable ABI
>b-but it's stable
>No, here's proof
>b-but they are different languages so it doesn't count
>How about compilers from different vendors, do they agree on the same ABI for a given version of the """spec"""?
>b-but why would you use different compilers?
every time
>>
>>56011511
>discussing C / C++
>not understanding what "implementation defined" is
Read the standard faggot.
>>
>>56011509
They don't have an ABI for each version of the standard. They are forced to change the ABI when the standard is updated, but old code will still use the newer ABI.
>>
>>56011511
Not him, but no one said they are different languages.
>>
>>56011520
>it doesn't matter anyway tho
EVERY TIEM!
>>
>>56011521
You can still use whatever version of the ABI you want, using macros. That's how GCC has worked for ages. Even for C.
>>
>>56011524
>no one said they are different languages
sure, sure
>>
>>56011531

>C99 defines VLAs as mandatory
>breaks literally every existing ABI
>C committee has to change VLAs to "optional" exactly because of this in C11
>no complaints

>C++11 is a huge modernization of C++
>breaks ABI
>/g/ complains about ABI being broken

every tiem
>>
>>56011537
Great. You have to tag all of the declarations with what ABI you want to use, in the most non-standard and importable way possible.
How fun.
>>
>>56011567
>VLA mandatory
>breaks literally every existing ABI
nope, try again
>>
>>56011567
How the fuck does VLAs break an ABI?
Do you even know how VLAs are implemented and what an ABI even is?
>>
>>56011567
>I don't know what ABI means
that why you got told in the first place
>>
>>55999615

Python then C.

I actually recommend in that order and do some of the free online data science courses in both languages.

That way you can learn the ins and outs of certain data objects in python then deeper in C.

Plus you can write shit in python put the computation into compiled C and the python can call the C natively.
>>
>>56011594
It did
>>
>>56011626
>I'm literally retarded!
>>
>>56011626
An ABI deals with integer sizes and alignment, how arguments are passed into functions, what symbol you actually jump to when calling functions, and how syscalls work.
VLAs has literally no affect on any of those.
>>
>>56011645
why bother, he won't understand half of those words
>>
>>56011616
>look everyone, I'm strawmanning

>>56011639
>look everyone, I learned how to use greentext

>>56011614
>>56011594
>>56011645

https://gcc.gnu.org/ml/gcc/2002-04/msg00020.html

TOLD status
[ ] not told
[x] fucking told
>>
>>56011669
That is about a GNU extension, not standard C, you fuckface.
>>
>>55999615
If you have 6 years experience in C++ then this is no place for you to come for advice.
>>
>>56011669
>This is a problem only for programs using the GCC dynamic arrays extension
>dynamic arrays
>not VLA
raped again and again!
>>
>>56000958
Careful not to slip on all that shit on the street, Pajeet.
>>
>>56011695
Read the email, it's talking about mandatory C99 VLA and how it isn't possible on Itanium.
>>
>>56011722
>>56011695
See >>56011731

>didn't even read the entire thing
>samefagging
>>
>>56011731
>talking about mandatory C99 VLA
>This is a problem only for programs using the GCC dynamic arrays extension
nope, that's not VLA
>>
>>56011763
>doesn't know how gcc implements VLA
I get it. It's "only a compiler error" when it's C, but when it's C++ it's the language it self and not the compiler. Cool story
>>
>>56011784
You can't bring up non-standard shit when discussing these sorts of things.
Those has nothing to do with the language.
>>
>>56011731
>how it isn't possible on Itanium.
Jesus christ, is this your comprehension level? How fucking retarded can you be to fail to understand simple english? They're talking about a gcc extension that allows variable sized aggregates that behave in such a way that it can't be easily implemented for ia64. They're NOT talking about VLA, because VLA don't change anything about the ABI: arrays passed as arguments to functions are converted to pointers regardless if they're normal arrays or VLAs.
It's fucking spelled right there in the mail:
"Since an array as parameter
decays to a pointer in C, there appears to be no variable sized aggregate
parameter problem in C99."
Really, are you actually mentally ill?
>>
>>56011784
>"only a compiler error" when it's C
C doesn't have dynamic arrays, you don't know what the fuck you're talking about in the first place
>when it's C++ it's the language
you don't have a clue about C++ anyway, so why keep talking?
>>
>>56011802
>>56011805
>>56011832
Butt hurt C fags got rekt
>>
>>55999615
>Do some of you prefer C++ over C?
They serve different purposes.
C is a more simple language and there is compilers for almost any architecture, so C is very good for embedded programming.
C++ has a lot more tools, which makes it usable for desktop applications.
>What are your reasons?
Lets compare a simple example: strings.
A string in C is a pointer to the first char and the string will end with a zero.
It could also be an array where you know the maximum size of the string.

This is good for embedded systems as having a character limit isn't a bad thing, and the environment in which you run the application is static.

In C++, a string is a class which is a vector of characters.
This means you can store things like the length of the string, you can make the string bigger and smaller dynamically, you don't have to rely on zero termination.
And since it is a class, you have operator overloads so concatenating a string can be done +=, cout automatically knows how to format the string, etc.

Now something like strings is implemented in a lot of libraries, so C can use a sane string format and C++ has to switch between the different formats, depending on the library.

>In this moment I fail to see any good reason to actually use C++14/17 over C11.
I don't think 17 is fully implemented everywhere, so that would be a reason not to use 17 over 14, but I don't know why you would use 11 over 14.
If you like specifics, I am a big fan of the
[[deprecated]]
tag, which generates warnings.
>>
>>56000958
>it's full of students and NEETs who think anything vaguely difficult makes them 1337


Sums up a lot of attitudes in tech', really. You get a mix of people who have a vested interest in keeping things hard because it gives them job security, and people who have that "abused as a child" mentality where they had things difficult while learning this shit, so everyone should.
>>
>>56011846
>got so told I'm bleeding from the ass
>>
>>56011910
>continuing after being proved wrong
>engaging in mental gymnastics to justify arbitrary reasons for why something applies to C++ but not C
>being this emotionally invested in not liking a particular programming language
Literal autism
>>
>>56011937
>literally raped to death
>>
>>55999615
>Do some of you prefer C++ over C?
Obviously.
>What are your reasons?
I don't have any, I don't prefer C++.
>>
>>56011942
>using literally when you mean figuratively
Retard detected
>>
>>56011985
figuratively fuck yourself
>>
rust is essentially a perfect version of c++

even though it's so new, library support is pretty good.

wrapping a C library yourself is very simple too
>>
>>56012036
Replace Rust with D
>>
STOP TEACHING C GODDAMIT

https://youtu.be/YnWhqhNdYyk
>>
>>56011625
>the free online data science courses in both languages

What is a good free online data science course for C ?
>>
>>56010980
>As a game dev
>I'm currently working on fractal renderer
http://nuclear.mutantstargoat.com/articles/sdr_fract/

Hope I didn't invalidate too much work.
>>
>>56000607
>C++
>maintained by a competent team
The C++ committee is run by autists that cream their pants over abstract constructs and how they can be used to further complicate the language. Just listen to any one of their conferences, it's ridiculous.
>>
>>56010980
>Rust and C are about the same when it comes to speed.
Rust is several orders of magnitude slower in most operations, thanks to safety checks.
>>
>>56012143
confirmed for massive retard.

all rust safety checks are done at compile time
>>
>>56012159
Doesn't it to bounds checking?
>>
>>56012159
>>56012168
It also has "drop flags" which are runtime checks to see whether a destructor has been run. It records these for every object.
>>
>>56008449
>Also: you always know in C what the fuck does
> x = i * j mean.
#define i (int)
>>
File: frac.png (569KB, 1920x1080px)
frac.png
569KB, 1920x1080px
>>56012036
Well, Rust still lack inherence and/or Trait members, struct alignment and function overloading.
I's still my favorite language, but these features are clearly missing and often requested(especially by Servo devs).
I would love to see some static initialization as well, but I understand this is against the main idea and lazy_static does its work fine.

>>56012048
I never used D, what are the main differences?

>>56012116
This is way simpler than the project I'm working on.
I wrote 128 bit fixed point structs for operations, they give me way more accuracy than floats(23 bits of exponent). It's not worthy to run it on GPU since it's way slower than CPU in fixed point and I can't vectorize it, but at least I implemented all operations on it using asm so it's not that bad.
Also I basically finished sole rendering, now I'm just optimizing it(the project you provided doesn't have any of them) and adding interface.

>>56012143
>>56012168
Nope, nearly every safety check is compile time.
Run time checks are present only on Debug builds.
http://benchmarksgame.alioth.debian.org/u64q/performance.php?test=mandelbrot

>>56012197
Not true. It's used only when object implements Drop trait and it's impossible for compiler to predict where will they drop at compile time.
>>
>>56012313
So rust is AS unsafe as C? Why use it then?
>>
>>56012313
>I never used D, what are the main differences?
D has inheritance, uses garbage collection instead of refcounting, and keeps most C syntax instead of inventing its own crazy bullshit. Otherwise it's very similar to Rust.
>>
File: 1448873919441.png (3KB, 344x341px) Image search: [Google]
1448873919441.png
3KB, 344x341px
>>56012351
How have you come to that conclusion?
>>
>>56012197
>"drop flags"
fuckin dropped!
>>
>>56012386
If you can disable runtime safety checks, they are meaningless in the first place.
>>
>>56012386
No bounds check = vulnerable to buffer overflow = security issue
>>
>>56012168

10
down vote
accepted
Because checking indices at compile time is not feasible. Reasoning about the possible values of arbitrary variables is somewhere between hard and impossible even for small programs. Nobody wants to have to:

formally prove that the index can't be out of bounds, and
encode that proof into the type system
... for every single slice/Vec/etc. access. Because that's what you'd have to do to perform bounds checks at compile time. You essentially need dependent typing. Aside from possibly making type checking undecidable (and getting a program to type check vastly harder), type inference becomes impossible in general (and far more restricted in the best case), types get much more complicated and wordy, and the complexity of the language increases significantly. That indices are in bounds can only be proven without significant additional programmer effort in very simple circumstances.

Furthermore, there is little incentive to get rid of bounds checks. Lifetimes pull their weight by almost entirely eliminating the need for garbage collection --- which is a huge, invasive feature with unpredictable throughput, space and latency implications. Run-time bounds checking in the other hand is very non-invasive, has a small and well-known overhead, and can be selectively turned off in performance-critical sections even if the entire rest of the program uses it liberally.
>>
>>56012402
>>56012426
They are used to detect what gone wrong while debugging/using non-release build.
But you've missed that Rust has solid compile time safety checks. This is the most amazing feature. There is really few runtime checks to begin with, it's for integer overflowing or reading out of bounds. All the other checks are happening on the compile time: validating pointers/references, reading uninitialized memory, shared mutual access, data racing, memory/reseource leaks, type checks and all other things. It's way more secure than C or C++.
Of course you can read outside of bounds, but you would need to disable the checks and only use primitive types. It's much easier and safer to use standard containers, iterators, etc. which have bound checks build-in when needed anyway.
>>
>>56012458
So what are you saying? It doesn't do bounds checking because it's too hard?

I knew Rust was fucking snake oil.
>>
>>56012516
>using containers
Might as well use C++ then if that's your argument
>>
>>56012539
Nearly every modern high-level language has some containers, so I might as well use PHP.
>>
>>56012570
Not with the speed C++ have
>>
>>56012570
The whole point of Rust is to be low-level and write everything from scratch like in C, but safer

If it can't do that, why bother with it?
>>
>>56012530
let mut arr = [1, 2, 3];
println!("{}", arr[3]);
//
Compiling specialization v0.1.0
src/main.rs:41:21: 41:27 warning: this expression will panic at run-time
src/main.rs:41 println!("{}", arr[3]);
^~~~~~

//-------
let mut vec = vec![1, 2, 3];
println!("{}", vec[3]);
vec = vec![1, 2, 3, 4];
println!("{}", vec[3]);

// no warning


do you understand now?
>>
>>56012588
>low-level
>but safer
pick one
>>
>>56012588
fn main() {
for x in 1..100 {
match (x % 3, x % 5) {
(0, 0) => println!("FizzBuzz"),
(0, _) => println!("Fizz"),
(_, 0) => println!("Buzz"),
_ => println!("{}", x)
}
}
}


can you do this in C?
this is all zero cost abstractions and compile time checks, btw
>>
>>56012530
>reading comprehension
Static bound checks are too hard, no one does them.
Runtime bound checks doesn't slow much and can be disabled.

>>56012586
Rust has the same speed.

>>56012588
You can do it and it surely will be safer than in C because Rust has all the static checks.
There is also no point in writing everything from scratch(but you can), just because functionality of Vec and Iter etc. is so basic you would probably need to implement them anyway. They give you lot's of functionality and there is no reason to not use them anyway.
>>
>>56012616
Now do
println!("{}", arr[i])


Where the value if I is from standard in.
>>
>>56012651
thanks other based rust-bro for trying to educate these fucks
>>
>>56012651
>You can do it and it surely will be safer than in C because Rust has all the static checks
So does any modern C linter. Your argument is invalid.
>>
>>56012644
>>56012693
>>
>>56012693
Which C does this?
fn main(){
let refa;
{
let a = 5;
refa = &a;
}
println!("{}", refa);
}


rust.rs:5:17: 5:18 error: `a` does not live long enough
rust.rs:5 refa = &a;
^
rust.rs:2:14: 8:2 note: reference must be valid for the block suffix following statement 0 at 2:13...
rust.rs:2 let refa;
^
rust.rs:4:19: 6:6 note: ...but borrowed value is only valid for the block suffix following statement 0 at 4:18
rust.rs:4 let a = 5;
^
error: aborting due to previous error
>>
>>56012670
yes, just like the second example, that is infeasible to prove at compile time.

remember that not all programs are fizzbuzz-size like you usually write
>>
You can create OOP in C (ex: GTK+) without all the bloat and overhead that C++ brings, I've used it to make music players, operating systems, all kinds of networking tools, and even an OpenGL game on it. C for me is the best that exists
>>
>>56012807
can you create traits in C?
>>
>>56004495
https://github.com/id-Software/Quake-III-Arena
>>
>>56000769
This.

Also, OP answered himself with the very Venn diagram he posted.
>>
>>56000854
>I can't use C++ libraries from C or vice versa-- how does, /g/?
You would not ask such questions if you were ready to tackle such problems. Go and educate yourself.
>>
>>56012767
Pic related

>>56012644
>can you do this in C?
You can do this in C++, which is the discussion of this thread, isn't it?
>>
>>56012644
>zero cost abstractions
yeah, right
>>
>>56012904
But that's returning reference of local variables, lifetime checks are something much larger.
For example it doesn't allow you to use reference to vector element after you add something to it(it can realloc) or send reference to other thread(first one can panic) and many other things. C linters just checks for common, trivial problems while rust guarantees there will be no bug of these kinds, even if the code is not trival.
>>
>>56012807
>GTK+
>without all the bloat and overhead
you sound retarded
>>
>>56012904
#include <iostream>

int main()
{
int *aref;

{

int x = 5;
aref = &x;

// x dies here
}

// currently aref is pointing to an undefined location in memory
}


~/Documents $ g++ main.cpp -Wall
-- no warnings --
>>
>>56012974
>can't tell the difference between saying GTK is unbloated and "you can create unbloated OOP code in C" said separately
at least I only sound retarded.
>>
>>56012904
>You can do this in C++, which is the discussion of this thread, isn't it?

look at who you linked to.

you cannot do that in c++
>>
>>56012997
>yes, I'm literally retarded
we know
>>
>>56013023
well at least you can admit to it. don't blame yourself, you didn't make your mom smoke crack on your own
>>
>>56013011
>you cannot do that in c++
>what are templates
>what are lambdas and multiple dispatch

You're a retard
>>
>>56012997
>you can create unbloated OOP code in C
example pls
>inb4 gtk
>>
>>56013043
>let there be no doubt I'm retarded
there isn't
>>
>>56013049
show me the code and let's compare ;)
>>
>>56013081
>still trying
it's ok to get roasted, chill out man
>>
>>56013049
>multiple dispatch
something C++ doesn't have
>>
>>56013083
Give me some minutes, it's been 2 years since I programmed C++ last. If this thread dies in the meantime (close to post limit now?), make a new one and I'll post there
>>
>>56013092
>it's ok that I got told and rekt
sure thing anon :^)
>>
>>56013100
https://en.wikipedia.org/wiki/Visitor_pattern
>>
>>56013123
whatever helps your butt feel better :^)
>>
>>56013134
any language can fake it
>>
I love C but outside of embedded or low-level system programming there's not much point. Maybe I'm tired and overworked but I don't want to implement my own data structures and associated methods, I just want to get my shit done and get paid.
>>
>>56013148
>my ass hurts
we all know
>>
>>56013178
python4lyfe
>>
>>56013194
don't worry, maybe you'll have better luck in banter next time :^)
>>
>>56012990
But this code is obviously wrong. No professional would ever write that, C programmers are a lot smarter than you give them credit for.
>>
>>56000958
>Java is the best general purpose language
"No"

>>56004963
He is right, fag.
>>
>>56013216
i propose we disable all compiler errors. i am smart enough to never make a mistake
>>
>>56013212
Never used Python. C++ at the moment and doing some Swift/iOS shit on the side.
>>
>>56010393
>What percentage of all written software are we talking here?
Almost any code that uses large chunks of data, any game programming, almost all complex simulations. I mean it's easier to find examples where it doesn't use matrices.
t. mathematician
>>
>>56012990
>>56013216
>>56013242
It gives a warning with clang
>>
>>56013387
Yeah? How about now?

void JUST(int **c)
{
int x = 5;
*c = &x;
}

int main(int argc, char **argv)
{
int *c;
JUST(&c);
*c = 4; /* OH NO */
return 1;
}
>>
>>56013276
>it's easier to find examples where it doesn't use matrices.
of course, you can just say "almost all software ever written"
>>
>>56013417
literally nothing wrong with this
>>
>>56010393
not iostreams, but just any streams

NetworkPacket packet;
packet << 1 << 2 << 3;
packet << myDataType;

tell me that isnt useful?
>>
>>56013515
>tell me that isnt useful?
ok: it isn't
>>
>>56013417
http://frama-c.com/value.html
>>
>>56013542
i suppose you're kind of right...
packet.add(1, 2, 3);
packet.add(myDataType);

you could do something like this ^

but im not sure you could do something like this:

packet.add(1, 2, "asdf, myDataType);
>>
>>56013577
>Known restrictions

>Only the simplest uses of dynamic allocation are handled precisely.
>Only sequential code can be analysed at this time.

kys
>>
>>56013581
>im not sure you could
sure you can; you forget there's an entire turing complete language available at compile time
>>
>>56013613
i don't know how to do this.
can you have parameter packs of parameter packs in any order of any type?
dont think something like

pack(1, 2, 'a');
pack('a', 2, 'a');


would be possible
>>
>>55999678
meme/10
>>
File: 079567490005.jpg (107KB, 900x900px) Image search: [Google]
079567490005.jpg
107KB, 900x900px
>>55999678
remove rust
>>
>>55999615
How can you use c++ for six years and not know anything about c? Off yourself faggot
>>
>>56001907
>OOP is fundamentally flawed. It leads to shared state and overcomplicated and over-engineered designs.
Any example of the overcomplicated design being forced?
>>
File: cibuki.jpg (54KB, 500x375px) Image search: [Google]
cibuki.jpg
54KB, 500x375px
>>55999615
>>
>>56014245
:3
>>
>>56001753
>There's a huge difference between using functional programming where it makes sense, and using imperative constructs other places, than to use only one single paradigm and refuse even to use basic I/O because it has side effects.
wisdom
>>
>>55999615
> Do some of you prefer C++ over C?

I do. There are several C++ features that add no runtime overhead, but they help me organize the code better.

For example, automatic execution of constructors and destructors helps ensure that things get properly initialized and cleaned up. You could do it in C, of course, but then you would need the discipline to make sure you call the constructor/destructor every time. With C++, it happens automatically. That can save me some time, and makes it less likely I will have errors.

I work on larger pieces of code, and I have found the C++ namespace feature useful in preventing name clashes. This can be particularly nice when you have to integrate code written by another engineer, and don't want to deal with accidental name collisions. Again, it's a C++ feature that introduces no overhead. You could do the same thing in C by putting a common prefix on everything, but that's more work.

Also, I find that strings in C++ are easier to use in a way that's guaranteed to be 100% correct and robust. In C, you have functions like strcpy() and so forth that require discipline and thought to use correctly. In C++, you don't have to think as much about string implementation issues (like allocating space), so it's more likely to be completely robust. However, the price you pay is that the code is slower than if you had written it in C. So C++ strings are better for higher-level code where you don't have to worry about speed.

Basically, I recommend using C++ features sparingly. Anything complicated like SEH (structured exception handling), you definitely want to look at it with a very skeptical eye before using it at all. But if the C++ feature is just a more convenient way of expressing something you could have done in C, then you can consider using it.
>>
>>56012990
>currently aref is pointing to an undefined location in memory

No reasonable compiler would insert a deallocation of x at the point where you have the comment "x dies here". That would make the code both larger and slower, which would be a lose/lose situation.

As a practical matter, x and aref will both be dellocated at the end of the function.

That's not to say that the code you posted is good programming practice. But it's a good idea to learn what compilers actually do in cases like that.

To see what's going on with the variables, just compile with g++ -S main.cpp and look at the assembly code in the main.s file.
>>
>>55999615
red
>>
>>56002049
Scala is based though.
>>
>>56014982
Scala is hot garbage and a meme and you know it.
>>
>>56014901
>No reasonable compiler would insert a deallocation of x at the point where you have the comment "x dies here".
You're saying that the compiler won't pop a stack frame, and you're technically correct. What might happen instead is that the compiler could reuse the same location in memory for a new variable that comes into scope later in the same function. The point being, if a variable goes out of scope, it's fair game for whatever the compiler wants to do with the memory it occupied.
>>
>>56004235
>Java is the weird middle ground of all programming language concepts all merged
Not even remotely. In fact, that's so wrong that it's actually an assault on the truth.
>>
File: 1468839104430.png (73KB, 2048x1024px) Image search: [Google]
1468839104430.png
73KB, 2048x1024px
>>55999678
>>
>>55999615
They're almost the same really. Anything you would do in C you can in C++, which is why I prefer C++.
>>
File: 1451240808065.jpg (419KB, 1200x1000px)
1451240808065.jpg
419KB, 1200x1000px
>>56015165
>>
>>56015165
i dont understand how mozilla's employees' personal lives affect the programming language.

if you take a look over at github, the extremely competent main developers of rust aren't sjws, and there's no "slave/master" type of bullshit going on
>>
>>56000958

This.

C++ has its purpose, but for some stuff it's just insane to use C++.

Java is a langauge nobody really likes, but you can use it in so many fields and plattforms, Science, Web, Android, embedded..

It's everywhere.
>>
>>56015442
Their SJW mentality is baked into the language. The obsession over safety should have tipped you off to that.
>>
>>56015008
No it isn't. Has both functional paradigms, and imperative, JVM to boot.

I'm just not part of your /g/ autist army.
>>
>>56001076

I agree with these, but I'll add a few of my own.

1) Namespaces
2) Function overloading
3) Boost
>>
Guys, if I have to use my brain to learn new paradigms to use a language, that means the language is convoluted.

It HAS NOTHING TO DO WITH ME AS AN INDIVIDUAL BEING LAZY AND DIM WITTED. It's entirely the language's, and the entire community around the language's fault, because I am a god.

My favorite programming language is Blub, btw.
Thread posts: 307
Thread images: 11


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.