Show newer

@namark A good example of this at play is actually the Aparapi app I wrote. It started as relatively pure Java, then the parts that made more sense as C were replace with JNI (basically C code integrated into Java). In the end the app uses C when memory management or low level control has an advantage, and Java where it serves no advantage.

Since it was written well there was no issue of "untangling", the boundaries were always clearly defined. Doing the whole thing in C from the get go would have been the wrong move just as doing it all in Java was the wrong move...

right tool for the job.

@namark Largely it depends. In practice you will find often, though not always, a memory managed system , when done properly, will outperform something like C out of the box (as discussed) and only be marginally slower when compared to C done "right" (as best as possible for the problem. It often is the case that the additional time it takes to code C correctly, combined with the fact that mistakes can lead to bugs not possible in a memory managed system, can often make the extra effort of C an argument that simply isnt compelling.

Its also important to note that memory management in languages like C and some others is not a simple matter of completely ignoring the issue and you still have a great deal of control through use of various types of controls over memory, namely: hard, soft, phantom, and weak memory. All of which can be ignored or used to whatever extent you need to.

So long story short, unless you need a very marginal improvement in memory, or are doing something special with memory at a low level, you probably wont get anywhere near the level of improvement with C that justifies the added effort you'd need.

As I said already, its all about the right tool for the job. Any mentality that things one language or approach to memory management is always superior is ultimately going to put you in a bad spot and waste many hours that need not be wasted by trying to use the wrong tool for the job. C is often the right tool, it is also often the wrong tool. Situational awareness is important to be a good programmer IMO.

@namark Yea I understand your (incorrect) opinion. It is perfectly possible to write good clean code that isnt spaghetti code in Java as it is possible in most languages. Simply saying a thing doesnt make it so. That said its also possible to write spaghetti code in any language, including C.

Like I said anyone who thinks their language is the only one possible to write good code in no matter the scenario is already behind the 8 ball.

@namark I never claimed it was relevant directly to what you original meant. Its relevance is that both are "things people complain about in C's memory management", that is all.

I am also not presenting Java's memory system as good anymore than I am saying C's memory management system is good. Both are different tools for different purposes and if you think either is the "end all and be all" of what represents a good language, then you are wrong in either case.

Java's memory management means really good performance out of the box. C's memory management is much slower out of the box but with significantly more upfront effort its performance can match or even exceed that of Java's. Therefore both server a purpose depending on your needs.

@namark thats exactly what i said, java slates its memory, thus faster than calling malloc on a per-oobject basis in C (which is often how its done, despite not being the proper approach).

As I already stated early to get the performance of java's new operation one would have to pre-slate memory in C. Certainly doable but often not done due to the extra effort when you get that out of the box for free.

My point is, memory handling in C is more tedious to make performant for many often leading to the effort not being made at all.

@namark no we arent talking spagehti code, nothing to do with that. We are literally talking about a single operation, memory allocation.. Java's new vs C's malloc, and java's new is substantially faster out of the box compared to C's malloc.

@iron_bug

That doesnt remotely address what I specifically said now does it. I never said C cant be made to be as fast as Java. I said out of the box memory allocation in java is over 40x faster than C (using malloc), this is fact. Slkated memory allocation in C can get around this but is mor work for the coder, which is fine, and as such with additional work C can be as faster or faster than java.

@namark

@namark the ineffiencies in raw C are a legitimate problem and why, particularly when it comes to memory management, things like Java can be 40x faster or more out of the box.

Slated memory allocation in C is ultimately the way to go but since its not built-in a lot of programmers dont do it.

That said nothing stopping someone from coding up C properly and making sure they do exactly that. I just wish more coders did.

A picture of the very first car ever created/invented. It was made by founder of the Mercedes Benz car company.

@mc the casio on the left is wrong, and most calculators, the vast majority, would disagree with it.

@saxnot It takes a form that is particularly annoying.. Something like this:

"I dont think we should need licenses for guns because then the government can arbitrarily take away guns by use of a stringent qualification test".

"But the government requires licenses for cars, this is no different"

Despite where you may fall on the opinion of guns this sort of argument, a Tu quoque fallacy, is particularly annoying.

@saxnot The nice thing about stuff like this is **everything** has a name. But yea its super annoying.

What is your favorite kind of curd?

Which of the following logical fallacies do you find most frustrating to hear used?

Now request The Police - Every Move You Make

Remember . Big Brother is watching shouldn't you be watching him? :D

@djatropine444 I requested it and didnt realize the metaphore until half way through.

I just played "Rockwell - Somebody's watching me" on my Amazon Alexa... it felt appropriate :)

@louisrcouture if you like it then you will probably do better at it. But if there is one thing that is obvious its that 90%+ coders dont like it beyond finding their job easy for the amount of pay... in fact the vast majority of people dont like their job to the extent they would do it if they werent paid.

In the netherlands a lot of people work at supermarkets stocking shelfs or similar work. None of them like their job besides perhaps enjoying their co-workers and/or boss.

Show older
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.