HNHacker News
TopNewBestAskShowJobs

sjolsen

390 karma · joined April 17, 2014

submissionscomments
sjolsen··on I would have hired Doug, but...
It's a shame, too, since C++14 is a far cry from 1983's C++ (or whatever version the majority of the segment of the industry which uses C++ is actually using), and the others are similar stories.

One the one hand, I suspect ams6110 was referring more to those things we give names like "pattern," "architecture," and "paradigm," maybe even "stack," "platform," or "library" than to languages. On the other, my suspicion may be wrong, and I'd agree with him about it if it were anyway; so little that's been developed in the world of programming languages recently is anything new, and what isn't is as often as not a poor reimagining of something Lisp or ML had figured out pretty damn well ages ago, thank you very much.

Still, though, progress has been made even on the mainstays, even if the industry hasn't quite caught on yet.

sjolsen··on Alan Kay on Messaging (1998)
Other differences between message passing and function calls aside, I disagree with this characterization. While many mainstream languages perform static binding of functions, it is not an inherent feature of functions (at least as I personally have come to understand them); the canonical example is Common Lisp's generic functions, which behave in almost exactly the way you describe message passing.

I think no small part of the disagreements in this thread can be attributed to people simply having different notions of what phrases like "function call" mean, with some envisioning invoking a statically resolved, monotyped C-style subroutine, and others a more abstract notion of issuing a command to perform a computation with an understood set of semantics on a provided collection of data. The latter is what I think of a function as in a computational context, and from what I've gathered from the other comments here, a fair approximation of what is typically meant by "message passing."

Now, there's something to be said for differences like the treatment of synchronization and process boundaries, but I'm inclined to categorize those as the same sort of pragmatic-but-technically-untrue distinctions as that between so-called "compiled languages" and "interpreted languages." Certainly there is at the very least an isomorphism to be established between the two conventions, given access to threads, promises, and some form of IPC.

sjolsen··on Where Rust really shines
I tried using Rust the other day, and I had the same problem. What I found indicated that "unstable" features are permanently disabled in all but the nightly releases.
sjolsen··on Learn you an Agda
Runtime performance for Agda... well, it leaves a lot to be desired, at least with respect to the MAlonzo compiler. For example, operations on the natural numbers à la Data.Nat get very slow very quickly-- but while the representation used by Data.Bin speeds things up a lot, you just can't do the same Peano-style structural induction on it.
sjolsen··on Learn you an Agda
This was one of my first encounters with Agda, and it's a language I've developed something of a soft spot for. I highly recommend playing with it if you have any interest in Haskell or ~undergraduate-level pure mathematics.
sjolsen··on Random Points on a Sphere
>Although we’ve successfully generated uniformly distributed points on a sphere, it feels messy. Some points seem too close together, and some seem too far apart.

This is how randomness should look. If you randomly generate (using a high-quality random engine) uniformly distributed points on a square plane or even a line, you'll see the same apparent clustering.

Put another way, if you plot every point on a coordinate grid with integer coordinates, you'll have a uniform distribution, but it will hardly be "random."

sjolsen··on Fearless concurrency with Rust
>I haven't investigated it but variadic template template arguments might help there, though.

They do:

    template <template <typename...> class Container, typename T>
    Container <T> fin (T n) {
        Container <T> set;
        for (T i = 0; i < n; ++i)
            set.push_back (i);
        return set;
    }
    
    int main () {
        for (int i : fin <std::vector> (10))
            std::cout << i << std::endl;
    }
sjolsen··on Fearless concurrency with Rust
>I think generics are poorly understood in general

Perhaps by programmers (and the designers/maintainers of certain mainstream languages...), but there are some very strong models out there; we've had well-behaved parametric polymorphism à la Hindley-Milner for decades and Haskell's typeclasses are in my opinion a very well-thought-out approach to ad-hoc polymorphism (and which the more ambitious C++0x version of Concepts in some ways resembled).

C++'s templates are like the untyped lambda calculus of the type-level world; they're perfectly capable of doing most anything you'd want from them, but using them effectively requires a lot of boilerplate and discipline (and as for std::allocator_traits et al., I think that's more an issue of library design than the design of templates).

I've never found subtype polymorphism particularly convincing beyond the case where independent single classes implement meaningful interfaces, and that's basically like a member function–oriented version of typeclasses.

Now, all this said, I haven't actually used Go, so I don't know how well the rest of the language would interact with these ML/Haskell-style systems, but I imagine at least basic parametric polymorphism would be relatively unobstructive.

sjolsen··on Ask HN: What is your favourite unpopular programming language?
Agda; it marries formal mathematics and programming in a very satisfying way. I can't wait to see what comes of it and other intuitionistic type theory–based systems.
sjolsen··on A Brief Guide to the Common Lisp Object System
For more on CLOS, "Object-Oriented Programming in Common Lisp" is a fun little book. It has some reasonably practical examples and touches on just enough of the system's low-level details. It doesn't have much to say on the Metaobject Protocol, though, and I think for that "The Art of the Metaobject Protocol" is pretty much the standard text.
sjolsen··on Artificial Sweeteners May Change Our Gut Bacteria in Dangerous Ways
I'm assuming you're talking about canker sores. I don't know how much help this will be to you, but here it is anyway:

You may have tried these, but I've found the best ways to dull the pain are swishing 50/50 Maalox/Benadryl and using a styptic pencil.

Also, I've found in my case that what helps most to prevent them is keeping my mouth as clean as possible. The two main causes I've identified are illness and physical trauma to the tissue. The worst offender is the crap plaque excrete; it eats away at tissue, and I've found more than a few new sores under a stray piece of lunch. Oh, and I've had far fewer sores since I switched to an SLS-free flavour of Sensodyne.

sjolsen··on The Importance of Mathematics Courses in Computer Science Education
>Computer science is often treated as an offshoot of mathematics when, in reality, you need to do far, far more writing than advanced math. Most students are going to be leaving school and working on professional programming, where they'll largely work with a group of people jointly maintaining systems. And these systems require good writing skills to effectively write documentation for the code, as well as writing the design documentation.

Computer science is an offshoot of mathematics— or it was until everyone decided that "computer science" meant "software engineering."

sjolsen··on The Importance of Mathematics Courses in Computer Science Education
>Programming != Math.

Programming also isn't computer science.

>Logic is important, but that is mostly orthogonal to any course of math instruction I've ever been exposed to.

I think that's the issue the author intends to address: computer scientists not having been exposed to a mathematical treatment of logic.

>you may go weeks without using any math that an elementary-schooler couldn't perform

If by "math" you mean "arithmetic and basic algebra," yes. If in "math" you include logic, induction, abstract algebra, graph theory, combinatorics, etc., then you're using math every time you write any code at all, whether it's ensuring you don't write any cyclic dependencies, making sure you correctly handle all return values, or making sure an algorithm doesn't require quadratic time or worse before you implement it. You need math if you want to know that your custom comparators won't cause a sort routine to blow up, to recognize certain possible sources of bugs in unsafe languages, and most of all to recognize and assess the validity of potential optimizations.

I mean, one can program with just a basic grasp of boolean logic and high-school algebra, but they'll have a hell of a time of it.

sjolsen··on Google Says 5% of Visitors to Its Sites Have Ad Injectors Installed
It's so hard to tell sometimes.
sjolsen··on Google Says 5% of Visitors to Its Sites Have Ad Injectors Installed
>I haven't tried Linux recently (about two years ago) but when I did I had major headaches with a Broadcom wireless driver, and a Bluetooth chip, that both worked flawlessly on windows 8.

As someone who has used Debian almost exclusively for a few years now, I've got to admit that Windows 8 really does handle drivers nicely. Linux systems are generally pretty good about drivers these days, at least if you allow proprietary drivers, but nothing beats total out-of-the-box automation.

sjolsen··on Google Says 5% of Visitors to Its Sites Have Ad Injectors Installed
>You'd never see OSX or Linux letting people install software without going through a walled garden.

I can't speak for or against OS X, but with respect to Linux this is plainly false, unless by "Linux" you mean "Android" or by "walled garden" you mean "basic user authentication."

sjolsen··on Sublime Text 3 Build 3080
I'm not offended or insulted by what you said. I don't even disagree with most of it, except maybe how you're using the terms "complete" and "proper." Saying that something isn't complete or proper generally really isn't compatible with a claim of impartiality.

I really have no problem with criticism of Emacs (provided that it's true, and now that you've expanded a little, I think what you're saying is true), but if you feel that familiarity (whether everyone's or just someone's) really sets Emacs and Sublime Text apart, call it criticism! :)

sjolsen··on Sublime Text 3 Build 3080
>I can't see any smoothness in scrolling of Emacs' graphical interface in Linux.

I'll grant that Emacs doesn't have this. Most programs don't either, though, and in the few I've seen that do (e.g., Firefox), it slows scrolling down so much as to make it practically unusable, even if it does make it easier to track the text with your eyes.

The real usability problem with Emacs' scrolling, in my opinion, is that the default scroll increment is too large. That's easily fixed. Some people also don't like that keying the cursor past the top or bottom of the window causing a large jump as the displayed region recenters around the point, but again, that's easily fixed.

>Only a handful of 3rd party packages use some badly-imitated pop-ups and I've never seen anything even resembling a pop-up in Emacs' graphical interface (maybe except the GTK+ open file dialog)

Most prompts (e.g., yes-or-no prompts, the password prompt for auth-sources) initiated with the mouse use pop-ups. Between that and the file chooser, what exactly is missing?

As for alerting the user that input is needed, Emacs doesn't generally require input from the user except when the user has just deliberately issued a command which requires input, in which case they don't need to be alerted (the one exception I can think of is when opening an auth-source may fail, and Emacs does use a pop-up for authorization then). What's more important in the long run is how easy the input method is to use, and unless you're already using the mouse (in which case Emacs does use pop-ups, as noted above), pop-ups are not easier to use.

>I can't see anything resembling the command palette Emacs' graphical interface. Everything is either use the minibuffer or open a new window.

The command palette looks a lot like helm-M-x to me.

>Speedbar isn't even close.

I didn't say it was. Now, I don't know about connector lines, but direx looks the same to me as Sublime's file tree sidebar and neotree even has icons.

sjolsen··on Sublime Text 3 Build 3080
>It's not just a familiar interface. It's a better interface. Smooth scrolling is better than line-based scrolling. A popup is better at alerting the user that input is needed than a small prompt at the bottom of the screen. The command pallete, which is clearly visually distinguished from the surrounding text by a gui border, is better design than yet more lines of text indistinguishable from the rest. Current selection highlighted in a bright, theme-able colour is better than just toggling the background colour. Little graphical icons next to lines indicating changes, breakpoints, etc is better than a random text character put before the line. Smooth animations are better at conveying change than instantaneous changes to text. Filesystem trees with pixel-wide connector lines and icons indicating file type, displayed in a smaller font than the main text are better than a file tree drawn with ASCII art. The fact that key bindings can interfere with your terminal emulator or shell's keybindings is an annoying restriction.

I agree with almost all of this, which is why I use Emacs' graphical interface instead of its terminal interface.

sjolsen··on Sublime Text 3 Build 3080
So all in context, it sounds to me like you're saying that what sets Sublime Text apart from Emacs is simply that it uses a familiar user interface. I suppose that's fair enough.

What I wouldn't say is fair, though, is characterizing something as incomplete and especially improper simply for being different from what you're used to.

sjolsen··on Bug 1202858 – Restarting squid results in deleting all files in hard-drive
>And don't even get me started on how Bash interprets filenames as part of the arguments list when using * (e.g. file named "-rf")

That's not Bash. That's just... programs in Unix. Such is life when everything is stringly typed.

sjolsen··on Sublime Text 3 Build 3080
>For me, the thing that sets sublime apart from vim and emacs is the fact that it is a full gui app. Things like go to definition, autocomplete, build panel, command pallete, sidebar, context menus, are all technically possible in vim, but hacking these features into a command line interface always ends up seeming clunky, confusing and slow.

I can't speak for vim, but Emacs is also a "full gui app." It has go to definition (in fact, I wouldn't be surprised if this idea was invented in some incarnation of Emacs), autocompletion, and various other such features like gdb integration and build message hyperlinking. The discoverability argument applies as well.

sjolsen··on The Go Programming Language by Brian W. Kernighan, Alan Donovan
>The problem is now how complex a language is, but how much needless complexity it allows you to build yourself.

Any Turing-compelete language allows you to build arbitrarily much needless complexity. I don't see how it's a useful metric at all, except to say, "Well, this language isn't quite so horribly stunted that you can't even produce a nonterminating program."

If you want to talk about how easy it is to build needless complexity— well, I've yet to see a programming language that knows the difference between necessary complexity and needless complexity well enough to allow the former and prevent the latter. Rather, languages either let you build complex things easily, whether you need that complexity or not, or they just make it a right pain in the ass to accomplish anything.

Personally, I prefer the languages that let me express the complexity of my problem domain easily; sure, I could use them to make things more complex than they need to be, but I don't, because to be quite frank that's just part of being a competent programmer.

sjolsen··on C Questions and Answers
>I think this was silly, the author clearly does know C but they are complaining about optimizing compilers which do things "behind your back" and are becoming an increasing nuisance

I think the compiler behaviour is meant to be illustrative of the main point, not the main point itself, which I think is simply that the actual C language is more complicated than people appreciate. Most of the examples have nothing to do with optimization whatsoever; they're purely focused on correctness.

sjolsen··on C Questions and Answers
I don't believe the author is claiming that C is obsolete; nor do I believe he is claiming that no one knows C.

What I do think he's implying, if not outright claiming, is that there are many people who grossly overestimate their knowledge of the language. That doesn't mean there aren't a lot of very talented and knowledgeable C programmers— but there are a lot of people out there who think they're hot shit because they've done all the exercises in K&R, but who have no real familiarity with the formal semantics of standard C.

sjolsen··on C Questions and Answers
>Did he make sure the behavior he mentioned is uniform across all ISO standards?

I don't know.

>What is his source for coming up with a certain answer to a certain piece of code?

His conclusions are consistent with my understanding of the C standard. His justifications for his conclusions refer to specific rules regarding program behaviour, which suggests he's using the standard(s).

>First of all, this gives a strong indication that he's analyzing a compiler output, a compiler that he didn't reveal in the article.

He is using the output of some compiler to illustrate the potential consequences of making the given mistake. It doesn't really matter which; the point is that it is not legal to perform lvalue-to-rvalue conversion on the result of indirecting through a null pointer.

>could you or him point me to any page in the C99 standard document where it is explicitly stated along the lines that the compiler "should assume" the pointer to be not NULL after an undefined dereferencing in line (1) and hence ignore (2) and (3)?

No, because the C99 standard document does not say that. What it does say is effectively that the compiler MAY assume the pointer not to be null; more generally, the compiler is allowed to assume that the program never exhibits undefined behaviour.

sjolsen··on C Questions and Answers
There is no mention of which compiler he's using or whether the results might be different for different compilers and/or hardware platforms precisely because he's discussing the C language— not the idiosyncrasies of particular implementations.

>and how they correlate with multiple C standards

There's nothing going on here specific to any particular revision of ISO C (that I can see).

sjolsen··on LibreOffice Project's Check
>the function as you wrote, when used in the expression (getColor() == getColor()), results in undefined behavior

In C++14 (and I believe C++11), this is not correct. Specifically, §1.9/15 says, "Every evaluation in the calling function (including other function calls) that is not otherwise specifically sequenced before or after the execution of the body of the called function is indeterminately sequenced with respect to the execution of the called function;" this sentence is marked with a note that reads, "In other words, function executions do not interleave with each other."

Item 4 under the "Sequence point rules" section on the page you linked says basically the same thing. I haven't looked at the C++98 standard, but I imagine it allows this, too.

The two calls to "getColor" are indeterminately sequenced. As a result, the behaviour of evaluating "(getColor() == getColor())" is merely unspecified, not undefined. In fact, the behaviour is guaranteed to be equivalent to one of the possible orderings (§1.9/13: "Evaluations A and B are indeterminately sequenced when either A is sequenced before B or B is sequenced before A, but it is unspecified which").

sjolsen··on Templating in C
You're absolutely right of course; just about any facility's shortcomings can be overcome by redesigning that facility, but that's how we get Greenspun's Tenth Law. :)

Unfortunately, redesigning for safety/correctness in C almost always means a loss of place-of-use conciseness. For example, you'd have to manually wrap each argument to your hypothetical printf replacement in a "struct type_wrapper." Plus, there's no way to enforce that your format string has the same number of placeholders as you have arguments.

Speaking of which, you can actually do that in C++. It would look something like

    #include <cstddef>
    
    template <std::size_t N>
    static inline constexpr
    std::size_t num_args (const char (&fmt) [N]) {
    	// Count args
    }
    
    template <std::size_t N, typename... Args>
    void printf2_impl (const char* fmt, Args&&... args) {
    	static_assert (N == sizeof... (args), "Wrong number of arguments to printf2");
    	// Interleave args into fmt and print
    }
    
    #define printf2(fmt, ...) (printf2_impl <num_args (fmt)> (fmt, __VA_ARGS__))
You could even just typecheck the format string against your argument types and forward to printf. The biggest problem with this what happens when you give printf2 an empty __VA_ARGS__, but such is life when you're using the C preprocessor.
sjolsen··on Templating in C
>They are not the same

I didn't say that they were. I said that they were equally expressive, because the claim was that C++ is more powerful than C.

>VLA in C are on the stack vectors are allocated from dynamic memory (heap)

That is not necessarily true. It's an implementation detail, and as far as it's relevant, so is the fact that everyone supports VLAs in C++.

>Right but that is why in practice C++ it is not a strict superset of C

Nobody said that C++ was a strict superset of C. The claim was that C++ is more powerful than C, and the fact that you have to specifically request ABI compatibility is not evidence to the contrary. Rather, the fact that you can do this at all (and that you can't use C++ linkage in C) is evidence in support of it.

← PreviousPage 3 of 6Next →