Originally posted by sinepgib
View Post
Announcement
Collapse
No announcement yet.
Google Engineers Lift The Lid On Carbon - A Hopeful Successor To C++
Collapse
X
-
Originally posted by darkonix View PostIt really depends at what problem are you looking at. For an individual programmer you may be very well be right but for the industry in general there are statistics that prove that around 70% of security issues are relate memory related.
Besides, UB most often causes memory errors AFAICT. "Oh, this NULL check is in the wrong place, let's erase it", boom, memory error triggered by UB. In fact, almost all memory errors I can think of are either UB or caused by it, with the exception of memory leaks? Accessing uninitialized memory: UB. Dereferencing NULL and freed pointers: UB. Double frees: UB. Out of bounds accesses: UB. Wrong pointer casting: UB. Maybe I'm wrong about it being most, but it surely a lot of it is.
- Likes 1
Comment
-
Originally posted by sinepgib View Post
Both problems are real, but OP states a decent understanding is good enough to catch the memory errors (which seems to not be true, by the cited statistics), while even then it's certainly not enough to be constantly wary of UB in unexpected places.
Besides, UB most often causes memory errors AFAICT. "Oh, this NULL check is in the wrong place, let's erase it", boom, memory error triggered by UB. In fact, almost all memory errors I can think of are either UB or caused by it, with the exception of memory leaks? Accessing uninitialized memory: UB. Dereferencing NULL and freed pointers: UB. Double frees: UB. Out of bounds accesses: UB. Wrong pointer casting: UB. Maybe I'm wrong about it being most, but it surely a lot of it is.
Thinking back I suspect that more than 90% of the bugs I had back in the day that caused the application to be unstable would have just been impossible to cause using Rust today. It would just not compile. Whatever one feels of the language that is a big advantage.
The other advantage I just recently realized is that the error message are incredible useful. For example I mistyped a variable name and in the error it suggested that there is another variable with a similar name (see screenshot attached). Note that this is the compiler, not an IDE. It really puts every other compiler I remember to shame. I'm not sure if Rust (or Carbon) are going to be successful in the future but it sure raises the bar for me of how informative a compiler should be to its users.
You do not have permission to view this gallery.
This gallery has 1 photos.
- Likes 2
Comment
-
Originally posted by darkonix View PostThe other advantage I just recently realized is that the error message are incredible useful. For example I mistyped a variable name and in the error it suggested that there is another variable with a similar name (see screenshot attached). Note that this is the compiler, not an IDE. It really puts every other compiler I remember to shame. I'm not sure if Rust (or Carbon) are going to be successful in the future but it sure raises the bar for me of how informative a compiler should be to its users.
- Likes 1
Comment
-
Originally posted by sinepgib View PostThose two claims pretty much contradict each other. If you need a lot of math background and formal education then it's not easier.
Originally posted by sinepgib View PostIt's like claiming advanced calculus is actually easier than basic arithmetic...
Originally posted by sinepgib View PostBesides, the problem with C is seldom manual memory management. That's a big pain point, and something you can screw up for your whole career, but the real issue is it's hard to always keep in mind all the foot guns in terms of undefined behavior all the time.
Originally posted by sinepgib View PostIn that sense, C and C++ are more or less equally bad, although at least some coding guidelines make it easier to not need the dangerous parts in C++.
And both Microsoft, Apple and Google had plenty of internal reports and surveys corroborating those figures which is why they all ended up developing alternative languages to try and reduce their C++ code-base as much as possible.
Originally posted by sinepgib View PostThat is irrelevant. The point of replacing a language is that you don't need to cover the other way around.
C++ is like the dinosaurs. It will die out in most use-cases, leaving a few gator-like living fossils libraries just like you can still find FORTRAN being used in ML to TK/TCL in python for GUIs. All the new stuff is written for DSLs. And in a DSL eco-system, C++ is just legacy.
- Likes 2
Comment
-
Originally posted by c117152 View PostThat's not how it works. Between different universities, C and python are used interchangeably while teaching the relevant math in primary courses. After 2-3 semesters, the people starting with C pick up C++, Java or Python to learn abstract programming concepts (OO, functional...) while the people who started with Python pick up C to learn low-level and system subjects. The gap is closed within another semester or two following. And when you look at total time spent on learning the language, you'll find C is simply not as demanding since it doesn't cover as much material by itself.
2. Considering what you see in college as representative of any real use of C is almost a joke. I don't know about your university, but in mine there's seldom any attention to how the language really works.
3. Length of material and ease are not the same thing. Maxwell's laws are rather short to express, and yet...
Originally posted by c117152 View PostNo it's not. You do need basic arithmetic to learn calculus but Python isn't required to learn C nor does C is required to learn Python.
Originally posted by c117152 View PostUndefined behavior and manual memory management are interchangeable since the "undefined" part is simply hardware and OS details that leak behind the data type abstractions when you don't bound check everything.
Originally posted by c117152 View PostC's defect rate coef. is 0.11 while python's is 0.08 and C++ is taking the lead in most defect inducing language there is at 0.18: https://cacm.acm.org/magazines/2017/...ithub/fulltext
And both Microsoft, Apple and Google had plenty of internal reports and surveys corroborating those figures which is why they all ended up developing alternative languages to try and reduce their C++ code-base as much as possible.
Originally posted by c117152 View PostThat's generalization since all of the modern programming languages aim at specific domains rather trying to do everything and failing like C++ did. Rust, for instance, aren't too focused on fleshing out many of the abstractions C++ facilitates which is why they're not quite ready for GUI development and the likes. Go too, doesn't intend to replace C in low level as you can plainly tell from their huge run-time and GC dependent stdlib and are only expanding their coverage towards some other use cases.
Originally posted by c117152 View PostC++ is like the dinosaurs. It will die out in most use-cases, leaving a few gator-like living fossils libraries just like you can still find FORTRAN being used in ML to TK/TCL in python for GUIs. All the new stuff is written for DSLs. And in a DSL eco-system, C++ is just legacy.
Comment
-
Originally posted by Ironmask View Post
I'm starting to think you're furiously enraged at Rust because you're refusing to sit down and learn how it works.
Comment
Comment