No. Javascript is the current "official" language because of historical reasons. I just wanted to make it clear that you can use other languages, but just have to be aware of the tradeoffs.
@whmountains
Nothing here yet.
Nothing here yet.
No blogs yet.
No. Javascript is the current "official" language because of historical reasons. I just wanted to make it clear that you can use other languages, but just have to be aware of the tradeoffs.
You can write in most languages in the browser right now, and it's getting easier and more popular as time goes by. There are many serious downsides, as well as compelling advantages. Some downsides to using a different language: JavaScript has, arguably, the worlds largest community for any programming language. It's easy to hire developers or find contributors for your OSS project. JavaScript has NPM, an awesome repository of modules that can do almost everything you'd ever need. This is especially an advantage when prototyping. Other languages have a tendency to die out, but JavaScript will always be with us. The latest version of JavaScript is pretty good, and it only gets better every year. Is it really worth jumping ship to some niche language when JavaScript is probably going to catch up soon anyway? Of course, there are benefits from using other languages. Most of them only show up with large, long-lived applications: JavaScript doesn't have static types. A large app can feel like a ticking time bomb waiting to get in some inconsistent state and have a runtime error. Static types can catch many of these errors ahead of time. JavaScript's flexibility means that it works with most programming styles, but specializes in none of them. Other languages have different opinionated rules and tools which can make your code more expressive and catch bugs earlier. Other languages frequently offer more expressive syntax and data constructs which lets you write the same code in less lines. There are three main categories of alternate languages to be aware of: Languages that have JavaScript compilers. Languages designed as alternatives to JavaScript Languages that use Emscriptem, ASM.js, and/or Webassembly Languages that have JavaScript compilers JavaScript is popular enough that most major languages have tools to "compile" them to JavaScript. If you already "speak" one of these languages then they can be a great option to bring your existing code and expertise to the web. Go with gopherjs Java with jsweet C# with bridge.net Ruby with Opal . Hyperloop also looks cool. Python with Transcrypt Clojure with ClojureScript Rust is coming soon once this WIP gets finished. Languages designed for JavaScript Each of these languages were designed by very smart people with a JavaScript background to solve real-world problems. They are definitely not a good idea if you're making small apps, since ES2016 is pretty good anyway and you'll lose compatibility with the existing ecosystem. However if you're making a large webapp that's going to be used in production and have features added over time, then you should definitely consider these languages: Dart is made by google and used by them for large projects. CoffeeScript is an alternative syntax for JavaScript that is more concise and readable. TypeScript Is a small addition to JavaScript that adds static types and better IDE tooling. It is 100% backwards compatible with JavaScript and has the potential for adding lots of productivity with no upfront cost. Elm is a very cool language based on the functional-reactive style. It has an innovative data-handling model and no runtime exceptions. There are more, but I'll stop there since those are the biggest. Emscriptem, ASM.js, and Webassembly TL;DR: If you want to make video games, write them with Unity and they'll run everywhere, including the web. One big problem with all these "compile-to-js" languages is that Javascript is kinda slow. It is weakly typed and so the javascript engines have to do crazy on-the-fly recompilations as the data changes for maximum performance. If only there was some kind of low-level language which we could run in the browser but which didn't need any kind of optimizing engine. Like an assembly language for the web. Enter ASM.js: ASM.js is a very ugly subset of javascript that looks like this: function strlen(ptr) { ptr = ptr| 0 ; var curr = 0 ; curr = ptr; while (MEM8[curr]| 0 != 0 ) { curr = (curr + 1 )| 0 ; } return (curr - ptr)| 0 ; } Notice all the |0 ? Those are valid Javascript which casts the values to integers. A smart JavaScript engine will pick up on that and produce much faster code. ASM.js also does some other things like manually managing it's own memory in a TypedArray which means no pauses for Garbage Collection. With these optimizations paired with a browser that's also been optimized for ASM.js, you can usually get within 1/2 the performance of native code. Another important tool is Emscriptem which compiles C/C++ code to ASM.js. (I'm simplifying here. Go check it out if you want the full story.) Thanks to the great performance of ASM.js, people have been able to compile entire video games for the browser. In fact, Unity, which is one of the most popular video game engines, can export to asm.js as one of it's official targets! ASM.js is just about as far as you can push regular JavaScript. But thankfully, the browser vendors have come together to give us something even better: WebAssembly. WebAssembly is a cross-platform assembly language that's safe to run with untrusted code. This means that, someday soon, almost any language will be able to compile for the browser without sacrificing speed or having subtle quirks due to JavaScript's limitations. The future is bright for assembly languages on the web. ASM.js already works in all modern browsers and WebAssembly works in Firefox Nightly and Chrome Canary. If you want to have a taste of the future go check out this video game demo which has both ASM.js and WebAssembly versions. If you want to be a web developer If you're looking to get into front end development, then JavaScript is still the way to go. JavaScript is one of the few languages that actually has a job deficit, so it's a very good career move. Whatever company you get a job for will probably already have decided whether to use vanilla JS or some other language, and won't be interested in changing. If they use some alternate language, then their strategy will probably be to hire JS developers and train them in.
Yes! I'll tell you how I usually do it. Just to be clear before we start, it's a bad idea to make a full-fledged web server on your laptop. There are very cheap services where you can run real web servers. Most web developers, however, need to set up temporary web servers for different reasons on a regular basis. This guide will show you how. Creating the web server You may already have a server If you're a web developer, I expect that you already start a web server as part of your day-to-day work. If you go to localhost:3000 in your browser, then that's already a web server and you can skip to the next step. Simple File Server I create a file server on my mac all the time. Like this: $ python -m SimpleHTTPServer 8000 It will start serving files on port 8000. You can see the result by going to localhost:8000. This is my favorite way to transfer files between computers. BrowserSync server This one is pretty cool. If you use BrowserSync, it will give you a server for free and also auto-update all the connected devices every time you change the code. $ npm install - g browser- sync # do this once to install browser- sync $ browser- sync start --server --files "*" --port 8000 Advanced Method If I need a more advanced web server, I just drop in a stock express.js server. Not everyone uses node.js, but I see that you do so I'll hope you won't mind. I won't go into the details here, but by tweaking this file you can serve from multiple directories, integrate socket.io, require passwords for certain folders, and so on. const app = require ( 'express' ) const morgan = require ( 'morgan' ) const app = express() app. use (morgan( 'dev' )) app. use (express. static (__dirname)) // change this line if you want to serve on something besides port 8000 app.listen( 8000 ) Then in terminal: $ npm init -y # you've probably already done this step $ npm install --save express morgan # do this once to install express and morgan $ node server.js # do this every time you want to launch the server Now you can open your server in your browser at localhost:8000 Accessing the web server from another computer Now say you want someone else to see your server. You can access it on your laptop at localhost:8000 , but how do you get to it from another computer? The first step is to find your ip address. If you're using browser-sync it will tell you when you launch, but otherwise you'll need to look it up. If you're on a windows, you can find it like this: $ ipconfig You'll see a whole bunch of information printed out and buried in there will be the ip address. If you're on a mac, you can find this in System Preferences > Network The number highlighted in red is your local IP Address. Let's say that your local ip turns out to be 192.168.1.47 . That means you can access your server from another computer by going to 192.168.1.47:8000 in the browser. Cool! Losing the :8000 All my examples so far require you to add :8000 to the end of the URL. You don't have to do that though. Port 80 is default, so if you serve from that you can just access your site from localhost or 192.168.1.47 instead of localhost:8000 or 192.168.1.47:8000 . But if you try to start a server that way, it will give you a permission denied error. That's because you need administrator privileges to serve from any port number that's lower than 1024. To solve this, just add sudo before the command to start your server. This will prompt you for your administrator password before starting. For the Python server: $ sudo python -m SimpleHTTPServer 80 For browser-sync $ sudo browser-sync start --server --files "*" --port 80 For an express.js server $ sudo node server.js Accessing the web server from another part of the internet The one caveat to the previous example is that you can't access the server from another part of the internet. The computer accessing the server has to be on the same network as your computer. That's good because it keeps hackers from messing with you, but sometimes you really do want it to be public. There are two ways: The Standard Official Way This is the method that you should use if you really want to serve a website with a standard domain, like mysite.com. I won't go into details, but this should get you started. In brief the steps are: Configure your computer with a static ip address Configure your router to forward port 80 to your computer Either request a static ip address from your ISP, or set up a dynamic DNS service. Buy a domain name and point it to you. The Quick and Dirty way If you don't want to set up a permanent server and just want to, say, let someone else temporarily see what you're working on, you can use Ngrok. Sign up for an account at https://ngrok.com Download ngrok from https://ngrok.com/ and unzip it Now comes the terminal work $ cd path/to/ngrok # wherever you extracted the zip $ ./ngrok authtoken b5ES7AyAytsbWNX2AY # you got this when you signed up $ ./ngrok http 8000 # replace 8000 with whatever port you're serving on. You should see a success screen that gives you a URL to access your site from anywhere in the world: In my case it's https://d0affdd3.ngrok.io (Notice that ngrok always serves on port 80, even if my app serves on port 8000.) Notes I hope that helped. Probably you know some of that already, but I couldn't tell your knowledge level from the question. Hopefully this answer can be useful to someone else as well.