Hello,

I am thinking about teaching my students JavaScript first so that they can start creating websites and make their career, what are your thoughts?

all 76 comments

sorted by: hot top controversial new old
[–] 67 points 7 months ago (4 children)

If you also plan on teaching html and css, than I'd go for js first. Having your code instantly response in a visual way, is super motivating for most students.
If you just want to tech programming concepts, i'd go for python.
If you want this to be the start of a complete cs study, than you can start with C

  • source
  • hideshow 4 child comments
  • [–] [S] 11 points 7 months ago (3 children)

    That makes sense, I am also teaching html amd css first so I think JavaScript makes sense to teach next.

    I was thinking about C because that's the first thing I learned in the college and that's my favorite language till this day.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 14 points 7 months ago

    The problem with C as a language for learning is that the error messages are not very specific or descriptive and often you need extra context to understand what is happening. Messing up memory management can result in inconsistent gremlin-like behavior from your programs, it can get very tricky. I had a pretty difficult time when I got to classes that taught C compared to other languages, but the main thing was just that I needed someone to look over my work and explain things to me because unlike with other languages, the self-service ways of figuring it out were much more difficult and it's easier to get stuck with no idea what to look into next. I ended up begging people online for help with understanding what was going wrong with my programs to supplement the limited amount of time the professor and TAs were available, really grateful to those guys as I probably would have failed it otherwise.

    Anyway I would just say that if you do really want to go with C, I think you should be willing to put in more time to explain things to students one on one because many of them may need it.

  • source
  • parent
  • [–] 14 points 7 months ago

    What level are your students (primary school, high school, technical college, university)?

    You said it's not a core skill, so what is their core skill? IT? Machinist? Electronics engineer?

    C is an excellent "fundamentals" language that anyone with a software engineering and maybe computer science should have exposure too, but if their programming is purely practical (e.g. scripting for IT?) C is essentially irrelevant.

    Javascript is very narrow in scope but if they're web designers then it's essential.

    I'll back the other commenters that if they need a language they can do useful things in (e.g. simple automations, calculations), Python is hard to pass over.

  • source
  • [–] 13 points 7 months ago (2 children)

    I would teach Typescript. Being able to write the types down and hover things to see what types they are will definitely help them.

    I think C would put them off. I also wouldn't go with Python, in case they want to do things like write games or make websites, which are common tasks you can do with Typescript but not very well with Python.

  • source
  • hideshow 2 child comments
  • [–] 11 points 7 months ago

    Probably JS as the fact that every computer has by default everything you need to execute JS. But there is a bunch of browser stuff you have to worry about before you can do anything with it. I'm not sure how you learn JS before html.

    With Python you can do simple command line stuff without having to really know anything else. You can learn one concept at a time.

    That being said, people have a lot of familiarity with browsers and it might feel less abstract. JS might a better choice for demystifying coding. Python is probably a better choice for accomplishing anything useful.

  • source
  • [–] 10 points 7 months ago (1 child)

    What grade sudents is this for? Do you intend for this to be a dedicated class/semester or just a single unit? How good are they at operating a computer? (Typing, clicking, etc)

  • source
  • hideshow 1 child comment
  • [–] 16 points 7 months ago

    I would start with Python. It's a fun language to learn, and generally recommended for beginners. Towards the end, I would spend a few sessions on c, not to teach them c but to give them an appreciation for what they get for free in higher level languages.

  • source
  • [–] 16 points 7 months ago (1 child)

    I mean, they'll probably learn more from C. But please. You can do better than javascript. At least teach them python or something.

  • source
  • hideshow 1 child comment
  • [–] 1 point 7 months ago*

    JS is actually pretty great as a language these days.

    It doesn't have to imply NPM hell. And it's got normal syntax and doesn't do Python's weird meaningful-indentation thing.

    (It does have the == typecasting weirdness though.)

    -- Frost

  • source
  • parent
  • [–] 8 points 7 months ago* (1 child)
  • [–] 8 points 7 months ago

    Javascript is a horrible language, but it is ubiquitous. You'll want to spend a little time on html and css if you expect them to do more than print output.

    You could focus on TypeScript, which will help them avoid some of the worst things, but then you spend more time on tooling and it won't just run in the browser console.

    Python is a reasonably popular language with a good standard library. It has fewer bizarre quirks like adding two lists of ints together to get a string.

    I wouldn't teach C to a general audience.

  • source
  • [–] 30 points 7 months ago* (8 children)

    Why not python? C needs constant memory management and JavaScript is too chaotic. Both seem to me a bit too complicated for someone just starting

  • source
  • hideshow 8 child comments
  • [–] [S] 6 points 7 months ago (7 children)

    The main reason to not including python is that students aren't particularly in the CS field, they are learning it as their "augmented skill" (I don't know what it's called bad English). That's why I don't want to force them to learn CS concept which they might not even need.

    I was thinking about C so that their fundamentals gets cleared but I think it will be too much for students who aren't into CS. What do you think ?

  • source
  • parent
  • hideshow 7 child comments
  • [–] 52 points 7 months ago

    If they're not in the CS field, and you don't want to teach them CS concepts that they don't need, then you have eliminated C as an option by your own criteria.

    With C, they'll have to learn about compilers, build systems, memory management, and pointers at the very least.

  • source
  • parent
  • [–] 6 points 7 months ago

    The main reason to not including python is that students aren’t particularly in the CS field, they are learning it as their “augmented skill” (I don’t know what it’s called bad English). That’s why I don’t want to force them to learn CS concept which they might not even need.

    That's an even better reason to pick Python, then.

  • source
  • parent
  • [–] 9 points 7 months ago (1 child)

    Python allows you to focus on a single concept in isolation (building on what you've already learned, of course). JS has a bunch of other stuff mixed in. Like the DOM. Interacting with the DOM is necessary for any browser code. You can hide it with abstractions and boilerplate, but it's always going to surface in error messages. Debugging JS can be quite a bit harder than other languages.

    Caveat: beginner JS is many years behind me. It may not be as bad as corporate code full of react and angular and all kinds of requirements.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 6 points 7 months ago

    The fact that every computer has a browser where they can practice javascript probably makes it the better option. Python would probably require, on Windows, some setup that isn't what you want to spend time on, and may be a barrier to them trying stuff on their own time at home.

  • source
  • [–] 11 points 7 months ago

    C teaches a whole variety of low level concepts that are helpful in any comp sci field. That’s my vote. Python holds your hand too much and JS would require more to get started. If they aren’t shooting for a comp sci degree and are just looking for helpful scripts then python would be fine.

  • source
  • [–] 8 points 7 months ago

    Like a lot of people mentioned, there's a few good things you could start with, but C is probably not one of them. At my old job I ran a course for software engineer 2s to go over C, and even they had some struggles with it. If professional engineers struggle with C, it's maybe not the best starting point. Even C++ might be better, but still adds a lot of complexity that isn't necessary to know as immediately as the beginning.

    Whenever people ask me where to start, I say python. It gives you a relatively tame taste of environment setup, and can run code very easily and flexibly. Its type system is flexible enough to make a user aware of it, without it being as rigid as C or as vague as javascript. Because there's enough libraries that are easy to pull in, even a beginner can start building useful programs without having to know how to build something equivalent to those libraries themselves.

    Obviously if you want them to make websites, javascript will be necessary eventually, and isn't a bad place to start. If you're going purely for CS knowledge, I do think python is a little better; going from python to JS is probably easier than JS to python.

  • source
  • [–] 4 points 7 months ago* (1 child)

    After reading through some of the comments, here is my opinion.

    C would be a good language IF you know your students plan to get into IT, specifically a sector where the low level knowledge is useful. Beyond that, I assume your students probably use windows and I personally always find it a pain to work with C on windows outside of full IDEs like jetbrains and Visual Studio. It's also a lot more work till you get some results that you are happy about. Unless you start with an Arduino, which I find pretty nice to get students interested in embedded stuff.

    I don't like JavaScript because I find it a mess although it is very useful for anything web related.

    Given you said in another comment that this is meant to be a general purpose skill for your students I would strongly recommend python. While I dislike the dynamic type system, it is a very powerful language to get stuff done. You can quickly get results that feel rewarding instead of running into hard to fix issues that turn your students off of programming in general. Also it's very useful outside of IT as a scripting language for analyzing data in basically any field or for generating nice plots for some document

  • source
  • hideshow 1 child comment
  • [–] 1 point 7 months ago

    C on windows outside of full IDEs like jetbrains and Visual Studio

    My university used gcc on WSL and it worked fine. VS Code integrates well with it so you can use your VS Code installation on Windows to your code editing.

  • source
  • parent
  • [–] 9 points 7 months ago

    The answer is Python

  • source
  • [–] 13 points 7 months ago* (last edited 7 months ago) (6 children)

    No way it's C. The average student will go home and find that they can't do much of anything they like, with the level of C they know. Even printing a string is famously hard in C, they'll hate it. Nothing drains their interest in programming faster than segfaults.

    The average students wants to build games, websites, discord bots etc. Javascript makes it easy, none are easy in C.

  • source
  • hideshow 6 child comments
  • [–] 12 points 7 months ago (5 children)

    printf(“hello world!”);

    If this is famously difficult to you, I don’t think computer science is your bag.

  • source
  • parent
  • hideshow 5 child comments
  • [+] 3 points 7 months ago* (last edited 7 months ago) (1 child)
  • [–] 2 points 7 months ago* (last edited 7 months ago)

    I'm glad someone is saying it. I'm a software engineer and someone elsewhere in this thread is giving me shit for not having much use for the low level stuff.

    I was teaching a junior about character encoding a couple of months ago (I suspect his CS degree came free in a box of cereal) but most of what we do is build tooling on top of other tooling. I'm not working on bare metal here!

  • source
  • parent
  • [–] -1 points 7 months ago (3 children)

    That is not a valid C program.

    print('hello world')

    Is a valid python program.

  • source
  • parent
  • hideshow 3 child comments
  • load more comments (-1 replies)
  • [–] 3 points 7 months ago

    Without knowing anything about your students, it's hard to say. If I were the student I'd much prefer to be taught C, but that's because I have an existing interest in computers and a desire to develop systems programming skills. I wouldn't like to teach JS to anyone because it's a bad language and I don't want students to go away making more web 3 slop but if they actively are interested in making web 3 slop that'd be a case for teaching JS. I'm of the pedagogical school of teaching students what they are actually interested in learning. They might not know enough about programming to know which language they want to learn off the bat, but maybe ask them what sort of software they're interested in making. If they want to make websites, you might want to teach them something like Python with Flask, as something less bad than JS as well as easy enough to learn.

    Imo C is a good teaching language as it teaches you a lot about how computers work, as well as the fact that nearly everything runs on C. It is "harder" though, and imo is also for students who are actually interested.

  • source
  • [–] 4 points 7 months ago

    As a first language, JS is too much. They would need to learn three languages to make websites (JS, CSS, and HTML).

    I'd start with Python. It's easy to learn, and modern Python gives you the tools to write code that's easy to read and follow without being too verbose.

    uv should make things very easy to setup too. Install uv, then give them a starter repo with the Python version set. uv run should just work after that, no manual venv/conda/etc nonsense involved.

  • source
  • [–] 4 points 7 months ago

    C takes the cake

  • source
  • [–] 2 points 7 months ago (1 child)

    My high school AP computer science course in the ealry aughts taught C first.

  • source
  • hideshow 1 child comment
  • [–] 2 points 7 months ago* (last edited 7 months ago)

    Depends in the goal.

    If they are interested in Hardware, there is no better solution, than buying a hand full of cheap, "knock-off" Arduino Nano or RP2040 boards, a couple of LEDs and resistors and then let them Experiment with Arduino C, which teaches C programming in a fun and meaningful manner.

    If they should get actual useful skill, start with Python. It's easy to learn. It's widely used for small, single-person projects, e.g. for gathering and analyzing data, running simulations, organizing something, interacting with APIs...

    For any project, where I'd say, that it can be done quickly by a single person quickly on the side, Python is usually the best option. Even for experienced programmers. But especially for people that are new to programming or learning. It's easy, approachable and (because everything is handled by some library) quite safe to work with.

    It's by far the most useful language for anyone that isn't a full software developer. And it's among the easiest to learn.

    Also, when teaching Python, consider teaching with Jupyer documents. It immediately shows, what the short block of code is doing, instead of writing a huge and long script file, then executing it and struggling with debugging where students might not even know, how to start. An easy to host solution to supply Jupyer to a whole class is JupyterHub. If you aren't concerned about your students data, Google Colab is a JupyterHub for free.

    And now, finally, if you want a course that has some practical use (e.g. data analysis and math stuff) while also doing fun things and being incredibly interactive because of the use of hardware... Well... It's python again.

    Let them write a short branching story using Ren'Py. It's easy and will get them engaged. Go on and switch to Jupyter/Colab and do a bit of data scraping, data analysis/math or image filters. Basically introduce numpy, then pandas, then scipy, beautiful soup or openCV. Pure hard skills, that are applicable in many jobs. But realistically, due to time constraints in normal courses, all you want to do here, is numpy to get into it and automate math homework, followed by pandas, to load and automate excel files. And finally, let them do something with hardware, by programming a RP2040 in microPython. It's not as widely adopted as the Arduino ecosystem, but it's good enough for the simple stuff students will be able to learn, and you don't have to introduce a completely different language.

  • source
  • [–] 5 points 7 months ago*

    Neither. Teach them Scheme. They need to start by building good habits (functional programming).

    “Learn the rules like a pro, so you can break them like an artist.” ― Pablo Picasso

  • source
  • [–] 5 points 7 months ago (3 children)

    If you want to help people develop a fundamental understanding of IT concepts, teach them Python. C is very hard for beginners and will discourage most people. JavaScript is too inconsistent. Python will let people get results quickly and that way encourage them to carry on. Plus, it's one of the most popular languages out there so Python skills are definitely useful in the labour market.

  • source
  • hideshow 3 child comments
  • [–] [S] 2 points 7 months ago (2 children)

    Yes, python is very easy language for begginers and they might need it to create backend however most students don't even know the difference between frontend and backend. They just want to create few simple website. And even if I teach them python first to write APIs, I eventually have to teach them about html, css and js

  • source
  • parent
  • hideshow 2 child comments
  • [–] 4 points 7 months ago*

    Python. They'll only learn bad patterns from JS. Please teach bottom-up knowledge, not top-down narrow scope.

  • source
  • [–] 3 points 7 months ago* (2 children)

    I would say C first. You need to learn the fundamentals:

    • pointers
    • allocation
    • reference vs value
    • recursion
    • stack
    • panics, errors, error propagation
    • data structures

    Many devs don't know it and they are honestly just clueless about anything they are doing. They just want to make it work.

    JavaScript is just too high level, and makes you think you are immune to these low level concepts, but you are not.

    And not only that, but also good practices, like:

    • git
    • linting
    • types of tests and how to implement them
    • working with third party dependencies
  • source
  • hideshow 2 child comments
  • [–] 2 points 7 months ago

    I wouldn't say that pointers and memory allocation is a good thing to start with. I teach programming to students with no prior experience, and sometimes it's hard to even get them to grasp basic programming in Python. At least in the beginning. You have to start slow.

  • source
  • parent
  • [–] 3 points 7 months ago* (last edited 7 months ago) (2 children)

    I was taught a bit of C and still don't understand why. I see the use of C but it feels much too low level to be useful for the kinds of things I might want to do.

    Python and JS are much more relatable.

    Edit: I'm getting a lot of hate for this "hot take" for some reason. I don't know what to tell you, people learn this stuff differently. For me the "from first principles" approach framed programming as something I shouldn't bother with because it'd be forever until I learned how to do anything useful with it.

    To me C and C++ seem powerful but it feels like having to invent the universe before I can get anything done. I'm not working on embedded systems or something.

  • source
  • hideshow 2 child comments
  • [–] 5 points 7 months ago* (1 child)

    Ill counter that by saying that because you started with something more low level, the other stuff was easy (my belief).

    Also, depending on what the students are actually studying, I think you need to give an introduction to low level stuff because while some will want to do web dev for example, others might want to do low level stuff. Obviously if its a web dev course you dont want to do that, but if its something like CompSci or Software Engineering then i think having a grasp of the fundamentals of low level stuff is necessary.

    Lastly, if its a general introduction to programming course I think C has advantages over other languages since almost everything is done by you, instead of the compiler (for example iterating over an array - C: you need to do the for loop to manually handle the data depending on whatever type is stored in the array - Python: for x in y is sufficient). Im tutoring my little sister in programming because they have it in school, and they use python. Sure its easier to get things done, but its harder to learn/teach general programming with python in my opinion. C would have been my choice, especially since at that level its not like you need to teach/learn memory management, or complex data structures. Its the same concepts as with python (input, output, variables, conditionals, loops, functions) but the syntax just doesnt hide too much from you, unlike python, making it easier to understand whats actually going on

  • source
  • parent
  • hideshow 1 child comment
  • [–] 3 points 7 months ago

    I didn't find the difference in fundamentals between Python and C to be substantial. C felt similar but more unintuitive and more annoying to work with due to having to compile.

    Understanding exactly how the sausage is made didn't help me in the slightest. It was needless complexity when I already had a lot to digest.

    I understand your perspective but for me it was like throwing up countless roadblocks to the point where I lost all enthusiasm for the subject.

    It was many years before I tried again, this time with JS and Python.

    These days I'm a professional software engineer.

  • source
  • parent
  • [–] 4 points 7 months ago (4 children)

    Dont teach anyone javascript. periodt

  • source
  • hideshow 4 child comments
  • [–] -1 points 7 months ago (3 children)

    @dadarobot @ghodawalaaman TypeScript is way more powerful than JavaScript. I recommend learning TypeScirpt, Kotlin, Python, C# and Java but not Rust

  • source
  • parent
  • hideshow 3 child comments
  • [–] 2 points 7 months ago (1 child)

    JS for sure.

    It has a reputation among programmers as being a bit of a mess, but I think the reasons behind that reputation are largely irrelevant to your use case.

    Basically:

    1. It has some bad decisions about basic stuff, like truthiness, equality, coercion. But those aren’t major stumbling blocks, really. When they run into those situations, they’ll probably already be aware that they’re trying something weird and won’t have the same already-developed intuition about “how it should work” that many of us are bringing to the table.
    2. Production deployment can easily turn into a Rube Goldberg machine. I think this is mostly what the kneejerk “really? JS?” response is about. Different ES versions, module systems, WASM, dependency hell, transpilers on top of transpilers, and a billion different runtimes. And the fact that everyone and their grandma apparently wants to build a custom DSL on top of JS that requires additional transpiler plugins or codegen steps. But your students won’t have to worry about that shit. Just pick one environment and do that. Maybe warn them that stackoverflow might use different syntax (require vs import) or try to import stuff that doesn’t exist in their environment though.
  • source
  • hideshow 1 child comment
  • [–] 3 points 7 months ago

    If there's a need to introduce students to virtual DOM, I'd choose a library that doesn't require language extensions or editor plugins, but allows to easily code with just the syntax of JS itself: properties as Plain Old JavaScript Objects, map/reduce with arrow functions, ternary operator, variables as usual, components as functions. Adding Mithril to existing WordPress websites for making dynamic parts such as calculators or quizzes was quite straightforward. On the other hand, its API is somewhat less convenient than what React offers.

  • source
  • parent
  • [–] 1 point 7 months ago*

    I would go for something like Processing for students who are just trying to learn a bit of programming as an extra credit. The JS implementation is called p5.js. I would introduce a little bit of C later in the course once the students are familiar with basic programming concepts. That way you can show them what is happening behind the scenes without overwhelming them from the start.

  • source
  • [–] 1 point 7 months ago

    Let them learn what they’re interested in so long as it passes muster as capable of sufficiently handling the concepts you wish to convey. Some will want low level, some will want an app, some will want to make games. The cross pollination of concepts will demonstrate that while languages may have individual benefits they should not stop at one.

  • source
  • [–] 1 point 7 months ago

    Why not SmallBasic then? You could even point them to old computer magazines and see which codes they can get running without much workaround.

  • source
  • [–] 1 point 7 months ago

    I'd start with logic, infrastructure and design first. Once that is locked in they can use any language to move forward as it's only syntax you need to learn once your logic and design is solid. I'd offer them a choice of three different languages to achieve the same end result of the assignment. This shows them the importance of logic and design and the transference of skills.

  • source
  • [–] 1 point 7 months ago

    TypeScript > JavaScript all day

  • source
  • [–] 1 point 7 months ago

    Maybe a middle ground like Go.

  • source
  • [–] 1 point 7 months ago

    So, of the two JavaScript, because motivating them to program is more important than anything else if they have no prior knowledge. javascript has great tooling and faaar less hurdles to get something going then C. Personally i'd go with TypeScript if it has to be anything in this family of languages, because making them think of types early on is helpful when moving to anything more than little web apps. If any other languages are considered, i'd go with python with type hints because it forces you to format your code somewhat readably (believe me, i know that it's possible to write unreadable python code) but is really low on boilerplate, has great tooling (at least third-party, use uv) as well as stellar IDE support and allows for multiple different paradigms to be explored.

  • source
  • [–] 1 point 7 months ago
    [–] 0 points 7 months ago

    C and python simultaneously.

  • source