Good vs. Evil

  • FTB will be shutting down this forum by the end of July. To participate in our community discussions, please join our Discord! https://ftb.team/discord

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
62 I did a good bit of stuff today.
notably the fact that now the characters page from my rp_tracker_client project is now going full on module mode making it very easy to reuse the creation of a table with characters and their stats, the ability to click on those stats and add/remove/change the modifiers on them and also the table containing characters and their abilities along with whatever I decide to add to it :)

The only problem is that their is a bit of a race condition if a module has a dependency on another module but right now that is not a problem as their is only 1 module that has a dependency and that one is only needed if the user clicks on a stat before that module is loaded. I do fear that I am doing a bit too much with javascript as I start to make use of its unconventional ways to do stuff. Take for example this piece of code
Code:
const check = function(value,kind){
       if(!kind){
         this.counter=0;
         this.max = 0;
         Object.keys(strippedList).forEach(
           value => {
             this.max = this.max +strippedList[value].length
           }
         );
       } else {
         this.counter++;
         if(kind==="js"){
           that.loadedDeps[value]=true;
         } else {
           that.loadedHTMLDeps[value]=true;
         }
       }
       this.counter===this.max && callBack();
     }
See that "this" that I use? That refers to a function, thus each time you call this function its changes state. That is something that in pretty much all other languages can't be done with normal functions. In lua you will need a co-routine and other languages would call it generators and you need special syntax for both. JS on the otherhand, doesn't care. I guess there may be a code smell in here as a result but to the alternative is in my opinion worse looking.
 

duckfan77

Popular Member
Mar 18, 2013
80
683
118
61 The only issue I see is that it is JS, which is, at least in my opinion, an ugly language to work in, given the lack of classes and the like.
 

triggerfinger12

Well-Known Member
Apr 17, 2017
255
457
89
Rock
62 My Dad (who used to work in IT) says that Java (not necessarily JS, but maybe idk) has the worst compatibility between versions of any other language. He said that if someone at the office accidentally updated Java he would have to go through this whole ordeal to get it fixed.
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
63
61 The only issue I see is that it is JS, which is, at least in my opinion, an ugly language to work in, given the lack of classes and the like.
Javascript has now classes. JS actually has come a long way but that doesn't mean that it hasn't some horrible flaws though like
Code:
console.log(1+"1") //this will print 11.
console.log([] + []) //this will print an empty string
Though, that is something most weakly typed languages have to deal with that decide to use the plus sign both to combine strings and to add numbers together.

62 My Dad (who used to work in IT) says that Java (not necessarily JS, but maybe idk) has the worst compatibility between versions of any other language. He said that if someone at the office accidentally updated Java he would have to go through this whole ordeal to get it fixed.
Javascript is pretty much completely backwards compatible, it has to be as it powers the web. That is also why we have user agents strings like
Code:
Mozilla/5.0 (Windows NT 6.4; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36 Edge/12.0
If you don't know yet, a user agent string is something your browser sends to a server to let the server know what for browser you are using.
(If you are curious, the above is from edge)
firefox is Mozilla/5.0 (Windows; U; Windows NT 5.1; cs; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8
and chrome is Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/7.0.540.0 Safari/534.10
Note that the exact version numbers can differ depending on the browser version you have

For those curious how we got ourself into this mess: http://webaim.org/blog/user-agent-string-history/

Also, as you can see from the user agent strings, every browser is saying they are firefox. Therefor it is clear that firefox is the best, I mean, why else would browsers say they are firefox? :p
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
64 learning to write code is relatively easy. The hard part is learning to write good code (Spoiler : No one will ever succeed in this).
Another problem may arise if you use windows, as for some programming languages it can be hard to get everything it needs working on windows.

I suggest to just pick a language and try stuff out if you learned the basics of one language you know the basics of pretty much every language.
Javascript can easily be written. if you have firefox you can click on dev tools and open a scratchpad(shift+f4) that is a reasonable editor and allows you to execute the written code directly on the page.
If not you can just write a .html file and open it in the browser, this should also execute any javascript that you write in said page. This also allows you to play around with html and css.

Another option is of course to go with computercraft. Lua is a fast, small and above all very easy language to learn due to its very easy syntax. On top of this, playing with turtles that then react with the world is a lot better motivator then just seeing some text appear on the screen. There is also an edu version, which if I remember correctly removes the need to type anything, allowing you just care about learning the logic that programming needs rather then the syntax of a language, which makes it an even better choice.

Another but more expensive option is to buy a lego mindstorms. Just like the edu version of CC you don't need to write code by hand and instead use "blocks" that tell what the lego robot need to do. I have no experience with the newest version (EV3 or something) but if the software is anything like the one from the NXT it should be easy to use. You simply place blocks and connect them, the robot will then execute them in order. On top of that each block also can take some nicely labeled input from other code blocks, which you can easily accomplish by drawing lines from one block to another.

Other languages that you may want to look into are python and php. php because it still gets used a good bit and python because its syntax is relatively simple and will force you to indent well, which though easy to do makes it a real pain if you don't.
 

duckfan77

Popular Member
Mar 18, 2013
80
683
118
64 Not really. It helps, but I've written code in normal notepad, though when it comes down to it I prefer an actual IDE, or Notepad++ at the least. It is free though, and useful for far more than writing code.
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
65 I am currently using geany. I've also used sublime, notepad++ and gedit.
for Javascript it doesn't really matter what editor you use for as long as it has code completion and syntax highlighting. Sure there are a few other features that could be nice but as the language has no native modules (Well, it supposedly has one now but chrome is the only browser that supports it and is relatively new) it can be hard for editors to actually be helpful.

For example brackets is an editor that has a lot of potential, but last time I used it the build in JS hint was completely worthless as it doesn't know which files are loaded, making it raise an error the moment you use something from another file.

PHP has much the same problems, but that at least has a build in way to run other files in the current scope though. Not sure if there are editors that got around this lack of imports for php and thus have good, advanced auto completion rather then the basic "oh, this word starts with the same letters as that other word. Maybe he is trying to type that again".

From my limited time playing around with the JME SDK I miss its autocomplete the most. It was even able to guess the params I would pass to a method and only showed the methods that where from the given object.