4 ms·
The thing that always get me when doing infrequent development is the differences in how languages handle common tasks. For instance, if I have a string and ne
by tzs 9y ago
The thing that always get me when doing infrequent development is the differences in how languages handle common tasks.
For instance, if I have a string and need to get its length. Do I call a length() function passing the string? Or is a string an object and there is a .length() member function? Or maybe its an object but the length is a property?
Not a super big deal...but it is an annoying interruption when I realize I don't remember which this particular language uses, and have to either go Googling or start looking around the code to try to find an example. There are a whole bunch of these.
Is it "elseif", "elif", "elsif", "else if", or sometime else?
Is the "for" loop like C, or does it take some kind of iterator object? Is it "for" or "foreach"?
Null, nil, undef?
How to break an outer loop from within an inner loop? How to continue an outer loop from within an inner loop?
Variable scope is a whole can of worms. In some to access a global from inside a function you have to explicitly say you want the global. In others variables in functions are global unless explicitly marked otherwise. Is the scope of a variable declared in a nested block just its block, or the whole function? Is it lexically scoped?
(The scope ones are particularly treacherous, because getting those wrong often won't cause a compile or run-time error. You might just end up creating a global when you thought you were creating a local, or changing a local when you thought you were changing a global).
How do I do multi-line string literals? How do I concatenate strings? Parse strings as numbers? Apply regular expressions to strings? Find substrings?
- deleted 9y ago[deleted]
- tomc1985 9y agoClassic polyglot problems :) I really, really resent how every language seems to use the same concept but slightly different wording. The elif/elsif/'else if' distinction is a particularly annoying one. Same for null/None/nil
- 52-6F-62 9y agoAnd camelCase or not to camelcase: foreach(...) /* OR */ forEach(...)
- kerkeslager 9y agoI think these problems go even deeper. Languages have patterns which are used at the architectural level, too, and an infrequent developer will miss those patterns. A good example of this is generators in Python. Generators have become pervasive in Python 3, but infrequent users of Python will often prefer lists to generators. This will result in pretty large memory and performance overheads in rare cases, but more often it just results in inconsistent code. At the most extreme, infrequent users can have such an effect that they affect the language. JavaScript has had a prototypical object model for over a decade, but ES6 adds classes because too many infrequent JavaScript developers from other languages couldn't be arsed to understand prototypes. The result is that now there are two object models which are incompatible at the edges (yes, classes are technically implemented on top of prototypes, but the pattern the class expands to is an anti-pattern in a prototypical object flow).