7 ms·
Wait, you're telling me I can just download these 3-5 source files, type `make`, and it will _just build_? No: * Setting up an isolated build env * Pulling 1
by jvanderbot 3y ago
Wait, you're telling me I can just download these 3-5 source files, type `make`, and it will _just build_?
No:
* Setting up an isolated build env
* Pulling 1600 dependencies and building them from source
* installing a filesystem layer with 1600 .so libraries
* running docker, npm, etc?
_AND_ it compiles in a fraction of a second?
Amazing what this new language C can do.
- xtracto 3y agoAah this brought me back memories! Waaaaay back in the day (90's) I would implement my own methods I stead of say including stdlib.h or other libraries because I had the (wrong) idea that including it would bloat my C programs (didn't know how a like worked uh?) . 12 year old me would choke seeing NPM, pip, or bundle these days... or Electron! We could do so much with so little!
- dheera 3y agoI've always loved programs that didn't even need "make". The ideal build and install experience should be: $ gcc foo.c; cp a.out ~/bin/foo $ foo Now that is a REALLY good build experience.
- tomcam 3y agoYou probably know that this is routine and even simpler in Go: $ go run main.go
- dheera 3y agoYes, and it boggles my mind why C/C++ hasn't come up with a better built-in build system already. I shouldn't have to specify a ton of flags to g++ something, it should find them within the project directory and pull in dependencies automatically. Header files should be done with. Poof. Gone. There is zero reason for them to exist. I know exactly why they exist, but it's an artifact of a system where preprocessor, compiler, linker are separate. I should be able to do "import<foo/bar>" multiple times and it should pull in all the classes and functions in "./foo/bar.cpp" or "./foo/bar.so" (whichever is available), just like Python, and cache the ".so" files just like Python caches ".pyc" files. Improving C++'s build experience would have absolutely zero impact on execution speed. Yet they're busy adding some stupid spaceship operators and other things people almost never use.
- morning-coffee 3y ago> Yes, and it boggles my mind why C/C++ hasn't come up with a better built-in build system already. Wait... you didn't get the memo? They did, and renamed the language in the process... it's called Rust. ;)
- tomcam 3y agoI’m annoyed too, because I love C and back in the 90s languages like Turbo C and Microsoft C were quite intuitive to use from the command line and using whatever old editor you wanted. I would still very happily be using modern C if the overall experience were like Go.
- lelanthran 3y ago> Header files should be done with. Poof. Gone. There is zero reason for them to exist. The reason they still exist is due to how useful they are. The majority of Android applications probably wouldn't exist if C had done away with headers.
- lelanthran 3y agoEven simpler in C, when using tcc as the compiler.
- chungy 3y agoYou don't need a Makefile, but you can just run "make foo" and it'll automatically run "cc -o foo foo.c" for you.
- anyfoo 3y agoAlmost thirty years and I never knew that.
- wruza 3y agoMake has builtin rules for most obvious build jobs: https://www.gnu.org/software/make/manual/html_node/Catalogue-of-Rules.html https://www.gnu.org/software/make/manual/html_node/Catalogue... You also can pass env vars to it: $ CC=clang make foo https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html https://www.gnu.org/software/make/manual/html_node/Implicit-... And (with care) define your own in: https://www.gnu.org/software/make/manual/make.html#MAKEFILES-Variable https://www.gnu.org/software/make/manual/make.html#MAKEFILES...
- kstrauser 3y agoI helped interview a front end developer who bragged about and insisted on hand-writing every bit of JavaScript so that we’d have the leanest possible website. He did not make it past me. Not that we don’t care about those things, but we have better uses for our time and money than implementing an in-house version of React. Also, our other engineers would probably have strangled him.
- tambourine_man 3y agoYou may have lost a good developer. Enthusiasm is valuable. Trying to do the best possible thing, even if misguided.
- intelVISA 3y agoNice, you really showed him.
- GuB-42 3y agoGP was talking about stdlib, you are talking about react. Not the same thing at all. Using stdlib is almost free on most systems. It is usually preloaded so it doesn't even use up ram. Unlike functions you write yourself. And with static linking, linkers will only take the functions you actually use, not the whole library. A js library needs to be downloaded and compiled in its entirety by the user browser. There are techniques to make it less bad, none of them ideal. The way I interpret GP post is that 12 year old didn't want to bloat his code but had a misguided idea of what causes bloat. You are saying that bloat is fine if it saves on dev costs. Two very different ideas.
- kstrauser 3y agoReplying to myself: Please give me a little credit! It wasn't that I'm against writing code in-house. That's my favorite part of my job! But someone insisting that they want to write everything themselves is a huge red flag. I mentioned React to give it a contemporary context. The interview was a few years ago, and they were ranting against the bloat in jQuery. That also wasn't the only reason I said no, and I won't go into detail about the rest.
- anyfoo 3y agoOh god, fun related memory. When I was 10 or 11 or so, I programmed in Turbo C on my PC. At some point, I messed up some pointers that I passed to strcpy(), so young, smart me decided that "string.h must be broken" (I actually also thought it contains the actual definitions), and moved the file away so that I don't accidentally used it. Yeah sure, that's what must be broken. Not my code. A while later I got smarter, and progressed enough to hook into DOS interrupt handlers with my C code and some assembly glue code. I decided to make a program that would click the PC speaker every time the hard drive is accessed (not a new idea, but a good exercise), by hooking into INT 13h (in DOS/x86 in general, sw interrupts were basically used as system calls). To my delight, it worked, and it suddenly seemed like I had a very loud hard drive. But DOS would also spit out strange I/O errors when trying to list the current directory. Huh, weird, I wonder if the same happens in the root directory? So, "cd \", followed by "dir", and, yep, I/O error. Okay, let's reboot and... doesn't boot? It dawned on me pretty much immediately what must have happened: I didn't restore all registers correctly before calling the old hard drive sw interrupt handler (again, system call in modern parlance). It must have been unlucky enough to convert some reads into writes. And by trying the same thing on the root directory, I probably converted some reads to the sectors making up that root directory into destructive writes... oops.
- xtracto 3y agoGreat stuff! Back in the msdos/win3.11 days I experimented with TSRs and viruses (following tutorials and the like) . At one point i borked my (Dad's) computer running some stupid "virus" I created that infected COM files... had to basically delete the whole disk.
- glandium 3y ago> young, smart me decided that "string.h must be broken" I mean, fundamentally, you weren't completely wrong.
- echelon 3y ago> Amazing what this new language C can do. One well-maintained C project in isolation. I've also seen nightmares that are difficult to build on certain platforms or require undocumented build dependencies. Let's not forget how horrible the automake/Cmake/Scons/etc. ecosystem can be. Everything is awful when there's no attention to the dev experience.
- fsociety 3y agoJust wait until you add a bunch of dependencies. Then you get to discover the nasty parts.
- twic 3y ago> Wait, you're telling me I can just download these 3-5 source files, type `make`, and it will _just build_? No. You need make and a C toolchain installed. If you have those installed, you almost certainly also have Python, Perl, and possibly even a reasonably recent Java (not on MacOS, yes on most Linux distros, i think) installed, and all of those are also capable of doing this with zero dependencies.
- croes 3y agoI think parent wrote that because nowadays many projects are for JavaScript or Python with lots of dependencies.
- kramerger 3y agoNot only that. The build systems can also be really crazy I've seen embedded C code that requires Python AND Ruby to build. Linux is still using makefiles (+ config). Your project cannot possibly be more complicated
- tremon 3y agoLinux, being a kernel, has no external dependencies (except for its menuconfig, which requires ncurses). That sort of isolated build tree is very rare in almost every other software project, even something like gcc has a dozen external dependencies IIRC.
- endgame 3y agoIt does, including at least a shell, a C++ compiler, make, and a bunch of other UNIX/GNU tools to run the whole thing. And where do you get those programs from, and can you trust them? If you look really seriously, a scary problem emerges. (See: Trusting Trust Attack) The Guix project recently hit a massive milestone in untangling this, by creating a package set which starts by building a 357-byte program and works its way up to the utilities you'd expect: https://guix.gnu.org/blog/2023/the-full-source-bootstrap-building-from-source-all-the-way-down/ https://guix.gnu.org/blog/2023/the-full-source-bootstrap-bui...
- the_gipsy 3y agoSame for every language: if the env is installed and the program has no dependencies, just run build command. This one needs some unspecified versions of gcc, make, and ncurses installed.
- jvanderbot 3y agoMinimizing dependencies is a lost art, is mostly what I'm saying.
- sophacles 3y agoThat's not what you said though, you said i could just download it and type make and it would just work. That's not what happened for me, and it seems to be a very odd way of presenting a very different message. Turns out the minimal dependencies needed involve several OS packages and also the special "dev" versions of those packages installed, and I need to use one of the right subset of terminals. Having the implicit knowledge to get the "magic", doesn't have anything to do with minimizing dependencies. Sounds like the real thing being said is: "It's neat when people use a toolchain and environment I'm familiar with". I don't think that extrapolates to "minimal dependencies are what we want".
- jvanderbot 3y ago"Minimizing Dependencies" Consider the set of dependencies required to recreate this in language / framework X. I assert that this set of dependencies is larger (in some cases much larger) for probably all languages and frameworks, except those that are built using the same language, compiler, and libraries used by, and shipped with, the target operating system. I would also assert that the speed to build, install, and deploy the package would be worse. Larger here means "includes more lines of code", as well as "requires more libraries" and "requires more executables, probably from interpreters". "Worse" here means "more time required to resolve", "requires more downloads", and/or "requires more CPU cycles to solve the multiple levels of indirection from interpretation". It just so happens I have npm, nodejs, cargo, g++, python3, pip, and gcc floating around, and I almost always find that 'make' with `gcc` is the fastest gun in the west, as long as you stick to some basic OS libraries, as this project does. Cargo is real, real close, and probably equal if you ignore the long dependency chains that result for almost any project. But that's much more verbose, and I think the original message implied this for most readers.
- j1elo 3y agoTo be honest, I must admit to believe that whoever else did this same tool with JavaScript, no doubt would have used a package.json that needed to download at least a couple hundreds of dependencies.
- sophacles 3y agoAnd unless a person is using linux with the right tools installed, they have to go download an entire OS, get it set up, install all the right libraries and then, maybe (if they did it right) they can type make and pretend to "not have to install a whole bunch of dependencies".
- j1elo 3y agoYour comparison is a bit disingenuous. I thought that the reasonable point of comparison was obvious, so let me state it in case it's not: * For this C program: Let's say a default install of a Debian system, with GCC and Make installed. Nothing else. Just clone and run make && ./bin/nms. * For an hypothetical JavaScript implementation: Same Debian system, with Node.js installed. Nothing else. Just clone and run node ./src/nms.js. Now tell me that the second point would ever happen, of course without the obvious trick of vendoring tens or hundreds of dependencies in the repo itself. Given the current trends and ecosystem incentives in the JS development world, I highly doubt it. These trends only favor mindless composition, of which the latter is good, but the former is bad. IMHO most devs would probably not even consider the idea of writing a compact, self-contained piece of code and have their own termio [1] or charset [2] implementations, to begin with. [1]: https://github.com/bartobri/no-more-secrets/blob/master/src/nmstermio.c https://github.com/bartobri/no-more-secrets/blob/master/src/... [2]: https://github.com/bartobri/no-more-secrets/blob/master/src/nmscharset.c https://github.com/bartobri/no-more-secrets/blob/master/src/...
- sophacles 3y agoSo your assertion is that if those exact same devs would write C, they would somehow magically stop seeking out libraries to solve the problem for them? Because there are thousands and thousands of C libraries, just like there are libraries in every other language. That seems a bit of a stretch - my "disingenuous" assertion is that library use is orthogonal to language. Also, there are plenty of non-C languages (js may be one of them, but it's been half a decade since I touched it and longer since I used it in any meaningful way) that you could transliterate this program into - its a handful of lookup tables, a couple loops, and a couple syscalls available in every stdlib I'm familiar with. It seems disingenuous to assume that there are only C and JS (or being generous that those extremes are the only options).
- stavros 3y agoFrom personal experience, the number of times that I've typed `make` and it worked are so few, that now I basically think "cool, but there's no way I can compile that" and close the tab whenever I see a C project. This project built fine, though.
- theandrewbailey 3y agoAgreed. 90+% of the times that I've wanted to compile something, I couldn't. I suspect that it was mostly because of missing or outdated dependencies. The only things that I can reliably compile are image encoders.
- uwagar 3y agoif ud like to ride a rollercoaster try this: http://plusplus.free.fr/rollercoaster/ http://plusplus.free.fr/rollercoaster/
- philsnow 3y agoDon't forget the bad-old-days of `sudo make install`. I'll note that this project does come with an `uninstall` Makefile target, but not a lot of projects do/did.
- nsxwolf 3y agoI expected to have bad luck on my Mac, but I ran: git clone https://github.com/bartobri/no-more-secrets.git https://github.com/bartobri/no-more-secrets.git cd no-more-secrets make ./bin/nms It worked!
- omniglottal 3y agoI just did the same on Android in Termux. Clone, make, and it "just works".
- varispeed 3y ago> Amazing what this new language C can do. To be fair it's a very old language, but what's crazy is that decades later engineer still have not come up with a way to execute the C directly, but have to rely on a process called "compilation". I mean how hard is it to make a CPU that understands C? /s
- charcircuit 3y ago>decades later engineer still have not come up with a way to execute the C directly The dynamic C listener from symbolics C could do this decades ago.
- Name_Chawps 3y agoCrazy how few dependencies a toy console program needs. I wonder how minimal a giant web app written in C would be? Would it still compile in a fraction of a second?
- jvanderbot 3y agoI've deployed microservices in C! It's a PITA. Not to build, but to get the microservice to accept C. It builds real fast. Then zip, and `aws lambda blah blah` works fine.
- marcus0x62 3y agoIt would compile quickly -- on a relative basis -- it would just take 2 - 10x longer to write than something in a language more suited to web development... And probably also contain a bunch of RCE vulnerabilities.
- netfortius 3y agoWhere is the API GW cluster load balancer?
- theamk 3y agoOnce you have gcc installed, yes it just works. It's only 184MB and 2153 files (tested on random VM). Python is actually smaller, 82MB and 1461 files, and has a much better stdlib. If you never wrote zero-dependency python scripts, give it a try! It's a very nice experience: download file / clone repo, run a file and that's it. Not even a build step.
- sgarland 3y agoThis (and learning stdlib better) is precisely why on a Python project of mine, the only external dependency is a C shared library to run some parts faster than Python can (making giant arrays of ints and shuffling them). I bundle precompiled libraries for the architectures I have available, so you don’t have to make if you don’t want to.
- anthk 3y agocheck tcc
- pixelbath 3y agoAnd the repo doesn't ask you to pipe curl output directly into the shell? Neat!
- speedgoose 3y agoYes it’s very different. You download source code and execute it. Compared to downloading source code and executing it.
- opan 3y agoThe more manual and stepped method makes it more likely you'll read through it first.
- speedgoose 3y agoI don’t believe the average user carefully analyse the makefile or similar build instructions.
- bdavbdav 3y agoIs this code for “check out the number of git stars and go ham on the .sh”
- andai 3y agoIt's funny, C++ projects either have the best or the worst setup experience. Took me hours to get Audacity building on Windows. Actually, I might have given up and installed Linux instead, and built it there. That's usually way easier! But the other day I built an old MP3 encoder (BladeEnc) in a split second. It brought a tear to my eye. That's with Visual Studio 6. Which somehow builds an entire project before the new VS even begins compiling!
- lsh123 3y agoThis is a property of Windows C++, not other C++'s :) :) :)
- tempodox 3y agoEven more incredible is that the project readme actually explains everything and you don't have to be a member of some cult to get the secret knowledge that makes everything klick.
- deleted 3y ago[deleted]
- lxe 3y agoshakes head in windows > make: The term 'make' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
- msla 3y agoThe supported Windows version is WSL. Everything else is weirdo legacy crap. /s
- benguild 3y agodon’t worry, someone will port it to JS
- jonmasters 3y agoBut it would probably be better as a containerized microservice with 100 RPC endpoints. Just think how flexible this would be. Even better, 1000 containerized microservices with failover and autoscaling.
- chaxor 3y agoDon't advertise these languages, else they will become like the wretched python is now. Python used to be fantastic. It actually used to just work. That stopped once everyone caught on to the language, Nvidia got involved, and tensorflow / pytorch /ML ruined everything with so many script kiddies writing nonsense that had no interest in making their packages compatible with anything. The community is the best, but also very very much the worst part of the language.
- anyfoo 3y agoI doubt C needs much advertising nowadays...
- wruza 3y agoIt already happened with autotools, bsd ports, cmakelist list lists and static-y linked apps like “snaps” and its analogs. C is not special in this regard. Special part is an OS itself that takes the role of a single system-wide virtualenv or node_modules/.. with all common trouble packaged in. Python and others didn’t create this trouble, they ejected it from your system into a single rm-able folder.
- anyfoo 3y agoMy favorite example of this is `xneko`, which is a cute cat that chases your mouse pointer. It's a C program running under UNIX/X11 that was last updated in 1993. Last I tried, it still compiled with absolutely minimal changes (I think I had to change an #include directive or something) after typing `xmkmf; make` (which was the way to compile X11 programs at the time), and runs, on macOS. Provided you have Xquartz installed.
- NoZebra120vClip 3y agoWayland should put the kibosh on that. How long until macOS has to migrate?
- galkk 3y agoI am not talking about terminal support or something like that, but I actually find this example quite telling too, but from totally different perspective. An effect that I could write in high school using Pascal and that would require only builtin library and few loops, in proposed source code requires so much *stuff*. Given that this is a fun demo and not something that one needs to maintain as enterprise software, I totally would accept such trade off and remove dust of something simpler. Oh, memories. Using Crt; GotoXY();
- Gordonjcp 3y agoWell, it still seems to be sitting up top, so I had to pick on this comment when I made a demo of the proggy: https://youtu.be/jDwy8Js4FiU https://youtu.be/jDwy8Js4FiU
- lmm 3y agoIt'll also silently send all your credit card information to the mafia if you compile it with the wrong version of GCC. How do you know which is the wrong version of GCC? That's the neat part, you don't.
- anta40 3y agoFirst, make assumes a C compiler is already installed. Example on Debian: do apt-get install build-essential Second: usually docker, npm, etc are not needed. If the code use 3rd party C libraries, you need to install it. On Debian, again you can use `apt` to make life easier.
- worksonmine 3y agoIt would be safer if written in rust, especially since it deals with something as important as encryption. /s in case anyone is confused.