Is const necessary

Do you think the const qualifier is a must in modern programming languages?

Attached: 1501116901692.png (225x225, 4K)

const correctness should be taught to children

It's kind of a stupid concept. Nothing is actually permanent. You can always change data once it's in memory. If there's a 4, the language should just let you get a pointer to that and change it to a 5.

your existence is effectively but a fart in the wind. why then do you need a social security number?

I bet you dont encapsulation is also a bad idea
The point of a const is "we need this bit of data but you really shouldnt be changing it or something will break"

It depends on the programming style that you use. You could eliminate its use with encapsulation where the class is only initialised on the constructor, and then you only provide accessors that either copy by value or return a pointer/reference to another type/class that itself has only accessors (recursively down the references in-memory graph).

In other situations its useful but I think its overthought by people at times. Passing const parameters to functions seems sensible but enforcing const-correctness across all methods of a class seems a bit odd at times.

I am the master of my own computer and nothing happens on it except by my command. I will damn well change a piece of memory if I feel like it.

sooooo ... you never ship software/code and are the only user of your libraries/code?

If the OS puts all const data in read-only pages you will get a segmentation fault when attempting to write to read-only memory.

t. has never written anything beyond fizzbuzz

No, modern programming languages should have values immutable by default and have a mutability qualifier instead.

t. schizo bum that thinks he's talking to god.

yeah it is very much needed. Putting constrains on code you have written is always good so that it does not get misused. Maybe if that constant gets changed while the program is running it fucks up some loop IDK.

Now the real question is what languages are modern and even have you explicitly write the data type.

inferred types are still strict, my friend.

const guarantees that CPU doesn't have to write a things back to memory at
compiler can strip unnecessary calls, move things out of loop etc. if it has enough knowledge of side effects and const ensures no side effect for that data
immutability of data is a good knowledge for working with data in concurrent runtime without locks

high-level language should have this knowledge but not exposed it to the programmer (e.g. with immutable data structures)
low-level language benefits a lot from this (although const in C is worthless meme)

>js

Attached: Capture.png (130x141, 2K)

js doesn't have types, my friend
>b-b-b-but it does
no it doesn't. it has duck typing.

>nigger rigged data types

Segmentation fault (core dumped)

strong autism

it lets other people know the role of that variable or whether it should be changed, so pretty much just for the sake of being explicit.

only if you are an idiot

Attached: cjf.jpg (706x540, 61K)

Are you a rust programmer?

This, honestly.

op here, i should've probably asked a less vague question:
Should a modern programming language based on C have the const qualifier? That is, do we really need it? A compiler is perfectly capable of checking if a variable is ever modified in the length of a program. I do understand that you should offer a way as to guarantee that the user of an API doesn't change certain data but that should also be possible to guarantee by issuing errors/warnings through attributes.

for example:

[const : "error message here"]
int x = 100;

>modern programming language
>based on C
what

Well... touche.
Let's say similar to C, like Java, C# or D.