If you write applications / websites, I’m really curious what are your thoughts on doing a lot of things with Javascript, which you have never done just a few years ago (namely multi-platform-apps and running webservers based on JS).
You see, I started to work in the IT-field when JS was nowhere near where it’s today (with the thousend libs for anything you want to do).
You used it to do some form-validation and maybe (but only if you’re really brave!) some simple animations.
If you wanted a rich website, you used Flash without any question.
I kind of liked getting Flash replaced with JS and it’s upcomming frameworks like JQuery, prototypeJS and extJS.
But now - and I hope I don’t insult anyone - I think it’s absolutely mental what are a lot of freelancing developers and even big companies are doing with Javascript (with the help of Cordova and NodeJS).
I think this is fine for small projects, but what makes one choose JS for middle- to big-sized projects?
Here’s the thing: I never understood why you would sacrifice the beauty that is Generics, Interfaces, Static classes, IOC-Containers and much more just for the sake of … (I can’t even finish this sentence, because I really don’t see any advantage).
It’s not like we would have a lack of alternatives;
-If you want to build a mobile-app for multiple operating-systems, why not use Xamarin, or Corona SDK?
-If you want to build a webportal, you have tons of alternatives
Now, I know there are some transcompilers like CoffeeScript, or TypeScript (which will provide Generics in an upcomming release!), but even with these “walker frames”, you can never reach the organisation, or the productivity you have with C#, or Java (I’m speaking about mid- to big-sized projects with more than one developer).
So does anyone understand the greatness of Javascript, or what’s your opinion on that topic?
Well, personally I don’t like Corona much, but that’s besides the point.
But I’m really interested why JS is on the way of being THE programming language.
Even if you have to build a Win8-App, you can do almost anything with the JS-API.
Sure it get’s the job done, but with that argument you could use a Basic-dialect.
I made some mid-sized Cordova-Apps in the past and getting back into the code after a few months is way harder (and with that more time-consuming) than with ObjectiveC or any other “mature” language.
With all the “big companies” like Microsoft or Adobe promoting JS-Apps and countless “experts” who telling in interviews that JS is the future, there must be some advantages…
I’m kind of a bad programmer so personally, as long as the technology does the job,I will probably go with option which looks easy and has most resources, tutorials, forums etc. Wouldn’t it be cool if everyone started to use BASIC again?
I’m not talking about Frontend-Stuff, but on doing Server-Logic with JavaScript (speaking about NodeJS).
When it comes to Frontend, you really don’t have a choice and I think for DOM-Manipulation it’s good.
Never heard of that as an option to build the server side of a portal.
But I wouldn’t deny javascript zealots the right to use it for such a purpose. For me js/jquery is the mean to add beatification and easiness of use to web pages. Other than that, i really don’t like it, it took me a while to get used to the horrendous way of lambda style of declaration.
Not necessarily. JavaScript lacks syntax for classes, which leads to exploiting the functional nature of the language to emulate (thus, some really freaking wierd development patterns.)
On top of that, many prominent libraries like jQuery go a step further and pretty much require the use of closures, which while not bad, can be a major mind-screw to pick up (pretty much, you have to come to grips with the fact that a closure isn’t just that function you’re returning, but also the referencing environment. Yes, you’re getting function state AND the function at the same time. Sounds a bit like a class doesn’t it?)
Further, JavaScript is weakly-typed/duck-typed. Under the hood, you have three pseudotypes: number, boolean, string, and of course object. However, you can’t know that from a variable declaration, which is always ‘var’. If you truly want to figure out what something really is, you have to perform a duck test:
A) does it walk like a duck?
B) does is float like a duck?
C) does is quack like a duck?
If all of these presumably ‘duck-specific’ capabilities are present, then yes, you can reasonably assume your object is a duck. Replace ‘duck’ with whatever type you’re trying to check on.
So, no, I wouldn’t say JavaScript is more understandable than many other languages out there. Bear in mind I have considerable bias as a C# developer, but also that in the shop I’m working at, we’re converting old legacy apps to more modern web technologies (MVC3, .NET 4.0), so I actually use JavaScript in a modern context.
This was the case for 8 or 10 years and then due to all the contributions towards flash not been a choice going forward , it was a case of ok … whats left for us to use now? oh javascript
Its a case of been in the right place at the right time. laying dormant in second place with only two competitors.
But in reality anyone more accustomed to better languages does NOT want to actually code Vanilla JS. Hence the flurry of subsets or wrapper frameworks you mentioned and even attempts to push brand new solutions into its place (google dart). The race is on.
Sadly I conclude that until all this settles/changes one day and some mature , easy to use , tool sets emerge again - I will miss flash.
Flash IDE+AS3 language was to artistic and animated web development what Unity3d is to game development
I love Javascript, I was on a big html5 kick prior to getting my unity mobile licenses, but for standalone apps the mobile licenses blow vanilla js html5 out of the water.
Javascript can use normal design patterns, there are great books on amazon for $20 called Javascript design patterns and “Pro javascript design patterns” and you can do all the normal factory, interface, decorator, etcetcetcetc and javascript is just such a cool language where everything is an object, methods, variables, etc are objects and objects can have properties.
Here’s a javascript tile engine I was dicking around with more than a year ago: Welcome simplehotkey.com - BlueHost.com for testing purposes there are 150,000 tiles in that scene.
But I’ll be sticking to Unity and C# for games, despite how much I love js…
I made a little sprite player for a webpage the other day with JS and it was really simple and works great it’s pretty neat to just throw something in notepad and not need to compile or build it.
First of all, I kind of think you’re asking this question in the wrong place, as this is not where you’re going to find the most JavaScript experts, that are going to be able to tell you why. The Unity variant of JavaScript (actually called UnityScript) is not full JavaScript, as there are things you can do in JavaScript that don’t work in UnityScript, so UnityScript users aren’t going to feel the full advantages of using JavaScript.
If you want to pull in HTML content into your app, so you can reuse data that is already on the web (as most businesses already have web sites before they go for a native mobile app), then it often makes sense (from a cost and speed to release perspective) to reuse existing assets as much as possible. If it’s HTML, then the best thing to manipulate it is probably JavaScript.
As I see it, re-use is a big reason. Why write the code twice or more in multiple different languages, when they can write it just once in JavaScript (which you’re going to have to do if you’re building a web site) and then re-use a lot of that code for the mobile app? Costing less, and getting to market faster are big reasons for many businesses.
Well, from what I’ve heard reading articles, before LinkedIn chose to use NodeJS, they had a large team of developers working on a project in another technology (Ruby I think, but as I recall they also looked at Java), and then part way through development, they decided to give NodeJS a chance, and brought in a couple developers to work on making the same thing in NodeJS. The NodeJS team of only 2 developers ended up catching up to what the larger team had done in a short time, meaning that they completed the same thing in less time with less developers. On top of that, when benchmarked, the NodeJS app ran faster than the Java version, by a LARGE margin. The reason for it’s increased performance is often chalked up to JavaScripts non-blocking IO. Last I heard LinkedIn now powers their entire mobile app back end with NodeJS. Here is an article with some more specific tech details about why they made the switch:
There are a number of other companies using NodeJS now to run their back end, for likely similar reasons, such as PayPal, WalMart, Yahoo, Google, and even Mozilla, to name a few.
Another benefit I’ve heard for using the same language (JavaScript) both front end and back end is that the developer doesn’t have to switch mindset when switching between languages. This can mean faster development. There is also the benefit of easily moving code logic from the back end to the front end, and vise-versa.
I hope that helps shed some light on it for you? Just to be clear, though I’ve done a lot of front end web development, I don’t think JS is the answer for everything, and I’m very glad Unity has C#, as that is my language of choice for Unity development.
Jacob
P.S. If you are a web dev used to JS, who is using Unity, it might make sense to use a UI solution like Coherent-UI, which is entirely driven by HTML, CSS, and JS (I have no affiliation).
Sadly though, they don’t support all Unity platforms, as they’re currently missing Windows phone, and Blackberry. For complex UI, especially with a lot of text, HTML and CSS can excel at those things.
JS uses prototypal based inheritance which has it’s own set of pros/cons over C# inheritance. While C# is class-based, JS would be function-based - functions are first class citizens, they can have properties, a prototype (think parent class) and can be passed around just like a variable. The functional nature of the language allows for some things that just aren’t possible with C#.
JS is a great language - 6-7 years ago, I would avoid it like the plague, but great JS frameworks like jQuery, backbone solved all the cross-compatibility issues that made it such a nightmare to work with. Now we also have all the browsers focused on meeting W3C standards (even IE), and constantly improving performance, so it’s become a huge part of the web ecosystem and has helped make websites a lot more interactive and responsive.
I would hate the idea of using C# or some other language in the place of Javascript here, because JS is a scripting language. I don’t want to have to create 2 different classes or worry about type safety just to make something popup in the middle of the screen.C# could work here I guess, but the whole idea just feels wrong.
Using Javascript for server-side applications (ie: NodeJS) was a little strange at first, but I’m very impressed with it now. NodeJS is supposed to be a lot faster than a typical web server (and playing around with it seems to confirm this), and the non-blocking+functional nature of the language makes some things very easy to do when compared to other languages.
I disagree. Just because it’s not class-based, doesn’t mean it can’t be organized and I find that I’m a lot more productive using Javascript in certain situations. Will it replace C#/Java/Some other class-based OO language? No. But it can exist on it’s own.
But does it really matter what type it actually is? If it quacks, then that’s enough - I don’t need to know it’s a duck, just that it can quack like one - variables never change type automatically, so unless I’m a terrible programmer I should already know what variables I’m passing into functionA.
If I do need to check, it’s as simple as:
if (myVar.quack != undefined)
myVar.quack();
While I love type-safety in .NET, it is completely possible to write solid code in JS without ever checking the type of a variable. And a few JS unit tests would help boost confidence.
Edit:
I should point out (before I’m labelled as a .NET-hater) that C# is my language of choice. But I also like JS and feel that it gets a lot of unjustified hate sometimes. 6 years ago, I would’ve grabbed a pitchfork myself, but after really using it over the last 5 years, my opinion has completely changed - once you start to really understand how a lot of it works under the hood, it all starts clicking into place and you learn to appreciate it’s capabilities (well - at least that was my experience).