|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
idk, I used to think exactly like that until I realized that's a stupid way of thinking about it. Just because the language looks similar shouldn't imply that previous ideas from other languages should map onto the new language. If it does, then yay, if it doesn't then sure, it's not the same language, what should I actually be doing? Just remember the first time you learned a language. You knew nothing and made assumptions and had them proven true or false. Now you know stuff that may or may not be relevant to the language, just because some of your assumptions work doesn't mean that they all will.
Essentially it's really our fault when we make implicit assumptions about a language's api calls based off of our own models of what api calls should look like from other languages.
I thought like you did too and circle jerked around Javascript being shitty until I actually used it more than in passing. Eh, it's just like any other language's idiosyncrasies.
|
On April 15 2016 16:09 Blisse wrote: idk, I used to think exactly like that until I realized that's a stupid way of thinking about it. Just because the language looks similar shouldn't imply that previous ideas from other languages should map onto the new language. If it does, then yay, if it doesn't then sure, it's not the same language, what should I actually be doing? Just remember the first time you learned a language. You knew nothing and made assumptions and had them proven true or false. Now you know stuff that may or may not be relevant to the language, just because some of your assumptions work doesn't mean that they all will.
Essentially it's really our fault when we make implicit assumptions about a language's api calls based off of our own models of what api calls should look like from other languages.
I thought like you did too and circle jerked around Javascript being shitty until I actually used it more than in passing. Eh, it's just like any other language's idiosyncrasies.
Pretty much that.
JavaScript isn't actually terrible. It has a terrible reputation because of different browser implementations and such, but as a language it's actually pretty nice, just very different. It's much closer to languages like Perl or even Lisp than to "classic" languages like C++.
I used to hate JavaScript with a passion, but the more I accepted it as a language that just requires a different mindset, the more I saw some of the advantages it had. Of course there are still some things I don't like about it, every language has it's problems, but by now I prefer it to PHP by a large margin.
|
|
On April 15 2016 17:35 Nesserev wrote: There are some things that I like about JavaScript, but there are a lot more things that I hate about it... it really is a shitty language as a whole, but it's a necessary evil if you ever wanna touch a browser, and you can circumvent most shitty things. The worst things that you constantly have to watch out for, are: - hoisting - implicit global variables - only function-scope, no block-scope
There's also the lack of const'ness outside of declaring constant variables, but this is a problem for a lot of languages. Outside of those few things, it's actually an okay language in my opinion.
The first two are the result of poor programming, the function scope is true, though it's not really a problem imho since you'll want to make heavy use of functions and lambdas anyways, e.g. you don't use a for loop but a forEach method that executes a function on each element, so blocks aren't really that relevant.
For global variables you'll want to use the module pattern, which is essentially just
(function(){ // code here })();
(function(globalVar){ // code using globalVar here })(globalVar);
// common use: (function($){ // $ is now always jQuery with no conflict with other libraries using the $ variable })(jQuery);
That way all variables are scoped inside the module and don't affect the outside unless you use global variables that were defined outside the module.
The one thing that is annoying about JavaScript and even more Node.JS is the potential for callback hell, though there are also methods to avoid or at least reduce that.
|
Bisutopia19152 Posts
Are the any unity guys out there who have successful used multiple displays for a game? I need display 1 to be on one monitor and display two on another monitor. I have extensively researched for answers on this and found none.
|
On April 15 2016 17:35 Nesserev wrote: There are some things that I like about JavaScript, but there are a lot more things that I hate about it... it really is a shitty language as a whole, but it's a necessary evil if you ever wanna touch a browser, and you can circumvent most shitty things. The worst things that you constantly have to watch out for, are: - hoisting - implicit global variables - only function-scope, no block-scope
There's also the lack of const'ness outside of declaring constant variables, but this is a problem for a lot of languages. Outside of those few things, it's actually an okay language in my opinion. Well at least ES6 makes two of those problems go away :D and implicit globals aren't possible with 'use strict' either.
edit:
On April 15 2016 18:24 Morfildur wrote: The first two are the result of poor programming
Disagree strongly that implicit globals hurt you because of 'poor programming' - if you consider 'making typos' to be 'poor programming' I don't think I want to work with you
|
On April 15 2016 07:31 Manit0u wrote:Show nested quote +On April 13 2016 16:20 supereddie wrote:On April 12 2016 10:03 Manit0u wrote:Speaking of DB queries and all... Do you think it would be possible to turn this into a query (PostgreSQL)? $string = 'AB.6740.D.336.2011.AP'; $regex = '/\.(\D)\./'; $alphabet = range('a', 'z');
preg_match($regex, $string, $matches);
if (!empty($matches)) { $letter = strtolower($matches[1]); $num = array_search($letter, $alphabet) + 1; $string = preg_replace($regex, sprintf('.%d.', $num), $string); }
echo $string;
This would have to update all the rows of course. The things I have to deal with... I know that you can do WHERE field *~ '\.(\D)\.', but I'm not sure you can do replaces with regex. Well, if it is a one-time thing you can just write out the update and do 26 replaces... The thing is, I need to update over 120k rows in the db, replacing all .[LETTER]. patterns with the corresponding number. Well, if the pattern is consistent and you're really desperate:
update table set column = left(column, 4) + case charAt(column, 5) when '0' then 'A' when '1' then 'B' when '2' then 'C' when '3' then 'D' ... end + case charAt(column, 6) when '0' then 'A' when '1' then 'B' when '2' then 'C' when '3' then 'D' ... end + ... + ...
I am unfamiliar with PostgreSQL syntax, but this is doable in MS SQL
|
On April 16 2016 01:17 supereddie wrote:Show nested quote +On April 15 2016 07:31 Manit0u wrote:On April 13 2016 16:20 supereddie wrote:On April 12 2016 10:03 Manit0u wrote:Speaking of DB queries and all... Do you think it would be possible to turn this into a query (PostgreSQL)? $string = 'AB.6740.D.336.2011.AP'; $regex = '/\.(\D)\./'; $alphabet = range('a', 'z');
preg_match($regex, $string, $matches);
if (!empty($matches)) { $letter = strtolower($matches[1] ; $num = array_search($letter, $alphabet) + 1; $string = preg_replace($regex, sprintf('.%d.', $num), $string); }
echo $string;
This would have to update all the rows of course. The things I have to deal with... I know that you can do WHERE field *~ '\.(\D)\.', but I'm not sure you can do replaces with regex. Well, if it is a one-time thing you can just write out the update and do 26 replaces... The thing is, I need to update over 120k rows in the db, replacing all .[LETTER]. patterns with the corresponding number. Well, if the pattern is consistent and you're really desperate: update table set column = left(column, 4) + case charAt(column, 5) when '0' then 'A' when '1' then 'B' when '2' then 'C' when '3' then 'D' ... end + case charAt(column, 6) when '0' then 'A' when '1' then 'B' when '2' then 'C' when '3' then 'D' ... end + ... + ...
I am unfamiliar with PostgreSQL syntax, but this is doable in MS SQL
The pattern is consistent but the ".A." stuff won't be at the same spot all the time since everything inbetween the dots is variable and depends on gazillion things.
|
i am sure i will figure eveyrthing out its pretty basic
|
Okay I am 99% through this bit of a batch file for changing the default folders in Sketchup 2016. The batch file changes several registry values. For sake of focus I am just placing the 1% that I am having trouble with in the following code block:
set key="HKCU\Software\Sketchup\Sketchup 2016\File Locations"
set sketchpart1=%USERPROFILE%
set sketchpart1=%sketchpart1:\=\\%
set sketchloc2="\"%sketchpart1%\\AppData\\Roaming\\SketchUp\\SketchUp 2016\\SketchUp\\Classifications\""
reg add %key% /v Classifications /d %sketchloc2% /f
Now if you run this in a batch, it changes the key just fine, no syntax errors or such. However if you open Sketchup 2016, you get an error saying that there is trouble with one of the default paths. After you go to the place it points to, you see one of the paths surrounded in red. Inspection of the offending path shows as:
"C_\users\lilwisper\AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Classifications\
I know I have to change the set sketchloc2 portion of my code, I just can't think of the way to change it to make it appear properly inside of Sketchup 2016.
|
In what you see, I don't know where the "_" comes from instead of ":". The text it builds should be this:
\"C:\\user\\lilwisper\\AppData\\Roaming\\SketchUp\\SketchUp 2016\\SketchUp\\Classifications\"
The question I have is, is this correct with all those \" and \\ instead of just " and \?
You can play with all of this on the command line prompt. Like, you can do this here:
> echo %USERPROFILE% C:\users\lilwisper
> echo %USERPROFILE:\=\\% C:\\users\\lilwisper
> echo "%USERPROFILE%" "C:\users\lilwisper"
> echo "\"%USERPROFILE:\=\\%\\AppData\\Roaming\\SketchUp\\SketchUp 2016\\SketchUp\\Classifications\"" "\"C:\\users\\lilwisper\\AppData\\Roaming\\SketchUp\\SketchUp 2016\\SketchUp\\Classifications\""
What I wonder is, are you sure you don't want just this here:
> echo "%USERPROFILE%\AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Classifications" "C:\users\lilwisper\AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Classifications"
You could also take a look at what 'reg query' outputs after you have manually set up the path in SketchUp's menus, to compare with what you are trying to do in your batch file. I think it would be this:
> set key="HKCU\Software\Sketchup\Sketchup 2016\File Locations"
> reg query %key% /v Classifications
|
On April 16 2016 18:44 Ropid wrote:In what you see, I don't know where the "_" comes from instead of ":". The text it builds should be this: \"C:\\user\\lilwisper\\AppData\\Roaming\\SketchUp\\SketchUp 2016\\SketchUp\\Classifications\" The question I have is, is this correct with all those \" and \\ instead of just " and \? You can play with all of this on the command line prompt. Like, you can do this here: > echo %USERPROFILE% C:\users\lilwisper
> echo %USERPROFILE:\=\\% C:\\users\\lilwisper > echo "%USERPROFILE%" "C:\users\lilwisper" > echo "\"%USERPROFILE:\=\\%\\AppData\\Roaming\\SketchUp\\SketchUp 2016\\SketchUp\\Classifications\"" "\"C:\\users\\lilwisper\\AppData\\Roaming\\SketchUp\\SketchUp 2016\\SketchUp\\Classifications\"" What I wonder is, are you sure you don't want just this here: > echo "%USERPROFILE%\AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Classifications" "C:\users\lilwisper\AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Classifications" You could also take a look at what 'reg query' outputs after you have manually set up the path in SketchUp's menus, to compare with what you are trying to do in your batch file. I think it would be this: > set key="HKCU\Software\Sketchup\Sketchup 2016\File Locations"
> reg query %key% /v Classifications [/code]
As far as I read online, the string the current code builds is the one needed to have it pass the reg command correctly. It is due to the space in the path. The slashes and quotes all need to be escaped so that the string builds properly.
|
|
...Here I sit, explaining a 4.th semester computer science student why
Classname1.doSomethingWhichAccessesAttributes();
doesn't work, only to get asked by the same student just a bit later why
Classname1 myClass = Classname2.doSomethingWhichAccessesAttributes();
doesn’t work...
I am not a big fan of java myself, but at least it saves me from always answering the same questions regarding pointers and references... and this particularly mistake has nothing to do with any of javas quirks.
|
Hmm, if for some reason your programme doesnt really teach any OOP I can get why a student would into static vs instance confusion. If you do get OOP stuff then that guy is one of those few students who arent capable of anything but still manage to stick around somehow .
|
He had OOP since the very first semester
|
On April 18 2016 05:40 solidbebe wrote:Hmm, if for some reason your programme doesnt really teach any OOP I can get why a student would into static vs instance confusion. If you do get OOP stuff then that guy is one of those few students who arent capable of anything but still manage to stick around somehow  .
... I was like him one day... But now I get it...
|
On April 18 2016 05:45 waffelz wrote:He had OOP since the very first semester  Hit him over the head with an object and tell him you couldn't do that if you were static
|
On April 18 2016 10:17 Acrofales wrote:Show nested quote +On April 18 2016 05:45 waffelz wrote:He had OOP since the very first semester  Hit him over the head with an object and tell him you couldn't do that if you were static 
I have to laugh at this one. Good example. Lol
|
On April 18 2016 10:17 Acrofales wrote:Show nested quote +On April 18 2016 05:45 waffelz wrote:He had OOP since the very first semester  Hit him over the head with an object and tell him you couldn't do that if you were static 
Already did that to a fellow student of his. Doesn’t really help them with understanding the problem but it helps myself a lot… Can highly recommend this to keep your insanity to normal levels while tutoring/lecturing.
|
|
|
|