Igor🇺🇦
They were not examples for alternatives. I was arguing the fact that C++'s "newest" features are kind of late for the time other languages provided them.
That's like saying "Haskell will always be behind, just look at their support for new features like pointers"
Nomid Íkorni-Sciurus
That's like saying "Haskell will always be behind, just look at their support for new features like pointers"
Pointers are not needed in Haskell specifically. It was an example of a language whose features overcome C++'s. You have pointers in NIM anyway. (but it is an example)
Nomid Íkorni-Sciurus
Nomid Íkorni-Sciurus
(and anyway pointers do exist in Haskell)
zZackz
Ok
Hamid
Hello
NXiss7
There are lots of fields in programming. C++ fits many, and mostly connected, necessary fields. But not everywhere. C++ is perfect as a "C with high level features", intermediate level language. But try writing a monile UI with that, well... good luck...
NXiss7
You can't use one languahe on every area, but you can use C++ in many many areas pretty well.
Anonymous
Message from @nurlybekovnt: How do I connect the #libpqxx library in the #CMakeLists file? There is a project where MySQL is used, I changed it to use PostgreSQL. First, I wrote a simple program using PostgreSQL, compiled it manually as " g++ main.cpp -std=c++17 -lpqxx -lpq". Then I changed the main project. But now I can't compile the project because I can't connect the libpqxx library to its CMakeLists. So I first created CMakeLists for the test program. In CMakeLists for a test project, if I add option "-m32"(to generate 32bit code), I get this error: "/usr/lib64/libpqxx.so: error adding symbols: File in wrong format collect2: error: ld returned 1 exit status", if you do not specify it, everything is cool. But I have to specify it, because the main project has it. Installed libpqxx as " sudo yum install libpcap-devel.x86_64", not found in the repository for i686. https://gist.github.com/nurlybekovnt/d8b699125773ea8e998d109c12463c53
Stanislav
it's illegal since C++11 )
András
It's ub
András
On the stack
Artöm
String itself is in static area. Local pointer to it is on stack
Artöm
On the stack
Pointer only
Надир
you forgot about find_path ...
Remade so, but still the same error, left modified version of CmakeLists on gist
András
Pointer only
Okay, I was mistaken
Nomid Íkorni-Sciurus
Rust?)
yeah, Rust as well
Nomid Íkorni-Sciurus
I know, and also use Dart for Flutter. But they are more like a "workaround", and that's why (with another reasons to, ofc) C/C++ called "native"
Nim and Rust have no such "workaround". Nim does have a very light runtime but it's only enabled when you're manipulating the AST at runtime.
Nomid Íkorni-Sciurus
There are lots of fields in programming. C++ fits many, and mostly connected, necessary fields. But not everywhere. C++ is perfect as a "C with high level features", intermediate level language. But try writing a monile UI with that, well... good luck...
Yeah, I agree about this. But there's to say that interoperability is a must nowadays. Dart, Nim, Rust, D, all of these do implement that. I'm pretty sure you could do the same things you do in C++ with these languages.
Nomid Íkorni-Sciurus
You can't use one languahe on every area, but you can use C++ in many many areas pretty well.
I would really love tell this to anybody writing javascript node applications thinking it's "systems programming"
NXiss7
Yeah, I agree about this. But there's to say that interoperability is a must nowadays. Dart, Nim, Rust, D, all of these do implement that. I'm pretty sure you could do the same things you do in C++ with these languages.
Bro, many of these languages doesn't even expose memory, they manage memory by themselves. Whatever, I don't want to argue about this anymore, you got my point, I got your point, we share a common point. 😄😄😄😁
NXiss7
Every language is translated into asm in the end, every language. That is the only language that CPU understands but it's really hard to read, write, use... That's why languages like C/C++ exists. C (compiler) directly compiles into asm code, then assembler assemles that file.
Francisco
You should definitely know how to read assembly, but not really write it
Khaleed
Yeah that's it but............
NXiss7
VM based languages like Java, C# use pseudo-asm (instruction sets) codes, when you write Java code it's conpiled to Java-asm instead of x86 asm. Then you install JRE and that translates Java-asm to native CPU asm.
Anonymous
👍
Francisco
I can read code in almost any programming language, and that doesn't mean I know how to write it
Mat
Where's the problem? You can be able to understand what every instruction in ASM do without knowing how to create a project in ASM
Igor🇺🇦
There is a difference between being able to generally understand the code from reading it and writing code. You can try yourself with small samples here https://godbolt.org/
Mat
I can read ASM, yep. I'm not able to create what I create with C++ or Scheme or Haskell or whatever with ASM
Francisco
Nope
Ajay
I've string s; s = function_that_returns_a_string(); I can't do string s = function_that_returns_a_string(); What is the cheapest way to store the returned string into s without temporary allocations and deallocations?
Francisco
Syscalls let you request stuff from the kernel itself. The asm instructions are executed in the CPU, not in the kernel (if that even makes sense). The kernel just makes sure your program is loaded in memory and pass through the CPU
Igor🇺🇦
Does anyone know the state of 2017 parallel algorithm in different compilers? What's the support, what's the overhead, when should they be considered? I've seen just a bunch of articles and videos from 2017/2018 about how little support there is.
Igor🇺🇦
I'm interested in "good practices" and performance considerations
Ибраги́м
/ban banning also available
NXiss7
No, does system calls when required
Artöm
You need to learn pls to write first abd read second. You wouldnt want to write web server in asm
Artöm
And no, only compiled languages are compiled (duh). Eg you cant compile python or js to asm
Artöm
If you do it explicitly or library function does it. Syscalls are to be avoided when possible
Artöm
You dont need it most of the time
Artöm
Im a student
Igor🇺🇦
I've string s; s = function_that_returns_a_string(); I can't do string s = function_that_returns_a_string(); What is the cheapest way to store the returned string into s without temporary allocations and deallocations?
Why can't you directly construct a string from the method return value? And anyway move assignment will be used here. It's usually faster than copy assignment.
Igor🇺🇦
MSVC and gcc have full parallel STL support, but gcc requires linking against Intel's TBB
I'm not talking about support in general. But something more in depth. Like performance characteristics, when it's useful to be considered and when it certainly isn't worth it. Some rule of thumbs when and what is the best way to use it.
Francisco
I'm not talking about support in general. But something more in depth. Like performance characteristics, when it's useful to be considered and when it certainly isn't worth it. Some rule of thumbs when and what is the best way to use it.
Too many questions that depend on the project itself. The tool is there for you to use it. Is it worthy using it? It depends. If you need more speed, you'll surely find yourself using it, but always measure and make decisions based on those measurements
MeNotMe
I have a life hack for Y'all So you know( i++) right? Replace it with (i -=- 1). Its symmetric and Beautiful😂😂😂😂
Igor🇺🇦
Too many questions that depend on the project itself. The tool is there for you to use it. Is it worthy using it? It depends. If you need more speed, you'll surely find yourself using it, but always measure and make decisions based on those measurements
There are always some rules of thumbs - like prefer vector to list. Is it always better - absolutely not, but in general it is. No one is measuring every line of their code, but there are some suggestions and considerations anyway. Do I need collection of hundreds or thousands or millions items to start thinking about it ? Does it work better on larger items or smaller? How does it depend on CPU?
Artöm
yes.
Then initialization should work. Show full code
Ajay
Then initialization should work. Show full code
string common_prefix_suffix(string &s, string &t){ int mx = prefix_function(t+"#"+s);//this just return an integer //string ret = s; //ret+= t.substr(mx,t.length()-mx); return s+t.substr(mx,t.length()-mx); //Isn't this temporary alloc ? } Later the returned value is stored in predeclared string variable.
Ajay
These 2 snippets are identical regarding allocation
I wrote the second snippet just to clear it out so that someone could have suggested me to make string s as an rvalue reference (string &&s = fun_call()).
Ajay
I mean I've a pre-declared string variable s and during return from the common_prefix_suffix function, temporaries are allocated and deallocated.
Ajay
No need
But doing string &&s, won't it prevent copying?
Artöm
Theres no copying
Artöm
Copy will be elided. Worst case is moving, whuch us cheap anyway
Ajay
string s; s = function_that_returns_string(); doesn't that cause copying?
Artöm
Thats move assignment
Ajay
Thats move assignment
so the s still points to the same string that is returned by the function?
Artöm
Read about move semantics, then about copy elision
Ajay
Read about move semantics, then about copy elision
but kindly answer the above question
manas
so the s still points to the same string that is returned by the function?
The compiler understands that the rvalue won't be needed, so it simply moves instead of copying
Artöm
so the s still points to the same string that is returned by the function?
In c++ copy is deep copy, move is shallow copy. For string moving is pointers (string data members aka fields) reassignment
Ajay
👍