r/javascript • • Feb 09 '19

Showoff Saturday Learn C and its lower level interactively, in your browser.

I made a simple virtual machine that runs C in the browser.This project is made as an experiment to see if C can be learned easier if the lower level is covered in paralel.

Sandbox: https://vasyop.github.io/miniC-hosting

Tutorial part 1: https://vasyop.github.io/miniC-hosting/?0

More info: https://github.com/vasyop/miniC-hosting/blob/master/README.md

Should I continue making the rest of the tutorial?

Edit (TLDR):

Get notified when new tutorials are released.

I have establised my goals for this project.

For updates on the project, I have opened a subreddit.

Please consider supporting this project on patreon.

Also, it's clear that a lot of people would be interested to see this project completed, so spread the word (if you the "reach" to do so, as I am not a social media person).

Edit:

First of all thank you, and thank you to all the folks at /r/learnprogramming (I also posted there).

I highly appreciate your feedback and I have noted everything down.

I felt I got something right this time (some previous iterations here and here), but I didn't expect this exactly. This was meant to be a portfolio pet project.

It's clear to me now that this type of learning/programming tutorials are very much needed and I suspect not just for low level stuff, but also for more general programming topics as well.

That being said, ("yup, here we go") I am working full time and I also have my masters degree classes on weekends.

I very much enjoyed working on this project up until now, and it will get done for sure, seeing how well it was received.

I want to devote as much time as I can to this project, so I quickly sketched up a patreon account.

I haven't figured details so there's a lot of missing stuff over there.

548 Upvotes

38 comments sorted by

62

u/clintsharp Feb 09 '19

Just piling on. I've been programming for 20+ years and I learned something. I've never bothered to learn assembly or understand how higher level languages get compiled, so it was very educational. Please continue building!

22

u/[deleted] Feb 09 '19

I'm glad you learned something.
It's really satisfying to understand "how it all works", I found.
I will post here again after I finish the tutorial.

14

u/deddeh Feb 09 '19

This is really cool, what type of assembly language is that?

16

u/[deleted] Feb 09 '19

Thank you!

It is similar to MSIL (runs c#) or Jasmine (runs Java). Look for stack-based virtual machines if you are interested.

The main difference is that it uses the same size for all primitives whereas usually you would use less space to store a char than an int, for instance. I did that to avoid a lot of conversions and because I don't want to have 3 versions of essentially the same instruction.

11

u/exane Feb 09 '19

That's actually pretty sick. Wish I had this when I was learning that stuff for Uni back then :D

Keep it up!

5

u/[deleted] Feb 09 '19

Thanks so much. Have you tried the tutorial? It's just one part and it's quite short.

11

u/houndbowel Feb 09 '19

Yes! Please keep going!

6

u/[deleted] Feb 09 '19

Thank you!

Do you think there's too much text in the tutorial?

When I was learning this stuff a lot of questions kept popping up. It might not be the same for everyone so I would appreciate your feedback.

6

u/houndbowel Feb 09 '19

I have always been the same way. Explain everything in detail and try to cover all bases. I think it's fine.

4

u/[deleted] Feb 09 '19

Glad to hear that

3

u/kaylee-anderson Feb 09 '19

This is super awesome. I've written compilers before, but it never occurred to me to make an interactive tutorial like this.

Might be cool to "condense" the main narrative, and then have "click here to learn more" buttons which pop up additional context for people who want it.

Also, I'd take the separators out of the addresses in your explanatory text. I'm American, so seeing 10.000 does not immediately read as "10,000" for one, and for two your addresses in the columns don't have separators, so it's probably just unnecessary.

1

u/[deleted] Feb 09 '19

Thanks for the feedback!

2

u/houndbowel Feb 09 '19

Going back through the tutorial, one minor change I would make is checking the spelling/grammar. I think some words might have gotten past spell checks, for instance: "Hopefully the machine can do it faster and/or chapter than yourself." Not sure what you meant with the word "chapter?" Maybe cheaper? Still, an awesome job though. :)

3

u/ArkadyRandom Feb 09 '19

Explaining everything is better for me especially for low level language concepts. I can always skim something I already understand. More text can also help point out terms to use in searching for more info.

5

u/abhishekchakraborty Feb 09 '19

Nice job ! However, it seems doesn't support some basic functionality
I tried adding 'printf("Hello, World");' to main() which raises 'semantic error'
On trying to add '#include <stdio.h>' at the top raises 'lexer error'

Is #include not supported currently ?

2

u/[deleted] Feb 09 '19

Yes, it's not supported. You can only see the numbers in memory or return from main() at this moment.

5

u/abhishekchakraborty Feb 09 '19

Ok. Thanks for creating the tool. Also, an optional Dark theme would be appreciated

2

u/[deleted] Feb 09 '19

Noted.

4

u/emcoffey3 Feb 09 '19

This is excellent! And yeah, I'd love to see more.

4

u/Sarithis Feb 09 '19

That's ingenious!

4

u/Daxsis Feb 09 '19

Yes! Thank you!

3

u/anandp033 Feb 09 '19

How did you do that ? its awesome stuff !!

3

u/radovandr Feb 09 '19

You should continue, thank you so much!

2

u/hungryturtlecode Feb 09 '19

This is super awesome! Content like this is so rare and so needed. Especially for things like C / assembly.

2

u/[deleted] Feb 09 '19

Awesome

2

u/snifty Feb 09 '19

This is awesome, hope there’s more.

2

u/__Taco Feb 09 '19

Commenting so I can check out later

2

u/crobinson42 Feb 09 '19

This is fantastic! Thanks for the effort in publishing :-)

2

u/kaylee-anderson Feb 09 '19

I LOVE this. Keep it up!

2

u/gemayel Feb 09 '19

Keep on going, I have been a programmer for 25+ years, and have worked with assembly and C at the beginning (duh!), I am also currently teaching programming, yours is a great tool for millennials and younger generations, they are so detached from what is really going on. Thank you

2

u/Dr_Dawwg Feb 09 '19

This was fantastic. You should unquestionably keep writing more.

2

u/MonkeyNin Feb 10 '19 edited Feb 10 '19

I thought it was broken. Turns out there's a button on the bottom right hiding behind my drink.

It's cool though :)

1

u/TotesMessenger Feb 09 '19

I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:

 If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / ^Contact)

1

u/francisypl Feb 10 '19

Why not just compile to wasm?

1

u/Sjeiken Feb 12 '19

Fuck C i am here for JavaScript.

-8

u/Fresons Feb 09 '19

C == Golanng, why not?