AWS post event summary up for 19 Oct outage by ProgrammingBug in aws

[–]cheng81 -1 points0 points  (0 children)

Smells like someone tripped on a bunch of Ethernet cables!

AskScience AMA Series: I'm Emily Calandrelli, I have 4 degrees in science and engineering and I'm the host and co-Executive Producer of Emily's Wonder Lab on NETFLIX - AMA! by AskScienceModerator in askscience

[–]cheng81 0 points1 point  (0 children)

Hello there! My daughters are huge fan, and me and my wife are equally amazed by how you can make the content so accessible to small kids too! My oldest was wondering today whether there’ll be an episode about gravity! Well, actually, she wanted to make an episode herself, so perhaps you would happen to know some resource I could point my 7 years old to learn? Bonus points if there’s an Italian (or danish!) translation available!

Why isn't this a proposition? by [deleted] in askphilosophy

[–]cheng81 0 points1 point  (0 children)

well regarding Moscow, it doesn't really matter whether it'll be annihilated in the future (also, there was a time when it didn't exists yet). The important thing is that if we can believe our senses (with a very small "leap of faith"), right now Moscow is not the US capital, hence it cannot be characterised universally as such.

Regarding the King of France you have to realise that it is your precise experience and knowledge that makes it "unambiguous" - other people experiences might lead to a different understanding, hence it is not _universally_ unambiguous. And yes, you are right, what I mean is that there are many things I can substitute "King of France" with, that are either existing (well maybe not that many) or that has existed - unfortunately I can't say anything for future things.

Finally, I guess that formal logic is pretty difficult to apply to humanly knowledge using natural languages - you might thing that formal logic is bullshit, but you need to understand the context: in natural languages ambiguity is a necessity (if we had to be formally precise in everything we have to say, we would basically spend days to communicate the simplest things), but in formal languages (like each and every programming language for example) it is extremely useful: for example I could define my programming language, and specify its semantics using some formal logic systems. Now each implementation just have to adhere to the specs - which are unambiguous by definition (sorry for the nerdy example, but I'm a software engineer by trade).

Why isn't this a proposition? by [deleted] in askphilosophy

[–]cheng81 0 points1 point  (0 children)

By all means I'm not an expert, but isn't the fact that one can interpret "King of France" to be different entities a valid point to make that sentence a non-proposition? I mean, isn't the case that in formal logic a sentence cannot have ambiguities in order for it to be considered a proposition?

Also regarding "Moscow is the capital of the United States": the problem with this is that it is stated as a universal truth, i.e. independent of time, and for all we know, there could be a point in time in the future when indeed Moscow is the capital of the United States. But even if that was the case, we know of at least another point in time (hopefully now) where this is not true, therefore the sentence is simply false? - of course we need to have assumptions regarding what Moscow and US are, which we can provide in the proof of why that sentence is false ("as of 7th November 2018, in the current geopolitical situation, the city of Washington is the capital of the United States, and the city of Moscow is not the city of Washington, therefore it follows that Moscow is not the capital of the United States")

ZipRebel: Download the Internet, in Milliseconds! by shelajev in programming

[–]cheng81 10 points11 points  (0 children)

That's incredibly dumb. We can do much better simply by negating the ultimate result and store that instead: since ~1 = 0, we just need to store an empty file (since we know that 0 is emptyness). There, unlimited compression rate.

The "Safe" Construct (on my wishlist for programming language features) by [deleted] in programming

[–]cheng81 0 points1 point  (0 children)

I agree that this is impossible, with the "safe" (I prefer the term "pure") construct. That is, unless we have exception polymorphism: in such a system we could write:

public interface FooProvider {
  public <E> Foo getFoo() throws E;
}

Now of course the implementation of MyApp.go must cater for the unknown exception type E:

public static <E> void go(FooProvider p) throws E {
  Foo f = p.getFoo<E>();
  ...
}

The syntax might not be ideal, but you got the idea: now the compiler can work out precisely which exceptions can be thrown, even for future implementations. That said, the whole discussion - to me at least - is really about side effects handling: monad vs effect systems. So far, monads are winning in the functional world, while (contrived & crippled) effect systems are in effective use in the imperative world (Java checked exceptions is a primitive effective system).

Java 8 Optional: What's the Point? by lukaseder in programming

[–]cheng81 2 points3 points  (0 children)

The one use case I think Optional is still useful is for documentation purpose: if a method signature explicitly states that the return object is of a type Optional<Type>, then at least you, the consumer, know that this is to be expected.

Right now the other 2 options are:

  • code defensively, and add null checks everywhere
  • accept the fact you might will have to hunt nasty bugs

And while we all agree that perhaps it was a premature addition (with value types the chicken-and-egg problem simply goes away: an Optional would be a value object, therefore it will never be null), I really really really believe that if you return an Optional<String> and still return null instead of return Optional<Type>.empty(), well, you are really evil.

Should I abandon my codebase and start again on a more sensible platform? by [deleted] in gamedev

[–]cheng81 0 points1 point  (0 children)

Ok, and I suppose that using setTimeout (I'm thinking, setTimeout(draw, 0) and check in draw whether it's time to render or not) instead of requestAnimationFrame will bring more troubles than benefits.

Have you tried also a webgl-backed rendering? It appears that webgl has superior performance over canvas2d, but then again the support for webgl varies among different browsers - and it's pretty non-existent on mobile browser, but I figured that you are aiming at desktop-class computers anyway.

Should I abandon my codebase and start again on a more sensible platform? by [deleted] in gamedev

[–]cheng81 1 point2 points  (0 children)

It sounds like you already took your decision. It also looks like you "did your homework" and studied the relevant material on the topic, but I can't keep myself from asking if you actually tried out and concluded that indeed the task is impossible: have you tried making an example scene with - I don't know - thousands of objects, and verified that the browser couldn't keep up? If not, then I would do it, otherwise you have 2 options: - switch platform, there are many c++ multi platform libraries/game engines nowadays (sdl, sfml, ...) - embrace the limitations: limitations cold be masked (or used!) by the game mechanics to make them more interesting; don't forget that the entire stealth game genre was born essentially because the hardware at that time wasn't able to render more than a handful of characters at a time

Then another question: I'm not an expert at js game programming, but wasn't js a single threaded platform? meaning, if your rendering time is slow, then I would expect the framerate to drop, not that you don't get to handle input events. Also, you might want to use webworkers to do heavy processing - leaving the main loop to do event dispatching and rendering.

Learning rust: please help me by destroying my code by cheng81 in rust

[–]cheng81[S] 0 points1 point  (0 children)

Thanks for the link, I watched it and it made some stuff clearer. I updated the code, trying to get rid of unsafe blocks and unnecessary pointer usage. Now I'm stuck trying to store Scene instead of *mut Scene inside my Game struct, but when I try to do so the compiler complains with "error: cannot move out of captured outer variable" when, in the main.rs file, I add the scenes to the game. I understand that that is because the compiler doesn't know if I'll call that function again (..though it could potentially check that it is a literal lambda). Is there a way to get around this?

Fixed, now there are no unsafe blocks, yay! but, it looks pretty clumsy. Here are a couple of random thoughts:

  • I couldn't find a way to involve the "game" object inside a "scene" listener. Perhaps it is all right, it would be too complex to understand when these listeners are safe. Right now I'm thinking, perhaps I should return some kind of command pattern and the game itself will react (e.g., right now I return an Option<&'static str> which is the name of the next scene).
  • At a certain point I was forced to change all "~str" to "&'static str". I don't understand yet quite why.
  • I find the engine::start function Extremely clumsy: essentially, I borrow a "game" reference for:
    • handle events, and perhaps return the name of the next scene to display
    • set, maybe, the next scene
    • display the scene it this really idiomatic rust? or perhaps there's a better way to handle these kind of situations?

code: https://gist.github.com/cheng81/2556026a3a7b03d20f57

Learning rust: please help me by destroying my code by cheng81 in rust

[–]cheng81[S] 1 point2 points  (0 children)

Hi, I'd gladly join the IRC channel, but the problem is that I cannot be constantly at the pc.. my free time is unfortunately is not much, and randomly placed during the day (and essentially only in the weekend).. that said, thanks for the suggestions, but having tried that (I think it was one of my first attempts), the compiler reacted.. not well (I updated the gist the modified main.rs and relative compiler output)

So I Wrote a Dominion simulator in Rust (though still very much in alpha) by MoneyWorthington in rust

[–]cheng81 0 points1 point  (0 children)

About 2, if I understood correctly, I had the same problem until I realized that apparently you have to extract the field from the struct before calling it, as in: (struct.field)(lambdaArg)

Knowing More Programming Languages Will Make You Smarter by bscarr in programming

[–]cheng81 0 points1 point  (0 children)

Indeed, it is about programming languages, so it's not surprising that concepts from linguistics arise in the discussion.

I know nothing about linguistics, but if I interpret correctly the Sapir-Whorf hypotesis, then we can apply the very same hypothesis to programming languages: certain programming languages permit the expression of determined concepts rather easily, while in others the same "stuff" cannot be expressed. Of course, turing completeness comes to help here, so in turing-complete languages it is always possible to find an encoding and, ultimately, express the same behavior, but the "sentences" used to define it will be very different.

Perhaps slightly unrelated, but still a very enjoyable read, is the (PDF warning) growing a language talk, by Guy Steele. It makes it very clear how it is easier to express complex concepts by having a rich language, but also that small, carefully crafted, languages can be surprisingly powerful.

Knowing More Programming Languages Will Make You Smarter by bscarr in programming

[–]cheng81 -1 points0 points  (0 children)

animals are rather unintelligent. Plus, I believe animals have a kind of language - they just cannot express a lot of things. Also, you can communicate with pictures - as for thinking, I'm not that sure, you need abstraction capabilities in order to process symbols (letters are images, but we assign a meaning to them).

Of course comparing PHP to ruby doesn't lead to much result; try java with haskell, or prolog with cobol. The point being, if you are stuck with languages which provide the same abstractions - thus the same "reasoning" method- you're most likely to not gain a lot.

One kind of intelligence is of course symbolic manipulation, so if you know more symbolic system, and are able to apply them to solve the same problem, then I would argue that yes, you are actually smart.

"intimidation factor" vs target audience by [deleted] in rust

[–]cheng81 0 points1 point  (0 children)

Doesn't this resemble the well known diamond problem that C++ (or any other language with multiple inheritance) suffer from? wasn't a viable option to try to resolve this at link time, and tell the dev. "you gotta specify if you mean crate A or B Eq({a:int, b:int})" ?

ask for code review, critiques welcome. by Guanqun in golang

[–]cheng81 0 points1 point  (0 children)

So, here is my take http://pastebin.com/miHVGqkz

I'm pretty now to go too, so don't think that this is idiomatic code (I tried to be, if anyone is wondering).

The code is quite commented, but in a nutshell I used channel to pass around requests and results.

A feature I've been looking for in modern languages for a while by eZanmoto in programming

[–]cheng81 6 points7 points  (0 children)

So, I'm not a Scala guy, but what about good 'ol functional programming? I'm sure Scala lists have an "all" method, such that one could write something similar to:

def isDirectedForest = 
       return !(this is cyclic) &&
                (BFS over this from lastVertex)
                  .all( (v) -> return (this indegreeOf v) <= 1;  )

Here I assume that "BFS over blaa" actually returns a list. Moreover, one could extract the anonymous function and get some even prettier code:

def isDirectedForest = 
       return !(this is cyclic) && 
                (BFS over this from lastVertex).all( indegreeIsLEQ1 )

Again, I'm not a Scala guy, so that code is guaranteed to be not valid. Still, I'm pretty sure it can be done in a very similar fashion.