Тёмный

Python in 8 minutes (compared to Java) 

NeetCode
Подписаться 755 тыс.
Просмотров 70 тыс.
50% 1

🚀 neetcode.io/ - A better way to prepare for Coding Interviews
🐦 Twitter: / neetcode1
🥷 Discord: / discord
🐮 Support the channel: / neetcode
Coding Solutions: • Coding Interview Solut...
0:00 - Java printing text
2:00 - Python printing text
2:30 - Java storing data
3:40 - Python storing data
4:30 - Java Loops
6:00 - Python Loops
Java vs Python java or python
#python #java #neetcode
Song: Bamboo by Oak Studios
Creative Commons - Attribution ND 4.0
• [Royalty Free Music] B...

Наука

Опубликовано:

 

20 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 133   
@blankfornow.7690
@blankfornow.7690 3 года назад
"Texas Smash" "Detroit Smash" Someone likes My hero Academia.
@jathebest2835
@jathebest2835 Год назад
Lmao.. I wondered why he used a weird relation.. I thought 'Did he undervalue Detroit or whaaaaat'
@ZedsDeadXO
@ZedsDeadXO 2 года назад
I can really see the benefits of learning Java instead of Python as your first programming language as someone who's just about to finish his first semester in computer science. Java teaches you A LOT of fundamentals that are done in the background for you in Python. The steps leading to learning Python if you know Java are also going to be much easier than the opposite.
@aragonnetje
@aragonnetje 2 года назад
Honestly, i disagree. As someone who started in python, the ease of use really helped me learn the basics of programming and through working on a project in python i discovered the value that OOP and static typing can have, which helped me appreciate many features in java which otherwise just felt like bloat.
@ZedsDeadXO
@ZedsDeadXO 2 года назад
@@aragonnetje We'd just have to agree to disagree, as we seem to have completely differing philosophies in our approach to learning programming. I still prefer having knowledge of the fundamentals so that you're fully equipped from the ground-up.
@gbagba81
@gbagba81 2 года назад
Guys I really need some advice about this. I don't know if getting into java or python because I don't really know what's more convenient. Let's say I get into jpa hibernate, is it different from learning sqlalchemy or storm if I were doing python? Thanks a lot
@FG-td4vs
@FG-td4vs 2 года назад
@@gbagba81 I would go with java
@gbagba81
@gbagba81 2 года назад
@@FG-td4vs oh, I have already started with python xdxd. Thanks a lot for the advise though. I know I'll be into java at certain moment in the future
@NeetCode
@NeetCode 3 года назад
My first programming language was C, so I loved Java when I started it. Then i discovered python! Thank you for watching, feel free to leave any feedback! like/sub to support the channel it helps out a lot : ^ )
@jer_sr
@jer_sr Год назад
What editor are you using here?
@AlexBastuba99
@AlexBastuba99 3 года назад
This is a great intro to some of the differences, thank you.
@Skycrafter_
@Skycrafter_ 3 года назад
In Java you could've done data.forEach((k, v) -> System.out.println(k + "=" + v)); Also for the hashmap: Instead import static java.util.Map.entry; Map map = Map.ofEntries(entry("Texas", "Smash"), entry("Detroit", "Smash")); If you learn Java properly, you can make the code as short as python, and (in my opinion) more readable
@kjul.
@kjul. 5 месяцев назад
Not for beginners though. I'm an experienced Java and TypeScript developer, and holy hell this line "Map map = Map.ofEntries(entry("Texas", "Smash"), entry("Detroit", "Smash"));" is going to confuse the fuck out of anyone trying to learn programming, I guarantee you. Python does a lot "behind the scenes" but is still more predictable than plain JavaScript, so even though I myself started out with Java, I greatly value Python for its simplicity. Every language has its purpose.
@surya8985
@surya8985 Год назад
I was comfortable with python earlier and used to code in python as its very easy to code. It helped me build ml models too.But my company told me to learn java/cpp as it is more useful there. Now i forgot python and coding in java and feeling bad as i missed python 😔.
@saksham9170
@saksham9170 3 года назад
Cool, I'm gonna do leetcode in python from now on. That way I can more focus on the logic and pattern rather than the code. Thanks!
@raiyan22
@raiyan22 2 года назад
bro what phase are you on right now?
@saksham9170
@saksham9170 2 года назад
@@raiyan22 I ended my leetcode grind a while ago, I got an offer from amazon, most of my work is ironically in Java/spring now 😂
@raiyan22
@raiyan22 2 года назад
@@saksham9170 dyammm 💥💥💥 Congrats bro! 🎉🎊 Could I please connect with you? I would really use some help perhaps
@gunahawk6893
@gunahawk6893 2 года назад
@@saksham9170 bro can i use python for dsa and interviews in big tech or faang
@gaugea
@gaugea 2 года назад
@@gunahawk6893 Yup
@Lara-zw4vb
@Lara-zw4vb 2 года назад
Thank you for this video! Starting to learn these two languages, very fascinating to see the similarities and differences between these programming languages.
@suryac850
@suryac850 2 года назад
I have used java for almost 4 years at work and used to LC in java for a long time. But now I have decided to move to Python because it saves time during the interview.
@RustedCroaker
@RustedCroaker Год назад
The perfect example of a wrong decision. Switch to C++ instead.
@freddymintarja2186
@freddymintarja2186 Год назад
@@RustedCroaker there's no right or wrong answer when it comes to learning new language
@RustedCroaker
@RustedCroaker Год назад
@@freddymintarja2186 Learning isn't a problem, moving in is.
@tanujarora4906
@tanujarora4906 Год назад
I am a java backend engineer. I still give all the interviews in python
@jinettew.3192
@jinettew.3192 2 года назад
love you man! Thanks for your amazing videos and advice. I've just begun my leetcode journey and I'm loving all of the learning curves, steep and easy. Your vids are perfect for me.
@AnnabellaGuzheng
@AnnabellaGuzheng 3 года назад
Oh nice! This is really helpful, me trying to learn Python syntax
@for_whom_the_bell_tolls
@for_whom_the_bell_tolls 11 месяцев назад
Actually in Java you can iterate over key/value pairs of hashmap too, using map.entrySet() method instead of map.keySet(), but still the syntax is not so concise as in Python for sure
@whytushar
@whytushar 2 года назад
You've got it all figured out. Python3 is the way to go for LC-style interviews. Would it be possible for you to make a video on the syntax and all for usage of various data structures in Python? This video could be just a compilation of all the operations commonly used in all the data structures in LC type questions. Basically just what would be enough to be able to convert english -> python code. Built-in functions used on the regular and other such tidbits. Having one 10-15 min concise video on this would greatly help!
@dinov5347
@dinov5347 8 месяцев назад
The java code above is the naive approach. The above java code can be rewritten as Map data = Map.of("Texas", "Smash", "Detroit", "Smash"); System.out.println(data); data.forEach((key, value) -> System.out.println(key + "=" + value));
@gradientO
@gradientO 7 месяцев назад
Wow that's elegant
@sap1363
@sap1363 3 года назад
Can you please add tutorials for java . you explain really well
@RatherPleasent
@RatherPleasent 2 года назад
IMO I learned Java first and enjoy using it for interviews. I also think the language is powerful when using TreeMaps, PriorityQueues, as well as being able to use Lambdas to dynamically define sorting or comparators. Haven't used Python enough to know if it has those things out of the box.
@RenanHiramatsu
@RenanHiramatsu 3 года назад
This is so true! And I started brushing up on my old python 2 weeks before my technical interview, god wish me luck! LOL
@hristokolev6016
@hristokolev6016 3 года назад
How did it go?
@_b001
@_b001 2 года назад
Is it ok to use JavaScript in interviews ? I've heard we can use c, c++, Java and python but never heard anything about people using scripting language like JavaScript.
@akhii2681
@akhii2681 Год назад
Hi sir As we know python is Comparatively slow because of its dynamically typing nature, being interpreted language and Global interpreter lock by garbage collection and also to tackle such issues we have like C extensions, threading and multiprocessing modules, Numba JIT, there is no one such standard python developer best practice to write the code which could match the speed of java and c++ a bit closer. So you being a python developer in such a big company,could you please share some standard applied practices to make the python code faster and make ourself feel we are confident about our preferred choice of programming language.. Thanks in advance
@JitendraSingh-lr4nu
@JitendraSingh-lr4nu 2 месяца назад
The execution speed doesn't matter, development speed does. For your kind information Instagram and Discord backends are powered by Python Django framework.
@ZackOfAllTrad3s
@ZackOfAllTrad3s 3 года назад
This is the best leetcode channel! That said I hate that you program in python. Too much is abstracted away, too much syntax sugar, which is not ideal when trying to learn.
@Eveproguides
@Eveproguides 2 года назад
It looks very clear but doesn't Java encourage better code and OOP? Readability?
@NeetCode
@NeetCode 2 года назад
I agree, if i was building a large project or API i would much prefer Java.
@nafis3294
@nafis3294 3 года назад
Kinda sad nobody picked up on the MHA references
@NeetCode
@NeetCode 3 года назад
now at least one person did :)
@uHnodnarB
@uHnodnarB 3 года назад
I was going to come here to say this lol.
@NeetCode
@NeetCode 3 года назад
@@uHnodnarB that makes two :)
@kaibluck1380
@kaibluck1380 3 года назад
i was going to coment that but you already commented it
@RM-xr8lq
@RM-xr8lq 2 года назад
i kinda wish my school started with python instead of java, it is a lot easier to get into, and would turn away less people from CS we went Java (basic OO programming) -> C/ARM (memory) -> C++ (ds + algo) -> electives (ocaml, verilog, javascript, etc.)
@Anthonydp
@Anthonydp Год назад
Blows my mind how simple Python is compared to Java
@MaxKar97
@MaxKar97 3 месяца назад
So Neet man, thank you for the refresher and with a nice example!
@kavinsp
@kavinsp 7 месяцев назад
1. The class name and filename should match only if the class is public, the visibility of public classes are throughout the project so it simplifies it. Single page application that isn't going to be reused have no reason to be public 2. var data = Map.of('NEET', 'code', 'Neet' , 'code'); would have acheived the same thing in a concise manner 3. data.forEach( (key, val) -> System.out.println(key + " = " + val)) Is a simpler one liner
@keyone415
@keyone415 2 года назад
I interview a lot of candidates, I don't know if this is a trend, but candidates who choose to do the coding in Python usually do better, and solve the problem I give them in time. For Java, it takes more time. Golang is in between, sometimes they write their own handy function during the interview that Python would have out of the box. Example: get max between two integers, or sum of all integers in an array, all these are one-liner in Python, you will need to write your utility function or import external library to do the same in other languages.
@FG-td4vs
@FG-td4vs 2 года назад
Well that does make sense, nothing to do with the competency of the programer tho
@mohithadiyal6083
@mohithadiyal6083 2 года назад
Finally someone who uses MHA as reference ;) 👍🏻
@ziedmarouani6257
@ziedmarouani6257 3 года назад
To be honest i liked the video until you added the elements to python dictionary by writing inside the dictionary , could have just wrote data["NEET"]= "code" , also same for java could have initialized the hashmap with the values or used Map.of ..
@boriskolomoiets5602
@boriskolomoiets5602 3 года назад
Don't forget about speed of this languages when you need to something real useful (not playing with console output),🙃
@boriskolomoiets5602
@boriskolomoiets5602 2 года назад
@Philotheos for ex Java
@heckervarun
@heckervarun 2 года назад
it could be done in other way..... dict={'neet':'smash','Neet':'Smash'} for i in dict: print(i,':',dict[i])
@jathebest2835
@jathebest2835 Год назад
You are right, my python dude.. Key-Value pair..😎
@Naranja93
@Naranja93 Год назад
I'm thinking about learning some python because Im interested in machine learning. So far I only know java and sql
@andiuptown1711
@andiuptown1711 6 месяцев назад
You are literally me lol
@cancergamingph8113
@cancergamingph8113 2 года назад
Java first semester python second semester. This video is very helpful 👍
@zombi1034
@zombi1034 4 месяца назад
void main() { System.out.println(" THIS IS JAVA "); var data = Map.of("Texas", "Smash", "Detroit", "Smash"); System.out.println(data); data.entrySet().forEach(System.out::println); } Using Java 21 with preview features. If executed inside the JShell REPL it goes down to 4 lines only, even less than the Python version :)
@B3Band
@B3Band Год назад
I'm glad I learned Java first. It would be really hard to learn Java after learning Python first
@yasinnkhann
@yasinnkhann Год назад
Texas, Smash... Somone's an All Might fan
@skycrow9594
@skycrow9594 Месяц назад
i learned python first, java and c# second, yes its less code for python, but i didn't understand what it truly did, and i wouldn't be able to create as much new stuff.
@rallealyt
@rallealyt 5 месяцев назад
Most of the times languages are compared just on syntax and how the code looks and all other aspects of the language are not considered. Also, many things in this video are not true nowadays. Java had a lot of innovation to simplify some of the syntax. But syntax isn't everything.
@ismaelfernandezmendez1664
@ismaelfernandezmendez1664 Год назад
Java is more verbose, but that's a good thing to me, it's like more clear to me. Also, I like the WORA philosophy.
@noname_hacke_9747
@noname_hacke_9747 2 года назад
For me java is better maybe python is good for you but I love java
@joshingaboutwithjosh
@joshingaboutwithjosh Год назад
People say python is great but java makes more sense to me
@c0dertang
@c0dertang 2 года назад
Java is hella more verbose, but when compared in speed... Edit: 3:26 NEETCODE WATCHES MHA?
@blasttrash
@blasttrash 3 года назад
If you already know Java or C++ etc, and only want to learn python for interviews, I would not recommend it. Its a waste of time. Instead spend time on learning DS/Algo etc. On the other hand, if you are just starting, then learn python, it will help you in interviews as well. I say this because 1. Typing speed is never a bottleneck in interviews. Mostly you will type at best 100 lines or less even in language like java. Also there are tricks in Java or C++ to reduce no.of chars for example. If you really knew Java, you could do Map map = new HashMap(); // or var map = new HashMap(); instead of doing what the youtuber did. Also you can use modern java's Map.of() method to initialize some of the stuff. Essentially to say that if you already know a language, dont waste time learning new language, just refine your skills in the above said language. For example, most of the people who think they know java dont know some of the above tricks(even leetcode solutions have verbose java where they dont use lambas etc). 2. If you are learning new language only for the sake of interviews, you will not learn enough and have half knowledge. You will not understand the time/space complexity of things like s[1:] in python. You will not be in a familiar territory in an interview when faced with such challenges. Again typing is never a bottleneck for interviews. Now if this was for competitive programming etc, I would of course agree that using c++ or python would help you tremendously depending on the question. But if you already know Java, C++, etc just use it. Dont waste time learning a new language. Once you get into FAANG etc, then you can learn a new language and after 2 or 3 years, then you can use the new language for interviews again when you are ready to jump to another FAANG. P.S Look into firenvim and neovim to get intellisense on any website for the most part.
@jsega996
@jsega996 2 года назад
This makes sense but even with your examples of shortening java, when you're trying to bang something out under the clock, I don't think I can agree that the required boilerplate of Java (still required even though you can remove a little) and enforcement of OOP structure, are not negatives in this scenario (while most would say at least the OOP part is a positive in a real project scenario). It's not simply the statement syntax but also the required structure, import statements, etc. You're just adding unnecessary bloat to a situation where you're simply trying to display that you comprehend and can solve a given problem.
@blasttrash
@blasttrash 2 года назад
@@jsega996 you missed the key point here. "if you already know java". Just for interviews, its waste of time to learn python. You will come of as a beginner in python if you are unable to explain tc of simple python stuff or dont know function signatures of some common string methods. This would take a long time to learn and is risky in an interview setting. Better to go with language that you are familiar with and all the shortcomings of java or any language that people mention are not that big of a deal is what I am saying. If leetcode styled interviews are asked, then there are hardly OOP questions and all the concerns that you mentioned are not a big deal. If its a LLD question, then most of the interviewers dont expect to run your code anyway. In which case, imports are not a big deal again. Also since you would be used to using java in day to day life, you would know what lombok is, the common Collections utils methods etc so its again not a big boilerplate anyway. Your concerns of encapsulation might be a problem only in this case and even here you could mention lombok etc to get away with most stuff. Also imports as a problem would exist in python as well(although not as much as java). For example heapq. Again if you already know a language very well, dont waste time learning python just for sake of interviews. If you do think you will use python in future for some other reason, yeah go ahead and learn it. But just for interviews its not worth it and you will be easily trapped if you make mistakes or give wrong answers for internals of python(intern equivalent, slice operator tc, etc)
@blasttrash
@blasttrash 2 года назад
@@jsega996 btw I have been part of some discord channels where we discuss and do mock interviews and I can code much faster than folks who are using python. Why? Because I know my language and have also learnt the tricks for leetcode(using short comparators, using sonarlint suggestions etc). If you are just starting, getting to this level with python is much easier and I would ask people to get started with python as well. But if you already know a language, it will take a longer time(more than for interview prep) to get decently comfortable at it so that it becomes muscle memory. For example I can code LRU, LFU cache faster than most people. And in fact the difference in no.of lines between java and python for such problems is very less and negligible(unless you do python code golfing at which point your interviewer wont understand it anyway)
@jsega996
@jsega996 2 года назад
@@blasttrash Interesting points, thanks for the response. The only language I know decently right now is JavaScript. I've only just begun leetcoding but I was thinking of picking up another language for more than one reason but partly because there are so many more good resources for this type of content with python, Java, and c++.
@markomarko3898
@markomarko3898 3 года назад
Awesome video! My first programming language was Python. And in my opinion, If you grow up on Python it is much more difficult to switch to Java than vice versa.
@muzzammilsblocks2000
@muzzammilsblocks2000 3 года назад
You mean switching from Java to Python is easier than switching from Python to Java?
@markomarko3898
@markomarko3898 3 года назад
@@muzzammilsblocks2000 Yup.
@JohnWick-lr6xg
@JohnWick-lr6xg 2 года назад
@@markomarko3898 which one is better and easy to learn for beginners?
@markomarko3898
@markomarko3898 2 года назад
@@JohnWick-lr6xg it depends on where are you heading: Web - Javascript ML - Python Android - Java iOS - Objective-C / Swift and etc. No programming language is easy, they differ visually but not logically since you achieve the same. But, if I were you, I'd choose based on two things: - How many educational resources are there online. - What first project do I want to make.
@JohnWick-lr6xg
@JohnWick-lr6xg 2 года назад
@@markomarko3898 thanks marko for the information But im basically from electrical engineering background who even don't know what is programming So i want to built strong foundation I heard java is too hard to learn And mess kinda ??
@KOl-xj4jt
@KOl-xj4jt 8 месяцев назад
python more difficult than java because in heavy programming gonna be lost thats why brackets good idea
@johnyvtk
@johnyvtk 3 года назад
I am a java developer, I hate this. Since I have more experience in java, it is hard for me to switching to python. I am so confused.
@Xyneex
@Xyneex 7 месяцев назад
Strict Data types and code compilation makes my day. Python sucks!
@pankaj3746
@pankaj3746 2 года назад
Oh Boy! Some people have no idea what they're talking about. Be happy by writing short code till your app crumbles badly under a load of millions of users due to slow performance. FYI -> I'm a VP of technology at an investment bank.
@keki4578
@keki4578 2 года назад
Java looks like the beginners’ coding nightmare
@Anthonydp
@Anthonydp Год назад
It is lol
@kmartin6582
@kmartin6582 2 года назад
It it bad idea to choose Python as your first language.
@collinsa8909
@collinsa8909 Год назад
I agree
@JavaCodeShorts
@JavaCodeShorts 7 дней назад
import java.util.Map; public class Main { public static void main(String[] args) { System.out.println("Hello world!"); var map = Map.of("key1", "value1", "key2", "value2"); map.forEach((k, v) -> System.out.println(k + " " + v)); } }
@XMine4Craft
@XMine4Craft Год назад
why no one talks about the my hero academy reference "ah yes I like Detroit"
@ivanzq21
@ivanzq21 2 года назад
I guess Java looks better 😄
@jay-rathod-01
@jay-rathod-01 3 года назад
😒 still your survey about java wins.😛 Please code in java or c++ bcz for people who dont know python syntax but knows the concepts actually cant figure out.😐
@MrVineesh27
@MrVineesh27 3 года назад
but java code looks so beautiful
@pastori2672
@pastori2672 5 месяцев назад
the days
@eragon3934
@eragon3934 5 месяцев назад
Lets not talk about wich one is faster ok.
@ShadowDev6969
@ShadowDev6969 3 года назад
first of all if you learned java first at school then you went to the wrong school
@NeetCode
@NeetCode 3 года назад
thats true, unfortunately a lot of schools teach Java in intro to CS courses so they can weed out students. (at least this is true in the U.S.)
@ShadowDev6969
@ShadowDev6969 3 года назад
@@NeetCode in the uk, year 7 CS you learn python. It's a ok first language but people should move on to other better languages. people should go. python, js, c#. That would create the base for them to learn more advanced languages.
@bobaGogo
@bobaGogo 3 года назад
@@ShadowDev6969 i disagree. If you learn a language like C# or Java first you learn a lot more programming concepts, like memory management or what the garbage collector is. It will give a really good introduction to what programming actually is. python will also become extremely easy to learn later.
@euler4513
@euler4513 3 года назад
@@bobaGogo I somewhat I agree with that you’re saying, the part that I don’t agree with is Java teaches you memory management; I think this is probably untrue, cuz why would you learn memory management when there is a garbage collector (which kicks in unexpectedly in some cases). I think if you wanna go deep into those things you’re free to that’s why c/ rust exists, but Java as a whole is too verbose and doesn’t explain concepts that transfer for one programming language to another. Yeah I’m slightly biased to Rust or C because it’s simple and not heavily verbose like Java omg why on earth would I need to say public every time why not assume public and then specify what’s private/ protected. It’s just annoying dealing with Java and I’m kinda stuck with it cuz I need to know it to pass Data structures and algorithms. 🥲
@Skycrafter_
@Skycrafter_ 3 года назад
@@euler4513 Omfg, typing p then pressing enter for autocompletion "public" is too much work. Java is way too hard to code 😱
@raghav5354
@raghav5354 Год назад
No java leetcoders were harmed in this video
@alexisxander817
@alexisxander817 Год назад
I am full blown machine learning engineer. I don't know why I am still watching this video lol
@sidsingh9165
@sidsingh9165 2 года назад
I prefer Java overall.
@collinsa8909
@collinsa8909 Год назад
Personally, I wouldn't recommend Python to anyone serious about being a programmer. It teaches some bad programming techniques
@storage7279
@storage7279 11 месяцев назад
Can u elaborate a little on those bad techniques?
@tunderues8061
@tunderues8061 2 года назад
Lies
@JJSmalls
@JJSmalls 2 года назад
C Programming Users laugh in pointer arithmetic
@TrendyLaughs
@TrendyLaughs Год назад
This make me watch MHA once again.
@user-rt2oq3dy9q
@user-rt2oq3dy9q 2 года назад
👍🏻👍🏻👍🏻👍🏻
@patrickpantea2037
@patrickpantea2037 2 года назад
Great video ! Jesus loves yall, may He bless yall as well !
@KiraLis39
@KiraLis39 6 месяцев назад
Лишний раз убедился, что Java лучше, спасибо. На фиг эту змею.
@andiuptown1711
@andiuptown1711 6 месяцев назад
😂
@hektorjasso7194
@hektorjasso7194 3 месяца назад
Python sucks tbh and you won't find any job opportunity outside in the real world, advise from a Full stack dev.!!
@Tokagawa89
@Tokagawa89 3 года назад
TEXAS SMASH! XD *MHA music commences*
Далее
5 Useful Dunder Methods In Python
16:10
Просмотров 55 тыс.
Beautiful gymnastics 😍☺️
00:15
Просмотров 10 млн
Stray Kids "Chk Chk Boom" M/V
03:26
Просмотров 31 млн
Python Vs C++ Vs Java!
4:41
Просмотров 473 тыс.
This Is Why Python Data Classes Are Awesome
22:19
Просмотров 796 тыс.
What is the Java Job delusion?
12:23
Просмотров 110 тыс.
Big-O Notation - For Coding Interviews
20:38
Просмотров 431 тыс.
8 Design Patterns EVERY Developer Should Know
9:47
Samsung laughing on iPhone #techbyakram
0:12
Просмотров 642 тыс.