ChubakPDP11+TakeWithGrainOfSalt

  • 30 Posts
  • 25 Comments
Joined 8 months ago
cake
Cake day: February 10th, 2024

help-circle




























  • It’s a term that generally refers to the more ‘mathematical’ side of programming, as opposed to the more ‘practical’ side of things. I believe it means ‘Data Structures and Algorithm’ so its a generalization of ‘meaty’ programming. Think, someone who writes shell scripts does not need ‘DSA’ to oil his grind, but someone needing to write a compiler does.

    Now we live at an age where you can generate a shell script with a simple prompt, and hell, you could piece-meal a compiler, but it’s not as straightforward. If one wishes to make moola in the post-LLM world, one needs to have strong theoretical and constitutional foundation.

    At this point, any employer who hires more than 1 person for the ‘simple tasks’ is doing charity. And charity ain’t what employers known for!

    That is not to say, don’t use AI in your work. I believe AI is the BEST way to learn DSA. In fact I straightened a lot of my misconceptions using ChatGPT. Like, I have written 2 compilers and abandoned them because I never meant to finish them, it was an excuse to prompt ChatGPT with more complex requests and do some reckon on my knowledge. I managed to do ‘basic’ SSA with ChatGPT, and anyone who has read a compiler book or taken a class knows SSA is not easy. I generated the SSA, and confirmed with the SSA book that I had. IT was very decent. But ther SSA book was very ‘crude’ and ChatGPT’s example was really, well, ‘uncrude’? So it was a GIANT help in me understanding SSA.

    So if you need to learn DSA, I can recommend these three steps:

    1- Learn a functional language or LISP-like language, Scheme, Racket, OCaml, SML, Haskell, etc. These langauges are extremely fluid and scientific.

    2- Read books. Just go on Libgen or Zlibrary and read books. I recommended SIpser’s above (or was it in another post?) but there’s dozens. I remember a book called “Grokking Algorithms” which was really good. I read this book when I was sick with Covid, Steven Skiena’s “The Algoritmh Design Manual” and it seems like everyone just LOVES this book. I mean it, try it, it’s the best. If you can, buy it, because it’s very precious. Also, keep a copy of CSLR/CLSR or whatever as a reference on your desk, PC everywhere.

    3- Piece-meal ChatGPT into designing you a complex application. It really helps if you got an aim. One thing I recommend is Genealogy software. Make a Genealogy DSL perhaps. Or a simple compiler.

    My advice may not be sound, but some aspects of these were helpful for me.


  • I think you are irresponsible towards your future if you are a gainfully employed self-taught programmer, and don’t invest in formal education. If you say ‘I don’t have time!’ well, consider this, even night classes in junior colleges teach you stuff you don’t know. Go to them, get your associates. I am in the process of getting into a contract where I do some thankless jobs for someone I know, he in exchange pays me to go to college. I am 31 – as I said in the other thread, THERE IS NOTHING WRONG WITH BEING A LATE-COLLEGER!

    I have been to college, I have studied 3 subjects for a total of 9 semesters, I have no degree to show for any of them :( I quit English lit, French lit and “Programming” all after 3 semesters. But when I was studying French lit, there was a guy in our class who was SIXTY-FIVE YEARS OLD! He wanted to learn French to open up some a commerce consulting office, focusing on import/export from France.

    What I wanted to do was to ‘write’, keep in mind, ‘write’, not ‘draw’ bande dessine! But now that I am older and hopefully wiser, I have a set goal in mind. I am going to go this ‘boutic’ college near our home to study Electronics Engineering and when push comes to shove and China makes its move, start a chipset engineering firm with a production wing.

    Just like how electronics is math with physics, programming is the virtual aspect of it. it’s ‘applied math’. I understand enough discmath because I studied enough of it both in college, and high school (since I was math/physics elective) so I have managed to understand some very rough and old papers.

    You can always self-study if you haven’t got the time. Here’s a book which is kind of a meme, but it’s still very good: https://fuuu.be/polytech/INFOF408/Introduction-To-The-Theory-Of-Computation-Michael-Sipser.pdf

    This is the 2nd edition though, 3rd is out — I think 4th is coming. The best goddamn book, regardless of its meme status.


  • I remember that from ages ago. It was very, very cringe-worthy. I think it’s the fault of whatever shit bootcamp he attended to learn his ‘craft’ for using imperative languages to teach DSA, if they taught him DSA at all? That is why in real universities they mostly teach DSA with functional languages. I studied ‘programming’ (not CS, ‘programming’) in a college which by American standards would be considered ‘junior’, for 3 semesters, and they, too, did not touch on functional languages. It was not until I had dropped out that I learned how to do FP using SML, Ocaml, Haskell, Scheme etc. That was when I ‘understood’ DSA for real.

    Truly, this person is an embarrassment. I am currently working on an implementation of Appel et al’s ASDL (github.com/Chubek/ZephyrASDL, check the new_version branch!) and it now emits decent C code, so it is time to write the man page (it currently has a sucky one) and the TextInfo. I COULD potentially have ChatGPT make both, it is very decent at doing so. But see, I am not a moron. So I use write them in Markdown and have Pandoc make the final markups.

    Truth is, if you know your tools, if you know how to use a DSL-driven approach to programming, you won’t need to use AI to generate your code. You don’t need to go to Harvard to know DSA, neither a junior college like mine. Just grab CSLR and read it on your spare time!

    I think this person is the guy behind Homebrew. I don’t know why he thought Homebrew is an accomplishment that would give him immunity from knowing basic DSA — which in real world, is what programming is about. Package managers have existed since the dawn of time. Linux has like dozens of package managers. His package manager being ‘unique’ on MacOS does not mean it’s an accomplishment, it means MacOS sucks cocks!

    Basically, when you start a project, think: can I turn this project into a paper? If you can’t, then it’s worthless. He could have just strapped Pacman to be built on MacOS and called it a day!

    These days, employers are looking for people with theoretical, constitutional knowledge. Any monkey can code. I let ChatGPT aid me with a lot of my C code, it’s very decent at generating C. Like I need a Makefile, it makes it for me. I need a print help function, it makes it for me. There’s nothing wrong with using AI to ‘help’ you, but don’t use it in vital shit!

    But, if the code that AI generates is as good as the vital backbones of your software, maybe save up some money and go to college if you haven’t, a 2-year degree at a junior college will be good. I am going back to college next year and I am 31! There’s nothing wrong with being an old student.

    Just don’t expect people to suck your dick when you don’t know how recursion works!


  • Good point me lad. The plain-text based approach indeed makes scraping much easier. And plus, if we send a ‘process’, the process can be easily malicious, even if we don’t elavate its access.

    Like imagine today. I tell you to wget a shell script and pipe it to shell to install my software from my remote (FPT, Git etc). This almost always needs sudo. I can’t imagine how many 12 year olds would be fooled to sudo rm -rf *?

    That is provided that a 12 year old would even know how to do that. I know several people who began their UNIX journey when they were as young as 7~8, but there’s a reason these people earn 500k a year when they are 30! I can’t imagine if your normie aunt would really feel like using a UNIX pipeline to check her emails.

    HTTP ‘just werks’. Derpcat told me this in 2010 when I told her I hate HTTP in 2010. IT JUST WERKS. Kay’s solution, although extreemly unbaked, would not allow my mom to read her Intagram feed.

    Besides money, the computation cost is also high. Kay used to use mini-computers, us poor people used micros (if i were a poor person when mini/micro distinction existed, today it’s just clusters vs Jimmy’s gaming rig, oh, where art thou, DEC?)

    But again, nobody has given a it a thought. THAT IS THE ISSUE. Academic text on alternatives to web, AFAIK, is rare. Part of it is the ‘just werks’ thing, but also, academia just does not care about web.

    I think if people who are smarter than me would give this a ‘thorough’ thought, they will come up with a good solution. Web won because it was ‘open’, it was easy to navigiate, as opposed to pesky newsgroups and the such. You can still go to the first website to see this: http://info.cern.ch/ (browse this with Lynx or W3M, it’s the best way to do it! Don’t use FF or Chrome).

    I dunno!


  • You don’t need any garbage 3rd party packages. Just use ctypes.

    Read the documentation for ctypes. You can use any native object in Python the way you do in C using ctypes.

    Whatever you do, don’t trust some god-forsaken 3rd party package. I think people have forgotten to be clever and resourceful these days. A binary object is itself a package, why would you use s another package to communicate with it?

    Here’s how you can import libc into Python:

    from ctypes import CDLL
    
    libc = CDLL(None)
    

    Just pass it path to the binary object that holds the symbols for GPIO.

    Some tricks. Here’s how you can use libc to make a syscall in Python:

    libc = CDLL(None)
    
    TIME_NR = <syscall nr for time(2) on your arch>
    
    libc.syscall(TIME_NR)
    
    
    

  • So I am going to explain the concept of macro preprocessors to you — m5.awk is a macro preprocessor, so is m4 so is GPP so is C’s CPP, so is my Ekipp and so is my AllocPP.pl. They all work like this:

    1- Frank Frankis (hereby referred to as FF) creates a file called my-file.randextrandext here meaning that macro prerpcoessors work on all kind of files, be it a C code, a Python code, an HTML template, your tax files, your notes to your GF, your angry letter to your boss, etc;

    2- There are dozens and dozens of uses for a macro preprocessors, but let’s say FF wants to obliterate two birds with one sniper shot, he wishes to write a manual for his new Car XAshtray ™, in HTML and Markdown, but he wants it to be contained within one single file – and he wishes to reuse certain fragments of text, certain HTML tags, certain Markdown syntaxes, to be ‘reusable’, just like a ‘function’ is reusable piece of code in an imperative language (but not a functional language!) or how a template works in C++, etc.

    3- FF enters the file with his favorite text editor. He defines these ‘functions’, which are the ‘macro’ part of a macro preprocessor. Think what ‘macro’ means. It means ‘big picture’ basically. I think the better term here is ‘meta’. These two words have a close relationship in the English language, don’t they?

    Now let’s see what macro preprocessor FF uses. Since GPP is really similar in syntax to C’s preprocessor (at least with default settings) let’s use GPP. I would use my Ekipp here but I honestly have forgotten the syntax (believe it or not, creating a language does not mean you are good at it).

    #ifdef __HTML__
    #define TITLE <h1>My Car XAshtray Manual</h1>
    #define SUBTITLE <h5>Throw your ash on me</h5>
    #define BOLDEN(text) <b>text</b>
    #elif __MARKDOWN__
    #define TITLE  \# My Car XAhtray Manual
    #define SUBTITLE \#\#\#\#\# Throw your ash on me
    #define BOLDEN(text) **text**
    #else
    #error "Must define a target language"
    #endif
    

    FF keeps defining these. Now comes writing the actual manual.

    Keep in mind that GPP stands for ‘Generic Preprocessor’, it’s a text macro prerpcoessor and not a language preprocessor like CPP (C’s preprocessor) is. m4 and Ekipp are like that. My AllocPP.pl is a language preprocessor, it preprocesses C. So now, this means FF can now freely treat my-file.randext as a text file, with a ‘language’, the Macro Preprocessor language, defining the output (I’ll talk about what I mean by ‘output’ soon).

    So he writes his manual:

    TITLE
    SUBTITLE
    
    Hello! Are you okay? Why did you buy this ashtray? BOLDEN(ARE YOU OKAY?). In this manual I will teach you how to use my ashtray...
    ...
    

    Replace the last ellipse with rest of the text, the Car Ashtray manual.

    Now, FF needs to ‘preprocess’ this text file. This is, well, the ‘preprocessing’ part of a macro preprocessor. It’s like compiling a program with a compiler, except you are compiling text-to-text instead of text-to-binary.

    gpp -D__MARKDOWN__ my-file.randext > my-manual.md
    ``
    But what happened at `-D__MARKDOWN__`? I think you have already guessed. In the 'program' we asserted if '__MARKDOWN__' is 'defined', then then define those macros as Markdown, else HTML. We can also define a macro with a value:
    
    

    gpp -DMyMacro=MyValue my-file.randext > my-manual.md

    
    Now, GPP has more built-in macros like `#ifdef`, they are called 'meta macros` (as opposted to the macros you yourself define). There's `#include` which includes a file. There `#exec` which executes a shell command. Etc etc.
    
    Now, you can read more about GPP on its Github. I was in touch with its maintainer, Tristan Miller, very recently when I showed him my Ekipp. He has made a new version of GPP so don't install it from your package manager like apt, install it from source because the release is very recent and these packages take ages to be updated. GPP is just one C file, very neat and clean. Read the man page (`man 1 gpp`) for more info.
    
    m4 and m5 or Ekipp etc, as I said, are too, generic text preprpocessors. My Ekipp has this feature where, you can treat any program like PHP works:
    
    

    #! delimexec $ ‘‘awk “{ print $1; }”’’ | <== foo bar ==>

    
    This will run the AWK program in the file.
    
    You can install my Ekipp using these commands:
    
    

    sudo apt-get install libreadline-dev libgc-dev libunistring-dev wget -qO- https://raw.githubusercontent.com/Chubek/Ekipp/master/install.sh | sudo sh

    
    Bring up `man 1 ekipp` to learn about it.
    
    Keep in mind that Ekipp has some bugs. I will have to completely rewrite it honestly but I am busy making an implementation of ASLD (github.com/Chubek/asdl) and I am working on an implementation of AWK and later C so a macro preprocessor does not bite me really.
    
    Thanks.
    
    
    
    
    

  • I forgot to mention, tools like Bison and Autoconf use m4. Andrew Appel calls languages that need preprocessing ‘weak’. The specs for D also call C ‘weak’ for needing to be preprocessed. Preprocessing is almost an abandoned practice, at least in the world of programming, because Scheme-like ‘hygenic macros’ have taken their place. Some languages like Rust and Zig are attempting to reinvent the wheel by re-inventing macros, but Scheme had it right in the 70s. Truly, C and Pascal’s preprocessor were out the door in the 70s, let alone, now.

    Here’s another preprocessor that is 'neat: GPP.

    I have made my own preprocessor, it’s very nasty and has a lot of bugs because I was an idiot when I made it: https://github.com/Chubek/Ekipp

    I have half a mind to remake Ekipp. I don’t know what purpose would it serve. But it’s just neat, I think preprocessors are neat, as useless as they are.