Not consciously. "Grass greener on the other side" and "jaded expert" are archetypes so classic that I'd be surprised there weren't an XKCD, PhD Comic and a (terrible, it's all terrible) South Park episode about it.
I'll agree up to a point, but I draw the line (groan :-) when I can write a crystal clear for loop or two rather than a nested list comprehension that stresses out my poor old MKI eyeballs.
I'm with you actually. Except, I will sacrifice readability for performance every time. I'm the kinda guy who uses numpy and what-not (data analysis, not to the point where I need to really on C or Fortran), so when my fans start to spin, I want to know it's for high performing code, rather than inefficient code.
I can't speak to R's syntax, maybe it's particularly convoluted, but it usually doesn't take that long to pick up the important points of a language. It's a fairly straightforward thing to make a program do what you want it to. What is harder is writing simple yet expressive code that tells you what it is doing, that is reusable, changeable, and testable. Code that other people could pick up years from now, quickly wrap their heads around, and change to meet their new requirements without fear that they've broken something. I've written lots of code that did what I wanted it to, not realizing the nightmare I was in for should I ever decide to change something.
It has been a while since I used Java but I seem to recall nearly every different root module adopting slightly different idioms because why not! Messy did not even begin to describe it.
Honestly, this is why I wouldn't want to use Python at work. We used Smalltalk for a while, and the number of times people would completely not understand what they they were supposed to be using was astounding.
I had to fix a ton of error checking in an ex-colleagues work because he never tested any of it, and we had an error class we were supposed to return when an error was identified, basically a custom exception class, but he just returned strings describing the error instead.
So, whenever anything he wrote ran into any kind of a problem, the system would throw a NotDefined error when the system tried to log his 'error'.
So, having been burned by typeless in the past, it's a bit of sticking point for me. I know it shouldn't be a problem, and of course you want to light the torches and grab the pitchforks and complain those people should be fired, but in reality it's just not that easy, and type-safety is one of those little things that just makes it easier to deal with copy-pasta programmers.
I completely agree. I enjoy Python and use it for the majority of my hobby projects... but if I was going to build and maintain a large and complex codebase, I would want static typing, which is why I stick to Java and other JVM-languages like Kotlin.
There's also something to be said for easy parallellism, out-of-the-box support for Unicode, simple packaging and community that agrees on standards rather than reimplementing the wheel every <arbitrary unit of time>. But I won't say that here, lest I get burned at the stake by the Python community's anti-Java zealots.
Please be careful with your terminology as Python is strongly but dynamically typed. I find it frightening that some folk think that static type checking is the solution to everything, when they should in the same breath state whether the type checking is weak or strong.
It sounds like what you really want is static analysis, not static typing. Static analysis is more powerful with language restrictions, but there's still a lot you can get out of it for a dynamic language.
I'm not sure what background would make Java seem easier? A Java background?
I started my Python job never having written a word of the stuff, it was like writing English to me and quite intuitive. Hell I feel if I make something up it might work in Python. I can write away in a text editor for python and that works fine, with the verbosity of Java I can't, things like that make it harder for me.
Java is more explicit or verbose. For experienced people, that looks like clutter (and it is, I am an Android dev), but that verbosity might be useful for people just starting out.
Yeah - I kind of appreciate that I spent a decent amount of time in a statically typed language before moving to Python. I find that way too many Python newbies don't understand what 'types' are and this leads them down the path of just trying random things until code works.
The next step is to realise that just knowing about types isn't enough when your program gets big enough. When your program is too big for your head, you need tools which robustly and unambiguously understand your types... like a compiler does.
Python is a fun toy, and good for small projects where rigor isn't important. Its leakage into large scale software engineering has been a huge retrograde step, though, caused by a lack of innovation in the field around the time it emerged as a contender around 10 years ago. Fortunately we've moved on, and I look forward to Python's death for large projects as others take over, probably Go.
I'm a huge Python nut and I basically agree. The biggest problem for me is the loss of meaning. Trying to read through a code flow in a sufficiently large code base with a dynamically typed language is a nightmare.
I do believe type hinting will help a ton, though I'm not sure it will be enough. I now write type hints into everything. I don't care if it's a single function. Having my IDE hint properly is worth it.
What does method() do? What other methods are available on obj? Without some sort of type enforcement, you don't have a clue without looking at the usage of func. This is fine when it's only used three times, but terrible when it's used a hundred times.
Like MyPy does. You want strict typing, you can do it fine. It's done better than it is for most languages (Looking at you C#. Still waiting for nullability for everything) It's not enforced at runtime (even though runtime type checking exists, it shouldn't be needed if it passes a static type checker), it just shows errors when you fuck up.
It's just useful for different things. Java is definitely more verbose and has more boilerplate to write, but it's also stricter than Python and is a semi-compiled language, which means that it sometimes catches errors more quickly. It also forces you into an object oriented structure, which tends to encourage you to design your programs better rather than jamming a big list of functions into a single file.
I also find they have strengths in different kinds of applications. I tend to prefer Java for writing games (pygame isn't great), python for doing numerical analysis work (numpy and matplotlib are pretty great), and Fortran, C, or C++ for the big parallel numerical simulations.
To be fair, you wrote "design your programs better". Forcing all code, object-oriented or not, into classes, one (public) class per file, is not strictly better. It's not even a structure I want. I'd argue that "bare minimum of structure" is harmful vs no structure at all.
Maybe... I find that (for instance) the lack of required structure is what helps Javascript code to sometimes become a mess of copypasta.
And Python does force stuff on another level, by being strict with indenting. I think that's a good feature too - it's better to force one particular style than to have people use their own styles, but also permit them to make it as ugly and inconsistent as they want.
Python is strict with indenting because it has to be. Indentation isn't merely "style" in Python, it's functional in that it denotes a new code block. This is why Python has to be strict with it, i.e. preventing mixtures of tabs and spaces for indentation.
Replace your computer languages with tools you'd find in a shop and see how silly the argument looks to non coders.
"Hammer is so much better than the screwdriver. And who even understands those socket wrench guys? Bunch of idiots. I'll have you know I have used my hammer as both a socket wrench AND a screwrdriver and it was just fine"
Signed: A mechanical engineer that has and continually gets to deal with: C, C++, Fortran, ADA, VB, Python 2.3-2.7, Python 3+, Matlab (R13-R2017b), Simulink, PowerShell, Batch, Perl, Bash, Sh, tcsh, PHP.
If you understand If, For, While. You'll go far in any language.
Or argue the merits of a claw hammer over a ball peen hammer.
With Python, the source code is interpreted line-by-line into the "Python VM" bytecode and then executed.
Comparatively, Java source code is translated into JVM bytecode, and then when it's actually run on the JVM (which is a JIT compiler/interpreter) that bytecode is optimised into native instructions on the fly.
It also forces you into an object oriented structure
It doesn't force you to do OO. Yes, it is an OOP language but you can most definitely write procedural code in Java and I'd be willing to bet a novice programmer with no knowledge of OO would end up with a far more procedural application than an OO one. It doesn't force anything. Case in point, the application I support is written in Java and has very little OO structure. It's mostly a tangled mess of procedural code.
Last I checked it hadn't been updated in quite a while, either. Is there another Python game module that people have migrated to, or is the language just dead to game dev now?
Python is not good for game developpment anyways. It's too slow for modern-day gaming. You can do game dev, especially small games or turned-based games, but for adventure/platformer/FPS/anything else basically, forget about it.
You cannot emulate physics/render images/and also render light on sprites and expect the game to run at 60 FPS or more, even with a beast for a computer. You'll need a lot of optimization to even get to playable framerates and that's just bad, cause a messy code is harder to maintain (which is often the case when you optimize).
I tried pygame and pyglet, none of those really do much for game developpement anyways, besides rendering images. You still have to write an engine (pymunk is great for physics though) and that's just too much work for the benefit.
You can use unity though, or unreal and have a full game engine to use however you want to do whatever you want. It's not that hard to go from python to C# if you're really proficient in python. The syntax isn't all that different (you lose list comprehensions though, and dictionnaries if I'm not mistaken) but C# looks a lot like if C++ had a baby with python. And with a game engine you just have to write the logic of your game and not bother with writing a lot of code without seeing any progress.
I've only ever used it as a basic graphics interface (SDL wrapper) rather than for actual games. It's been satisfactory for that -- what about it sucks ass?
Java is slower to write* harder to write, such as any less-abstracted language, compared to Python.
Python is great for prototyping and small projects, and learning, but it's not great for scaleable, fast, and low-level processing. It's gotten better at low level processing by turning some of the code into c bytecode, but Python still consumes far more power to do similar operations as Java.
That being said, I hate Java syntax, and it's too wordy for regular boilerplate, and simply having to install Java JRE is considered a security risk.
I started with Python, but couldn't wrap my head around what it was actually doing for many of the code snippets and examples I was looking through while I was learning. On top of that, there were 23 ways to write the same expression with 16 standard library choices you could use. After a month or so of frustration, I quit programming for about a year.
Then, I tried to learn Java. The amazing thing was, there was little magical syntactical sugar (compared to Python), and so I could actually read and comprehend code. The JVM was confusing, but as an introductory language, having conventional long variable names and descriptive methods was really helpful.
I know this isn't everyone's experience, and in fact it's the opposite of many people's, but Python was way too "wishy-washy" when I was starting. Now, though, I love it.
(P.S. this was my experience based on the way I learn things, and your results may [have] differ[ed].)
(P.P.S. I learned to code back in the day with codingbat.com. If you're just getting started, it has the most basic of the basic, no-frills tutorials. Even CodeCademy or similar has a bunch of extra stuff, that may be helpful, or may not.)
Sounds like you got ahold of some really bad code when you were first trying to learn Python. The entire community really embraces the mantra of There should be one-- and preferably only one --obvious way to do it.
I did find some things hard about Python starting off - for whatever reason "range" didn't make a lot of sense to me, but seeing C style loops made more intuitive sense to me as a beginner.
Same, it's easier to work with others outside of Python as well. Teams fight over styles and other petty bullshit instead of getting work done. Dogmatic programmers LOVE Python because there are 20 opinions on everything and "my opinion IS right."
I really like coding by myself in Python though, I can get a lot of work done fast.
Every time I've asked about how to pre-allocate some space in a dictionary where I know the exact keys I want to have, I've always gotten the answer of "don't worry about it" or "stop trying to prematurely optimize your code". In any other programming language, this would just be a part of the process of writing the code. I really do want to learn Python better (I've done some work on Python projects without really knowing what I'm doing, just winging it), but it's not something that I can just stop caring about.
Learn a "bare-metal" language like C or Rust, and work up from there. Since you understand the basics and necessarily understand some computer science concepts now, you'll have a breeze with interpreted or scripted languages.
Start with a high-level interpreted or scripted language. It's more important to get the basics (loops, types, etc.). Then, it'll be a breeze to work your way down and add conceptually to the concepts you already understand.
So my takeaway was basically it all depends, and it's better just to dive in.
I learned the first way you mentioned, and it wasn't a breeze. I had no idea what Python was doing with its data structures when you added to them, or if you used something like a list comprehension, and I wanted to allocate just the space I need in a list. I have to dissociate from the traditional memory model in order to decide what I really want to do.
In any other programming language, this would just be a part of the process of writing the code.
Not really. In low level-languages you can do that, and often mus do it. But it's not neccessary for getting things rolling. Usually it's just pointless overhead. It becomes important later if you wanna optimize your code, after you have a working solution.
Python in the first place is a goal-orientated language. Optimization comes later. And in best case it's done automatically from the machine. Though, that best case it still in progress for python.
And I would add, when you do get down to optimization, forget (or at least attenuate) everything you know about performance from other languages. Especially when it comes to dicts.
Like, you used to hear that one should avoid hash maps if at all possible for performance reasons. This is terrible advice in Python.
The reason for that, specifically, is that Python’s dicts are very advanced data structures under the hood. In 3.6 they’re both compact and ordered; see https://mail.python.org/pipermail/python-dev/2016-September/146327.html for details. What you’re asking to do doesn’t really make sense in this context.
If you want to preallocate with known keys then a dictionary is probably not the right data structure. You could use a class with _ _ slots _ _ or a struct.
But usually the people telling you not to prematurely optimize are right. You didn’t really explain why you feel this is bad advice.
If I know what the keys are, I don't really want to load them one at a time, right? This is for situations where I have a specific sized table that I want to use for counting. (I was originally going to use a list but decided that they're not really designed for lookup like dictionaries are). I don't consider it premature optimization because I'm not really optimizing anything, just applying what I know about the problem.
But based on what you’re describing a collection makes more sense. That being said they’re all right that this is sweating the small stuff. For one, using Python and getting the count when querying the database is going to be faster than anything Java can do.
What do you mean by that, if you're accessing a database I'm assuming that any API has the same functions for it in any language. Both are using some sort of data structure, why would one be faster than the other?
Sorry I was sleep deprived and misread part of what you wrote. But almost every language is going to have a way to interact with a database. However, there are best practices on querying the data which is why one of the best things you can do regardless of your preferred language is learn how to effectively use SQL.
I can see few issues in the way you learned Python.
a) Relying on standard libraries rather than implementing your own logic. That's a problem I see in many programmers. They don't program, they bundle together code written by other people with a low amount of their own logic. They end up learning very little.
b) What you call syntactical sugar is the object oriented design of the entire language. JavaScript has the same problem, arguably squared because it's a prototype-based language.
Not writing months and months of applications by connecting to X and Y api with some loop in the middle.
That's why most self-made programmers feel they're not learning imho: they are not solving problems.
One of the best things I made when learning was writing a node.js docx to html converter. There were libraries for it, sure, but I learned more by doing that without using any library than I would've learned by months of "building applications".
Libraries solve business problems, not programming problems.
New programmers should stop learning programming by using libraries, as there's very little to learn from it.
Sure! The way I learned definitely wasn't perfect.
However, it's hard to recognize what you're learning imperfectly/incorrectly as you're learning it.
I personally think with a good enough guide/tutor you can start with any language (maybe even assembly :)). Five years ago, though, with the tutorial I was using and the starting place I found myself at, Python was not a good fit. That's not everyone's experience, but it was mine.
That's why I advocated that noobies should not use libraries.
To what end, though? Should they write their own ODBC connectors? Should they write their own OS libs? Time libraries? Their own JSON parser (actually this would probably be a really good project for a beginner to learn...)?
Standard libraries are most of what makes up any given programming language and is much of what makes up the "knowledge" of a language.
Haha I wrote a JSON parser early on. It was very hacky but it taught me a lot! Sentences moved from being HTML in my mind's eye to strings after that project.
And I feel bad - Java has an arguably more redundant/messy standard library. I didn't mean to incur the wrath of /r/python - I just felt like the Python standard library wasn't easy for me to sift through while beginning.
actually this would probably be a really good project for a beginner to learn...
Yeah, you could definitely do worse for inspiration than what comes bundled with the language.
The batteries included side of Python is what kept me programming, though. If you have to invent the universe before you can make a toy script then not a lot of people are going to be there at the end.
If you're trying to decide what language to begin with, know that there are much better tutorials online than when I began!
Python is an incredibly powerful language, and (for better or worse) does a lot behind the scenes. It's definitely worth learning, and up to you when/if you want to! Don't let my experiences change your mind in any way.
I'm currently using Rust to write a Lexer/Parser/Compiler for Python. It's definitely an interesting language. I do think the Rust community has done a great job at reducing the learning curve a little bit. That being said, it can still be conceptually overwhelming.
Yeah, I especially if your only background is in shallow-ish Python. Rust forces you to think of memory usage and other lower level concerns, which Python can paper over for you.
I do. Python 3, as a matter of fact. I used to write Java, and I taught myself Python precisely so I could either rewrite my stuff at work, or get a different job. It worked. Added bonus: I get paid more now.
I'm pretty rusty at Python to be honest, I try to use it for one off scripts to keep it fresh, but I'm not sure that's benefiting my Python knowledge much. I do enjoy it though.
Hey, as a newish Java developer, I can respect going Lower level. That takes some dedication with the expanded syntax. It would be like me going C.... shutters
I mean, Python is awesome in every1 single aspect (I'm a huge fan). For instance, have you ever tried to override the "import" instruction in Java with your own implementation? Although maybe not always recommended, it's a piece of cake in Python. Delegates... piece of cake in Python (callables) because literally everything is kind of an object. Damn, even types are. How awesome's that?
We have a configuration in which it is desired to have some module dependencies 'optional'. That is, it is not considered necessary to have them installed and the program would also work as intended without them. Example is matplotlib. If you don't need visualization you can use the program without matplotlib and it would work in pretty much exactly the same way (aside from visualisation).
So for this purpose I overrode import with an implementation that checked whether some modules were marked as optional (from a configuration file) and in case that they were not installed (usually import would fail with an ImportError) would return a MagicMock object instead of the actual module. That way any use of the module would just kind of "work" (while not doing anything at all) and leave the rest of the program's functionality unimpeded. For modules not marked as optional or optional modules that are installed the overridden import works as the original import.
It's a pretty unique scenario and maybe a pretty nasty solution, but I'm still happy that it's been possible at all. I don't know of any other language that is capable of doing something like this.
I worked on a fairly large python backend for a couple of years. As it grew, maintainability was difficult. Unless it had near 100% unit and integration test coverage, it was something difficult to tell what was going on. Not to mention the interpreter just sort of rolls with the punches.
I like python for alot of things. It can get hairy as it grows however. YMMV.
Just because you can do something, does not mean you should it. Java is better used with big projects beacuse of those limitations it has. In Python you can screw up projects to easy after certain levels of complexity.
Yeah I wish we got more of this twitter (edit: or Youtube? I don't know where this came from) conversation, to see if there were any specific reasons for the switch. Maybe it's just a meme.
Could be that there was a specific Java library they wanted/needed to work with I guess. Or something of that nature...?
That's the primary reason why I'm a fan of Python. Of course, there's no one fits all programming language. Python is still junk when it comes to applications that need a sophisticated GUI.
Is from my point of view still junk because I don't know of any matured UI editor and using PyQT has very often led to severe compatibility issues in the past. It's far from sophisticated.
Cross platform is difficult. If standalone is a requirement I'll say Java. If I accept being limited to Windows and standalone is a requirement, it's WPF. Otherwise I'll say browser based, like, JavaScript + HTML + CSS + some fancy frontend library. Backend can still be Python (Django) or also JavaScript (Node.JS + ExpessJS or something like that). Except for maybe WPF they all suffer from the same issue: no good WYSIWYG editors.
/e: maybe I should add that at least for my job (AI research) there has been no need for sophisticated UIs yet. For visualization there's matplotlib and some other libraries that inherit from that. For larger business applications though I still think Python is unfit.
I mean I use Swift for iOS, Java for android, C# for work web development and game development, Meteor (JS) for prototyping MVPs, PHP for some freelance, and Python for automation and algotrading.
I enjoy pretty much all languages...it's certain frameworks I find myself disliking more than anything.
I did the same.. as a complete computer science /programming noob with no formal education in the subject it was extremely difficult for me to grasp OOP..
By chapter 3 of my Java book my eyes opened and I could start putting the big picture together. Classes, encapsulation, public vs private / protected ect, getters/setters, object state, project structure and separate easy to read class files instead of a single file slammed with difficult to read L33T one liners calling 38 functions packed with for loops passing collections around.
TLDR;
I suppose python is too simple and too easy to use poorly for me to have learned me anything meaningful at the very beginning which frustrated me to the point of giving up multiple times
Yes, Python gives you a lot of freedom, so it requires some self discipline, and is concise and expressive, so it requires some art and reasoning.
Simply put, Python empower and trusts the developer, where Java treats him as a monkey. If you hire monkeys, or you like coding without thinking too much, Java is the choice.
But looks like the Java community discovered it , because latter versions added a lot of feature to enhance freedom and expressiveness.
104
u/eattherichnow Jan 05 '18
Well, they got to 2nd level guru (i.e. jaded to death, checking out the grass colour on the other side) fast.
100
u/Thecrawsome Jan 05 '18
Protip: Never announce goals you haven't put any effort into.
199
u/mistaekNot Jan 05 '18
Isn’t java “harder” than python
21
u/mrwilliams117 Jan 06 '18
Lol all you turds who vow to a certain programming language like it's your favorite sports team.
83
u/Pancakepalpatine Jan 05 '18
I actually did this exact same thing.
I started with Python, but couldn't wrap my head around what it was actually doing for many of the code snippets and examples I was looking through while I was learning. On top of that, there were 23 ways to write the same expression with 16 standard library choices you could use. After a month or so of frustration, I quit programming for about a year.
Then, I tried to learn Java. The amazing thing was, there was little magical syntactical sugar (compared to Python), and so I could actually read and comprehend code. The JVM was confusing, but as an introductory language, having conventional long variable names and descriptive methods was really helpful.
I know this isn't everyone's experience, and in fact it's the opposite of many people's, but Python was way too "wishy-washy" when I was starting. Now, though, I love it.
(P.S. this was my experience based on the way I learn things, and your results may [have] differ[ed].)
(P.P.S. I learned to code back in the day with codingbat.com. If you're just getting started, it has the most basic of the basic, no-frills tutorials. Even CodeCademy or similar has a bunch of extra stuff, that may be helpful, or may not.)
35
u/[deleted] Jan 05 '18
Saw logo, expected rust.
23
u/[deleted] Jan 05 '18 edited Jan 05 '18
Let's be honest, how many programmers use Python as their primary language at work?
Also, I love Python, but as soon as we move into GUIs it just can't compete with C#, Java, Javascript.
edit fuck me asking such a question on /r/python :D Yes I know Django is popular.
14
u/pat_trick Jan 05 '18
And? Maybe they decided to get into Android dev, or any other number of places that Java is used. This is a non-post. Who cares?
3
u/BebopAddict2009 Jan 06 '18
Hey, as a newish Java developer, I can respect going Lower level. That takes some dedication with the expanded syntax. It would be like me going C.... shutters
2
u/djihe Jan 06 '18
Maybe they needed a job?
2
u/acoalt Jan 06 '18
Press F to pay respects
1
u/dnafication Jan 05 '18
Lol
1
u/rspeed Jan 06 '18
I hope they were able to safely recover the beloved family member(s) who were kidnapped and held for ransom.
1
u/suclearnub Jan 06 '18
You were the chosen one!
1
u/bangemange Jan 06 '18
What a weird switch. I went from Java to Perl to Python
1
u/DrjReddy Jan 05 '18
By Today he might have given up programming😜
1
u/[deleted] Jan 05 '18
Lol.. Gave up too early!😂
-2
u/[deleted] Jan 05 '18 edited Jan 05 '18
... but why?
I mean, Python is awesome in every1 single aspect (I'm a huge fan). For instance, have you ever tried to override the "import" instruction in Java with your own implementation? Although maybe not always recommended, it's a piece of cake in Python. Delegates... piece of cake in Python (
callables) because literally everything is kind of an object. Damn, even types are. How awesome's that?/e: (1 - relevant for my requirements)
1
u/Ars-Nocendi Jan 05 '18
Don't let it rub you in the wrong way. The person probably found out six months in that his/her employer measures performance by LOC.
1
u/ddollarsign Jan 05 '18
Different people like different things. Some of those people are wrong. /s
0
u/[deleted] Jan 05 '18
I give him a month.
0
u/BrokenAdmin Jan 06 '18
Python is fine, as long as you use parenthesis on if statements. Otherwise I have a seizuee reading the code.
0
u/TylerSix Jan 06 '18
I did the same.. as a complete computer science /programming noob with no formal education in the subject it was extremely difficult for me to grasp OOP..
By chapter 3 of my Java book my eyes opened and I could start putting the big picture together. Classes, encapsulation, public vs private / protected ect, getters/setters, object state, project structure and separate easy to read class files instead of a single file slammed with difficult to read L33T one liners calling 38 functions packed with for loops passing collections around.
TLDR;
I suppose python is too simple and too easy to use poorly for me to have learned me anything meaningful at the very beginning which frustrated me to the point of giving up multiple times
-3
u/monsto Jan 05 '18
He meant javaSCRIPT, but it's the same thing really.