Java vs C app performance - Gary explains

  Рет қаралды 474,924

Android Authority

Android Authority

Күн бұрын

Get 75% off our official Android Development Course run by Gary Sims himself: dgit.academy/75off
Read article: www.androidaut...
Java is the official language of Android, but you can also write apps in C or C++ using the NDK. But which language is faster on Android?
Talk about Android in our forums: www.androidauth...
Subscribe to our KZbin channel: www.youtube.com...
----------------------------------------------------
Stay connected to Android Authority:
- www.androidauth...
- google.com/+and...
- / androidauthority
- / androidauth
- / androidauthority
Follow the Team:
Josh Vergara: plus.google.co...
Joe Hindy: plus.google.co...
Lanh Nguyen: plus.google.co...
Jayce Broda: plus.google.co...
Gary Sims: plus.google.co...
John Velasco: plus.google.co...
Nirave Gondhia: plus.google.co...

Пікірлер: 996
@milasudril
@milasudril 7 жыл бұрын
You should benchmark traversing an array of structs. In C and C++, you can access data directly, but in Java, you cannot. Expect a 10 times slow down in Java due to cache misses.
@MrAlbinopapa
@MrAlbinopapa 7 жыл бұрын
Unchecked pointer arithmetic, iterators and indexing are all pretty close to one another to even care about. Biggest difference is indexing looks much nicer and is easier to keep track of ( cleaner code ).
@dansanger5340
@dansanger5340 7 жыл бұрын
Yes, the importance of this cannot be overstated. Because of the prefetcher, data locality trumps all. It's why in C/C++ you're almost always better off to use an array of data structures rather than a linked list of data structures, even when doing lots of inserts and deletes. The cache misses inherent in following pointers swamps everything, even doing thousands of copies. In Java, almost everything is a pointer, so you are continuously getting cache misses, and can't take advantage of data locality the same way you can in C/C++.
@G33KN3rd
@G33KN3rd 7 жыл бұрын
so every 1 nanosecond on C and C++ is 10 nanoseconds on java?
@11matt555
@11matt555 7 жыл бұрын
It seems to me like the only time you would want to use an array over a list when doing lots of inserts and deletes is if the inserts and deletes are almost always at or very near the end of the array, otherwise you'd have to be doing a lot of shifting around. Or does the prefetcher manage to overcome that penalty somehow?
@milasudril
@milasudril 7 жыл бұрын
True. But from my experience, inserts and deletes are most often at the very end of the array. Think stacks, and temporary string buffers used by a parser. BTW: this is a good guide to C++ containers: i.stack.imgur.com/G70oT.png. Mostly, I end up with std::vector, and then std::map (sorted dictionary). Then comes std::deque (BFS tree traversal). I almost never use std::list.
@RightToSelfDefense
@RightToSelfDefense 4 жыл бұрын
in Gary's comparison between C and Java, he was only comparing between the relative performance between the two. However, he did not compare the relative size of programs in memory. The foot print. And C has a much much smaller footprint than Java. And for some embedded systems memory footprint is a big factor, not just performance. That is why some embedded developers are sticking with C rather that migrating to Java.
@danielrazulay
@danielrazulay 3 жыл бұрын
Yeah, and it's really easy to optimize c by looking at what the compiler poops out then fixing the code. Java not so much.
@kassymakhmetbek5848
@kassymakhmetbek5848 4 жыл бұрын
Is it fair to estimate performance only by running time? I think memory usage should have been shown as well.
@wtfpwnz0red
@wtfpwnz0red 4 жыл бұрын
Yeah, overhead is a big factor. Requiring a full virtual machine, interpreter, etc not only impacts speed but also memory footprint, security, etc.
@jeffwells641
@jeffwells641 4 жыл бұрын
Yeah, but memory is meant to be used. You shouldn't be wasteful with it, of course, but if you're restricting your memory footprint without good reason you're probably doing your users a disservice. Also memory was rolled in to this test to a certain degree, as high memory usage was likely the cause of the 60% difference in performance for the 64bit 6.0 jvm in the first test, via the garbage collector. The second and third tests would have needed very little memory, and were consequently much faster (at least for 64bit 6.0).
@anandsuralkar2947
@anandsuralkar2947 4 жыл бұрын
And also different technical things to like core usage and all
@wtfpwnz0red
@wtfpwnz0red 4 жыл бұрын
@@jeffwells641 memory use shouldn't be needlessly restricted, but hogging extra because you can leads to bloat. Most users have more than one thing running at once, so lightweight is always better, all else equal
@roshanfreeacc8886
@roshanfreeacc8886 4 жыл бұрын
check iphone with 1gb ram n android with 1gb ram
@pingpong1138
@pingpong1138 8 жыл бұрын
I love it when Gary talks nerdy to me
@Caracazz2
@Caracazz2 7 жыл бұрын
Tem que ir com calma man
@victornaut
@victornaut 7 жыл бұрын
Eduardo said "pace that down dude"
@Caracazz2
@Caracazz2 7 жыл бұрын
asdfgl, o 'man' não precisava traduzir não, véi
@Aecor
@Aecor 3 жыл бұрын
@@Caracazz2 man dindnT need to translate man
@FalconGames109
@FalconGames109 8 жыл бұрын
The problem with these results is that all of them are very focused on just performing lots of math. In a real application, while these may make up a good amount of the code, you also have to deal with lots of allocations/freeing memory or processing strings, arrays, and other data structures that isn't reflected by raw math performance. With AOT (ahead-of-time) compilation (rather than JIT/just-in-time), ART can reduce a lot of the runtime bottlenecks (runtime type information can be removed, functions can be inlined, generic code can be specialized) in a way that still matches the device quite well. But the problem is that ART wouldn't be able to get rid of all your allocations or delay garbage collection to parts of the program where not much performance is needed on its own, and that's where C/C++ would help out a ton.
@BrunodeSouzaLino
@BrunodeSouzaLino 4 жыл бұрын
When it comes to the most fundamental level, your computer/mobile is nothing more than a fancy calculator that only does addiction and subtraction.
@mikefdorst
@mikefdorst 4 жыл бұрын
@@BrunodeSouzaLino Why do people like to say this? It's obviously not true - there are hundreds of machine instructions on most architectures and add and subtract are only two of them. If you're going to spout nonsense like this, why not go all the way and say that computers can ONLY add, since subtraction is just adding a negative number? Consider that no computer would be Turing complete without compare and jump instructions.
@RmDIrSudoSu
@RmDIrSudoSu 4 жыл бұрын
Also we would have to see what compilation flags where in use and if the machine code was as optimized as it could be, for math, his function might just be some operation where the result are not used afterward, if you compile in a debug flags mode, those will be compute, but if you use -O3 (in GCC wich is mostly the one I use) then most of your math function won't even be compiled because the results are not used afterwards and the compiler might even say "alright I don't need that function at all lets skip it." But I don't think that it's possible to compare generated assembly for both Java with ART and C.
@mikefdorst
@mikefdorst 4 жыл бұрын
​@@RmDIrSudoSu There are very easy ways to make sure that the result of the computation is used (e.g. compute the sum of all of the computations). If this guy didn't do that it would demonstrate serious incompetence.
@mikefdorst
@mikefdorst 4 жыл бұрын
@@RmDIrSudoSu Also what is "Java with ART"?
@mrflamewars
@mrflamewars 6 жыл бұрын
Java is the reason why your phone needs umpteen bajillion cores just to be responsive.
@melihcelik9797
@melihcelik9797 6 жыл бұрын
John with andorid 4.4 and before andorid 4.4, you are right. Java had many flaws on andorid. But its getting better with every os. Java kind of catching up lately. A little late but better than never
@nathanmead140
@nathanmead140 5 жыл бұрын
@@melihcelik9797 4.1.1 too
@streaper1
@streaper1 4 жыл бұрын
@@melihcelik9797 It is catching up because hardware improved drastically.
@yw5617
@yw5617 4 жыл бұрын
no that's wrong, those are multiple cpus in one die, those many cores don't run at the same time, look it up.
@harshivpatel6238
@harshivpatel6238 4 жыл бұрын
Every single Android device you can find on market runs 4 or 6 cores at a time, not more than that, the big.LITTLE arch is such that only one cluster is used at a time.
@SageMinimalist
@SageMinimalist 8 жыл бұрын
This channel needs more "Gary explains" videos!
@IRONDROID_ELECTRONICS
@IRONDROID_ELECTRONICS 8 жыл бұрын
Totally agree 👍
@mahmoudragab1787
@mahmoudragab1787 8 жыл бұрын
yeah, he is amazing
@wtfpwnz0red
@wtfpwnz0red 4 жыл бұрын
The optimization point can't be overstated. A skilled C programmer should be able to squeeze out a lot more performance because of the granular control over low level functions. However there's a lot more room to screw things up, too.
@DoomTobi
@DoomTobi 4 жыл бұрын
No, function level optimization is something that a Compiler can do better than you in most cases (especially when you have data about the program behaviour). Data structure optimization makes the largest difference
@wtfpwnz0red
@wtfpwnz0red 2 жыл бұрын
@@DoomTobi "in most cases" is a neat thing. I'm saying that, at the top end, a custom tweaked solution done by hand by somebody who knows what they're doing is going to be the best, most optimal solution. Is it going to be worth all that effort for a complicated mix of C and assembly that doesn't port easily? No, "in most cases" it's going to be more efficient to let a compiler or interpreter handle it. But for a situation where optimization is crucial, doing it by hand has a higher ceiling for performance.
@CasperBang
@CasperBang 8 жыл бұрын
One has to be very careful with these micro-benchmarks. One thing to remember is that once the C compiler has run, the generated code is frozen for good. Dalvik and Art however, are adaptive in that they will look for "hot code paths" at runtime and try to optimize. For brute data processing, the C compiler will almost always come in first place - but Java can easily and automatically inline code across linkage boundaries (think libraries/components). In other words, to do Java justice here, one should compare a large C application vs. a large Java application (Visual Studio vs. IntelliJ comes to mind). Last but not least, you can not write an Android app using only C/C++ and the NDK; to interact with the operating-system you need Java!
@PawanDubeyK
@PawanDubeyK 8 жыл бұрын
+Casper Bang Came here to say this. But I don't think that comparing the run times of applications of any size is fair as Java always has the overhead of the JVM and its non-deterministic garbage collection.
@gr0nis
@gr0nis 8 жыл бұрын
+Casper Bang LLVM can optimize "hot code paths" as well. The c compiler clang uses llvm. This means that the c compiler can also do the same optimizations. I don't know what c compiler Android is using though, but most likely, you can use any arm compatible c compiler.
@Roboprogs
@Roboprogs 7 жыл бұрын
In fairness, he is limiting his talk to Android devices and compilers. Otherwise, yeah: Garbage collection eats more memory than manual memory management, and can sometimes spoil caches, as well. OTOH, Manual memory management schemes sometimes hiccough reworking the heap, also. Interpreted C (and similar languages) is a pretty interesting practice, though.. Finally, if performance is the one true god, let's write it all in COBOL - completely static memory and compile time binding only. No???
@intuit13
@intuit13 7 жыл бұрын
CLisp, anyone?
@_SG_1
@_SG_1 7 жыл бұрын
A good example of seeing this branching / hotpath optimization is looking at Graal JVM and the showcases they did (I think it was Graal Ruby vs. plain Ruby)
@mmr-xh8cy
@mmr-xh8cy 8 жыл бұрын
Yeah C is "slightly" faster than Java :D
@Rai2M
@Rai2M 7 жыл бұрын
exactly my thoughts :)
@manuelcampi8956
@manuelcampi8956 6 жыл бұрын
java is also unstable,unreliable,too user friendly,and too slow
@LemonChieff
@LemonChieff 5 жыл бұрын
only 4 times.
@ThePC007
@ThePC007 4 жыл бұрын
@abcd efgh Binary is not a language, what are you talking about?
@ThePC007
@ThePC007 4 жыл бұрын
@@11_22_XX Well I mean, people do use FPGAs for performance reasons indeed.
@derstreber2
@derstreber2 7 жыл бұрын
Was the C code compiled with -O0, -O1, -O2, or -O3?
@TimeoutMegagameplays
@TimeoutMegagameplays 4 жыл бұрын
I think the NDK does not compile with GCC, maybe the compiler was at fault for the code not being so much faster.
@ianzen
@ianzen 4 жыл бұрын
@@TimeoutMegagameplays That's 200 iq play right there. Make the C compiler worse so more people will code Java!
@ssuriset
@ssuriset 4 жыл бұрын
@@ianzen lmaooooooooooooooooooooooooooooooooo
@reinerjung1613
@reinerjung1613 7 жыл бұрын
You also may want to extend your benchmark to not only include calculation. For example, most UI based software systems create lists, sort lists, search lists (and hash maps), data transformation, like form validation, translation from one representation into another, and serialization and deserialization. BTW: nice video.
@linf
@linf 6 жыл бұрын
I just like to say: People who believe in Java being faster than C are about the same people who believe in moto-perpetual machines. j/k, but you got the point ;-)
@staubsauger2305
@staubsauger2305 4 жыл бұрын
Java is not always faster than C but it can be because the JIT optimizer has more information at runtime than the AOT optimizer which has less information. Furthermore, in practice Java is often faster than C programs for the same amount of developer effort because it is much simpler for the developer to have Java run on multiple cores (which almost all CPUs now have). Consider the runtime of a program using the Java streams API to iterate over a dataset where utilizing all the cores is trivial whereas in C it is a lot more complex so people don't. Again, in practice and with the same developer effort (which is the constraint for commercial development which is time/cost constrained) Java is usually faster than C by nearly the number of cores you have due to Java's support for parallelism (both in its standard API and the fact the parallel garbage collector means the developer doesn't have to figure out ownership and resource release).
@michaelmorris2300
@michaelmorris2300 4 жыл бұрын
@@staubsauger2305 Java is faster than C because it uses a JVM written in............... C
@michaelmorris2300
@michaelmorris2300 4 жыл бұрын
Remember, the JVM, compiler, etc etc...... is written in C!
@ender2999
@ender2999 4 жыл бұрын
Michael Morris dear god, you’re saying this tongue in cheek, right? You don’t actual think it’s faster, do you?
@michaelmorris2300
@michaelmorris2300 4 жыл бұрын
@@ender2999 of course not!
@serpentvert
@serpentvert 8 жыл бұрын
Great video explanation of the speed difference between the two languages. Please make more like this!
@TheEVEInspiration
@TheEVEInspiration 7 жыл бұрын
He did not do any of this. This is just benching a few simple functions with only a few operations in each and not representative of real world software. C will always be faster when both versions are well optimized. The difference on certain tasks will be huge, but many tasks in Java will just see a constant lagging in speed when compared to C. The biggest influence is the programmer. Do stupid things like too much abstraction, too many objects or deep complexity by nesting unpredictable conditions or looping over them and you get crap performance. Data locality, access predictability and branch predictability are king and with C, a programmer can exert control over these things, with Java not as much.
@SomeUserNameBlahBlah
@SomeUserNameBlahBlah 7 жыл бұрын
This always seems to be the difference between Java programmers and C/C++ programmers. The C/C++ programmer actually understands hardware and how to write code to take advantage of it for speed boosts. Java programmers just write code and hope for the best.
@skeggjoldgunnr3167
@skeggjoldgunnr3167 6 жыл бұрын
C Compiler optimizations *do* exist, too!
@DoomTobi
@DoomTobi 4 жыл бұрын
What this video tells you: - given a numeric program with preallocated float[], Java is as fast as C => Pure hot path VM overhead is low What it doesn't tell you: - Given a program that is coded in the style of the language, it's starting to look completely different. => The main source for overhead are programing paradigms Reasons, why Java is slower than C/C++: - it forces you to do memory allocations for small objects - No pass by reference/pass by value semantics - everything is a virtual function - no template based generic programming - generics force you into object boxing/unboxing for basic types - interface inheritance is a bit expensive, as it requires a hash map/small array search - plain data arrays lead to bad programming style - garbage collection. Bad if you need real-time guarantees, bit in general not as bad as many think. Reasons why even C/C++ are not optimal in terms of performance: - no real knowledge about memory aliasing - bad simd instruction usage, due to independent compiler optimization steps
@welltypedwitch
@welltypedwitch 4 жыл бұрын
Nice comment! If those are your criticisms, what do you think of Rust?
@DoomTobi
@DoomTobi 4 жыл бұрын
@@welltypedwitch I'm not sure yet. I didn't have a deeper look into it, but it seems to have some very cool concepts. What worries me is the compile time on larger projects.
@Kamel419
@Kamel419 4 жыл бұрын
I think the work you've done here is great, very interesting looking at the difference in performance between the two. I'm a software developer and tester myself so I think I may be able to help shed some further light on this subject. I don't think this comparison - or any direct C to Java comparison - is going to really get at the meat of why C might yield far better performance than Java. The reason why is in my experience people who write in a Java mindset write code in a way that they wield these incredibly inefficient data structures around via instances of objects. Since C is not object oriented, the entire design and approach towards architecture will be handled differently in C. These differences in approach are where I have seen substantial gains in performance, rather than the specific language chosen. Even if the comparison were C++ versus Java, this concept would still be at work. For those who don't know, C++ is (over-simplified) object-oriented C. The reason is Java just makes it easy and convenient to carry around these huge memory intensive objects so programmers in Java tend to use this liberally where I have seen less of that behavior in C++. One can certainly argue why that is or is not, but I'm simply saying those are the patterns I've seen emerge in my experience (warning: small sample size :)). So, to sum it all up with a TLDR: It's certainly intriguing to explore this in a direct way, but the real world difference between the two has less to do with run time and more to do with Java programmer behaviors versus C programmer behaviors.
@ratgr
@ratgr 4 жыл бұрын
I am also a software developer and I just happened to work on both java and c++ we had lots of benchmarks to find when we should use c++ code vs java code, and while I can agree that java developers don't care about memory even thenm when doing the same code using the same way in c++ (all virtual bases, unneded polymorphism...) it is surprisingly faster, around 3x average which is why new development in java only happens on UI side, and this 3x is doing code like java in c++ which is not the way to go, once you optimize a little (moving things to vector, remove unnecesary polymorphism, add move constructors ... etc) we get much better numbers from 3x to 1000x with the average being around 15x , obviously this is hard to notice in microbenchmarks as the java jit optimizer enters and then the produced code has very little overhead. And this is before getting to memory, because memory improvements are HUGE and actually one of the main reasons the c++ code came into the question our application was consuming around 8GB base, after some time with java optimization, etc we got it down to 6GB, and using a transpiler to move some code to c++ (almost no performance improvement) it got to 3gb, now our codebase is even bigger and the app remains around 3GB usage and profilers show that most of that is from the java side of code
@andrewmorse210
@andrewmorse210 8 жыл бұрын
Anytime dealing with C as a student I think one word...pointers.
@groberti
@groberti 7 жыл бұрын
C, the language itself, imo is pretty simple. The hard part is to write good code with C
@stevewang8642
@stevewang8642 6 жыл бұрын
Grobee simple makes it elegant
@groberti
@groberti 6 жыл бұрын
C is pretty cool (I don't really like C++) but I despise macros
@mpmansell
@mpmansell 6 жыл бұрын
Try looking at modern C++. Many of us from the Stone Age hated C++ because it was very clunky and cludgy. It was also from a time when OOP was quite new to the general industry and no-one really knew how to use it well. (I looked at some of my old 20+ yo books the other day - no wonder I hated C++). Recent C++11,14,17 has drawn from the experiences of Java, etc, and become really nice languages (and I say this as a C enthusiast of 30+ years :) ). Oh, and macros are deprecated in modern C++ (I also despise them) :D Oh, and if you decide to investigate C++, go straight to Stroustrup. Had I done so 25 years ago, I might have had a different opinion of C++. He is an excellent writer and shows things clearly and sensibly.
@nathanmead140
@nathanmead140 5 жыл бұрын
I hate java (it's bad) there are so many files for a very simple thing and i have to put the same code more than 2 times in every file (when i get a iPhone im learning swift and eraseing all java codes from my brain).
@Lambda_Ovine
@Lambda_Ovine 3 жыл бұрын
One thing worth to mention about Java programs is the advantage of the bitecode to use features of future architecture through the JVM, while in C/C++, you need to recompile to machine code in order to utilize the same features. So, unless you recompile your C/C++ software, that initial performance gap between Java and C/C++ will disappear or move in favor of Java if you swap CPU. That's actually a great feature many applications, like servers that need to swap hardware but still need to provide services 24/7 or even at home if you built your new PC and you just swapped the OS drive. So, if anything, with Java you can be sure that every time you run your program, the software will use all the features of your CPU to the fullest extent.
@LubomirDohnal
@LubomirDohnal 8 жыл бұрын
Please, do a revisit with the new Android Nougat!
@mateusschembri2194
@mateusschembri2194 6 жыл бұрын
And oreo! :)
@BakrAli10
@BakrAli10 5 жыл бұрын
@@mateusschembri2194 and pie! :)
@Windsorsillest
@Windsorsillest 4 жыл бұрын
And 10 lol
@ivanov83
@ivanov83 4 жыл бұрын
You probably get such an impressive results on running some cryptographic primitives on android 6+ not because of improved java runtime but because this functions in java crypto api are probably intrinsic which means you call java api that actually calls compiled C code inside. It explains 3 percent difference on android 6 (where android keystore and hardware crypto was first introduced). Also as some guys have already noticed - comparing calculation operations is quite irrelevant. The real advantage of native code is its memory management. Try to iterate through a huge cycle that will include creating new java objects and the native C counterpart will become ridiculously faster
@ArjunPakrashi
@ArjunPakrashi 7 жыл бұрын
"Java is as fast as or even faster than C" not statistically shown. Also a language cannot be faster then another, because it's a language, depends how it's compiled or interpreted. Also, the way the C code was compiled was not mentioned, did they use -O3 if using gcc? Or Intel compiler or else? anyways, in real world, serious things implemented are in C or C++, including, Ironically, the JVM itself.
@mavhunter8753
@mavhunter8753 5 жыл бұрын
Arjun Pakrashi Exactly!
@reinerjung1613
@reinerjung1613 7 жыл бұрын
As Dalvik uses a just in time compiler, you need to adapt your way to measure performance. In the beginning the code is interpreted and then based on monitoring information optimized. Therefore, you have to run your benchmark multiple times (as you did) and throw away your time measurements of first 500 000 iterations of the functions (actual number depends on the number of cycles the optimizer needs).
@StonkeyKong
@StonkeyKong 6 жыл бұрын
What about Java vs C++? Obviously C is faster than Java... that’s like asking if assembly is faster than C. Like what about some function that implements a lot of object oriented programming ran in Java vs C++?
@DoubleCGamesStudios
@DoubleCGamesStudios 6 жыл бұрын
Jason Michelson C++ is just C with OOP, still a ton faster than Java. Actually there is no reason to use Java nowadays except for Android development. Other than that, if you want an easy and OOP-oriented programming language as Java, you have C#
@StonkeyKong
@StonkeyKong 6 жыл бұрын
DoubleC yeah I know what C++/C# are I’m a software engineer for a fortune 500 company lmao. I was just saying that comparing C to Java isn’t really a good comparison because C is a lower-level language and inherently faster.
@DoubleCGamesStudios
@DoubleCGamesStudios 6 жыл бұрын
Jason Michelson Generally C programmers don't compare C with Java, it's Java enthusiasts who like to go all out and cross fingers on these videos to see if maybe Java can have a magical "spark". Worthless nonetheless.
@sabetaytoros4123
@sabetaytoros4123 6 жыл бұрын
DoubleC responds to Jason Michelson C++ is just C with OOP. This was may be true before 2011. But today the c++ community which uses the new paradigm never write a program with OOP paradigm. OOP is the base class of evil is obsolete is finished. Why should I write a class which I should have to override a function again and again. To day writing PostModern C++ is essential. You define the concepts. And the compiler writes every needed class for you. Static binding is the solution. The compiler knows how to optimize the the progrem written modern c++.
@valizeth4073
@valizeth4073 6 жыл бұрын
C++ is slower than C, yet not by a lot. In speed: C > C++ > Java.
@tovare
@tovare 7 жыл бұрын
Memory allocation is one of the things that can cause a straight-forward C program to run significantly slower than Java. Now, some would say that you could simply implement an equally efficient algorithm in C, but since Java GC-performance has been evolving over decades putting in a couple of hours more work in the C-coding might not yield the desired result. Also, efficient threading requires more effort to implement in C than in Java and with some Android mobile processors having up to 8 or 10 cores that´s a huge potential win for performance.
@typedef_
@typedef_ 7 жыл бұрын
Please tell me this guy doesn't have a watch on each hand.
@nobodyanybody3374
@nobodyanybody3374 7 жыл бұрын
He has a smart watch on one hand and a fitness tracker on the other.
@mikecrapse5285
@mikecrapse5285 7 жыл бұрын
MizerienCauciuc no one told him that they make apps for smart watches that are fitness trackers
@wtfpwnz0red
@wtfpwnz0red 4 жыл бұрын
No it's a static discharge band. All true computer nerds are required to wear one at all times.
@johngarzone6092
@johngarzone6092 4 жыл бұрын
One is running C and one is running Java
@Rijndael1998
@Rijndael1998 4 жыл бұрын
He's so fat he's in 2 time zones at any time.
@LarryBank
@LarryBank 8 жыл бұрын
Nice job. Would probably be useful to let people know that ARM 32-bit doesn't have a divide instruction (integer nor float). Starting with ARM64, there are both. e.g. try to avoid doing divides on 32-bit ARM if you want fast code. A good alternative is to multiply by the inverse. Your benchmark also doesn't touch on another issue of Java versus C. In C you can use SIMD and special instructions with intrinsics. ARM64 has unique instructions for doing cryptographic operations (e.g. SHA1/AES/SHA256) that are MUCH faster than trying to do it in C/Java.
@jordanrocker100
@jordanrocker100 8 жыл бұрын
How many keep turning volume up just to ear what he's saying.
@jordanrocker100
@jordanrocker100 8 жыл бұрын
@Dennis Fluttershy Hear* typos are inevitable.
@gherbihicham8506
@gherbihicham8506 6 жыл бұрын
Yeah no one NOSE what he's saying.
@DantevanGemert
@DantevanGemert 4 жыл бұрын
@@gherbihicham8506 EYE see what you did there
@MisterRedFox
@MisterRedFox 8 жыл бұрын
Kudos for putting in the effort on testing all the different devices. The most interesting comparison would have been memory and resource management; but creating those kinds of tests and ensuring they are optimal from each language standpoint is really, really difficult.
@mullergyula4174
@mullergyula4174 7 жыл бұрын
Java has been very fast in the last 10-15 years. I ported some complex Java code to C once. I had to optimize the C code for days and it was still slightly slower than the Java version. In C you have a chance to go really deep and use things like x86's vector operations. But to use that you have to design your code for those instructions. This is not what the average programmer will do and it cannot be done every time.
@liquidminds
@liquidminds 7 жыл бұрын
pretty much a spot-on evaluation of the situation. If you want to go into depth, c allows you to do a lot more, but what you get with java, out of the box, does pretty much anything you want with good results. just by porting a java-app to c, will not make it run miraculously faster...
@mullergyula4174
@mullergyula4174 7 жыл бұрын
I am glad that you agree. The final goal of the porting was to run on the GPU, but that never happened.
@linf
@linf 6 жыл бұрын
In other words: "I'm an average Joe programmer who has about 0 experience with C, and therefore I blame the language", this is basically what you're admitting. I'm not a big fan of C because of its productivity issues, but trying to say some-language is faster than C or Assembly is just trying to prove the the earth and sun are equally flat. Don't juggle the truth, like saying a bazooka is a *weaker* weapon because there were no robberies in your neighborhood the last year with it, therefore handguns are more powerful. You can say that bazookas are less of a menace to society than handguns, that is correct, just don't push it beyond just because you like either bazookas, handguns, both or neither.
@superb4ever99
@superb4ever99 8 жыл бұрын
please get in to details I have read from sites and watch people talk a little bit about it on their video but they don't have any clue of what they are talking about. thank you again Gary, I've learned a lot from your videos.
@sergeiromanoff
@sergeiromanoff 7 жыл бұрын
The difference is that C++ guys don't seek validation by comparisons to other languages through questionable benchmarks
@groberti
@groberti 7 жыл бұрын
yep, they grow neckbeards instead
@mpmansell
@mpmansell 6 жыл бұрын
We also have sandals and pony tails. Never forget that :)
@seventyfive7597
@seventyfive7597 8 жыл бұрын
+Gary Sims C/CPP optimization used to be my expertise, comparison may have been skewed inadvertently: 1) C is extremely strict about you telling the compiler EXACTLY what to create, examples: a) If you did not tell the compiler that it may use intrinsic functions (unrelated to inline functions) it will use a generic sqrt function that is not allowed to use intel's SSE b) If we mention inline, it is also extremely important to allow the compiler to decide on inline, or explicitly use pragmas or other means to allow inlining - this is critical for timing c) A few things may be considered untouchable by the compiler, so I need to see your "maths" implementation as well to tell if such non-optimizable code should be changed 2) In fact, when you keep to some rules it is even easier to create optimizable programs in CPP than C due to C standard being very strict at times. 3) Not an android expert myself, but is timing done in exclusive mode? I don't just mean single-processing, I mean with the kernel not intervening at all. Otherwise we may be lowering the percentage gap due to adding a constant.
@seventyfive7597
@seventyfive7597 8 жыл бұрын
+Android Authority Critical addendum about the languages: While Java's garbage collection is non-deterministic and rules out Java for hard RT, the MAJOR performance hit comes from the dynamic ALLOCATION and not the release, in fact the most expensive action devs do REGULARLY is dynamic allocation: 1) Java, dyn alloc done a lot behind the scenes, hard to avoid, programmers almost always include hidden allocs 2) CPP - basically avoid STL containers in critical areas (including CPP11 containers), and you're good (while you're there avoid RTTI, but that's unrelated to alloc :) ). 3) C - you are always aware of allocations, but you are also indirectly given complete control of optimization, so you may cause the compiler to think you ask to not optimize some stuff.
@FabioSilva-bq7ou
@FabioSilva-bq7ou 8 жыл бұрын
HI SeventyFive, which is better if i want to write a emulator(such as psp or nintendo nds) for android , java or c++ , thanks!!!
@ztech-consulting
@ztech-consulting 8 жыл бұрын
And this is why apple can get away with a dual core processor. Everything is tightly controlled and the resulting code is highly optimized for that CPU. With android due to the variations of the OS/Hardware/SoC there is a lot of variations and getting the best optimizations is not easy. I wonder how the new Java will work after the Oracle Lawsuit.
@OverG88
@OverG88 8 жыл бұрын
+Z Vaper In enterprise world: Just fine. :)
@Ezio470
@Ezio470 8 жыл бұрын
google won the case...oracle cant do shit now
@sheridenboord7853
@sheridenboord7853 4 жыл бұрын
Whether java run time is using JustInTime or AheadOfTime compiling. The fact that its compiled at run time means the compiler has the ultimate chance to tailor the code for the machine/situation at hand. To get the fastest C performance you would have to compile an optimised version for each machine. At least testing your java against C is a good way to check your java performance.
@azzym8794
@azzym8794 7 жыл бұрын
*A good listen for Java Fanboys*
@zxnnightstalker2289
@zxnnightstalker2289 3 жыл бұрын
Obviously, I am a C++ fan. :(
@agentk3984
@agentk3984 4 жыл бұрын
I've tinkered around with visual C++ compilers on windows making them output assembly code. They seem to do some funny stuff with optimizations. Even going as far as completely breaking logic. And the thing is, that is ok, and actually makes sense. For example, you could write a program that adds 100 constant numbers together in a loop, then prints the result. Then if you look at the resulting assembly code, you see that the compiler has deduced that there is no need to do this loop, and has just plopped the sum in to be printed out where you would expect a for loop of some kind. Not to say that that is what happened here, but compilers are SMART. And they look further into the source code logic than you may think.
@americanswan
@americanswan 8 жыл бұрын
Happy to be running Marshmallow on a 64bit 808. LG G4.
@AndyTurfer
@AndyTurfer 7 жыл бұрын
americanswan I love the G4! Fantastic handset. I'm now using a G5 as my daily driver, but still hold a place in my heart for the G4.
@americanswan
@americanswan 7 жыл бұрын
Andy Turfer :) I'm on a V20 now. Very nice.
@AndyTurfer
@AndyTurfer 7 жыл бұрын
americanswan - Nice. I'm now holding out for the V30. Something I use everywhere is the IR blaster. Was very disappointed this was omitted from the G6, am hoping the V30 will include an IR blaster.
@xkmares
@xkmares 7 жыл бұрын
Each one has its time and place which it was he was saying. A simple side-by-side comparison of performance of the two should not be the determining factor of which one to choose. There are many factors that go into choosing either or both. Java will be around for a long time and so will C/C++. There are both extensively used in industry, but it depends on the domain. The important thing is that you know the advantages and disadvantages of each and when and when to not use them. Also, to the people hating on either side, you can't just say it sucks. You need to prevent evidence for your opinion.
@batismul
@batismul 8 жыл бұрын
Awesome video and explanation!
@ekfliu
@ekfliu 4 жыл бұрын
We used to write our backend code in c++ for both IOS and Android under linux. Then hook up to the UI with SWIG JNI and Objective C++. But it was cheaper to hire developers to do the same thing twice and no developers understands the C++ except one.
@cyborgsmurf6446
@cyborgsmurf6446 7 жыл бұрын
I come from QBasic to learn java... holy shit! So much stuff you can just "import"... imagine having that 20 years ago :/
@scuddkidd4017
@scuddkidd4017 7 жыл бұрын
keep up
@0x1EGEN
@0x1EGEN 7 жыл бұрын
You did have that 20 years ago. Java is 21 years old, and even older languages like C and C++ had that feature too, but it was "include" that imported header files.
@cyborgsmurf6446
@cyborgsmurf6446 7 жыл бұрын
I had hoped for you to tell me that earlier... :)
@amirabudubai2279
@amirabudubai2279 7 жыл бұрын
@Jason Lee Lets be honest, including in C/C++ is not as straightforward.
@0x1EGEN
@0x1EGEN 7 жыл бұрын
Amir Abudubai​ What do you mean? If you mean "not as simple as" then yes, it's not.
@HomerNarr
@HomerNarr 7 жыл бұрын
Thank you. As Dev/Admin i knew the Background and was no java fan for decades. But java has come very far, i am impressed. Until android, java was always considered hogging mem and time, but with android / smartfones it received much love, because there is no better solution to run the same on different phone architectures. Stuff learned.
@kishan.kumar219
@kishan.kumar219 7 жыл бұрын
What were your compilation flags for C
@florexsatis
@florexsatis 7 жыл бұрын
not mentioned.. -O -5 :D
@pleasedontwatchthese9593
@pleasedontwatchthese9593 7 жыл бұрын
-Slow
@llothar68
@llothar68 6 жыл бұрын
You want to know the state all of the more then ten thousand switches of gcc. Yes this is right, i've seen a CPPCON talk that there are more then 10000 options. Thats the difference to Java.
@muadrico
@muadrico 6 жыл бұрын
Lothar Scholz He only needs to show the options he set explicitly, because all others are defaulted (and therefore can be looked up) anyway.
@rich1051414
@rich1051414 6 жыл бұрын
With the right gcc compiler options, I can make any nearly equivalent processor appear to be faster than it's competitor. It is quite the money maker. Intel loves that shit.
@DerrickBest
@DerrickBest 5 жыл бұрын
Hi Gary. Not sure if you'll read this. But how bout revisiting Java vs C using newer version of Android. Might be interesting I think.
@fuzz33594
@fuzz33594 8 жыл бұрын
Gary - impressive, as always.
@proletar-ian
@proletar-ian 8 жыл бұрын
Excellent video! I'm about to get my degree in CS and this is consistent with everything I've learned in my foundation courses.
@christianregitz5791
@christianregitz5791 8 жыл бұрын
Gary the explaining god
@Caracazz2
@Caracazz2 7 жыл бұрын
7/10 at most.
@Jack-dv1tr
@Jack-dv1tr 8 жыл бұрын
Gary's videos never disappoint. Keep them coming!
@Dexx1s
@Dexx1s 8 жыл бұрын
The whole time watching this I was wondering: Isn't the Android API in Java anyway? And then I got to the end.
@GarySims
@GarySims 8 жыл бұрын
+Dexx the Duck :-)
6 жыл бұрын
The last benchmark might be related to question on stackoverflow, where a user complained that his java code ran several times faster than C with the same algorithm. The best answer was "Java is often faster at doing nothing at all", which follows from the fact that it can do runtime optimization of the code, wheras C compiler can only do a static one. And this most significantly helps in situations, where the code obviously does nothing.
@Krblkn
@Krblkn 8 жыл бұрын
I am a c++ programmer and I know a bit of java... I like C++ better but also like Java :)
@jscorpio1987
@jscorpio1987 4 жыл бұрын
I prefer C++ as well. I learned Java first but after learning C++ and getting used to the control it gives, Java just pisses me off now. It feels like an overprotective parent is telling me what I can and can’t do. C++ lets me do whatever I want and learn from my own mistakes. It definitely made me a better programmer.
@-morrow
@-morrow 4 жыл бұрын
Bugs are a main issue for software companies and sadly, not every programmer is great. It is much easier to write bugs in C/C++ (pointers, memory management, etc.) than in 'overprotective' java. it's so popular because the language and it's surrounding tools enforce a readable and maintainable code style.
@Erlisch1337
@Erlisch1337 4 жыл бұрын
Then you should stick to C# instead, for the best of both those worlds and often even better :)
@koenderbb5191
@koenderbb5191 4 жыл бұрын
@@Erlisch1337 Not really. Which best part of the world of C++ is C# inheriting? C# is basically Java.
@LydellAaron
@LydellAaron 4 жыл бұрын
Java's power is in its virtual machine. The virtual machine is also Java's biggest weakness. The Java virtual machine can be run on independent hardware (such as a supercomputer) and can be updated. Also, a custom hacked virtual machine can do advanced clandestine things, such as intercept and profile application data, memory-access signatures. Oh, and the Java Virtual machine is written in C.
@aleksd286
@aleksd286 4 жыл бұрын
KZbin recommendations 2016/2017/2018: Nah KZbin recommendations 2019 (almost 2020): It is time
@tubefile100
@tubefile100 4 жыл бұрын
Ikr
@NinadSheth
@NinadSheth 8 жыл бұрын
But the comparison did not include heavy memory allocation and deallocations and pointer arithmetic which a plus point of c and it's where c excels compared to java
@tarasov9794
@tarasov9794 4 жыл бұрын
As a C programmer, I am kind of happy for Java devs.
@jsbarretto
@jsbarretto 7 жыл бұрын
To clarify: The performance difference actually doesn't have too much to do with the language. It has far, far more to do with the optimisations performed by both the programmer and the compiler / runtime environment. C is not inherently "faster" than Java - the best Java runtime will generally generate faster code than the worst C compiler.
@guy1524
@guy1524 8 жыл бұрын
Cool test, however unfortunately in java, most developers allocate massive amounts of objects for the GC to collect. And every object is on the heap. So in real world situations, java is much slower.
@zamundaaa776
@zamundaaa776 7 жыл бұрын
Guy1524 stupid programmed java programs are way slower than great programmed C programs... The only thing is that if you program a C program stupidly then it probably won't work You can't really compare bad programmed programs of one language with good programmed ones of another
@stephenborntrager6542
@stephenborntrager6542 7 жыл бұрын
Personally, I would rather have the app not work unless the developer is competent. Would filter out so much garbage.
@mattizzle81
@mattizzle81 4 жыл бұрын
Yes I have seen this in an Android app I am writing that does some heavy processing, a lot of number crunching (creating 3D point clouds), however not just math, but also a lot of objects. The garbage collector goes crazy to keep up. It is much, much faster in C++ with little to no extra effort. The code is just as clean and readable in C++. The only difference is that C++ crashes harder when you make a mistake, and I have to make up for it by lots of debug printing to Logcat to figure out what is going on.
@PurushNahiMahaPurush
@PurushNahiMahaPurush 4 жыл бұрын
Java and subsequent higher languages are made to be a bit more "developer friendly" in the sense that when I write a program, I do not have to worry about memory management. The compiler and GC does it for me. Both C and Java have different reasons to exist. Java was developed for much better code portability and applications. C is basically when you want to interact with hardware or when you need blazing performance. C is basically the "hey man I trust you with what you are doing so I'll let you do it" language.
@apivovarov2
@apivovarov2 4 жыл бұрын
This video explains why iOS apps were 3 times faster than Android apps on comparable hardware in the past when iOS developers used Objective C
@becomepostal
@becomepostal 4 жыл бұрын
Alexander Pivovarov Are you implying that Swift is slower than Objective-C ?
@apivovarov2
@apivovarov2 4 жыл бұрын
@@becomepostal Looks like Swift compiler converts Swift code to LLVM IR and then it goes through LLVM optimizations. As a result Swift is compiled to highly optimized machine code. No Virtual Machines, no GC pauses, no BS. Because Swift is just another frontend language for LLVM the performance should be similar to Objective-C compiled by LLMV. BTW, LLVM is used in Android NDK. So, C/C++ code (.so libs) run fast on Android. But apps / UI is still non-LLVM Java/Kotlin.
@himanshnegi832
@himanshnegi832 4 жыл бұрын
That isn't how it works, it is much more complicated.
@dharmang
@dharmang 4 жыл бұрын
@@himanshnegi832 lmao? 😂 Please enlighten us
@aleksandarcvetic9489
@aleksandarcvetic9489 8 жыл бұрын
There is one mistake in C code. Variable described as long in C doesn't mean make 64-bit int. You need to make long long to get 64-bit int. That could explain that gap between JAVA and C on 32-bit phones.
@apivovarov2
@apivovarov2 4 жыл бұрын
Java/Kotlin are used to build UI and to assemble app components together. The actual heavy components are written in C/C++, compiled and linked to .so
@StephanBeal
@StephanBeal 4 жыл бұрын
Correction: "long" is (curiously) 32-bit on most or all 32-bit C platforms (every one i've ever coded on), whereas "long long" is 64-bit but is not part of C89. There is no 100% portable standard for 64-bit integers in C89, though all compilers support long long except in strict C89 compatibility mode. C99 portably specifies 64-bit integers. For a citation see the C_data_types page on Wikipedia.
@srda1989
@srda1989 8 жыл бұрын
love Gary videos😃
@hpgla
@hpgla 7 жыл бұрын
Loved that you pointed out the difference between different processors and Android versions
@charlech
@charlech 8 жыл бұрын
alright this is for all us CS majors
@mr.mxyzptlk6233
@mr.mxyzptlk6233 8 жыл бұрын
+HERRO Ikr. Always so interesting.
@DarrienGlasser
@DarrienGlasser 8 жыл бұрын
I dunno, this is some pretty basic stuff. I feel like this is for any major.
@XsaiddX
@XsaiddX 8 жыл бұрын
+Darrien Glasser agreed 👍 , i guess gary ignore why google prefere java than C , we're talkin about a market here and how wide the language's used , but we agree C is faster its obv its low level language
@georgescg7342
@georgescg7342 7 жыл бұрын
undergraduates
@MsSomeonenew
@MsSomeonenew 7 жыл бұрын
But what if you are only a private?
@AhsimNreiziev
@AhsimNreiziev 7 жыл бұрын
Aside from what you mentioned, there is also the difference -- and the tradeoff -- between *time performance* and *space performance*. Due to the fact that Memory Management is *hard*, programs run in C will often have quite a bit of Memory Leakage going on. Just open any Internet Browser in Windows, say, then open the Task Manager, go to the process that runs said Internet Browser in the "Processes" tab of the Task Manager, and do nothing while watching how much memory the process occupies in memory. I guarantee you that, for virtually all Browsers out there, over the course of let's say an hour, you will steadily see the amount of memory these processes take up increase, and never really decrease all that much. Now, due to the very Garbage Collection that the video mentioned costs time when running a Java Program, Java Programs will not have the issue of Memory Leakage. So C Programs might be more Time-Efficient -- plus they can communicate with the hardware better -- but they'll generally be less Space-Efficient.
@lordtejas9659
@lordtejas9659 4 жыл бұрын
Moral: C is faster than Java
@jscorpio1987
@jscorpio1987 4 жыл бұрын
C and Java are just text. They don’t do anything. It’s the compiler/implementation that actually create a computer program.
@becomepostal
@becomepostal 4 жыл бұрын
So?
@pow9606
@pow9606 4 жыл бұрын
Moral of the story is less instructions runs faster than more instructions... More instructions requires more power and juices the battery.
@lordtejas9659
@lordtejas9659 4 жыл бұрын
@@pow9606 Isn't that Same since C is static and Take almost Equivalent Assembly like Instructions! So That's same! Since whole code gets converted to assembly first then Binary! While Java has Little bit of Dynamic Functionalities!
@lordtejas9659
@lordtejas9659 4 жыл бұрын
@@jscorpio1987 They don't create the convert the Code to Equivalent Assembly then Binary....If you want to be more Precise!
@neonz2712
@neonz2712 4 жыл бұрын
What about the executable size? I know this a 3-year-old video, but I would like to know the sizes of each if you still have the executables available to you.
@LLLLLLEON216
@LLLLLLEON216 7 жыл бұрын
This is what I call "tech". Most "tech" channels on KZbin are actually just channels that talk about accessories or user experience.
@nsonnson
@nsonnson 7 жыл бұрын
Totally amazed by that amount of effort paid off by Gary and every guy in Android Authority to run this test!!
@redjammie8342
@redjammie8342 7 жыл бұрын
Am I the only one who got very annoyed by "Object Orientated" >
@awsm1680
@awsm1680 4 жыл бұрын
No
@FahadAyaz
@FahadAyaz 4 жыл бұрын
I'm surprised so few comments on that. Makes him seem a no0b, which he clearly is not.
@ObserverZero
@ObserverZero 4 жыл бұрын
Java is more "Class Hell" than Object Oriented.
@puncheex2
@puncheex2 7 жыл бұрын
A few things: 1) You become object orientated when you can orient your objects. :) 2) Yes, C is not object oriented, but C++ and C# are. Your comparison would be better if you'd have taken the high road here. You could point out that Java was designed to be OO from the start, whereas C had to go through some contortions to fit the armor on. 3) there's little difference in speaking about a virtual machine vs a machine compiler; they do essentially the same thing. The advantage is all for the compiler here: the machine doesn't have to be loaded or run to run the app.; less memory, better performance, and the programmer is in charge of running whatever GC he invents when he's ready. This fact is m/l proven by the drive to do pre-compiling and get rid of the most of the Java machine. 4) No, C isn't object oriented, as pointed out above, but C++ is. Garbage management is an adjunct of object oriented programming; in a non-OO the stack does the work, but stacks aren't OO so they can't be used with them. C doesn't have automatic memory management, but Java, C++ and C# do. 5) It would be more elegant (and correct) to say the garbage manager recycles memory, rather than discarding it. again, :) What it comes down to in the end is a preference for the language the programmer has to use, and the tools in the respective programming environments, and, as you say, availability of necessary APIs. Learning curve? bout the same for Java or C++/C#. Its learning those APIs and the libraries that is the real pain, and where comparing documentation modes might also be useful. Thanks for the exercise. I started programming in FORTRAN back in 1968; OO was introduced in, ahem, middle age.
@medilyesoudhini7411
@medilyesoudhini7411 8 жыл бұрын
Jaaava
@medilyesoudhini7411
@medilyesoudhini7411 8 жыл бұрын
Haha same here
@generessler6282
@generessler6282 4 жыл бұрын
Nice discussion, but the implication that garbage collection is necessarily slower than malloc/free is not accurate. Certainly it's bad when GC chooses to run at an awkward time. But in a program that does serious memory management, freeing space eagerly and explicitly per object can easily take more work than good copying GC because the latter's effort is proportional to the size of _allocated_ objects when the collector finally needs to run. Free objects are just that: free. The former does work proportional to the total number of alloc and free operations.
@nejrany
@nejrany 8 жыл бұрын
40 Java programmers disliked video
@domsau2
@domsau2 7 жыл бұрын
So, in Android, C vs Java is maximum is 500 times slower. Not a problem for some basic applications.
@shahinmodaresenshayi3576
@shahinmodaresenshayi3576 6 жыл бұрын
Do not want to be rude but I'm sure you are not a professional C programmer and you don't have a true understanding of C compiling process If you had the results would be diffrent.
@CarrotCakeMake
@CarrotCakeMake 7 жыл бұрын
The advantage of C is memory management. Integer arithmetic should be nearly the same between C and Java, those huge differences are a bit surprising. But for a proper test, you should write a program that requires major memory management...like a minimax searcher that uses a redblack tree to keep track of passed states. And no using standard libraries (which in java are probably written in C or ASM anyway). You'll probably find the C program finishes before the java program can even barely start.
@toobnoobify
@toobnoobify 7 жыл бұрын
_"Java is rather unique"_ ...except for a little known language called C#?
@jub8891
@jub8891 5 жыл бұрын
yeah... a little known language that came 5 years later...
@comicsans1689
@comicsans1689 5 жыл бұрын
C# started as J++, which was Microsoft copying Java and hiring some smart dudes to make improvements to it. At one point, Sun Microsystems sued Microsoft (probably because they were asshurt) and Microsoft changed the name to C# to distance itself.
@kilokartofli1
@kilokartofli1 7 жыл бұрын
There is way to write Android program in C(or c++) without java?
@lorantviktorgerber4809
@lorantviktorgerber4809 7 жыл бұрын
h jtyj Android NDK
@sud19891
@sud19891 7 жыл бұрын
reason behind why iPhones are faster than any Android phone...
@AndyTurfer
@AndyTurfer 7 жыл бұрын
Sudarsshan Telangi Gary did another video comparing the performance of an iPhone to a modern Android phone. Spoiler alert: have some tissues close by if you're an Android fan.
@kriss2005
@kriss2005 7 жыл бұрын
Only if you're a gamer. And only the loading screens.
@valinkdevr5520
@valinkdevr5520 7 жыл бұрын
kriss2005 "gamer"😂😂
@GTechFam
@GTechFam 6 жыл бұрын
oneplus 5 is actually faster than any iphone
@groberti
@groberti 6 жыл бұрын
It is not the fault of Java. I've just got my 7.1.1 update and it seems really smooth.
@AntonioBarba_TheKaneB
@AntonioBarba_TheKaneB 6 жыл бұрын
It's been several years that the server JVMs were almost as fast as C and C++, what held Android back was the horrible Dalvik implementation. Now we are seeing what a decent Java runtime can do. 30-50% slower than C on average is a very good result, but it would be nice to see better support for Android APIs from the C side, since at the moment there's really a brick wall between the JVM and the JNI interface. The tests where you see Java surpassing the C compiler are probably caused by latencies within JNI rather than the C code itself being slower. It would be nice to see C as a first class citizen, just like iOS and the good old BlackBerryOS 10.
@223Warlord
@223Warlord 7 жыл бұрын
damn... im gonna ditch java and learn c++ instead.
@americanswan
@americanswan 7 жыл бұрын
GAO Xiang2 Java is very very good and popular, just ignore the stupid structure of Java. Learn Qt for C++.
@groberti
@groberti 6 жыл бұрын
if you want to be an Android developer learn Java
@prim16
@prim16 6 жыл бұрын
If you're a real programmer, you don't "ditch" languages. You produce programs based on which language is most PRACTICAL for that one.
@groberti
@groberti 6 жыл бұрын
But that also means that you are not that proficient with any one language. Knowing the programming language itself is basically the easy part. The C - like languages are really similar to one another. The problem is that you have to learn to use the whole platform / a bunch of frameworks which can be really different from one another.
@not_my_name5200
@not_my_name5200 6 жыл бұрын
"I'm gonna ditch fruit ninja and start playing dark souls for casual fun!"
@reneb86
@reneb86 4 жыл бұрын
This is just arithmetic, the simplest of simplest to implement computing feature. Try adding tests where you have to allocate and deallocate gigabytes of data (like any app with a dynamic GUI would). Also try doing something with strings, or move to a Java vs C++ comparison, and bench some OO paradigms (like just about any app would). Java will be at least 100x slower.
@tzacks_
@tzacks_ 7 жыл бұрын
Java faster than C, what a fairytale :-)
@Matthew-dd6kp
@Matthew-dd6kp Жыл бұрын
My view is both have benefits and everyone should get along. I prefer Java because I find it more orderly and 99% of applications I design don't need the performance benefits that come with C.
@0xssff
@0xssff 4 жыл бұрын
Lol did you just compare C to Java? Wtf 😂
@KaranBulani
@KaranBulani 8 жыл бұрын
please do a comparison between C#and Java or something including C#
@MisterBadNews
@MisterBadNews 7 жыл бұрын
I hate every language which contains J in it.
@MisterBadNews
@MisterBadNews 7 жыл бұрын
Java also!
@ChrisD__
@ChrisD__ 7 жыл бұрын
Viorel I like one of them
@seanm1328
@seanm1328 7 жыл бұрын
-Japanese- / "Nippon" ✅
@herikaniugu
@herikaniugu 7 жыл бұрын
I bet you are poor in web programming cuz a website sucks without JavaScript
@MisterBadNews
@MisterBadNews 7 жыл бұрын
I also write web code, but C is my first love.
@justusonuoha8224
@justusonuoha8224 6 жыл бұрын
Cool comparison but Usually, mathematical computations speed partly depend on compiler optimization, a better test could be manipulation of strings of data retrieved from local file while allocating and freeing memory (in c of course)..my thoughts.
@bijaygautam9904
@bijaygautam9904 7 жыл бұрын
Americans- there is difference between c and java British - thea i defe betwee c ai ava
@KnownNever
@KnownNever 7 жыл бұрын
As someone who works a lot with Android NDK, unless you are doing graphics or some sort of real-time processing, like DSP, the learning curve to learn NDK is not worth it
@LAG09
@LAG09 8 жыл бұрын
Hang on a minute? Is the guy wearing *TWO* watches? I.e one on each hand. Talk about dressing up like a complete dork...
@jackcimino8822
@jackcimino8822 8 жыл бұрын
L_A_G The watches could be set to different time zones
@matthiass.3134
@matthiass.3134 7 жыл бұрын
It looks more like a watch and a activity tracker .....
@neilbertmillar9960
@neilbertmillar9960 7 жыл бұрын
the other one is not a watch but a smartband
@TNTsundar
@TNTsundar 7 жыл бұрын
This is a very much controlled test where the program uses very little memory and repetitive processing. This is only a minuscule when compared to the real applications which practically uses a lot of memory and a variety of functions that uses the CPU, Cache, etc to the max (think of games). The java performance would be far less is those situations. Well there's always a performance difference when some interpreter is involved.
@newbprogramming5043
@newbprogramming5043 8 жыл бұрын
Generally Java developers are so annoying, their "valid points" are always invalid. A few notes to this video: - Yes C is not object oriented, but C++ is, and you can use that as an alternative to C. - Anything interpreted by a engine via. bytecode will never be as fast as running natively in machine code, which C / C++ gets compiled down to. - Even C# gets compiled down to machine code, Java needs to get with the program (Java does have JIT though). - If you want to use a secondary language more advanced languages are Lua and JavaScript. These two perform way faster than Java and are interpreted languages as well. These have fantastic memory management and garbage collection systems as well. - Uninstall Java if you havn't already, there are many known security flaws.
@GarySims
@GarySims 8 жыл бұрын
+Newb Programming Indeed, C++ is an OO language, I didn't go into that, as it isn't the main point of the video. Also C# doesn't get compiled to machine code, it also get compiled to an intermediate language called CIL.
@newbprogramming5043
@newbprogramming5043 8 жыл бұрын
+Gary Sims Thanks for that correction. According to Microsoft, CIL is basically like JIT but a Microsoft version... which would mean C# should run slower at the machine level, because we all know Microsoft, heh.
@KurosuKirie
@KurosuKirie 7 жыл бұрын
Its not excatly native, but .NET native will compile C# to use win32 whenever possible so it will got speed boost, dont know if it ever as fast as c++ or not.
@newbprogramming5043
@newbprogramming5043 7 жыл бұрын
Glad you said that because .NET Core was introduced this year (well 2015, but not widely known), C# can now be compiled as if it were C and run on anything. Microsoft is really trying to spy on people from other operating systems so they're trying to give native support to developers just to prove Microsoft products are better. www.microsoft.com/net/core
@newbprogramming5043
@newbprogramming5043 7 жыл бұрын
C runs on anything UNIX (which is ran on just about everything we use).
@Foro5Cibercafe
@Foro5Cibercafe 7 жыл бұрын
Wait a minute, what happens is Java is written in C and Android is written part in C and part in Java, the C part handles Java, so there is no way Java can be faster than C, Android makes C slower than Java because now it does the task viceversa, the optimized JVM which drives Android and is called Android, creates a CVM C virtual machine
@VainRegret
@VainRegret 8 жыл бұрын
And that's why iOS is faster than Android.
@orifl6653
@orifl6653 7 жыл бұрын
No.
@arnsassassiner
@arnsassassiner 6 жыл бұрын
Thiago Anderson Martins yeah, no wonder the $1000 iphone x loses to a $500 oneplus 5t in speed test . pfff
@MiscellaneousAdventures
@MiscellaneousAdventures 6 жыл бұрын
Objective C is not C
@etmax1
@etmax1 7 жыл бұрын
One thing you mucked up badly on was that it's irrelevant whether you do 1 iteration or 1 million in a comparative sense except that it averages out interruptions that occur to normal program flow due to OS needs, i.e. if all machines/languages run the SAME number of iterations. and it's enough to average out the random OS incursions i.e. 1000 or 10 billion iterations, the results will be the same.
@sghaiermohamed2905
@sghaiermohamed2905 7 жыл бұрын
Just give us the results damn you
@typingcat
@typingcat 8 жыл бұрын
The problem for me was not Java's speed, but its lack of features. I never realised how feature-rich C# is until I used Java for Android... I used to think they were more or less the same...
Why Are Open Source Alternatives So Bad?
13:06
Eric Murphy
Рет қаралды 635 М.
Rust: When C Code Isn't Enough
8:26
CodeAhead
Рет қаралды 160 М.
АЗАРТНИК 4 |СЕЗОН 2 Серия
31:45
Inter Production
Рет қаралды 1 МЛН
WILL IT BURST?
00:31
Natan por Aí
Рет қаралды 48 МЛН
He bought this so I can drive too🥹😭 #tiktok #elsarca
00:22
Elsa Arca
Рет қаралды 55 МЛН
What is cache memory - Gary explains
9:09
Android Authority
Рет қаралды 163 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 805 М.
The Most Legendary Programmers Of All Time
11:49
Aaron Jack
Рет қаралды 559 М.
What is a GPU and how does it work? - Gary explains
11:32
Android Authority
Рет қаралды 227 М.
What is a kernel - Gary explains
9:50
Android Authority
Рет қаралды 957 М.
Comparing C to machine language
10:02
Ben Eater
Рет қаралды 5 МЛН
Coding Was HARD Until I Learned These 5 Things...
8:34
Elsa Scola
Рет қаралды 405 М.
Every Programming Language Ever Explained in 15 Minutes
15:29
Flash Bytes
Рет қаралды 325 М.
What is a VPN? - Gary explains
13:09
Android Authority
Рет қаралды 1,3 МЛН
Игровой руль - штука годная 👍
0:50
RxFx
Рет қаралды 3,2 МЛН
iPhone 16/Pro Impressions: The Great Separation!
16:14
Marques Brownlee
Рет қаралды 10 МЛН
D3 XIAOMI SU7 MAX
14:25
smotraTV
Рет қаралды 515 М.