As a Python programmer, all I see is heaps of very similar and the same words. It looks like mess, I'm sorry.
There's a trade-off being made between conciseness on one hand and fast feedback on the other. Python leans toward conciseness and Java/C++ lean toward fast feedback. In Python you can express complicated ideas quickly, but you can't necessarily express correct ideas quickly. Whereas in C++ you can express correct ideas quickly but you can't express complicated ideas quickly.
If it's costly for you to correct defects in deployed software then you might prefer the fast feedback of C++ or Java rather than the flexibility of Python.
String string = new String("string");
isn't enough repetition, and so they take it a step further: StringFactory mStringFactory = new StringFactory(StringFactory.FOO || StringFactory.BAR);
StringOptions stringOptions = new StringOptions();
try {
String string = mStringFactory.createString(StringFactory.STRING, "string", stringOptions);
} catch (java.lang.string.StringException e) {
runOnUIThread(
new Runnable() {
try {
// facepalm
I'm exaggerating ;) but as a Python programmer myself, this is what comes to my mind whenever someone says the word "Java" to me. Obviously not for strings, but for more advanced constructs (e.g. Bluetooth) I often do see this much repetition in Java code. It's almost like someone designed this language to prank engineers.BTW You missed:
public static final String STRING_STRING_CONSTANT = "string"; some_dict = module.scrape_api()
value_I_want = some_dict['my_value']
I gave up after a day, when I just wrote down exactly what I expected to pull down and what types were in the values and keys. I can understand it helps you prevent errors but man is there a learning curve... BTW, I could write those checks in Python as well, but they are optional.You're probably going to need to check `value_I_want` though. So maybe the checks aren't quite as optional as they look.
value_I_want = some_dict.get('my_value', default_value)
If you want a more strict check including type checking: value_I_want = some_dict.get('my_value')
if type(value_I_want) is not str:
do_something()
In Java the real problem is nested JSON objects -- it's a real PITA to read those. You can't do something like this (Python): value = some_dict.get("foo", {}).get("bar", {}).get("blah", default_value) value_I_want = some_dict.get('my_value':str)
and value = some_dict["foo"]["bar"]["blah"]