I remember being really unhappy about journals being binary for a long time.
Eventually though, I stumbled upon the fact that you can actually call something like strings $thejournalfile | grep MESSAGE on a journal and get the whole log in a more recognizable format. With just a bit more effort, you can actually recover the full log to plaintext in no time.
It would be nice if there were a convenience script like this provided with systemd, but that realization (i.e., in a pinch when the system has all but died, I can still go look at the logs because strings) pretty much ended any qualm I had with the journal.
I recognize that systemd is (still, somehow) pretty divisive, but ime, it has made system administration dramatically simpler and more pleasurable. I’ll use it till someone shows me something better.
I’d like to think I’ve a fair bit about UB in C (both recently, and over the years I’ve worked with the language), but I’m not familiar with the oldest version of the standard (C89) and was unaware of this difference from that version and its modern descendants.
I must say, many of the proposals I’ve heard online lately about fixing UB in C I’ve found either ill-informed, over-zealous or in some other way objectionable; but this seems to not only offer a much friendlier environment for the programmer, but also seems completely reasonable. It does not curtail a compiler’s ability to avoid having to care about the difficult-to-catch situations (as they can just ignore the case), which is one of the only general benefits of UB (to implementors).
I’m not a member of the C Committee (if only wishing made it so), but if I were, I’d love to hear this proposal.
I did not write this module, but I know the author and we’ve discussed this concept. His goal is to make programming more accessible and translating documentation is just one step towards this. I also know that the current implementation, using Google Translate, is more or less a proof of concept. The ideal scenario would be a help system for Python packages that supports localisation, i.e., provides ways in which people can document their modules in multiple languages, and perhaps optionally defaults to automatic translation for missing languages.
I’d be curious to know what other people think.
This is an awesome idea, and there has already been some work done in this space.
I don’t know how translations are handled in python (and since this tool is using google translate, I’m not sure how portable this idea is), but in C (and many other languages), GNU’s gettext is the standard. One of the benefits is that there are some great tools available for accepting translations; e.g., poedit. And there are online editors available too (though I cannot vouch for them).
Allowing a public translation effort (probably with review from someone) in a wiki style would be incredibly cool!
@achilleas, awesome project; I ope the author keeps it up!
The link is broken, yeah. The real link can be found in the top navigation. Reproduced here for convenience.
Rationals are so underrated.
I am constantly surprised by how many times I’m working on something and the perfect solution to the problem would be rationals, but the languages/frameworks/libraries/utilities at $DAYJOB don’t support them.
As a further example beyond the one in this article, there’s safe-money.
C#.NET and M$ SQL Server still have no built-in support for Rationals. It’s not hard to implement Rationals on top of Ints, but it means either extending the language (and creating a sane representation mapping in the db) with a pretty fundamental type or adding an external dependency (which I’m generally against).
This is yet another reason I’m so taken by Agda as a possibility for future development work. It has an incredibly powerful, dependent type system (including some of these fundamental types that I expect higher-level languages to have), wonderful syntax and identifier rules (notation as a tool of thought is one of my favorite paradigms championed by APL).
Fun write-up, thank you @begriffs. /me mentally marks down arbitrary user ordering as another wonderful application for rationals.
When I was doing video at Apple, I was always angry that neither Objective-C nor Java had a rational datatype. Particularly with video, you are almost never dealing with numbers that aren’t best represented as rationals. Trying to convince people that 23.976 is wrong and the right number is 24 * 1000/1001 was exhausting.
Interesting? Has there been some proposal to suggest this is bogus? (I don’t know one way or the other). I’d love to see some analysis that soundly debunks it.
Been reading up a bit on it, and this thread is a very succinct summary of what I’ve been seeing. Thank you for posting. I’ve removed my upvote on the thread.
Do we need a tag for “fake news”? I was hoping not ):
This looks awesome.
First of all, it’s compatible with lua 5.1, 5.2 and 5.3 so it’ll run on anything you can imagine. Second, (since it’s compatible with 5.1) it’s compatible with luajit, so it can run lightning-fast.
One of my big turn-offs with lisp is often that it doesn’t have the libraries and functionality I want pre-written. Yet, one of my biggest (though, really, only) beefs with lua is that its anonymous function syntax is so verbose.
This looks like it solves most of my issues with both languages; I get lisp’s compact syntax with lua’s wonderful library availability.
Next time I look coding up anything in lisp, I may seriously give this some thought.
Thanks for sharing technomancy.
link to my previous review of zig.
With that out of the way, let me say that this looks like a huge milestone for the language. A lot of the gripes I had about the language look like they’re being addressed (e.g., cutting down on the number of sigils, generating documentation, etc.).
Moving %return to try, for example, seems like a great decision to me. It elevates the return-type based error handling that zig has to use a similar vernacular as in exception-handling languages, but still keeping all the wonderful features of status-returns (plus it reduces the overloading of % which I deeply appreciate).
I can’t wait for 0.2 to come out; I’ll love trying zig again.
Oh and look! The docs are available online now! http://ziglang.org/documentation/0.1.1/ (I probably just missed this during the last release, but I’m so glad they’re available now!)
Congrats to Andrew; keep up the good work!
Interesting proposal, though it makes me wonder about something. Full Disclosure up front: my primary languages are C, Haskell and Lua; I’ve tried Rust numerous times and found it annoying/unusable enough that it will likely be a while before I take another serious look at programming in it. Having said that, programming language and library design is still something I find quite interesting.
I remember early on in Rust’s creation, many of the proponents of the language wanted to clean up some of C++ (and, by extension, C)’s mistakes. One of the things that I heard talked about a lot was #ifdef soup for platform/os support.
Recgonizing that I do not have a proposal for a better way of doing platform-portability, is this proposal not just a reversal of that stance and an adoption of the equivalent mechanic?
If not, then what am I missing? Is rust’s cfg somehow inherently better than the CPP’s #ifdef (more than just being in Rust’s macro system rather than a preprocessor)? If so, was this digression just a mistake/red herring (there’s nothing wrong with that, by the way—everyone makes mistakes); or something else?
I don’t think it’s a reversal of Rust’s previous stance. The current way of achieving portability in Rust is by putting platform-agnostic things in the stdlib, etc. This doesn’t change that.
I’m not very clear what “digression” you’re talking about.
Rust has always had cfg, and Rust libs have always used it for portability.
What this is proposing is that the stdlib should:
Before, you simply couldn’t use the stdlib for these platforms.
As far as I can tell, this is a revival of dwm’s tags/views model.
While, apparently, many dwm users use tags as if they are workspaces, that is only a fraction of their potential; and, when used properly, they can offer a workflow identical (from my perspective) to the one mentioned in the post.
This is not to say that the author is wrong or is stealing and should give credit or anything like that. It is only to suggest that this paradigm has been known and is available in some window managers.
Now, here’s where my knowledge of the subject gets a little thin. Where dwm supports this paradigm, I am unsure as to whether or not its many derivatives do (e.g., awesomewm, xmonad, etc.). I’d be interested in hearing from those users if this type of configuration is possible (presumably, anything is possible in xmonad since it’s really just a WM library and you can have whatever logic you’re willing to program, but I more meant, well-supported and easy to achieve through minor configuration changes).
Awesome supported this, I believe. I remember having Win+[1-9] set to switch between tags, and when I would accidentally hold control when switching I would get windows from both tags!
I like the idea of this, but I struggle with the execution when bringing in another tag causes overlaps or forces my current workspace to rearrange. For example, if I had chat and a browser open together taking up most of the screen while dealing with some operational issue, adding the editor group/tag to the screen would either overlap (if things were floating) or rearrange/resize existing windows (if some kind of tiling).
To those that use the group/tagging feature in the way described in the post, how do you deal with the overlap or resizing issue?
I fix the areas, so I don’t say «give me also group X», I say «please put group X in this subarea (and — in majority of cases — remove everything else from this subarea) without touching the rest of my screen»
I have pretty much the exact shortcuts you describe. I use tiling mode almost exclusively, so I expect it when I look at two at once. It seems totally normal. I also have super + J and K for moving windows up and down in the current order.
I’m not running xmonad at the moment, but it seems like xmonad-contrib has a XMonad.Actions.TagWindows module that does this.
dwm’s tags are indeed capable of handling that workflow I describe in this post, and even more IIRC.
My first experience with groups came with cwm which lets you add windows to a group. Doing so would automatically remove the window from any other groups.
With dwm, a single window can have multiple tags, thus allowing finer control over your task set, and which application to bring back and forth. This might be a little more complex to manage though, as you are responsible from adding AND removing windows from tags. Automatic removal from groups is, to me, the best compromise between workspace and tags.
I’m incredibly excited about this post for a bunch of reasons.
First of all, it’s great to have a commitment to weekly, public updates. I had grown concerned the project had just gone dark. Furthermore, to have the announcement that they are moving forward under the expectation that aarch64 will be their target is very exciting. It means that archlinux arm will almost certainly be reasonable to use!
It’s also exciting to hear the i.MX8 is in the works to get ful Etnaviv support so we can have a decent GPU experience.
Probably still a couple years out at the least, but I’m very excited!
I must say that I think there is a much better solution available here. Instead of dumping the full image in each time, use an SVG <use> tag. You can even define the SVG externally (for most browsers, and there’s even a polyfill for IE). You get to keep all your styling (assuming you’ve decorated your svg’s components usefully), and you dramatically reduce over-the-wire bits. You may still be sending more than with this hack, but it’s much cleaner and more flexible.
And, not to nitpick, but if your SVG is just a circle-enclosed exclam, it can be of much smaller size than that SVG is if you leverage things other than SVG’s <path>. Some things are much more compact when defined with <path>, but not all. And not in this case.
Cool, i didn’t know you could use an external source for SVGs with use. How would I got about reducing it? I’m not the original SVG creator. Is there some kind of optimizer I could use?
Sure. SVG have a large number of drawing directives. Programs that export to SVG tend to prefer <path> because it can do any possible shape that any other drawing directive can produce, so it is easier to programmatically output. Having said that, for anything like this, it is almost certainly simpler to use some of the other directives.
For example, here is the original you started with:
<?xml version="1.0" encoding="UTF-8"?>
<svg fill="#fff" class="issue-icon" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<path d="m8 0c-4.418 0-8 3.582-8 8s3.582 8 8 8 8-3.582 8-8-3.582-8-8-8zm0 14c-3.309 0-6-2.692-6-6s2.691-6 6-6c3.307 0 6 2.692 6 6s-2.693 6-6 6z" clip-rule="evenodd" fill-rule="evenodd"/>
<path d="M8.5,3h-1C7.224,3,7,3.224,7,3.5v6C7,9.776,7.224,10,7.5,10h1 C8.776,10,9,9.776,9,9.5v-6C9,3.224,8.776,3,8.5,3z" clip-rule="evenodd" fill-rule="evenodd"/>
<path d="M8.5,11h-1C7.224,11,7,11.224,7,11.5v1C7,12.776,7.224,13,7.5,13h1 C8.776,13,9,12.776,9,12.5v-1C9,11.224,8.776,11,8.5,11z" clip-rule="evenodd" fill-rule="evenodd"/>
</svg>
Here is a reduced version:
<?xml version="1.0" encoding="UTF-8"?>
<svg fill="currentColor" class="issue-icon" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<circle r="7" cx="8" cy="8" stroke="currentColor" stroke-width="2" fill="none" />
<rect width="2" height="2" x="7" y="11" rx="0.5" />
<rect width="2" height="7" x="7" y="3" rx="0.5" />
</svg>
The above is virtually identical to the one you are currently using (and can have its full color controlled with the following style):
.issue-icon {
color: #000;
}
This is a reduction in size from 678 bytes to 350 bytes. That change alone would have cut down on your page size pretty dramatically.
I am not aware of a minifier (as I said, most programs use <path> because it’s so much easier to programmatically generate), but it was not difficult for me (not a web-developer) to figure out this translation by-hand.
Note that OpenMP also works for C. However, in C, you need to set explicitly the loop variable as private, because C does not allow declaring it in the loop body:
int n; #pragma omp for private(n) for(n=0; n<10; ++n) printf(" %d", n); printf(".\n");
wat. The article was first written in 2007. Since C99, you have been able to declare variables in the for-loop preamble. The following works great for me, even when compiled with -std=c99:
#include <stdio.h>
#include <stdlib.h>
signed
main (void) {
#pragma omp parallel for
for ( int i = 0; i < 50; ++ i ) {
puts(i % 2 == 0 ? "Hello" : "World");
}
return EXIT_SUCCESS;
}
It works fine with GCC, but MSVC does not support declaring the loop variable inside the for of parallel for in C. If you try to compile the above code as C, you get “error C3015: initialization in OpenMP ‘for’ statement has improper form”, whereas it compiles fine as C++.
On a side note, MSVC does not allow the loop variable to be unsigned either (which I believe might be due to only supporting OpenMP 2.0, but still can be annoying (think size_t)).
It is very explicitly a C++ compiler that just added enough C99 compatibility for the C++ compiler to stay correct.
It is unreasonable to include it in the category of C compilers.
While that is true, it does seem somewhat random that it does support declaring variables in C for loops, except when they happen to be OpenMP loops.
Perhaps this is due to my thermonuclear blocking of scripts. But even after enabling scripts from cloudflare, auth0 (which I do not recognize) and unpkg (which I also do not recognize), I get a usable page; but entering anything in the search box does nothing (no results show up, for example).
This sounds like a cool project; might I suggest (noting that it’s open-source and you are not beholden to me to do anything) designing your site to gracefully fall back should js not load or be blocked?
I hope it goes well! More open-source search engines is probably a positive thing!
I’ve heard a few people mention negative things about OpenNIC, but they’ve never substantiated their claims or elaborated on what issue they have with the service. Can anyone enlighten me as to what the issue is with OpenNIC?
Personally, it’s a not-my-ISP DNS provider that doesn’t do DNS hijacking and offers a community to decide on what other TLDs should be served which isn’t motivated by profit (looking at you ICANN). That sounds awesome to me! What am I missing?
But how big is a char? According to the C Specification ISO/IEC 9899:TC3 Chapter 5.2.4.2.1 (the first one I could find on google) it is 1 byte (8 bits).
Nope. If you read the section referenced a little more carefully, you’ll note that the standard says that 8 is the minimum value for CHAR_BIT, not the exact value. While it’s not terribly common anymore, architectures having non-8-bit-bytes used to be somewhat typical. “Byte” ≡ smallest addressable unit of storage on a machine. “Octet” ≡ 8 bits.
When given a VLA, sizeof waits until runtime to compute the sizeof the variable. This is the only time that sizeof will operate at runtime instead of compile time.
Incidentally, this means that the argument to sizeof will be evaluated at runtime.
The things I find most confusing about sizeof tend to be things that are actually confusing to me about Cxx. Namely, the behavior in sizeof changes between C and Cxx in ways that can often be unexpected for C developers.
I would love this.
Though I am not likely to filter out C++ stories; I always feel a little sadness when I discover a C-tagged story that is really C++-related.
C++ is not a strict superset of C (it hasn’t been since at least C99); and since, the two languages have diverged dramatically with only a few features from C++ being migrated back to C.
If a C++ tag is not created, I would, at least, argue for the C tag being renamed C-family so that it is more encompassing and so my hopes are not so high when I see it.
I agree and would also not filter it out but I can see myself filtering down to just C stories. I am not interested in C++ but having a way to just list plain C articles would be useful.
I find this similar to having FreeBSD/NetBSD/OpenBSD as separate tags - they are all BSD/Unix but different enough to warrant their own sections. C is also not C++ even if they share a common origin.
I don’t see much point in ‘C family’ tag, as it’s hard to recall a single article or blog post that is relevant to all of the “family” at once and is not a 1000th rant about the perils of unmanaged memory.
Is there a chance for a donation feature that would allow the ad category to be filtered as normal? If so, then I have little issue; if not, then I’m vehemently against. I’ve worked pretty hard to lead an ad-free existence as much as possible for the last few years, and I would rather leave this community wholesale (which is something I’d prefer to not do) than to have it become yet another place where I am exposed to advertisement.
I have no issue with @jcs making money or, at least, breaking even on the site (hence my openness to donating), but I am not interested in seeing more ads anywhere ever.
I just recently gave notice at my job, so that has been winding down. My new job starts on 6 February, and my last day at my current place of work is 27 January, so I’ll have a week of down time in-between.
For fun, I do a bunch of things:
Possibly unpopular opinions (and a large block of text) incoming:
C++, Go, Swift, D and Rust all fail to adequately replace C for me. When given the choice, I would likely choose to just stick with C (for the moment; I’ll talk about what I’m considering at the end).
C++ has so much historical baggage and issues, it’s already an immediate turn-off. More than that, it’s explicitly understood that you should carve out a subset of C++ to use as your language because trying to use the whole thing is a mess of sadness (given that it’s massive at this point). I appreciate the goal of zero-cost abstraction and having pleasant defaults in the standard library, but there are just too many problems for me to take it as a serious choice. Plus, I still have to deal with much of the unfortunate UB from C (not all of it, and honestly, I don’t mind UB in some cases; but a lot of the cases of UB in C that just make no reasonable sense come across to C++). It should be noted that I do still consider C++ occasionally in a C-with-templates style, but it’s still definitely not my preference.
Despite how often people place it here, I do not believe Go belongs in this group of candidates The garbage collection alone makes it unfit for systems programming. I see Go as a very reasonable choice to replace Java (but I don’t use Java whenever I have the choice, so I might not be the best person to ask). There are many other parts of this language that rub me the wrong way, but mostly, I just think it’s not a good systems language (but is instead a great intro language for higher-level stuff).
Swift is really easy to rule out: It’s not cross-platform. Even if it were, it has all sorts of terrible issues (have they fixed the massive compile times yet?) that make it a no-go.
D, as far as I can tell, manages to be C++ without the warts in a really lovely way. Having said that, it seems like we’re talking about good replacements for C, not C++, and D just doesn’t cut it for me. GC by-default (being able to turn that off is good, but I’ll still have to do it every time), keeping name mangling by-default, etc.
-betterChelps with some of this, but at that point, there’s just not enough reason for me to switch (especially with all the weirdness of there being two de facto standard libraries from different organizations, one of which I think is still closed-source?sounds like I might need to take another look at D; though, again, its emulation of C++ still suggests to me that it won’t quite cut it).Rust is the only language in this list that I think is actually a reasonable contender. Sadly, it still bites a lot of these issues: names are still mangled by-default, the generated binaries are huge (I’m still a little bugged that C’s hello-world with glibc dynamically links to 6KB), et al.
But more than all of these things I’ve listed, the problems I have with these languages is that they all have a pretty big agenda (to borrow a term from Jon Blow). They all (aside from C++ which has wandered in the desert for many years) have pretty specific goals with how they are designed to try and carve out their ideal of what programming should be instead of providing tools that allow for people to build what they need.
So, as for languages that I think might (someday, not soon really) actually replace C (for me):
Zig strikes a balance between C (plus compile-time execution to replace the preprocessor) and LLVM IR internals which allow for incredibly fine-grained control (Hello arbitrarily-sized, fixed-width integers, how are you doing?). It also manages to have the best C interop story I have ever seen in a language so far (you can import from C header files no problem, and zig libraries can have their code called from C also no problem; astounding).
Myr is still really new (so is Zig really), and has a lot left to figure out (e.g., its C interop story is not quite so nice yet). However, it manages to be incredibly simple and terse for a braced language. My guess is that, in the long run, myr will actually replace shell languages for me, but not C.
Jai looks incredibly cool and embraces a lot of what I’ve mentioned above in that it is not a big agenda language, but provides a lot of really useful tools so that you can use what you make of it. However, it’s been in development for four years and there is no publicly available implementation (and I am worried that it may end up being closed-source when it is released, if ever). I’m hoping for the best here, but am expecting dark storms ahead.
Okay, sorry for the massive post; let me just wrap up a few things. I do not mean to imply with this post that any of the languages above are inherently bad or wrong, only that they do not meet my expectations and needs in replacing C. For a brief sampling of languages that I love which suffer from all the problems I mentioned above and more, see here:
They are all great and have brilliant ideas; they’re just not good for replacing C. :)
Now then, I’ll leave you all to it. :)
That was resolved a few years ago. D just has one stdlib, it’s fairly comprehensive, and keeps getting better with each release.
a bit of an understatement! The competing library was dropped in 2007.
Agreed with this. Go is my go-to when I need to introduce dependencies to a Python script (and thus fuck with
pip --userorvirtualenvor blah blah blah) for high level glue code between various systems (e.g. AWS APIs, etc.)I think there’s a reason Go is dominating the operations/devops tooling world - benefits of static compilation, high level, easy to write.
Look at the amount of hacks Docker needs to do things like
reexecetc. to work properly in Go, that would be trivial to do in C.Note that Zig is x86-only at the moment. Check “Support Table” on Zig’s README.
For that matter, Rust is x86-only too, if you want Tier-1 support.
I’m a big d fan, but I agree that it’s the wrong thing to replace c. Betterc doesn’t really help in this respect, because it doesn’t address the root reason of why d is the wrong thing to replace c (which being that the language itself is big, not that the runtime or standard library are). Personally, I think zig is the future, but rust has a better shot at ‘making it’, and the most likely outcome is that c stays exactly where it currently is (which I’m okay with). I haven’t looked at myr (yet), and afaik isn’t jai targeted at game development? It might be used for systems programming, but I think it might not necessarily do well there.
I think nim does this, and d for sure does, with d++ (I think this may also help with the c++ emulation? Also, I’m not sure why you’re knocking it for its lack of quality c++ emulation when it’s afaik the only language that does even a mediocre job at c++).
I agree!
As for knocking D for emulating C++, I did not mean to suggest that doing so is a count against D as a language, but rather just as a count against replacing C. I already ruled out C++, if a given language is pretty close to C++, it’s probably also going to be ruled out.
It’s been a long time since I looked at nim, but generating C code leaves a really poor taste in my mouth, especially because of some decisions made in the language design early on (again, I haven’t looked in a while, perhaps some of those are better now).
As for Jai, yes it’s definitely targeted at game development; however, the more I look at it, the more it looks like it might be reasonable for a lot of other programming tasks. Again though, at the moment, it’s just vaporware, so I offer no guarantee on that point. :)
I’m amazed that behind the project is Jonathan Blow, he is a legend programming original video games.