Coding: Fleeting Thoughts

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
Flumble
Yes Man
Posts: 2261
Joined: Sun Aug 05, 2012 9:35 pm UTC

Re: Coding: Fleeting Thoughts

Postby Flumble » Fri Apr 22, 2016 9:24 am UTC

Interesting... I've never thought about how similar a function declaration and an object declaration are in C++.
Huh, phlip's code is actually valid C++. Okay, sign me up for the C++ syntax hate club.

User avatar
bentheimmigrant
Dotcor Good Poster
Posts: 1366
Joined: Fri Apr 25, 2008 9:01 pm UTC
Location: UK

Re: Coding: Fleeting Thoughts

Postby bentheimmigrant » Fri Apr 22, 2016 9:33 am UTC

What's this? Another infinite loop? It seems I forgot to .MoveNext. Again.

One would think I would stop missing that out at some point.
"Comment is free, but facts are sacred" - C.P. Scott

User avatar
Flumble
Yes Man
Posts: 2261
Joined: Sun Aug 05, 2012 9:35 pm UTC

Re: Coding: Fleeting Thoughts

Postby Flumble » Fri Apr 22, 2016 9:48 am UTC

bentheimmigrant wrote:What's this? Another infinite loop? It seems I forgot to .MoveNext. Again.

One would think I would stop missing that out at some point.

What's this? A language that doesn't have foreach or mapping constructs that alleviates the programmer of tedious iteration statements?

One would think people would stop using those at some point. :P

User avatar
Thesh
Made to Fuck Dinosaurs
Posts: 6598
Joined: Tue Jan 12, 2010 1:55 am UTC
Location: Colorado

Re: Coding: Fleeting Thoughts

Postby Thesh » Fri Apr 22, 2016 9:49 am UTC

AHHHHH! ASP/VBScript flashbacks!
Summum ius, summa iniuria.

User avatar
bentheimmigrant
Dotcor Good Poster
Posts: 1366
Joined: Fri Apr 25, 2008 9:01 pm UTC
Location: UK

Re: Coding: Fleeting Thoughts

Postby bentheimmigrant » Fri Apr 22, 2016 10:18 am UTC

Flumble wrote:
bentheimmigrant wrote:What's this? Another infinite loop? It seems I forgot to .MoveNext. Again.

One would think I would stop missing that out at some point.

What's this? A language that doesn't have foreach or mapping constructs that alleviates the programmer of tedious iteration statements?

One would think people would stop using those at some point. :P

VBA. I'm abusing an Access database.

Normally I try to use For... Next, but I'm not sure I can with a DAO Recordset. I mean, I could probably do it indirectly, using the recordcount and an integer, but that feels wrong.
"Comment is free, but facts are sacred" - C.P. Scott

User avatar
3fj
Posts: 1715
Joined: Wed Jun 11, 2008 1:13 pm UTC
Location: Land of Whisky and Bagpipes (LOWAB)
Contact:

Re: Coding: Fleeting Thoughts

Postby 3fj » Fri Apr 22, 2016 11:10 am UTC

Am I high as a kite? Why doesn't something like this already exist as standard?

Code: Select all

public class BadRequestWithContent<T> : IHttpActionResult
    {
        private readonly HttpRequestMessage _request;
        private readonly T _content;

        public BadRequestWithContent(HttpRequestMessage request, T content)
        {
            _request = request;
            _content = content;
        }

        public Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)
        {
            var response = _request.CreateResponse(HttpStatusCode.BadRequest, _content);
            return Task.FromResult(response);
        }
    }
Everything's dead until it's alive. Man will exist, and then he will die. Just take the ride!

korona
Posts: 495
Joined: Sun Jul 04, 2010 8:40 pm UTC

Re: Coding: Fleeting Thoughts

Postby korona » Fri Apr 22, 2016 11:25 am UTC

Yakk wrote:Oh, and if `sockaddr_in` and `sockaddr` are layout compatible in C++, then the direct reinterpret cast should be legal. The fields in one will refer to the fields in the other.

If they are not, well, that isn't good.

Unfortunately layout compatibility has nothing to do with pointer aliasing. The pointer aliasing rules are defined in [basic.lval] of the C++ standard (+ there are some rules about valid reinterpret_casts but I don't think they matter here; essentially reinterpret_casts between object pointers are always valid, but using the pointer after the cast is subject to pointer aliasing rules) but I don't really understand how to interpret them. In particular the concept of an object's "dynamic type" is somewhat vague. I understand the intent of defining a dynamic type but I don't see where the standard defines how an object's dynamic type is established.

For the same reason I think that the union trick is undefined behavior. My understanding is that it would be fine if sockaddr was a union to begin with (i.e. type pruning through unions is valid) but casting a T pointer to a union (containing T) pointer and accessing that pointer is UB.

User avatar
phlip
Restorer of Worlds
Posts: 7573
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: Coding: Fleeting Thoughts

Postby phlip » Fri Apr 22, 2016 1:48 pm UTC

Flumble wrote:
Interesting... I've never thought about how similar a function declaration and an object declaration are in C++.
Huh, phlip's code is actually valid C++. Okay, sign me up for the C++ syntax hate club.

Oh, that's far from the only ambiguity in C++, though it's probably the most fun simple example.

There's all sorts of obscure tricks to tell the compiler what you want... like "typename" in templates, for constructs where the compiler doesn't know in advance if something is a type or a value, and so doesn't know how to parse an expression... or just random tricks like if "a b(c);" parses as a function decl when you mean it to be an object, then "a b((c));" has a good chance of doing what you mean.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
Xanthir
My HERO!!!
Posts: 5423
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Coding: Fleeting Thoughts

Postby Xanthir » Fri Apr 22, 2016 2:19 pm UTC

Oh shit, I didn't even think about function declarations occupying that parse-space, too. Jeezus.

I mean, writing up a proposal for an addition to JavaScript is complex because of the grammar issues, but at least it *has* a totally unambiguous and rarely confusing syntax, and tries hard to maintain that.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

Dr. Willpower
Posts: 197
Joined: Wed May 28, 2008 3:55 pm UTC

Re: Coding: Fleeting Thoughts

Postby Dr. Willpower » Sat Apr 23, 2016 1:08 am UTC

Had an interesting bug in JavaScript that was a sign there was too much magic going on. We were returning our own status codes in requests (the request would return 200 OK, but would contain an error). This allowed us to fail softly.

The problem arose when we hooked an application level failure onto the HTTP level request status. The HTTP request was always reporting success, but our app errored out and never marked the request complete.

Success meant starting over. So we ended up with:
1. Check application level status -> incomplete
2. Issue request -> HTTP request already succeeded
3. Success -> Goto 1
Image
Hat me, bro

User avatar
phlip
Restorer of Worlds
Posts: 7573
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: Coding: Fleeting Thoughts

Postby phlip » Fri Apr 29, 2016 6:34 am UTC

Man, been a while since I found an actual dangling else in real production code.

I haven't missed it.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]

User avatar
Xanthir
My HERO!!!
Posts: 5423
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Coding: Fleeting Thoughts

Postby Xanthir » Fri Apr 29, 2016 6:48 pm UTC

ahammel wrote:The desired behaviour is to have a zero element that resets the time series to mempty so that any mappends that happen "in the future" start from scratch.

So it turns out this is relevant to me today; I need to implement a system for retrieving metadata about a document from several sources, where each source can either extend the data defined in a metadata entry in the previous levels, or reset it and fill in brand new data. I need things to be associative, because I actually end up retrieving things in *reverse* priority order.

The solution that ended up happening here (track a secondary "reset" flag per key, and pay attention to it appropriately when combining) was exactly the ticket. ^_^
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
Flumble
Yes Man
Posts: 2261
Joined: Sun Aug 05, 2012 9:35 pm UTC

Re: Coding: Fleeting Thoughts

Postby Flumble » Fri Apr 29, 2016 11:03 pm UTC

Finally got Gate One working as intended. New terminals opened through the default SSH entry (a python script with some extra features like showing images) in the main screen would immediately close and no log file reported that anything was wrong. So I added an entry that just fires up the local shell (downside is that it always runs as the user running gateone) and be done with it.
Today I found out that I only have the binary python2 and no binary/symlink python, so, after linking it, the SSH entry was suddenly working. :D

Does anyone know of an alternative to Gate One? It's great at emulating a terminal and keeping sessions alive (goodbye screen and tmux ...and manual use of dtach) and really extensible, but I'm really missing a feature to easily transfer files (and right now I don't have the time/motivation to add that myself).

Regardless, next up is Guacamole for a Docker VM. No more remote desktop clients, only dreams HTML5 now. Maybe it even plays nice with my phone, unlike GO. (okay, that's probably overkill, since it has a perfectly fine RDP app installed)

User avatar
Thesh
Made to Fuck Dinosaurs
Posts: 6598
Joined: Tue Jan 12, 2010 1:55 am UTC
Location: Colorado

Re: Coding: Fleeting Thoughts

Postby Thesh » Fri May 06, 2016 8:22 am UTC

Maybe I'm a bit too tired....

Me: I'll just create a list in python containing a few billion pairs of lists of three integers each
Me: Hmm.... Why is my computer so slow?

Oh, yeah, because I'm completely out of RAM.

Oh well, I should probably fire up postgresql.
Summum ius, summa iniuria.

korona
Posts: 495
Joined: Sun Jul 04, 2010 8:40 pm UTC

Re: Coding: Fleeting Thoughts

Postby korona » Fri May 06, 2016 12:40 pm UTC

If you made it to a few billion you must have lots of RAM already :D
Considering that an int takes at least 4 bytes and Python likely boxes them in some way.

User avatar
Thesh
Made to Fuck Dinosaurs
Posts: 6598
Joined: Tue Jan 12, 2010 1:55 am UTC
Location: Colorado

Re: Coding: Fleeting Thoughts

Postby Thesh » Fri May 06, 2016 6:20 pm UTC

I'm not sure exactly how far I made it, as I didn't have any output notifying me of progress, but 3 billion is approximately how many items the main list would have had. Each row having two lists, each list having three integers. Overall the process was taking up a bit under 15 GB out of 16 GB total when I killed it. At that point, I think memory fragmentation was pretty much the main problem. I'd assume somewhere between 32 and 64 bytes per row for data and metadata, so I probably only got to 250-500 million rows before crapping out.
Summum ius, summa iniuria.

User avatar
Wildcard
Candlestick!
Posts: 253
Joined: Wed Jul 02, 2008 12:42 am UTC
Location: Outside of the box

Re: Coding: Fleeting Thoughts

Postby Wildcard » Fri May 06, 2016 7:47 pm UTC

I've just reinvented navbars in a GitLab documentation project.

It has the added bonus that since the link target is just a relative path within your directory tree, you can navigate it easily in Vim with "gf" (in the Markdown source).

I should probably do a blog post or something about this. It's actually pretty handy. :)

Thesh wrote:Me: I'll just create a list in python containing a few billion pairs of lists of three integers each

Obviously you should have been using Perl. :lol: </kidding>
There's no such thing as a funny sig.

User avatar
Thesh
Made to Fuck Dinosaurs
Posts: 6598
Joined: Tue Jan 12, 2010 1:55 am UTC
Location: Colorado

Re: Coding: Fleeting Thoughts

Postby Thesh » Sat May 07, 2016 3:49 am UTC

I'm actually going to rewrite in C++ for the performance gains. The full program may take days to run in python.
Summum ius, summa iniuria.

User avatar
PM 2Ring
Posts: 3715
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Sydney, Australia

Re: Coding: Fleeting Thoughts

Postby PM 2Ring » Sat May 07, 2016 10:59 am UTC

Thesh wrote:I'm actually going to rewrite in C++ for the performance gains. The full program may take days to run in python.

Wise. I love Python, but it's not particularly fast or conservative of RAM.

FWIW, in 32 bit CPython a small Python integer (i.e., one that fits into a 32 bit signed machine integer) consumes 12 bytes. An empty list is 32 bytes, and an empty tuple 24 bytes. At least, that's what I get from sys.getsizeof in Python 2. Tuples and lists are implemented as arrays of pointers; calling getsizeof on a list or tuple will will return the bytes used by the container object itself and those pointers, but not of the objects pointed to. OTOH, Python will recycle immutable objects like ints and strings, and it interns small ints, so if you do eg [7]*8 then no new 7 objects are created.

Standard Python does have an array type that's more efficient with RAM, but it can only hold simple datatypes, not structured data, so it'd be no good for your list of lists of ints, unless you can modify your list of lists algorithm to use a flat array. And of course there's also Numpy if you want arrays with RAM efficiency and speed. And a multidimensional Numpy array is pretty similar to a list of fixed-length lists, so it'd take less work to adapt your list of lists algorithm.

Ubik
Posts: 1016
Joined: Thu Oct 18, 2007 3:43 pm UTC

Re: Coding: Fleeting Thoughts

Postby Ubik » Sat May 07, 2016 11:23 am UTC

Memory-mapped files could be an interesting alternative to a database.

User avatar
Xanthir
My HERO!!!
Posts: 5423
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Coding: Fleeting Thoughts

Postby Xanthir » Sat May 07, 2016 3:25 pm UTC

I was just reading an interesting article arguing that we might be entering an era where it makes sense to treat the hard-drive as just another level of memory. All files are "open" and memory-mapped at all times, rather than requiring special load/save operations. Gotta introduce some new security notions to prevent touching memory for sectors you don't have permissions to, but still an interesting argument.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

commodorejohn
Posts: 1197
Joined: Thu Dec 10, 2009 6:21 pm UTC
Location: Placerville, CA
Contact:

Re: Coding: Fleeting Thoughts

Postby commodorejohn » Sat May 07, 2016 3:45 pm UTC

Xanthir wrote:I was just reading an interesting article arguing that we might be entering an era where it makes sense to treat the hard-drive as just another level of memory. All files are "open" and memory-mapped at all times, rather than requiring special load/save operations. Gotta introduce some new security notions to prevent touching memory for sectors you don't have permissions to, but still an interesting argument.

It's an interesting notion (after all, in a 64-bit system you could fit up to 16 exabytes of storage into the memory map, which oughta be enough for a while yet, until the industry develops another, even more ridiculously huge HD video standard and insists that we re-buy our video libraries in that format,) but it seems like it wouldn't really be worth it - by making files just a special case of virtual memory, you're making more work for the operating system to determine which is which as compared to having separate functionality for each, plus you'd still need the OS to serve as an index to which files are located where in memory anyway, and even in the age of zippy SSDs, is the overhead of a function call to the OS really where the bottleneck lies in file access?
"'Legacy code' often differs from its suggested alternative by actually working and scaling."
- Bjarne Stroustrup
www.commodorejohn.com - in case you were wondering, which you probably weren't.

User avatar
Yakk
Poster with most posts but no title.
Posts: 11129
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Coding: Fleeting Thoughts

Postby Yakk » Sat May 07, 2016 6:39 pm UTC

OTOH, you take some memory, then store it in the "file system" by giving it a name in a directory. Serialization finished.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

User avatar
Thesh
Made to Fuck Dinosaurs
Posts: 6598
Joined: Tue Jan 12, 2010 1:55 am UTC
Location: Colorado

Re: Coding: Fleeting Thoughts

Postby Thesh » Sat May 07, 2016 8:41 pm UTC

Ubik wrote:Memory-mapped files could be an interesting alternative to a database.


Actually, that would probably work. Each integer only needs 6 bits of storage, each list is exactly 3 integers, so I can store each row using exactly 5 bytes. With the estimated 3 billion records, that comes out to be 14 GB, leaving me plenty of room.
Last edited by Thesh on Sat May 07, 2016 9:14 pm UTC, edited 2 times in total.
Summum ius, summa iniuria.

commodorejohn
Posts: 1197
Joined: Thu Dec 10, 2009 6:21 pm UTC
Location: Placerville, CA
Contact:

Re: Coding: Fleeting Thoughts

Postby commodorejohn » Sat May 07, 2016 9:10 pm UTC

Yakk wrote:OTOH, you take some memory, then store it in the "file system" by giving it a name in a directory. Serialization finished.

Well, yes, that's just a RAM disk. I thought the implication was more of taking advantage of the size of a 64-bit address space to map mass storage as essentially an "in-memory" filesystem that's paged out to disk, or something. I'd be interested to know exactly which angle the article was coming at it from.
"'Legacy code' often differs from its suggested alternative by actually working and scaling."
- Bjarne Stroustrup
www.commodorejohn.com - in case you were wondering, which you probably weren't.

User avatar
Xanthir
My HERO!!!
Posts: 5423
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Coding: Fleeting Thoughts

Postby Xanthir » Sun May 08, 2016 4:36 am UTC

(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

commodorejohn
Posts: 1197
Joined: Thu Dec 10, 2009 6:21 pm UTC
Location: Placerville, CA
Contact:

Re: Coding: Fleeting Thoughts

Postby commodorejohn » Sun May 08, 2016 7:19 am UTC

Okay, so it is going with the let's-map-mass-storage-into-address-space angle, as I thought. Which, yes, is an interesting notion (and he looks to be talking more specifically about SSDs/flash storage, which could much more easily be treated as just a lower-speed tier of memory, if it was decoupled from the disk-drive-oriented interfaces that we currently buy it in - say, if there were a nice consumer-oriented version of those big PCI/PCIe flash-storage cards that I've seen intended for basically that purpose.) But I'm still not sure that's where the bottleneck really lies in modern computing.
"'Legacy code' often differs from its suggested alternative by actually working and scaling."
- Bjarne Stroustrup
www.commodorejohn.com - in case you were wondering, which you probably weren't.

speising
Posts: 2363
Joined: Mon Sep 03, 2012 4:54 pm UTC
Location: wien

Re: Coding: Fleeting Thoughts

Postby speising » Sun May 08, 2016 10:38 am UTC

This article ignores that file formats on disk are different than the data format in memory. The mentioned spreadsheet is saved in a very different, compressed format. Mapping the RAM directly to disk would produce huge files. And we don't have those PB disks yet.

User avatar
Yakk
Poster with most posts but no title.
Posts: 11129
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Coding: Fleeting Thoughts

Postby Yakk » Sun May 08, 2016 7:24 pm UTC

Compression can still be done. The fact that you do it "when you save to disk" is mixing two different phase changes that happened to be useful in the past. Imagine if instead of "save" you had "park" or "archive", or dbs not marked as "active" auto-compressed when system needed resources.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

korona
Posts: 495
Joined: Sun Jul 04, 2010 8:40 pm UTC

Re: Coding: Fleeting Thoughts

Postby korona » Sun May 08, 2016 9:02 pm UTC

Treating files as RAM has a huge problem: Accessing an uncached byte causes a page fault which suspends the whole thread for up to multiple ms. Such a system will never reach the throughput of proper manual asynchronous reads/writes. However most operating systems make it incredibly difficult to perform async file IO: In Linux you can only perform block-sized/aligned operations asynchronously and you have to use a API that basically says "this might be async or not, depending on your kernel version, system load and other factors; oh and something like sync() is not supported so you have to run it in an own thread". When the APIs of our OSes were designed event-driven servers were not a thing yet sadly.

User avatar
raudorn
Posts: 370
Joined: Mon Jun 13, 2011 11:59 am UTC

Re: Coding: Fleeting Thoughts

Postby raudorn » Sat May 14, 2016 3:25 pm UTC

Today I discovered the horror of bug dependencies. No, not dependency bugs, those are normal.

So there was a bug report for a bug. I couldn't reproduce, but the code looked like the bug should indeed occur. I digged further and discovered three related bugs, which I fixed. Now the bug from the report was reprodudable. I wanted to fix it, but my solution for the fourth bug refused so work. Further digging. The culprit: A workaround for the first three bugs was now working under false assumptions and produced a fifth bug, which stopped my solution. I wish I could fix this bug now, but there are other workarounds (and some genuine functionality) in forked repositories which makes the proper solution thousands of lines of changes long. So now I hope I can get enough time for the proper solution and knowing that I likely won't, coded another workaround for the fourth bug which replaces the one that produces the fifth bug. There, all bugs solved.

I want to shower now. And eat ice cream. And cry.

User avatar
Yakk
Poster with most posts but no title.
Posts: 11129
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Coding: Fleeting Thoughts

Postby Yakk » Sun May 15, 2016 3:58 am UTC

korona wrote:Treating files as RAM has a huge problem: Accessing an uncached byte causes a page fault which suspends the whole thread for up to multiple ms. Such a system will never reach the throughput of proper manual asynchronous reads/writes. However most operating systems make it incredibly difficult to perform async file IO: In Linux you can only perform block-sized/aligned operations asynchronously and you have to use a API that basically says "this might be async or not, depending on your kernel version, system load and other factors; oh and something like sync() is not supported so you have to run it in an own thread". When the APIs of our OSes were designed event-driven servers were not a thing yet sadly.

Yes: in such a system, you'd need a way to easily do all memory read/writes asynchronously, setting up dependencies between them so they can proceed earlier, and queue up possible future reads far in advance of actually needing it.

Programming languages where the runtime and compiletime environment can seriously reason about your code and rearrange it may be useful.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

User avatar
PM 2Ring
Posts: 3715
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Sydney, Australia

Re: Coding: Fleeting Thoughts

Postby PM 2Ring » Sun May 15, 2016 5:49 am UTC

raudorn wrote:Today I discovered the horror of bug dependencies. No, not dependency bugs, those are normal.

So there was a bug report for a bug. I couldn't reproduce, but the code looked like the bug should indeed occur. I digged further and discovered three related bugs, which I fixed. Now the bug from the report was reprodudable. I wanted to fix it, but my solution for the fourth bug refused so work. Further digging. The culprit: A workaround for the first three bugs was now working under false assumptions and produced a fifth bug, which stopped my solution. I wish I could fix this bug now, but there are other workarounds (and some genuine functionality) in forked repositories which makes the proper solution thousands of lines of changes long. So now I hope I can get enough time for the proper solution and knowing that I likely won't, coded another workaround for the fourth bug which replaces the one that produces the fifth bug. There, all bugs solved.

I want to shower now. And eat ice cream. And cry.

Well done, raudorn! It sounds like you need a hug after that traumatic experience.

Rysto
Posts: 1460
Joined: Wed Mar 21, 2007 4:07 am UTC

Re: Coding: Fleeting Thoughts

Postby Rysto » Sun May 15, 2016 5:23 pm UTC

raudorn wrote:Today I discovered the horror of bug dependencies. No, not dependency bugs, those are normal.

So there was a bug report for a bug. I couldn't reproduce, but the code looked like the bug should indeed occur. I digged further and discovered three related bugs, which I fixed. Now the bug from the report was reprodudable. I wanted to fix it, but my solution for the fourth bug refused so work. Further digging. The culprit: A workaround for the first three bugs was now working under false assumptions and produced a fifth bug, which stopped my solution. I wish I could fix this bug now, but there are other workarounds (and some genuine functionality) in forked repositories which makes the proper solution thousands of lines of changes long. So now I hope I can get enough time for the proper solution and knowing that I likely won't, coded another workaround for the fourth bug which replaces the one that produces the fifth bug. There, all bugs solved.

I want to shower now. And eat ice cream. And cry.


I call this Monty Burns syndrome, but that's because I didn't remember the Simpsons' episode correctly. In the Simpsons' they called it Three Stooges Syndrome.

User avatar
raudorn
Posts: 370
Joined: Mon Jun 13, 2011 11:59 am UTC

Re: Coding: Fleeting Thoughts

Postby raudorn » Mon May 16, 2016 7:24 am UTC

Rysto wrote:I call this Monty Burns syndrome, but that's because I didn't remember the Simpsons' episode correctly. In the Simpsons' they called it Three Stooges Syndrome.

Ha, that's a nice analogy. Before the fixes, everything was working fine, just not according to the client's expectations...

User avatar
Xeio
Friends, Faidites, Countrymen
Posts: 5101
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: Coding: Fleeting Thoughts

Postby Xeio » Tue May 24, 2016 5:39 pm UTC

So I finally got around to learning some PowerShell (because I needed it for work).

I actually do like it a lot, Everythings-An-Object makes piping data trivial.

Though the internet wasn't kidding about needing to sprinkle Get-Member everywhere when writing a script on an object you know nothing about.

User avatar
Wildcard
Candlestick!
Posts: 253
Joined: Wed Jul 02, 2008 12:42 am UTC
Location: Outside of the box

Re: Coding: Fleeting Thoughts

Postby Wildcard » Wed May 25, 2016 10:36 am UTC

Fleeting thought: Closures don't really seem that complicated. No more complicated than the concept of first-class functions, at least.

Is it even possible to have a language with first-class functions without support for closures? (It seems like it would be theoretically possible, but very weird.) Is there such a language?
There's no such thing as a funny sig.

korona
Posts: 495
Joined: Sun Jul 04, 2010 8:40 pm UTC

Re: Coding: Fleeting Thoughts

Postby korona » Wed May 25, 2016 4:42 pm UTC

The C language does that.

User avatar
chridd
Has a vermicelli title
Posts: 846
Joined: Tue Aug 19, 2008 10:07 am UTC
Location: ...Earth, I guess?
Contact:

Re: Coding: Fleeting Thoughts

Postby chridd » Wed May 25, 2016 7:27 pm UTC

C has function pointers, which one can pass around as data, but there's no way to (portably) create new functions at runtime, so I'm not sure if that counts as first-class functions.

I can think of a couple ways a language could do first-class functions, including generating functions at runtime, without closures:
• Some sort of way to generate a function given code, or some representation of code (e.g., an object-oriented language could have a way to generate a function given a list of Statement objects, or a LISP variant could have a way to generate a function given a list). The only programming language I can think of that has this feature is JavaScript, where you can make a function using something like

Code: Select all

new Function("x", "return x+1;")
but JavaScript also supports proper closures and I'm not sure how widely used the new Function thing is. (Also technically any language with eval has this feature.)
• Have functions be objects that overload the function call operator; one can do this in C++, even before it introduced actual closures/lambdas (so pre-lambda C++ could be considered a language with first-class functions but not closures). One could then do a more manual equivalent of making a closure, by copying all relevant local variables into members/instance variables in the object.
~ chri d. d. /tʃɹɪ.di.di/ (Phonotactics, schmphonotactics) · she · Forum game scores
mittfh wrote:I wish this post was very quotable...

User avatar
Yakk
Poster with most posts but no title.
Posts: 11129
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Coding: Fleeting Thoughts

Postby Yakk » Wed May 25, 2016 8:07 pm UTC

C has first class functions. You just have to use the `foo.f(foo.p, ...)` syntax instead of just `foo(...)`.

;)
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 2 guests