Question:
is there a high level programming language that supports pointers and manual memory management?
Wolfman
2011-07-08 15:43:02 UTC
Hi i have worked with java,C#,C,C++, and,Delphi and found merits to each one i did like the ability to control memory management in C and C++ but their cryptic syntax and having to write alot to accomplish a little was inconvenient to me, as for Delphi it had most of what i needed except the complete lack of documentation i mean its really hard to find online docs for its classes and methods something like the java docs for example, i like C# because its high level and has many built in libraries in the .NET framework that facilitate alot but i dont like the idea of the Garbage collector controlling my heap and also its support for pointers is immature and incomplete, so i need an answer to my main question and if yes please redirect me to website that contains the compile or a full IDE if possible, i appreciate any help you can offer :)
Four answers:
Ratchetr
2011-07-08 16:40:14 UTC
You obviously have not spent enough long nights/weekends debugging memory leaks or memory corruption bugs ;-)



I programmed in C and C++ for well over a decade. Now I use C#. The very last thing I miss (with the possible exception of header files) is the need to do my own memory management. Why would you want that???



In my first real C# project, I did use pointers. I was working with low level, binary formatted data packets, and pointers seemed like the natural way to do it at the time. But I haven't used them since, I've never had the need. And I really didn't need them then. A memory stream would have worked. I just didn't have enough C# experience yet.



I love C# because it lets me concentrate on the problem I am trying to solve, not on problems (like memory management/object lifecycle stuff) that the tool can do for me. So I'm more productive. A LOT more productive. And my code has a LOT fewer bugs, because I never forget to free something (don't have to). And I never run off the end of a buffer with a pointer (can't, if you don't use pointers).



The only language I can think of that does what you want would be Managed C++. But...yuck....Managed C++ is just plain ugly. I can't imagine why anyone would want to use it except as a bridge between existing C++ code and C# (or other .NET language). Managed C++ is .NET's ugly stepchild.



Just because C# manages memory for you doesn't mean that you can be oblivious to all memory management issues. You need to know when you need to implement or call Dispose, for example. You need to know that you can't just accumulate referenced objects forever. I worked with a contractor once who supposedly knew what he was doing. He wrote code that, every 10 seconds, added new buttons to a form. Without removing any buttons from the form. That wasn't what he was supposed to be doing. He was supposed to be updating the text on the existing buttons if something had changed in the last 10 seconds. But he kept adding buttons. Eventually, the program would grind to a halt because of all those buttons. When I asked him what he was thinking...he said: I thought C# would take care of that. The garbage collector should fix it for me. No. It can't. All those buttons are on the form. They aren't visible, you put other buttons on top of them. But they are still there, still referenced, still needed. He didn't get why. He didn't last long. So...see...you still have to think about memory management in C#, just at a higher level than you do in C++.



ETA:

>> " developing an app that loads entire tables from a database onto the screen and then it doesnt need the data cramming up 2GB of memory anymore"



There's your problem right there. You can't load 2GB of data into memory in any programming language on any modern server without hitting huge performance bottlenecks. Why on Gods green earth would you load 2G of data into memory to display it on the screen??? Do you have a REALLY REALLY BIG screen? My screen can't hold anywhere close to 2GB of pixels. Can yours? Can anyone's?



Don't blame the programming language. Blame your own design. You can't bring in 2G of data from a database and expect it to work well. That's why we do paging. Humans can't digest 2GB of data, so why clutter up memory with it in the first place?



Dealing with really large datasets is hard, in any language. But trying to pull 2GB of data out of the server is just...INSANE?



What is it you are really trying to do? And why do you need 2G of memory to do it?
husoski
2011-07-08 17:12:40 UTC
I used Delphi a lot back when it was still Turbo Pascal. I'm surprised that you think C means "typing a lot" by comparison, but I guess you get a lot of reuse from the class library. That was still pretty immature back then, and not too many functions applied to Fourier-transform spectroscopy. I wonder if it's better now? :^) Anyway, just on the grounds of typing begin/end all over the place rather than { }, made C seem like typing less. C arrays took some getting used to, though.



Lemme see, is it a high-level low-level language you want, or a low-level high-level language? The high-level folks don't seem to like pointers much, and the folks that use pointers a lot don't seem to want the overhead (like garbage collect) that comes with high-level languages. Pointers seem to be going the way of "goto".



One option is to join a users group for Delphi and work around the limited Google-able resources.



Another is C++, only with a decent framework, like Qt. The Boost libraries add a bunch while you are waiting for C++ to standardize them. Around a dozen of them have been becalmed in the "C++0x" version that was supposed to be out two years ago. The recommendations date to a 2003 technical report.



Maybe you could take a look at D. It has a simpler object model than C++, single-inheritance with interfaces and garbage-collected by default (much like Java). However, it does let you use custom allocators, much like C++ does, so you don't have to use garbage-collected memory for all objects.



I haven't seriously looked at it yet, so I don't know the pluses and minuses, but it's up to 2.0 now and I may soon. There's a reference implementation from the creators at Digital Mars, a Gnu D compiler, plus a couple of other compilers. The Gnu version means that IDEs like Code::Blocks will support D as well as C++. I know CB has a D project type in the standard distribution.



More info at: http://www.digitalmars.com/



Also see Qt: http://qt.nokia.com/products/



And Boost: http://www.boost.org/
2016-10-15 11:05:53 UTC
assistance are also utilized in c programming language. so no. yet another issues that make c++ extra suitable than C more suitable typing -the kind device in C++ is more suitable than in C. This prevents many user-friendly programming blunders - coupled with the subsequent major characteristic, the more suitable kind device even manages now to not be an inconvenience. Parameterized sorts-The template key-word facilitates the programmer to position in writing established (kind-agnostic) implementations of algorithms. the version being, that for instance sorting an array of integers, ought to, contained in the C case, require a function call for each and each evaluate, while the C++ implementation ought to enable the compiler to inline the integer evaluation calls, because the honestly kind user-friendly is instantiated at collect time, right away by technique of the compiler, with the perfect sorts inserted contained in the template arguments. a higher widely used library C++ facilitates the finished use of the C widely used library. it truly is major for sure, because the C widely used library is a pragmatic source even as writing genuine international courses. in spite of the indisputable fact that, C++ contains the classic Template Library. The STL contains various functional templates, like the kind user-friendly above. It contains functional user-friendly archives platforms which incorporates lists, maps, gadgets, etc. like the kind user-friendly, the different STL workouts and archives platforms are "adapted" to the certain desires the programmer has - each and each of the programmer has to do is fill contained in the varieties. for sure, the STL isn't any silver bullet - in spite of the indisputable fact that it does grant an excellent help very regularly, even as fixing well-known issues. How regularly have you ever carried out a itemizing in C? How regularly ought to an RB-tree were a extra suitable answer, if in simple terms you had had the time to do it? With the STL you don't need to make such compromises - use the tree if it really is a extra suitable in good structure, it truly is as user-friendly as utilizing the record.
?
2011-07-08 16:08:51 UTC
Better learn C++. Pointers and manual memory management are extremely complicated beasts. ANY language that lets you do this is going to risk memory errors etc and is going to be convoluted and unclear. Trying to get a language that fully supports pointers, allows manual memory heaps AND is easy to use is likely impossible.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...