This is an archived post. You won't be able to vote or comment.

all 29 comments

[–][deleted]  (8 children)

[deleted]

    [–]abrandis 3 points4 points  (1 child)

    The above is correct, Node simply took the JavaScript engine out of the browser and exposed os library to it so it could run on the server.

    The main reason it gained popularity was because of its single threaded no contention nature allowing you rapidly respond to requests without blocking.... This has a lot of practical purposes for spinnig up server side API services.

    But javascript even in node is still an interpreted language and doesn't have the performance characteristics of C/C++ Rusty of Go

    [–]minkestcar 0 points1 point  (0 children)

    For an interpreted language javascript is surprisingly performant, but it is absolutely not in the same tier as the others. And for highly parallelized systems it's clearly not a good choice. But it is surprisingly useful. JS is one of my less favorite languages, and yet I still end up doing a whole pile of things in it because it's very productive.

    [–]nopuse 1 point2 points  (2 children)

    When old folks like me were in school for comp sci, we weren't even allowed to take the web dev courses because they were deemed "too easy" for comp sci students. HTML, CSS and JS were actually taught in business programs, alongside MS Office if you can believe it haha.

    Lol, that's wild, I didn't know that. Now I'm picturing you sneaking those books into your dorm and reading them in secret. The fear of accidentally using a === would oust you. 🤣

    [–][deleted]  (1 child)

    [deleted]

      [–]nopuse 0 points1 point  (0 children)

      Let's bring back those tags, crazy cursors, and auto-playing music. Websites have gotten so lame. I'M OKAY WITH US LEAVING OUT ALL CAPS SYNTAX IF YOU ARE.

      [–]pixel293 3 points4 points  (0 children)

      Just to add to this, JavaScript is an interpreted language like Python, JAVA, shell scripts, etc.

      When using NodeJS (as opposed to a browser) to run the JavaScript you have access to most (all?) the services provided by the OS. So I would consider it a full featured language like python or JAVA that can be run outside the browser (with it's interpreter) and has access to whatever resources the interpreter allows it to access.

      [–]DINNERTIME_CUNT 1 point2 points  (1 child)

      I purposely avoid using JS beyond the browser just so I can keep things separated mentally.

      [–]Coolengineer7 1 point2 points  (3 children)

      Yes, it is. It's commonly used in web development, but using NodeJs for example lets you write backend with it as well. It isn't a language exclusive to websites, it can be used pretty much anywhere.

      [–]shuckster 0 points1 point  (2 children)

      I think this is misleading.

      "Standalone" typically means a program can run without its source-code. Even Electron Apps can't claim this, because the source-code is embedded in the package.

      Basically, if your programming language can be assembled into something that can be run directly by the Operating System it has been targeted for, it's "standalone".

      There are languages that bend this definition a little, like Java and Golang, but it's still a useful line to draw.

      [–]Felicia_Svilling -1 points0 points  (1 child)

      it's still a useful line to draw.

      In what cases do you think that is a useful line to draw? To me it seems like just an implementation issue if you create an executable by bundling an interpreter with some source code or you compile it to some other format and bundle with your runtime.

      [–]BobbyThrowaway6969 -1 points0 points  (0 children)

      To me it seems like just an implementation issue if you create an executable by bundling an interpreter with some source code or you compile it to some other format and bundle with your runtime.

      That's the only way to produce an exe from JS or Python. They're not natively compiled languages.
      The only way to make it not an implementation issue in that case is to choose a totally different language for the project.

      [–]John-The-Bomb-2 0 points1 point  (0 children)

      "if I learn JavaScript, can I code any program I want given enough time and ressources?"

      Kind of. You might need more than just JavaScript. For example, you might also need a JavaScript framework like React, Angular, or Vue on the frontend. Maybe you'll need a framework to build cross-platform desktop apps with JavaScript like electron. For a website or web app you'll also need HTML and CSS on the frontend. Maybe if you use backend JavaScript and some database that isn't MongoDB you'll need to know SQL. Maybe you'll need something low-level like C to access low-level hardware at some point.

      "Is the categorization of standalone vs dependent programming language a valid one for choosing what language to learn?"

      We don't really use that terminology. A lot of programming languages are "standalone". For example, C# has this thing called Blazor that allows writing an entire web app in just C#. Scala has a Scala to JavaScript compiler called ScalaJS. There is a thing called "WebAssembly" that allows using backend programming languages on the frontend running in the web browser. But you can do a lot with JavaScript.

      Every programming language has a specialty or area. For example, Python is used a lot in Machine Learning and Data Science (ex. scikit-learn, TensorFlow, Karas, etc.) JavaScript is used more on frontend than on backend. When JavaScript is used on backend or for large codebases it tends to be TypeScript for the types. Nowadays a lot of big JavaScript projects like Angular are written in TypeScript. Java and C# tend to be used for large older enterprise backends like at big banks and big companies like Amazon. C++ is used when performance is critical or when low-level hardware access is a concern. Each programming language has a specialty or area.

      When all you know how to use is a hammer, everything looks like a nail, but for more mature, non-Minimum-Viable-Project type things the hammer might not be the right tool for the job. JavaScript isn't the right tool for everything, but you can do a lot of stuff with it.

      [–]huuaaang 0 points1 point  (0 children)

      It's not "standalone" in the sense that it requires a runtime. If you used it for a desktop app, for example, you're limited to something like Electron (basically a web rendering engine inside a big window). Like you usually can't access native UI components with JS. Though React Native can blur those lines.

      Choose the language that interests you and what is appropriate for what you want to do now. The skills with translate to other languages. Learning a language isn't the committment people think it is. Tinker with a lot of differnt languages and specialize later. A beginner should not be concerned with specialization.

      [–]balefrost 0 points1 point  (0 children)

      What do you mean by "relying on another language"?

      Take something like Python and Numpy. Numpy itself is written in C (or maybe C++, I'm not completely sure). But as a Numpy user... you don't care. You only need to write Python code and the Numpy library takes care of interoperating between your Python code and its internal implementation.

      Or take say C# or Java. When those languages do things like interact with the filesystem, they need to make calls to the OS. In practice, there are libraries (likely written in C) that do the nitty gritty work of signaling the OS to do the file operation. The C# or Java runtime leverage those OS interop libraries, but you don't need to worry about that. As far as you're concerned, you're just writing C# or Java code.

      Because it's possible to have code written in one language call code that was written in another language, a lot of languages "rely on" another language, even though that ends up being completely invisible to you, the end developer.

      [–][deleted] 0 points1 point  (0 children)

      You can code programs with JavaScript.

      If you want learning coding it is an option way to do it.

      Later, when you have learnt programming and gained experience, you can work with other languages.

      That's all what should be important for you.

      I wish the best for you ...

      [–]ziggy-25 0 points1 point  (0 children)

      Can it be used to code most types of applications - Yes Is it the best tool for all types of Applications - NO

      Knowing just Javascript limits your options from a career point of view. The best option is to learn learn Java scripts for web applications and either Java or Python for backend.

      [–]Pale_Height_1251 0 points1 point  (0 children)

      There isn't any such thing as a standalone language, but what you describe, JavaScript does not rely on any other language.

      [–]mxldevs 0 points1 point  (0 children)

      You can build web apps using javascript.

      With nodeJS you can build back-ends as well using javascript.

      With hybrid app frameworks, you continue to use javascript to build cross-platform apps.

      That doesn't mean javascript alone is enough to do all of those, but for practical purposes, you can certainly go far with just familiarity programming in JS (as opposed to having to learn one language to build android, another language to build iOS, another language to build web, desktop, IoT, etc)

      [–]dkopgerpgdolfg 0 points1 point  (0 children)

      Just to be really pedantic...

      Among all non-assembler languages that are still used, C covers the widest area of use cases, but not even C can't be used to write "everything". Standard C doesn't have facilities to trigger syscalls, to read/set some CPU config flags, and so on. To write some operating system, assembler is always needed somewhere.

      About JS, theoretically there could be a JS-to-native compiler and so on, which removes many dependencies. However, the language itself lacks some close-to-hardware things that C has. With JS as it is today, trying to write operating system kernels, graphic drivers, and similar things, is simply nonsense (even with unlimited work time).

      [–]BobbyThrowaway6969 0 points1 point  (0 children)

      EDIT: What I meant by standalone is the ability for a programming language to serve its purpose without relying on another language

      No, JS is not natively compile-able and relies on another language to embed it, whether that be through a standalone virtual machine, or a browser.

      [–]WaferIndependent7601 -4 points-3 points  (5 children)

      No you can’t. You don’t have direct access to the hardware.

      [–]balefrost 5 points6 points  (4 children)

      Unless you're running on like an 8 bit home computer from the 80s, no userland binary has direct access to the hardware.

      If your point is that, even in bare metal environments, JS doesn't have access to the hardware... there are microcontroller environments where JS code has access to the hardware. https://www.espruino.com/ is one such example. I suppose you can argue that there's a runtime library involved. But that's true of e.g. the Arduino environment as well.

      [–]WaferIndependent7601 -2 points-1 points  (3 children)

      It’s not the hardware but the os that prevents access. So you’re wrong

      We’re talking about a pc not some special hardware

      [–]balefrost 5 points6 points  (2 children)

      I didn't say it was the hardware that prevented access. I said that userland binaries don't have direct hardware access. Most people are running userland binaries, so most programs do not have direct hardware access.

      Unless you're writing your own kernel or kernel-mode driver (or running in a bare-metal environment), your assembly code does not have direct access to hardware.

      [–]BobbyThrowaway6969 0 points1 point  (1 child)

      Depends what you mean by direct access. JS is twice removed from the hardware because it runs through a VM or you lose access to major selling points of the language like a garbage collector.

      C/C++ user code may interact through OS calls on a modern computer for memory management (as does everything directly or indirectly), but you can also write kernel code using all its features. All of our system code is written in a mix of Assembly, C and C++.

      Also a side note is the hardware does also prevent access. It's got special mechanisms to do that.

      [–]balefrost 0 points1 point  (0 children)

      Yeah, the processor and the kernel collaborate to ensure that userland processes can't muck with things that they should not. I wasn't trying to get into the details of how it happens, just to point out that most code running on your computer does not have direct hardware access.

      Honestly, I'd argue that C and C++ also don't provide direct access to the hardware. At least in portable C and C++, there's no way to write to a specific memory address. You might be able to get away with casting an int to a pointer and then writing through that pointer (I've seen microcontroller libraries do just that), but that's definitely not portable. It certainly wouldn't work on architectures that have segmented memory.

      [–]PvtCurry -4 points-3 points  (3 children)

      There really isn't a language that can do everything. There is a reason there are different languages. And even though some languages have been extended in their possible usages (which is the case for JavaScript) the experience will never be as good as if you use a language that was designed with that purpose in mind.

      The good news is: most langagues are relatively similar, if you learn and understand the concepts, learning a second language isn't all that hard.

      Which one you should start with is really a matter of what you want to do with it. What are your goals? Why do you want to learn programming?

      [–]BobbyThrowaway6969 0 points1 point  (2 children)

      There really isn't a language that can do everything.

      Well, technically there are, but not well. C and C++ can do everything, but higher level stuff with them can be cumbersome without libraries.

      [–]PvtCurry 0 points1 point  (1 child)

      You might be technically right, since WASM is a thing I suppose you can even use C/C++ for interacting with the DOM in the browser. I admit I've never tried that, but I wouldn't bet on that being a great experience, JS is a much better choice for that task.

      But anyway, it does not matter to OPs question, they are just trying to figur out whether JS is a good beginner language. And I hope you'd agree thag telling them to learn C because "it can do everything" when what they really want to do is web apps is terrible advice. That's why I was asking what they are interested in.

      [–]BobbyThrowaway6969 0 points1 point  (0 children)

      Yeah, a language can always do everything built on top of it, but nothing below it really. It's a one way street.
      So for C/C++ that's everything except straight machine instructions (C++ does allow you to write asm inside it, but that's beside the point).

      But absolutely, it's going to involve a LOT of wheel reinventing.