« first day (1939 days earlier)      last day (2903 days later) » 

6:00 AM
that for statement still says to me that you are updating pointers
but I think our difference lies in what is the "resource"
 
@NathanMerrill correct
a more efficient implementation
wraps the list in a shared resource
 
I really don't think you need clone tracking at all
literally all that clear_clones needs to do is self.l = self.l[:]
 
@NathanMerrill you don't want useless copies
 
hmmm, in one case, you are copying a list every modification. In the other case, you are reupdating pointers every modification of a clone
it really just matters whether you have more clones or more modifications
 
class Shared:
    def __init__(self, val):
        self.val = val
        self.n = 1

class COWList:
    def __init__(self, l):
        if type(l) is not Shared:
            self.share = Shared(l)
        else:
            self.share = l

    def append(self, val):
        self.deshare()
        self.share.val.append(val)

    def set_item(self, idx, val):
        self.deshare()
        self.share.val[idx] = val

    def get_item(self, idx):
        return self.share.val[idx]

    def clone(self):
this is more efficient implementation
 
6:06 AM
yeah, that works
 
now THAT is copy on write
as opposed to copy and write
the crux is that no copy happens until a write occurs
 
well, that's not strictly true
we also have a condition that a copy won't occur if its also the only copy
 
@NathanMerrill if it's the only copy then there was never a copy :)
basically it only copies when needed
 
its basically "copy on 'clone and write'"
but that's a bit of a mouthful
copy on write is pretty much always more efficient than copy on assignment, right?
 
@NathanMerrill no, because there is overhead
Shared is another indirection layer
before it was just
self.l, now it's self.shared.val
 
6:11 AM
but in terms of number of copies, copy on assignment will always produce equal or more copies
 
yes
but there's more things in the world than just copying
access time became slower :)
 
you can also have different strategies
for example if you very often copy some buffer and change only a couple elements
you can have a "copy on nth write"
and until the nth write it stores the changes into a dict
 
ok. So, I think I'm going to use the word "immutable" to indicate that all modifying functions are copy-on-write
unless there's a better word?
 
again, they're not copy on write
your strings and integers are immutable
they are never modified
there are no modifying functions
 
6:14 AM
right, but what other word indicates "you can't change this object, only create a new copy with a modified value"
 
that's just immutable
@NathanMerrill if I write 3 + 5
 
even though a copy-on-write list could be modified
in the case that there is only 1 copy
 
a list is not immutable
lists can be modified
a = [1, 3, 5]; a[1] = 42
 
a COWList :)
 
if I write 3 + 5 (or plus(3, 5)), it doesn't modify 3 or 5
it just returns a new (also immutable) value that is the sum of the two
 
6:16 AM
but is there a better word than immutable?
 
no
this is exactly immutable
 
(for copy on write)
 
I don't think that anything you're doing pertains copy on write
 
while I see the difference, I don't think there's a word that is closer
 
and you should probably stop using the term
immutable is a value that doesn't change after initialization
 
6:17 AM
no, copy on write is definitely what I want.
 
want or have?
 
that's what I mean
but copy on write is only relevant for mutable objects
things that can be written AKA changed
 
right, but if somebody makes a class
 
classes are mutable
 
6:19 AM
then I need some way for them to indicate that this a copy-on-write class
 
could you give an example of what a copy-on-write class would look like?
 
because in order for you to do that you already need to have a model of copying
 
classes will have a clone function
 
Python has __copy__ and __deepcopy__
which are used with the copy module
copy.copy calls __copy__ on an user-defined class
and copy.deepcopy calls __deepcopy__
@NathanMerrill but that is the simple part
now you need a protocol that determines what is 'writing', and what is 'reading'
if I have some class A, with an object a = A()
obviously a.l = [] is writing
but is a.l.append(1)?
 
6:22 AM
oh, that's part of my typing system
 
how do you detect that?
 
functions are by default read only
you have to explicitly declare that they mutate
so, writing to a class variable can only be done in a mutating function, as well as calling a mutating function
 
ok, then I guess it can be done
or...
you have to consider writes/reads from outside of functions
e.g. in the main body
 
only from a "pure" functional standpoint
another function could modify a variable I was reading
 
What is a good website to learn code for an absolute beginner?
 
6:26 AM
so, my read function doesn't necessarily always return the same thing
oh, I understand. Yes, if somebody had a publicly visible class variable, writing to it would make the function a mutating
(I don't have static variables outside of constants)
though, I am considering removing that in favor of logging
 
learn Python
 
@orlp hmm, the hard way...
and why Python?
 
Python is amazing for beginners
 
I haven't read the book, but I do agree that Python is the best first language
 
how about C?
 
6:30 AM
it's readable, simple and doesn't have a lot of wtfs that other languages have
@JesterTran absolutely not
 
@JesterTran it is full of the "wtfs" that orlp mentions
 
how versatile and useful is python?
 
well, all languages can pretty much be used anywhere. That said, python is mostly used for web development and scripts
 
is there anything that a turing machine cannot do
 
scripts being small programs that process data for one particular purpose
 
6:32 AM
but a regular programming language can?
 
@KennyLau yes
 
if you're looking for Android development, then you could learn Java.
 
@orlp like?
 
turing completeness refers to computational capability
but a brainfuck program can never show a picture on the screen
 
6:33 AM
sure, a turing machine can't access the internet
 
because it doesn't have the I/O capabilities
 
well, a java program can't show a picture on the screen either
 
there is more to a programming language than computation
input -> computation -> output
 
ok, I will learn Python
thanks, everyone
 
good choice!
 
6:34 AM
I'm referring to computation
is there anything that turing machine cannot compute?
 
@KennyLau yes
 
but it can compute anything that our computers can compute
 
but a regular program can?
 
In computability theory and computational complexity theory, an undecidable problem is a decision problem for which it is known to be impossible to construct a single algorithm that always leads to a correct yes-or-no answer. A decision problem is any arbitrary yes-or-no question on an infinite set of inputs. Because of this, it is traditional to define the decision problem equivalently as the set of inputs for which the problem returns yes. These inputs can be natural numbers, but also other values of some other kind, such as strings of a formal language. Using some encoding, such as a Göd...
 
6:34 AM
"but a regular program can"
 
@KennyLau that was added after I alt tabbed
either way, define "regular program"
 
what do you think of codeacademy's course for learning Python?
 
and define "compute"
@JesterTran I've heard bad things of codeacadamy
 
Well, we always stress on a language being "Turing-complete"
 
@JesterTran I had my sister take it. She thought it was a bit slow.
 
6:36 AM
as if Turing-completeness by default is already the highest level
 
but that said, its really not too bad of a resource
 
@orlp @NathanMerrill I see.
 
just realize that you are going to really learn to program when you come up with something you want to develop and actually make it
 
you really want a book
this is what I learned Python from
but I can understand not wanting to buy a book
so then you can use learnpythonthehardway that I linked, which are free
 
yeah, I'll probably learn it the hard way
 
6:38 AM
now, there is another option
and that is to learn scheme
through SICP
this is less about programming and making real-world programs, but is very fundamental in how compute programs work, and computation
 
@JesterTran Or you could just get someone to answer your questions
like "how to do <stuff> in python"
and then read through the Python documentation
 
@orlp I haven't used that, but is it really beginner friendly?
 
@NathanMerrill yes and no
it's beginner friendly for a freshman CS student
it requires some pre-existing mental fortitude, maturity and a lot of investment
 
sounds cool
 
@JesterTran if you have any question about Python you can ask them here
@JesterTran how old are you?
 
6:42 AM
ok
16
 
(don't answer if you are under 13)
 
@JesterTran I wouldn't recommend SICP then
 
chat mini-challenge: given two numbers on the first two memory position, put the maximum of them in the third memory position
 
@KennyLau in what language?
or machine
or context
 
oops
in brainfuck
 
6:47 AM
can the first two be destroyed?
 
You can use this template
yes, they can
 
@orlp what about unshared as a keyword for copy-on-write?
 
@NathanMerrill you mean shared?
 
no, because if they were shared, then they modifications in one would affect the other
 
I dno
I don't really care either =/ too long on the same subject :P
 
6:52 AM
ok
I'll sleep on it
thanks for the discussion anyways
 
@Sherlock9 try my challenge?
 
Link/onebox?
 
chat mini-challenge: given two numbers on the first two memory position, put the maximum of them in the third memory position in brainfuck
Please use this template
 
7:08 AM
wait something bugged
 
7:33 AM
Weirdass Internet connection
Hmm. I don't know BF very well. I'll see what I can do
 
@KennyLau do we need to handle 0?
 
No, you do not.
(I don't see how the code will be different)
 
7:49 AM
not terribly elegant
but it works
 
0
A: Sandbox for Proposed Challenges

Kenny LauBrainfuck-golf: find the maximum of two numbers code-golf You will be provided with two numbers on the first two memory cells, and you will write a code in brainfuck to put the maximum of the two numbers on the third memory cell. You may use this template and this template to test your code. ...

 
nice. how does it work?
 
>[<<+>>->-[>]<<]
the [>] is crucial here
it offsets one position at some point when one of them hits 0
 
I see
and then?
 
then it adds whats left
it's a bit weird but it works
 
7:56 AM
lol I don't get it
 
8:18 AM
The part before [>] increments tape[i+2], decrements tape[i+1] and tape[i]
If one is zero, [>] runs fewer times or something, making the loop stop
 
Hello
 
8:47 AM
@KennyLau I have a slow but elegant algorithm
it can probably be optimized quite a bit, just made it work
just running it should already tell you how it works
 
what do people think about length restriction fastest code challenges?
are they allowed, to start with
hi @orlp
 
hi
 
@orlp I like that
 
for example, fastest sat solver in under 150 bytes
 
@Lembik hi part of all
 
8:50 AM
hi @zyabin101
any thoughts?
 
@HelkaHomba That has been in the works for quite a few years already
 
9:06 AM
@LuisMendo Now I did, great news!
 
9:25 AM
any views on the acceptability of length restricted fastest code competitions?
I can imagine someone will hate hard length restrictions
 
@Lembik Don't think it's a good idea
 
@MarsUltor thanks! Why is that?
I am trying to avoid the problem where longer and longer solutions in lower level languages always win
 
Longer/non-esolangs have a disadvantage vs golfier ones
 
@MarsUltor but golfier languages are slower typically right?
 
i.e. golfy languages, although slow, can use a more efficient algorithm because they can perform more functions
 
9:29 AM
@MarsUltor right.. but SAT solving doesn't have a very fast algorithm
so I thought the compromise could be interesting
 
If the length limit is too low, non-golfy languages can hardly implement anything
 
@MarsUltor true.. setting the limit correctly is importsant
and hard to guess a priori
I was hoping people might help me with that on chat :)
 
Most C#/Java golf solutions are around 300, I think
Python/Ruby/JS would be around 100
 
ok.. so how about this concrete proposal. Fastest code competition to write a SAT solver in <= 350 bytes?
python is dog slow after all :)
 
Pypy is fast though
 
9:31 AM
I use pypy a lot and the situation is complicated
 
@Lembik I guess
 
your code has to be pure python to start with which excludes most of the point of python for people doing scientific work
that is the vast set of libraries
 
@Lembik Yeah
 
and second, even in pure python it is something 5 times faster and sometimes a little slower
it's hard to predict
 
It works well mainly when a function is called many times, because it caches the results for certain inputs
 
9:33 AM
they could just implement numpy in pypy but it goes at 1 mm/year as they just don't have the coders
pypy also works very well for simple and straightforward implementations of classic algorithms when you ignore all of the built in helpful functions like itertools
 
the devs say they hate itertools :)
 
@Lembik what time zone are you in?
 
This one :)
 
@EᴀsᴛᴇʀʟʏIʀᴋ monring
 
9:34 AM
you?
 
...
For me, it is 02:34.
 
12:35 here.
 
always or just right now?
 
for me it's always just before lunch :)
 
9:35 AM
@zyabin101 noon?
@Lembik ....
offset to UTC?
 
@EᴀsᴛᴇʀʟʏIʀᴋ UTC+3
 
@MarsUltor you are right of course that some languages will be better suited than others. That feels sort of inevitable though
what happened to GMT!!
 
it died in hell. Now answer me.
 
my mother told me not to give away personal data like which planet I was on :)
 
...
So did mine.
Last night. So I sanitized exactly 1 occurrence of my full name. shrugs
hey @Mego
 
Anonymous
 
Anonymous
11
A: Things to avoid when writing challenges

Martin BüttnerRequiring minimum scores In short, don't post a code golf that says "Your code has to be shorter than 100 bytes" (the same applies to any other winning criterion). The usual motivation is that the author found some code somewhere and challenges people to beat the score of that code. That's a fin...

 
Yeah, I think that one is a dupe.
 
Anonymous
It's very clearly a dupe
 
@Lembik are you going to answer me or should I go back to bed or playing nethack?
Well not a dupe, but a subset. Which still counts for closing as a dupe here.
 
Anonymous
I cannot fathom why aditsu would use his gold-hammer to reopen it
 
9:41 AM
@Mego I wholeheartedly disagree
gold-hammer? what is that?
 
Anonymous
You have a gold code-golf badge, which means that things like closing as dupe and reopening are immediate for you
 
Anonymous
You don't have close votes; you have a close hammer (same for reopen)
 
oh I didn't know about that
afk for a while..
 
Anonymous
I wholeheartedly disagree with taking unilateral action to reopen a challenge without a discussion on meta first
 
lol
@Mego I think he doesn't know what he did. :P
 
Anonymous
9:43 AM
You've been around for 6 years and didn't know that having a gold tag badge meant you have a close/reopen-hammer?
 
Anonymous
(not doubting you; just a bit surprised)
 
I didn't know I had a christmas present waiting in the closet for at least 4 days, and it then was destroyed by the cat.
 
> You have to download a total of 3,230 M. This download will take
about 2 minutes with your connection.
 
9:48 AM
wishes that was true
 
@Mego Already committed, sorry.
@MarsUltor if it is around 7 where you are, wtf are you doing up so late every day?
 
> first commit
@EᴀsᴛᴇʀʟʏIʀᴋ ?
late?
 
You are sometimes active on what is 18:00 PST, but isn't that like 23:00 for you?
 
11pm is late?
> first commit
 
@EᴀsᴛᴇʀʟʏIʀᴋ Do you sleep at like 9pm every day?
 
9:50 AM
if that was me, then yeah.
@KennyLau about there
 
Anonymous
@EᴀsᴛᴇʀʟʏIʀᴋ I didn't notice you had committed because your network account still uses your old username :P
 
Why is Area 51 pretending to be git
 
@MarsUltor First commit?
 
Oh wait
 
Anonymous
9:50 AM
@MarsUltor It's not. There are multiple meanings for "commit".
 
@Mego I know
 
@Mego fixed hopefully.
> "To help Marky Markov find a loving home..."
lol I forgot I wrote that
 
@HelkaHomba So now we can have software and hardware exploits on Android phones. Neat ;)
 
@EᴀsᴛᴇʀʟʏIʀᴋ Well, 1. because I can, and 2. in twelfth grade in Australia you probably usually stay up late doing homework/assignments anyway (not that I do)
 
@Mego the level of questions is too low to attract experts
 
9:53 AM
@MarsUltor okay
 
Anonymous
@HelkaHomba They've been "in the works" for many years (essentially since smartphones started getting really popular). I remember seeing a PopSci article about modular phones around 2010.
 
> twelfth grade
:O
 
Anonymous
@Fatalize What is that supposed to mean?
 
In Russia, there are eleven grades.
It should have that twelfth grade :D
 
@zyabin101 In New Zealand, there are thirteen (their first grade is preschool)
 
not actually?
:P
 
> Infinity/2
Seriously?
 
@Mego I'm not interested in answering questions like "What's the difference between AI and genetic algorithms?" which make no sense in the first place
 
> Infinity/2
Infinity
sorry smbc, you have failed.
 
@Mego Related :P
 
Anonymous
9:57 AM
Thought: is there any string (finite or infinite) that cannot be expressed finitely (as a result of a finite number of operations in some programming language)? In other words, is there any potentially-infinite string whose Kolmogrov complexity is infinite?
 
[3] and []
Seriously?
 

« first day (1939 days earlier)      last day (2903 days later) »