|
Athas posted:Actually, in APL, it is not valid to use Greek letters for variable or function names. It is valid for function parameter names, kind of, because the two parameters permitted for a function are always called ⍺ and ⍵. This means that APL can look kind of funny because everything that uses built-in operations is written very succintly using symbols, but user-defined functions and variables often have user-readable names. Here's an example written by a colleague of mine: Oh wow, so you can write reasonable looking code in APL. Whenever I've seen it, it's always been in condensed code-golf style.
|
# ? Aug 17, 2015 18:41 |
|
|
# ? May 23, 2024 21:17 |
|
kitten smoothie posted:Oh, nice, an Android library to help you figure out your user's phone from their model number ("Moto X," not "XT1049."). At least it was autogenerated.
|
# ? Aug 17, 2015 18:50 |
|
kitten smoothie posted:Oh, nice, an Android library to help you figure out your user's phone from their model number ("Moto X," not "XT1049."). code:
|
# ? Aug 17, 2015 18:51 |
|
kitten smoothie posted:Oh, nice, an Android library to help you figure out your user's phone from their model number ("Moto X," not "XT1049."). "When I'm using a Map, it feels like I'm doing something wrong" - Actual person that is also a Java Programmer.
|
# ? Aug 17, 2015 18:54 |
|
HashMap is slow, since it's an object. A switch statement is fast, since it's a goto.
|
# ? Aug 17, 2015 18:56 |
|
Source your quotes, please.
Space Kablooey fucked around with this message at 19:05 on Aug 17, 2015 |
# ? Aug 17, 2015 19:01 |
|
Dr. Kris Schnauser & Pete Kweller - The Big Book of Java Jokes (ISBN 978-6-15-126602-0)
|
# ? Aug 17, 2015 19:04 |
|
So you probably call getCurrentDeviceName once per app session at most right? Constructing the HashMap probably takes longer than it does to churn through that method once. It's not a terrible approach. I'd probably iterate over array literals though than the massive if/else if trees.
|
# ? Aug 17, 2015 19:08 |
|
Don't switch statements get optimized into jump tables when compiling, or am I thinking of .NET?
|
# ? Aug 17, 2015 19:17 |
|
ExcessBLarg! posted:So you probably call getCurrentDeviceName once per app session at most right? Constructing the HashMap probably takes longer than it does to churn through that method once. It's not a terrible approach. I'd probably iterate over array literals though than the massive if/else if trees. From a performance standpoint you have a point, but shipping the list as part of your package still means you're going to have to push regular app updates just to update this mapping. If you care that much about having the info, then you're probably willing to pay for a network call for it. edit: also don't all those string literals count toward your dex limit? (edit 2: no) kitten smoothie fucked around with this message at 19:49 on Aug 17, 2015 |
# ? Aug 17, 2015 19:29 |
|
Bongo Bill posted:Don't switch statements get optimized into jump tables when compiling, or am I thinking of .NET? Depends on their size, I think in both environments. Having my app depend on some random github user keeping their server up seems worse than baking in a list of phone mappings. Besides, if I care about some new addition to the list, my code is going to have to change to handle it as well, so I'm looking at an update either way.
|
# ? Aug 17, 2015 19:44 |
|
Bongo Bill posted:Don't switch statements get optimized into jump tables when compiling, or am I thinking of .NET? I don't think it's really straightforward to optimize a series of string comparisons to jump tables. Typically people use the jump table argument with C-like switches with a handful of sequential-integer cases or thereabouts.
|
# ? Aug 17, 2015 19:44 |
|
Vanadium posted:I don't think it's really straightforward to optimize a series of string comparisons to jump tables. Typically people use the jump table argument with C-like switches with a handful of sequential-integer cases or thereabouts. That switch is being done on a char, not a string. It shouldn't be a string comparison. Guarded language because Java, but that ought to boil down to a jump table.
|
# ? Aug 17, 2015 20:41 |
|
Vanadium posted:I don't think it's really straightforward to optimize a series of string comparisons to jump tables. Typically people use the jump table argument with C-like switches with a handful of sequential-integer cases or thereabouts. Yeah, it depends on the exact construct. In order for there to be a jump table (in any language) you pretty much need a C-style switch, or something that could be reasonably interpreted by the compiler as an integer switch (e.g. simple match statements in Rust are basically just matching the tag of a tagged union, which is just an integer switch). AFAIK, "jump tables" in Java are going to be at the actual post-JIT level, not the bytecode level, so it's dependent on who wrote your JVM. It very well could be a jump table on Windows and Android, but not on OS X, or any other such nonsense. (Like that one time I found out the JVM unrolled a certain loop I had written, but only on Windows, and only if your laptop was plugged into a wall socket and not running on battery...) Linear Zoetrope fucked around with this message at 20:50 on Aug 17, 2015 |
# ? Aug 17, 2015 20:42 |
HardDisk posted:"When I'm using a Map, it feels like I'm doing something wrong" - Actual person that is also a Java Programmer. I'm relatively new to work-programming and I started to worry that I was overusing hashmaps. Seriously am I crazy or are they the best option for approximately everything?
|
|
# ? Aug 17, 2015 20:45 |
|
ChickenWing posted:I'm relatively new to work-programming and I started to worry that I was overusing hashmaps. They suck for cache locality, but you probably don't care about this unless you're writing a AAA game engine or something. Hash collisions can also be a bitch, but hash maps are often a good first draft tool. They're the sort of thing that unless you know up front you're going to have trouble with them, they're better to remove later after profiling.
|
# ? Aug 17, 2015 20:47 |
|
JawnV6 posted:That switch is being done on a char, not a string. It shouldn't be a string comparison. Guarded language because Java, but that ought to boil down to a jump table. Although, it's a large enough list that a binary search is probably the fastest, and still doesn't require creation of fancy data structures at runtime.
|
# ? Aug 17, 2015 21:16 |
|
If you have a fixed list, generating a perfect hash for them isn't too hard. Lots of such tools exist.
|
# ? Aug 17, 2015 21:29 |
|
ChickenWing posted:I'm relatively new to work-programming and I started to worry that I was overusing hashmaps. Hash maps are so good that in Clojure you just use them for everything vaguely object-like. The language provides tools to create actual objects that still act exactly like hashmaps so that you can improve performance on the "expected" fields without changing all of your code that you wrote back when your object was just a map. Like was said above, use them until you have a reason not to.
|
# ? Aug 17, 2015 21:44 |
|
AndroidDeviceNames/lib/adn/androiddevicenames/src/main/java/tslamic/github/io/adn/DeviceNames.java Why do java projects have directory structures that are like a dozen levels deep? It just seems unnecessary.
|
# ? Aug 17, 2015 21:58 |
|
In my experience, the first several directories are usually identical. For example, I'm working with a directory "src/main/java/com/companyname/async/actor", but EVERYTHING is in "src/main/java/com/companyname", so as far as the IDE is concerned the directory is just "/async/actor"
|
# ? Aug 17, 2015 22:02 |
|
src/main/java is the standard layout for Maven projects The rest of the directories after /src/main/java are the package structure (one directory per package). So in that example, DeviceNames is in the tslamic.github.io.adn package, which is where the tslamic/github/io/adn directory structure comes from. As for why this is the case, I have no idea. Zorro KingOfEngland fucked around with this message at 22:20 on Aug 17, 2015 |
# ? Aug 17, 2015 22:13 |
|
How does the constant time in a hashmap lookup compare to the "constant time" of doing the constant amount of string comparisons that are hardcoded in that file?
|
# ? Aug 17, 2015 22:21 |
|
Jsor posted:AFAIK, "jump tables" in Java are going to be at the actual post-JIT level, not the bytecode level, depends what you mean. java bytecode uses the tableswitch and lookupswitch opcodes. this is android so it'll be dalvik byteode, but that has equivalent opcodes called packed-switch and sparse-switch.
|
# ? Aug 17, 2015 22:27 |
|
Zorro KingOfEngland posted:src/main/java is the standard layout for Maven projects There are two directory names in that path that are the name of the project (surely one is enough), and then two more that are "adn", which is just an abbreviation of the name of the project. So that's at least 3 directories in the path that I can't see how they are not completely redundant. And why does "github" need to be in the package name? What relevance does it have to anything that the project is hosted on github? What, if you decided to host it somewhere else you'd change what it was called? And naming it after the maintainer seems similarly suspect, although I have no idea of Java culture or idioms and maybe it's just standard practice for some reason.
|
# ? Aug 17, 2015 22:37 |
|
Hammerite posted:There are two directory names in that path that are the name of the project (surely one is enough), and then two more that are "adn", which is just an abbreviation of the name of the project. So that's at least 3 directories in the path that I can't see how they are not completely redundant. And why does "github" need to be in the package name? What relevance does it have to anything that the project is hosted on github? What, if you decided to host it somewhere else you'd change what it was called? And naming it after the maintainer seems similarly suspect, although I have no idea of Java culture or idioms and maybe it's just standard practice for some reason. Who cares, it's not like it's 1982 and directories are a precious resource
|
# ? Aug 17, 2015 22:47 |
|
Soricidus posted:Who cares, it's not like it's 1982 and directories are a precious resource I worked on a project recently where the directory depth on the build server hit some Windows limit and we had to rename a bunch of things.
|
# ? Aug 17, 2015 22:54 |
|
Nested NPM modules can have that effect pretty routinely, last time I checked.
|
# ? Aug 17, 2015 23:07 |
|
Soricidus posted:Who cares, it's not like it's 1982 and directories are a precious resource A developer's time is a resource, and any time you go looking for something in a directory structure how much time are you willing to spend unnecessarily sorting through gratuitous extra layers? Even if your tools mean you seldom have to do that, doesn't it just look ugly to you? I mean I know Java has a reputation for being verbose but drat.
|
# ? Aug 17, 2015 23:25 |
|
Subjunctive posted:I worked on a project recently where the directory depth on the build server hit some Windows limit and we had to rename a bunch of things. That this is still a thing in TYOOL 2015 (and it most definitely is) is loving ridiculous to me. And drive letters still existing but that's just such a deeply embedded thing that I doubt that will ever go away in my lifetime.
|
# ? Aug 17, 2015 23:30 |
|
Hammerite posted:A developer's time is a resource, and any time you go looking for something in a directory structure how much time are you willing to spend unnecessarily sorting through gratuitous extra layers? Even if your tools mean you seldom have to do that, doesn't it just look ugly to you? I mean I know Java has a reputation for being verbose but drat. It doesn't come up. If you're doing Java you're using an IDE, and your IDE hides the directories from you, you just have packages and classes and the tree will be flattened sensibly. If you're not in your IDE then you're probably looking at something like github or stash or what have you, which again knows how to flatten the tree and skip through empty directories. If you're on the command line then it's unlikely to hurt that the directory structure mirrors the package hierarchy and you can predict exactly which file a given class will be defined in without having to search for it. The only situation I can think of where it's inconvenient is if you're using a graphical tool that doesn't know about source code, like Windows Explorer or whatever, and in that case you have only yourself to blame because it's a bad tool for working with source code in any language.
|
# ? Aug 17, 2015 23:34 |
|
Subjunctive posted:I worked on a project recently where the directory depth on the build server hit some Windows limit and we had to rename a bunch of things. I had a file on my computer, when it ran Windows, whose filename was too long for me to rename or delete it.
|
# ? Aug 17, 2015 23:42 |
|
Soricidus posted:The only situation I can think of where it's inconvenient is if you're using a graphical tool that doesn't know about source code, like Windows Explorer or whatever, and in that case you have only yourself to blame because it's a bad tool for working with source code in any language. About once a month I'll get drunk (at least I hope that's my excuse) and browse through my source code using Finder and then I've got to hunt around for the script that will delete all of the stupid .ds_store files
|
# ? Aug 17, 2015 23:50 |
|
loinburger posted:About once a month I'll get drunk (at least I hope that's my excuse) and browse through my source code using Finder and then I've got to hunt around for the script that will delete all of the stupid .ds_store files my favourite thing is when I clone somebody's github repo and it turns out to have a bunch of .ds_stores that they've committed No Safe Word posted:That this is still a thing in TYOOL 2015 (and it most definitely is) is loving ridiculous to me. backwards compatibility. you can't change it without breaking practically every c or c++ program ever that does path manipulation in a fixed-length buffer sized based on the longest possible path, and for some reason nobody's eager to take that step just yet.
|
# ? Aug 17, 2015 23:54 |
|
Soricidus posted:If you're on the command line then it's unlikely to hurt that the directory structure mirrors the package hierarchy and you can predict exactly which file a given class will be defined in without having to search for it. actually it's really loving annoying having to hit tab an extra ten times for every path loinburger posted:About once a month I'll get drunk (at least I hope that's my excuse) and browse through my source code using Finder and then I've got to hunt around for the script that will delete all of the stupid .ds_store files find . -name .ds_store -delete is all you need
|
# ? Aug 17, 2015 23:56 |
|
Plorkyeran posted:actually it's really loving annoying having to hit tab an extra ten times for every path if you're doing this enough to matter then you can just create symlinks or whatever hmm, or you could probably hack your completion settings to skip empty subdirectories
|
# ? Aug 18, 2015 00:02 |
|
Subjunctive posted:I worked on a project recently where the directory depth on the build server hit some Windows limit and we had to rename a bunch of things. NTFS doesn't have arbitrary directory nesting limit AFAIR, just a single directory entry must have name shorter than 256 characters (and a path, 32k). sarehu posted:I had a file on my computer, when it ran Windows, whose filename was too long for me to rename or delete it. Try prepending "\\?\" at the beginning of the path in the future.
|
# ? Aug 18, 2015 00:06 |
|
Sometimes you need to deal with source code as file artifacts, in which case deep hierarchies can be annoying and add a lot of visual noise. src/java/main annoys me because in every case I've seen main could just be at the top of that level with no loss of clarity or structure.
|
# ? Aug 18, 2015 00:07 |
|
omeg posted:NTFS doesn't have arbitrary directory nesting limit AFAIR, just a single directory entry must have name shorter than 256 characters (and a path, 32k). It wasn't an NTFS limit as much as a Windows API limit which IIRC is 260 characters in the full path and 245 in the directory portion. Visual Studio choking on long paths is a well-known problem, I think.
|
# ? Aug 18, 2015 00:11 |
|
|
# ? May 23, 2024 21:17 |
|
Subjunctive posted:It wasn't an NTFS limit as much as a Windows API limit which IIRC is 260 characters in the full path and 245 in the directory portion. Visual Studio choking on long paths is a well-known problem, I think. Uh... yup. http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2156195-fix-260-character-file-name-length-limitation
|
# ? Aug 18, 2015 00:24 |