1,407 karma · joined Jun 14, 2010 (16y ago) · 438 submissions
comment 8y ago · link · parent
The problem with nulls isn't strictly null references, in the sense of "a pointer that points to nothing" or "a pointer that throws a null pointer exception", it's that languages with nulls implicitly make null an element of every type. They tend to do this because variables are allowed to have null references, but if you changed the semantics of variables to technically forbid null references, but still had a null value as an implicit element of every type, you'd still have the problem of needing to do runtime checks for null everywhere.
comment 8y ago · link · parent
- K is "const" and C is "flip"; they're generally used to for arguments to a higher order function: "map (const 5) myList", "foldl (flip f) 0 myList"
- Psi is "on", since it's regularly used to construct a new function "h = f `on` g"
- S is a specific type of application, called infix as "f `ap` x", but also has an operator to intentionally make it look more like just line noise: "f < * > x". (Had to add spaces to this operator so HN wouldn't interpret it as italics)
The operators might seem opaque, but the idea is to make it more visually apparent that it's a pattern, not some application-specific business logic. There are lots of concepts of "apply" - there's pure application ($), Applicative application (< * >), Monadic application (=<<), etc. - writing them out would distracting to read. Using operators makes it easier to skim and get the general idea of how the code works without worrying about the underlying structural details, while still being precise about them.
comment 8y ago · link · parent
The only better names you could really give are ones like func1, func2, arg1, arg2, which don't add any information, just add noise. Trying to get any more specific than that would leave the reader trying to interpret the meaning of the name, but the whole point is that it's strictly "apply this thing to that in this way, without looking at what they are". Even fix-point, which is unarguably cryptic, really needs a paragraph explanation for the unfamiliar more than it would benefit from better names.
comment 8y ago · link · parent
This is kind of presuming the conclusion, and ignoring the stated experiences of the people being discussed. The concept of gender identity (whether or not it does a good job of it) is explicitly intended to highlight that the causation isn't "I fit this stereotype, therefore I am this", but just "I feel I am this", with the implication that it may (or may not) be reaffirming to fit in socially with other people who are that way. Many don't identify with the stereotypes. Sure, some cling to stereotypes - maybe because they previously felt constrained from expressing themselves, or just as a practical measure against getting misidentified - but that doesn't imply that that's the cause or the goal. If you don't believe the claim that it isn't the cause, that's fair, but then it's just a person's beliefs against anothers' self-assessment.
The term "transitioning" is also used in a general sense, including "being yourself", as opposed to necessarily taking hormones. Taking hormones, changing paperwork, doctor appointments, losing fertility, etc., is kind of a long, drawn out, stressful ordeal that inherently starts with "being yourself in your own body" until changes kick in; it's pretty unlikely that someone transitioning hasn't considered just not doing the hard part, especially since it's so slow that there's ample time to turn back.
I'd wager most trans people are as opposed to gender essentialism and gender stereotypes as other feminists are. Nothing about accepting that they might actually just not be comfortable in their bodies, or at least just letting them be, implies philosophically accepting gender essentialism. Moreover, making the world more accpeting of people just being themselves is pretty closely aligned with just letting trans people be - if they actually don't need to transition, they'd be less likely to in a world where those who don't fit stereotypes, like trans people, are more accepted. And it's not a verboten topic - the Reddit trans communities have these discussions pretty often, when the questions are asked genuinely. It's just that, as with other minority-focused topics, it's often brought up with the clear intention of harassment rather than having an actual discussion, so there's a low tolerance for things that signal disingenuousness.
comment 9y ago · link · parent
First you need to find code relevant to what you want to do. You can take diffs of memory as you do things in the game to narrow down where the relevant addresses are, and then set breakpoints on read/write to those locations to find relevant code. After that, you can mostly just follow the assembly - you can even read backwards up the call stack by reading to what look like the beginning of a procedure, and searching for jumps to that address. Once you've found the code you want to modify, you just need to find some empty space in the ROM that you can branch out to to write your code.
The trickier bit is if you're in a spot where you need to worry about timing. On older consoles, this included things like changing the HUD or wave effects, etc., since you need to make sure whatever work you do gets done in time for HBlank/VBlank.
Some consoles also had some built in functions that would give you an idea of what code was for, like the lz77 compression on the GBA, which was mostly just used for graphics. Similarly, DMA was most often used for copying sprite data. On newer consoles where code was often compiled from C (rather than assembly with macros), I'm under the impression you can also do things like try to pattern match on the signature of standard library functions.
comment 9y ago · link · parent
His point is that there's no lost benefit in calling pure code from impure code - the code is already unconstrained. Calling impure code from pure code, though, means you've lost the purity constraint, which means you've lost the nice emergent properties you get from that constraint.
Even if you write 'pure' code in an impure environment, you can't depend on it being pure, because that constraint isn't actually enforced. No matter how pure I try to keep my Javascript, I can never depend on it being pure - there could be a bug, or someone could add impurity at the bottom of the callstack, breaking referential transparency.
comment 9y ago · link · parent
Anecdotally, I feel like Japanese picks a better point in the tradeoff space than other languages - Chinese characters are used where they get some leverage, with phonetics for everything else, even with a bunch of half-kanji words. Still, I'd imagine some of the less-commonly used ones will get dropped over time.
On the other hand, English+Emoji+Txt simplification seems to be approaching the same point from the other direction.
comment 9y ago · link · parent
Perhaps more to the point, Japan, which uses Chinese characters for nouns, adjectives, adverbs, and verb-roots, has a very high literacy rate. [1]*
[1] https://nces.ed.gov/pubs2014/2014008.pdf
* Not trying to cherry-pick for Japan being at the top, but Japan's not listed in the 2015 UNESCO report that's referenced all over the place. This US DoE report from 2013 seems legitimate enough.
comment 9y ago · link · parent
comment 9y ago · link · parent
comment 9y ago · link · parent
comment 10y ago · link · parent
Games that use a strict hiragana character set are readable by natives because they're already fluent in speaking; they're unnecessarily difficult for non-native speakers, particularly since they tend to only have the bare minimum of separators between words. After living in 4 prefectures, working for a small Japanese company, and dating a native speaker for roughly a decade, I still find those games hard to read - it's just hard to identify the shapes of words, like reading English with no spaces; you have no choice but to guess where the boundaries are and sound everything out syllable by syllable, because everything's written differently from how you'd see it anywhere else.
If some people want to put off kanji or memorize phrases from a travel guide, that's their prerogative, but not teaching the compositional aspects of kanji, and leaving students to fend for themselves after selling the idea that it's all rote memorization (and seemingly to push this implausible ethnocentric dream of the language one day being exclusively romanized) is just a disservice to the students, as it was to me.
comment 10y ago · link · parent
Given, much to Mair's displeasure, that actual native media is written with kanji, they're immediately necessary, and not studying kanji effectively bars students from any learning outside the classroom until they have - which is completely counter to giving students either the context necessary for immersion or the reinforcement for traditional study to work.
Maybe it's merited for Chinese classes, with its larger character set, but Mair's approach just sacrifices students' ability to learn on their own in favor of lowering attrition rates of intro-level classes. It's actively harmful to students aiming for fluency to build up the characters as this insurmountable mountain in the distance before they can actually use their knowledge, rather than the useful compositional blocks and visual aids that they are.
comment 10y ago · link · parent
I'm not usually one to speak bluntly, but, at least for Japanese, speaking from a lot of experience, this is flat out the wrong approach.
Older books like the romanzied "Japanese for Busy People" took this approach. I started with this book, it felt easy at the time, but it was immensely impractical - you don't build up enough of a base to learn from any other material. It's completely useless. After over a year, in a formal setting, I ultimately decided to just completely start over.
Currently Japanese courses mostly just focus on Hiragana and Katakana, since material for children usually has pronunciation guides over the kanji anyway. This is workable, but it just gives you no leverage where you could have some - you end up memorizing a thousand indiviaul words, some of which maybe kind of sound similar in parts, when you could instead learn a dozen charcters, and know that they share root words. Phoenetic approaches work for children who are in a situation where they can memorize from immersion with native speakers, and have additional clues like context and intonation to emphasize root words, to pick up new vocabulary.
When I started studying Chinese, we instead went with a "radicals-first" approach, and after just a short time of that, my Japanese vocabulary exploded - I could suddenly pick out all the seafood on a menu, and I started asking people mid-conversation "oh, does that use these characters?", and I could understand what it meant without them having to struggle to translate to English: Heart+Electric+Map - it's probably an electrocardiogram, especially if we're talking about hospitals. If you haven't learned the kanji, you don't even know if you can make that association from the sounds, much less how to ask that question.
That's how you get to fluency, by building up a foundation that lets you learn without active study. You can't get there by avoiding the basis of word composition in the language. Apologies if my frustration with characters-last approaches came through a little strong - they wasted a lot of my time.
comment 10y ago · link · parent
Of course, the real winner of this argument is probably Korean.
comment 10y ago · link · parent
The stroke order seems annoying at first, but it's pretty consistent, and actually really helpful for memorizing. The different pronounciations also seem intimidating at first, but for the most part:
- One's for composing with other characters
- Others are mostly variations on that one for fluidity, where people will still understand you if you get it wrong
- There may be one for when it's used on its own, that gets used so often you quicly think of it as basic
- Anything else is probably an edge case that you'll never see
tl;dr: Don't let the Kanji intimidate you
comment 10y ago · link · parent
[1] http://plv.mpi-sws.org/backpack/ [2] https://ghc.haskell.org/trac/ghc/wiki/Backpack
comment 10y ago · link · parent
[1] https://github.com/Gabriel439/post-rfc/blob/master/sotu.md#d...
comment 10y ago · link · parent
- Dataflow analysis, to get an idea of the types/range of values you're working with
- Pattern matching to try to identify higher level constructs from math to loops to jump tables.
- Compiler-specific pattern matching to identify things like function entry points
- Signature pattern matching common functions (like C standard library calls), along the lines of what's used in High Level Emulation.
comment 10y ago · link · parent
comment 10y ago · link · parent
Some people seem to fall back into it a bit when they discover point-free style (and that seems to make up a lot of what you see in mixed-paradigm code). I don't think it'd be controversial to say it's bad practice in any paradigm, so the association of it with FP is kind of like judging web programming by late 90's beginner PHP code (which, at one point in time, did describe a lot of web programming, but it was never good, and we'd like to put that behind us).
comment 10y ago · link · parent
The nice thing about functions like "map", "filter", "fold", "flatmap", etc., is that they describe intent - when you see a "map", you know it's not aggregating things, just applying a function: "map" has a distinct purpose from "fold" (and depending on how pure things are, you may not even be allowed to do anything crazy).
Aside from that, the higher-order functions have pretty intuitive algebraic laws for refactoring (like with "compose" mentioned in my other comment) - It's not clear how you'd factor code out of a nested loop without understanding the whole thing, whereas "flatmap" (a.k.a. "bind" for the list monad) has laws for refactoring it.
comment 10y ago · link · parent
Ah, yes it would. Clearly I'm a bit too tired to be writing code, if I've overlooked function application. I suppose it doesn't have to be point-free. =)
Pretty cool, though - thanks for the info.
comment 10y ago · link · parent
let open_file = |fname| (fname.as_str(), fs::File::open(fname.as_str()) );
let check_err = |(fname, f)| {
f.and_then(|f| Ok((fname, f)))
.expect(&format!("input file {} could not be opened", fname)) };
let to_buff_reader = |(fname, f)| (fname, io::BufReader::new(f));
let line_to_words = |line| {
line.unwrap()
.split_whitespace()
.map(|w| w.to_string())
.collect::<Vec<_>>().into_iter() };
let get_file_words = |(f, file)| {
file.lines()
.flat_map(line_to_words)
.collect::<HashSet<_>>().into_iter() // prune duplicates
.map(move |word| (word, f)) }; // emit inverted index entry
let add_to_index = |mut idx, (word, f)| {
idx.entry(word).or_insert(Vec::new()).push(f);
idx };
let idx = args.iter()
.map( compose(to_buff_reader, check_err, open_file) ) //[1]
.flat_map(get_file_words)
.fold(HashMap::new(), add_to_index);
[1] Does Rust have a compose function? I hope so. If not, you may need 3 successive "map"s. And stream fusion.comment 10y ago · link · parent
That's what's obnoxious about that comment - it's completely unprovoked trolling, and yet it was heavily upvoted. Of course the first reply disagrees with it - If I go to a thread about a Ruby library and insult people for wanting to use Ruby, you'd expect the top reply to disagree. What you'd hope not to see is for that trolling comment to be overwhelmingly upvoted to the top, and for the community to be making excuses as to why in this instance it's ok.
If someone's not interested in some content, or disagrees with it, that's one thing, but to actively find, mock, and seek community support in ostracizing people who are interested in learning it because of that interest - I'd argue that's anti-intellectual by definition. But whatever you want to call it, it's, as the grandparent comment stated, a community problem. Sadly for the author of that comment, the HN community excuses that sort of behavior - it's just different from the wonderful folks in whatever language community they're used to.
comment 10y ago · link · parent
comment 10y ago · link · parent
There are definitely some toxic assholes, as in any community, and it's really shitty if they're going to, e.g., /r/java and harassing people. I feel pretty strongly that the opposite is a more common problem, though, particularly on HN: the anti-intellectualism against functional programmers, and Haskell users in particular, is rampant and gets pretty offensive. Example off the top of my head - https://news.ycombinator.com/item?id=10527745 - article simply explaining a math concept gets, as what was the top comment at the time, a condescending comment calling it all "mental masturbation". I've stopped reading HN so much because it's pretty clear that people trying to learn abstract algebra and apply it to code aren't welcome here.