Switched from Java to Python for DSA practice. First thing that broke my code? The modulo operator. Not because I didn't know how it works — but because it works differently depending on the language, and I had no idea. In Java/C++, % follows the sign of the dividend: -7 % 3 → -1 In Python, % follows the sign of the divisor: -7 % 3 → 2 I was solving a prefix sum problem. Logic was right, approach was right, wrong answers. Took me embarrassingly long to find it. Once I did, I started noticing more: → Division: Java's 7/2 = 3 (integer). Python's 7/2 = 3.5 (decimal). Use // for integer division. → Floor vs truncate: Java truncates toward zero. Python floors toward negative infinity. -7 // 2 → Java: -3 | Python: -4 Same symbols. Different contracts. No errors thrown. Fewer lines of code. More silent assumptions waiting to bite you. #Python #Java #DSA #LearningInPublic #CompetitiveProgramming
Python vs Java DSA: Modulo Operator Differences
More Relevant Posts
-
After years of Java, I finally tried Python. Honestly? I didn't expect to enjoy it this much. No semicolons. No curly braces. No type declarations. Just... clean, readable code that almost reads like English. As a Java developer, some things caught me off guard: → Returning multiple values without creating a class → List comprehensions replacing 5 lines with 1 → Decorators that actually execute code (unlike Java annotations) → Context managers that feel conversational I wrote about my first impressions — the good, the surprising, and where I still trust Java more. If you're a Java developer curious about Python, this one's for you. #Python #Java #SoftwareDevelopment #Programming #LearningInPublic
To view or add a comment, sign in
-
🐍 Access Modifiers in Python — What Every Developer Should Know! Coming from Java or C++? You might expect Python to have strict private and public keywords. It doesn't — and that's by design. 🎯 Python uses a naming convention to signal access intent: 1️⃣ Public → self.name Accessible from anywhere. The default for all attributes and methods. 2️⃣ Protected → self._name Single underscore. A gentle signal for "internal use" — still accessible, but handle with care. 🔓 3️⃣ Private → self.__name Double underscore triggers name mangling → _ClassName__name. Harder (but not impossible) to access from outside. 🔒 💡 Python's philosophy: "We're all consenting adults here." It trusts developers to respect conventions rather than enforcing hard rules. Understanding this is key to writing clean, maintainable, Pythonic OOP code. #Python #PythonProgramming #OOP #ObjectOrientedProgramming #SoftwareEngineering #CodeNewbie #PythonDeveloper #Programming #TechLearning #CleanCode #100DaysOfCode #LearnPython #BackendDevelopment #DevTips #PythonTips
To view or add a comment, sign in
-
Zero-copy data sharing between Python, Java, C++ without serialization overhead. That's Apache Arrow. Arrow is not a file format. It's an in-memory columnar format. The Arrow ecosystem: Arrow: language-agnostic in-memory columnar format. Arrow Flight: high-performance RPC over gRPC. No more JSON/CSV serialization tax. Flight SQL: send and execute SQL queries over Flight. ADBC: standardized API for Arrow-native database interactions. DuckDB, Polars, DataFusion, Spark - they all use Arrow under the hood. If you're building anything that moves data between processes, Arrow is the standard to know. https://lnkd.in/dfXtSSwN
To view or add a comment, sign in
-
-
Stop choosing between Java and Python. In 2026, the market demands "Dual-Stack" proficiency. The roadmap to becoming a high-performance architect has changed. With Java 26 arriving and AI integration becoming the standard, mastering both Java and Python is no longer optional - it's a competitive advantage. At MyExamCloud, we use our proven PPA (Plan, Practice, Achieve) methodology to ensure you don't just study-you certify. Link in comments. #Java26 #PythonCertification #SoftwareArchitecture #MyExamCloud #CareerGrowth
To view or add a comment, sign in
-
When I recently posted about the speed-up in Mark Burgoyne's pyResToolbox using Rust, there was some push back concerning the Rust benchmarks as I was showing that my Java implementation was faster. https://lnkd.in/dgk-WyZA The general comment was that Rust should be faster than Java. I'd agree. Rust is compiled ahead of time and can optimise the compiled code for the target CPU. Java is compiled using a [just-in-time compiler](https://lnkd.in/deEMcCnm) from bytecode that is generated to be run on any CPU. Since my previous intent was just to show Java versus Python, or Java versus Python with Rust acceleration in a casual way, I decided to undertake a more comprehensive comparison which would allow fairer comparison. Mark Burgoyne has supplied a [variety of code examples](https://lnkd.in/dm7HyCd9) for the BNS viscosity method, including a pure Rust implementation and VBA for Excel. The results for this more comprehensive comparison are shown in the image along with this post. Note the logarithmic scale for calculations per second! Note the difference between single pressure and multiple pressure, is that multiple pressure does calculations for an array of pressure points on the same composition, so the loop can be optimised. This shows that Rust with parallel threaded execution for the multiple pressure point solutions is by far the fastest implementation, reaching ~ 61 million calculations per second. In comparison VBA for Excel manages a paltry 772 calculations per second. Rust is about 80,000 times faster, or nearly 5 orders of magnitude. As a long time advocate that most speed comes from the algorithm design itself, it is still remarkable to see just what a difference the language and environment makes. Remember, these are benchmarks for an **identical** algorithm. The difference is purely the language implementation. This dramatically illustrates the difference between speed and convenience. Where Excel and Python are (arguably) more accessible, parallel algorithms in Java and Rust deliver better speed. I think the Rust-accelerated Python solution that Mark wrote is a good compromise between the two. As an aside, this is the first Rust code I've ever written / used. I'm pretty impressed.
To view or add a comment, sign in
-
-
A common pattern in FastAPI code bases, one that is used in all example code, is to have a global variable which represents the SQL connection pool. The only problem with this pattern is making sure no class or function pulls it in directly, inline, where it can'tbe mocked. It's hard because so much of your code will depend on it. You'll quickly see why Java and C# used dependency injection as a standard design pattern. The question, then, is "Why?" And the answer is simply all your "unit" tests will now require a DB instance. Nothing says "fun" like watching all your test code blow up because someone forgot this (sometimes you're the someone.) Then you get to unravel layer upon layer of code. Claude can't do it all for you. #code #python
To view or add a comment, sign in
-
Switching from Python to Java: Coming from a Python-heavy background, working with Java has been a real shift in perspective. In Python, a lot is taken care of for you through powerful high-level abstractions. You can move quickly, write less code, and focus on solving problems. But Java? It makes you slow down in a good way. You start paying attention to details you might have overlooked before: type definitions, structure, and the mechanics behind what your code is actually doing. It demands more explicitness, more discipline, and a deeper level of understanding. And that’s the beauty of it. Different languages, different strengths, but stepping outside your comfort zone is where real growth happens. https://lnkd.in/deNbabM5 #Java #Python #SoftwareEngineering #CodingJourney #LearningToCode
To view or add a comment, sign in
-
-
Every insight Potpie delivers about your codebase starts with parsing. Our context engine builds a complete map of your codebase: its structure, its components, its relationships into a knowledge graph that agents can use to navigate and query code faster. Currently, it supports more than 15+ languages including python, typescript, java etc. We understand that parsing large repositories is inherently time-consuming, but it shouldn't slow you down. That's exactly why we rebuilt this critical functionality in Rust: to make understanding your codebase faster, without any performance compromise. Our benchmarks show approximately 30% faster parsing for repositories with 1M+ lines of code, with the performance gap expected to grow significantly for larger codebases. Looking ahead, we plan to introduce parallelization of the parsing pipeline to use multi-core threading for processing files simultaneously without Python's GIL constraints. This allows us to handle enterprise-scale repositories with sub-minute indexing times.
To view or add a comment, sign in
-
⚡ Why Java Still Wins in 2026 (Performance Reality) Is Python really “too slow” for modern systems? We’ve all heard: • Python is easier • Python has better libraries • Developer speed > machine speed That’s true… until you hit production scale. 💥 At scale: • Latency becomes visible • Infrastructure costs increase • Concurrency becomes a real bottleneck This is where Java still has a strong edge. 🧠 JVM optimizations (like JIT compilation) allow Java to handle high-load systems far more efficiently — sometimes dramatically so, depending on the workload. That said — Python is still the right choice in many scenarios (especially AI, data, and rapid prototyping). The real question isn’t “Which is better?” 👉 It’s “When should you use which?” I break this down in detail here: https://lnkd.in/dVjP3x4S Curious — what are you using in production today? #Java #Python #SoftwareEngineering #Backend #SystemDesign
Java vs Python Performance Comparison 2026 | Scale and Performance
https://www.youtube.com/
To view or add a comment, sign in
-
🔥 𝗗𝗮𝘆 𝟵𝟰/𝟭𝟬𝟬 — 𝗟𝗲𝗲𝘁𝗖𝗼𝗱𝗲 𝗖𝗵𝗮𝗹𝗹𝗲𝗻𝗴𝗲 𝟭𝟱𝟯𝟵. 𝗞𝘁𝗵 𝗠𝗶𝘀𝘀𝗶𝗻𝗴 𝗣𝗼𝘀𝗶𝘁𝗶𝘃𝗲 𝗡𝘂𝗺𝗯𝗲𝗿 | 🟢 Easy | Java Marked as Easy — but the optimal solution is pure binary search brilliance. 🎯 🔍 𝗧𝗵𝗲 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 Given a sorted array, find the kth missing positive integer. Linear scan works — but can we do O(log n)? 💡 𝗧𝗵𝗲 𝗞𝗲𝘆 𝗜𝗻𝘀𝗶𝗴𝗵𝘁 At index i, the value arr[i] should be i+1 in a complete sequence. So missing numbers before arr[i] = arr[i] - 1 - i This lets us binary search on the count of missing numbers! ⚡ 𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵 — 𝗕𝗶𝗻𝗮𝗿𝘆 𝗦𝗲𝗮𝗿𝗰𝗵 ✅ If arr[mid] - 1 - mid < k → not enough missing numbers yet, go right ✅ Else → too many missing, go left ✅ After the loop, left + k gives the exact answer 𝗪𝗵𝘆 𝗹𝗲𝗳𝘁 + 𝗸? After binary search, left is the index where the kth missing number falls beyond. left numbers exist in the array before that point, so the answer is left + k. No extra passes needed. ✨ 📊 𝗖𝗼𝗺𝗽𝗹𝗲𝘅𝗶𝘁𝘆 ⏱ Time: O(log n) — vs O(n) linear scan 📦 Space: O(1) This is a perfect example of binary searching on a derived condition, not just a value. A real upgrade from the naive approach. 🧠 📂 𝗙𝘂𝗹𝗹 𝘀𝗼𝗹𝘂𝘁𝗶𝗼𝗻 𝗼𝗻 𝗚𝗶𝘁𝗛𝘂𝗯: https://lnkd.in/gVYcjNS6 𝟲 𝗺𝗼𝗿𝗲 𝗱𝗮𝘆𝘀. 𝗧𝗵𝗲 𝗳𝗶𝗻𝗶𝘀𝗵 𝗹𝗶𝗻𝗲 𝗶𝘀 𝗿𝗶𝗴𝗵𝘁 𝘁𝗵𝗲𝗿𝗲! 🏁 #LeetCode #Day94of100 #100DaysOfCode #Java #DSA #BinarySearch #Arrays #CodingChallenge #Programming
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development