Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-8081-120121-160161-

/prague/ Q&A

Name: Anonymous 2013-11-19 12:18

Ask /prog/ anything.

Although don't expect an answer or even a good one.

Also, keep it /prog/ related.

Name: Anonymous 2013-11-19 12:37

What is the velocity of an unladen swallow?

Name: ddgbot 2013-11-19 12:58

Estimating the Airspeed Velocity of an Unladen Swallow
Although 47 of the 74 worldwide swallow species are found in Africa, 1 only two species are named after the continent: the West African Swallow (Hirundo domicella) and the South African Swallow (Hirundo spilodera), also known as the South African Cave Swallow.
style.org/unladenswallow/ More from style.org

Name: Anonymous 2013-11-19 13:26

What is /prog/'s general opinion on Dijkstra?

Name: Anonymous 2013-11-19 13:42

>>4
Lucky sonofabitch who attached his name to an algorithm learned by every first-year CS student. Founder (unintentional?) of a programming style cult that is severely overrated.

Also smarter than /prog/ will ever be, and with enough accomplishments that our opinion is completely irrelevant .

Name: Anonymous 2013-11-19 14:01

Why is pascal not suitable for systems programming?
What's the key differences with Algol 60 and 68?
Why was Cobol so popular for data processing applications?

Name: Anonymous 2013-11-19 16:26

>>6
Why is pascal not suitable for systems programming?

The main/"canonical" Pascal dialect is unsuitable because it's (deliberately) crippled by quirks like forcing all code to be in the same file. It's a teaching language. There are other dialects that "fix" some of these problems but there's no point when they end up having no advantage over C whatsoever.

What's the key differences with Algol 60 and 68?

Algol 60 was kind of a crazy research project where they just threw a bunch of ideas together and tried to invent a new language. It's an overengineered, underspecified mess. Different compilers had different interpretations of the lexical syntax alone.

Algol 68 tried to put the smack down on that kind of nonsense and bring everything under control. In the process it discarded some of the fun features of Algol 60.

Why was Cobol so popular for data processing applications?

There are two reasons, and the first is the same as with Java: It was marketed harder than the alternatives and got an early foothold. The second is that it was sort of the Perl of its day. For a language invented when malloc() wasn't a thing yet, it's surprisingly good at taking strings apart and splicing them back together.

Name: Anonymous 2013-11-19 18:54

>>5
this
i've got fucking C because faggot landwhale CS examiner did not believe that i devised this trivial algorithm all by myself and therefore was unavare of its ``real'' name. what a bunch of faggots. half a year later i've left to physics department, have never regret this decision.

Name: Anonymous 2013-11-19 19:23

Why do some of you insist that SGML is better than HTML? It's the same load of horse shit.

Name: Anonymous 2013-11-19 19:28

>>9
Who the fuck says that and isn't obviously trolling?

Name: Anonymous 2013-11-19 22:32

why aren't you using lisp?

Name: Anonymous 2013-11-19 23:04

What's your major?

If NEET, what would you spend 4 years of your life studying from home?

Name: Anonymous 2013-11-20 0:58

Why do i see a lot oc go shit on hacker news? Why the hype? What advantages does it have versus other xoncurrent programmig languages?

Name: Anonymous 2013-11-20 1:17

>>12
Math because I hate it less than everything else.

CS because I need to eat, and companies get uneasy when all you have on your resume is ``ABSTRACT BULLSHITE (and Matlab)''.

Name: Anonymous 2013-11-20 1:33

>>13
I don't go on HN because it made me me literally ill when I did *, but Go is
- From Google
- Designed to replace that icky, icky C language thingy that is, like, soooooo 1970s.
- In its early days, so desperate to get a standard library that all you had to do to get your code merged was show up with a file that compiled. This lead to a bunch of people feeling like they were important in the Golang Community, which is a really good way to get vocal people to write blog posts upon blog posts about `vision' and `revolution' and `paradigm'. (It also leads to code quality which leaves something to be desired, as a few people later found out.)

*Well, it was probably the sandwich I had for lunch, but I say it was HN anyway.

Name: Anonymous 2013-11-20 2:26

>>13
Asking why a language is good is like asking why a person is good. You can't really say someone is a bad person just because they're not successful or whatever. They have circumstances you don't know about and you're not going to get their whole life story out of them just so you can judge them for it. So maybe someone has a good heart but he's led an utterly shitty life through no fault of his own, and he ends up homeless and having to steal to eat.

When evaluating Go strictly on its merits as a language, I can't compare it favorably to much of anything invented after 19901. But let's pretend for a moment that all languages are equal in the eyes of the person actually writing the program: Go is no better or worse than Common Lisp, which is no better or worse than C, which is no better or worse than Ruby, and so on.

Now instead of comparing the languages themselves, we have to look at things like the release cycles of their major implementations, the change in documentation quality over time, the command hierarchy of their development teams, and all sorts of shit you wouldn't ordinarily include in your knowledge of the language itself. And in this sort of evaluation, Go is cast in a favorable light: It has a high-quality, open source implementation backed by literally one of the largest corporations in the world. It runs natively on a whole bunch of platforms without weird changes in behavior from one to the next (like Haxe has). The compiler runs quickly, producing fast binaries, and when errors occur it explains them pretty well. The documentation is downright bountiful. The community is very large, and a hell of a lot friendlier than the Ruby and Java clubs.

Go is the hedonistic, unambitious college dropout who never misses a day of work, never shows up late, and is always clean and sober and prepared to do the job. It doesn't claim to be a genius. It doesn't have to be. There is demand for someone who will move boxes around without breaking shit, and it fills that demand. That's all.

1. At least in terms of languages that are well-known enough to earn their complaints. Other stuff like X# (https://code.google.com/p/xsharp/) is obviously, and indefensibly, worse than Go. But nobody uses those anyway so you don't care about them.

Name: Anonymous 2013-11-20 12:17

Are linked lists really bad?

Name: Anonymous 2013-11-20 12:28

Quick question. In C, if I declare a pointer

int *var

What's the differences between *var, var and &var?

Name: Anonymous 2013-11-20 13:45

>>17
Pretty bad, yeah, at least if you have any kind of performance concern.

The problem is that they're wasteful. Let's say you have a hundred elements and you want to iterate over all of them. The processor tries to access the first element, loads it into the cache, and does a thing, maybe some quick arithmetic. We'll just agree not to worry about the time cost up to this point, because it's the same for both an array and a list.

So the CPU finishes doing the thing, and now it needs the second element. With an array, the second element is already in the cache, but with a list, it's somewhere else in the heap, and chances are low that it happens to be in the same cache line (which is probably only 64 bytes long). So right away, with the list implementation, you have a cache miss and you need to fetch from main memory. Meanwhile the array version just keeps plugging away on the subsequent elements. In the time it takes for the list program to retrieve element 2, the array program could be ready to look for element 4 or 8 or 16.

This effect is compounded over the length of the collection. In the worst case scenario, the list-based code needs to go all the way to main memory for every element, whereas the elements of an array are guaranteed to be lined up one after another. You probably won't see it get this bad in real code unless your collections are extraordinarily long, like for example in scientific computing applications. Usually you have bigger fish to fry, like disk or network access. And in the event that your elements are large data structures, you can't really do anything without blowing out multiple cache lines, so it no longer matters how you've organized them. At any rate, linked lists are a code smell for a cache-aware programmer, especially a list of boxed elements, which is almost always the case in dynamically typed languages.

Memory consumption is a little more obvious. A 64-bit pointer is 8 bytes. If your elements are one byte each (like a UTF-8 character sequence) and your processor expects everything to be word-aligned, each list element consumes 16 bytes plus whatever the allocator uses for bookkeeping. A hundred-element char list eats up 1600 bytes. A hundred-element char array uses 101 bytes (if you're using end markers instead of a length counter). Try writing a text editor with a linked list as your main data structure, and see what happens when it reads its own source code.

Now, it's possible to expose linked lists as an abstraction for the sake of pattern matching, and then when you actually compile the program, you instead generate tight inner loops and array manipulation code. That's how it ought to work. Haskell, to its credit, does this some of the time. However, I get the feeling the actual optimizations involved aren't low-level to make it totally pervasive, which is a weakness that needs to be addressed.

I'm not aware of any Lisp capable of such optimizations.

Name: Anonymous 2013-11-20 13:50

>>18


int var = 420;
int *pointertovar = *var;
int **pointertopointertovar = **var (== *pointertovar);
int varaddress = &var;
int pointertovaraddress = &pointertovar;

I don't feel like explaining, better read that K&R

Name: Anonymous 2013-11-20 13:56

>>18
typeof(*var) is int.

typeof(var) is int * (the address of an int value).

typeof(&var) is int ** (the address of a pointer which in turn contains the address of an int value).

Name: Anonymous 2013-11-20 14:07

>>20
>>21
I see, so why doesn't this function work? First, I passed the Record * that I declared in main() to a function named input(Record *Something) so that I can ask for some data and call insert(). Whenever I try to print the data, the Record * I declared first in main() only seems to refer to NULL

int insert(Record *Phonebook, char * lname, char * fname, char * mobile)
{
/*
RETURN 0 IF SUCCESSFUL.
*/
Record *New, *Temp;

New = (Record *) malloc(sizeof (Record));

/* If malloc returns a null pointer... */
if (!New) {
return 1;
}

New->lastname = (char *) malloc(strlen(lname) + 1);
strcpy(New->lastname, lname);
printf("%s", New->lastname);
New->firstname = (char *) malloc(strlen(fname) + 1);
strcpy(New->firstname, fname);
New->mobilenum = (char *) malloc(strlen(mobile) + 1);
strcpy(New->lastname, mobile);
New->Next = NULL;

if (Phonebook == NULL) {
Phonebook = New;
} else {
Temp = Phonebook;
while (Temp->Next != NULL) {
Temp = Temp->Next;
}
Temp->Next = New;
}

return 0;
}

Did I fuck up the scoping and deleted the *Phonebook in input() when it ended?

Name: Anonymous 2013-11-20 14:21

>>22
Did I fuck up the scoping and deleted the *Phonebook in input() when it ended?

First of all, you've got a poor understanding of C's manual memory management. You lost the address of the new Record you allocated, but it's still on the heap taking up space. That's a memory leak. Someone's gonna point that out and it might as well be me.

And second, yeah, you'll want to change Phonebook to a Record **, and rewrite that last section as follows:

if (Phonebook != NULL) {
if (*Phonebook == NULL) {
*Phonebook = New;
} else {
Temp = *Phonebook;
// ...
}
} else {
// Signal an error and/or deallocate New
}

Name: Anonymous 2013-11-20 19:42

>>19
How do you feel about cdr coding and GC-time list compaction?

For reasonable things like parsing config files or setting up a firewall or implementing a text editor that is; if a programmer did any consing (unless it's the kind that gets optimized out) in any tight loop that gets executed for more than 0.01s I would not only fire them but also douse them with gasoline and set them on fire, for humanity's sake.

Name: Anonymous 2013-11-21 7:26

What's your favorite data structure /prog/? I like trees. They're so beautiful when they're symmetric.

Name: Anonymous 2013-11-21 9:24

>>23

Yes I have yet to make a delete function.

Name: Anonymous 2013-11-21 11:50

>>25
I like arrays, because they have low overhead and high speed*, and can be used to implement many other data structures.

*Depends on the language, of course. But good array implementation is common.

Name: Anonymous 2013-11-21 17:43

>>25
Hashes or Database schemas (B-trees?)

Name: Anonymous 2013-11-21 23:01

>>27
How is it even possible to fuck up an array implementation? Can you call anything that's not a contiguous chunk of memory an array?

Name: Anonymous 2013-11-22 5:33

>>24
How do you feel about cdr coding and GC-time list compaction?

As I said, I'm not against lists as an abstraction so long as the compiler (or library maintainer) can mitigate the costs with a sensible representation. I would prefer unrolled lists, of which CDR-coding is a specialization, in a way, and there are environments in which the latter makes more sense. For example, if you're already committed to working with tagged pointers, or if the list structure has to be mutated often (ugh). CDR-coding's small additional cost in CPU instructions is certainly preferable to cache misses, if it ever comes to that. There are architectures on which it's downright negligible.

GC-time list compaction is something I admit I've never heard of and can't seem to google right now. From the name it sounds like it would only work with memory models that run on handles instead of direct pointers. Could you tell me more about it, and perhaps point out some implementations?

Name: Anonymous 2013-11-22 20:35

>>30
From the name it sounds like it would only work with memory models that run on handles instead of direct pointers.
Depends. If you don't want a non-incremental ("stop-the-world") collector (and you almost never do except when implementation simplicity/size is the most important thing) then you will have to do tricky, nasty and possibly inefficient things to avoid using handles. Using handles instead of pointers at most doubles your cache misses, and you can cache pointer-handle associations in a per-thread structure so you don't waste cache on handle table entries that you won't use anyway.

Could you tell me more about it (...)
The GC has the `power' to lock structures, and it [i]has[/i] traverse them anyway (to mark things), so while it's doing its marking stuff it could also compact lists into unrolled lists as it goes through them and move them to a new location.

(...) and perhaps point out some implementations?
I am not aware of any, sorry. I am not familiar with many languages' implementations.

Name: Anonymous 2013-11-23 3:56

Q: how harmful is serialize using JSON in Berkley DB?

Name: Anonymous 2013-11-23 6:24

>>28
B-trees, of course. Don't they make your heart go doki-doki?

Name: Anonymous 2013-11-23 7:00

>>29
I dunno, man. Maybe in a toy language or something. Maybe it turns out that under the hood the JVM doesn't actually create arrays as contiguous, or some shit like that. If I'd said that low overhead+high speed was universal, somebody would probably have pointed out a language in which it isn't.

Name: Anonymous 2013-11-23 7:38

>>32
I'd say it depends highly on exactly what you're serializing, and who
you want to read it. If you're storing records of people with names,
birthdays, street addresses, and other good-for-homework collections
of data that mimic slightly mutable hashes themselves, and especially
if there's a possibility that in 10 years another programmer will want
to pull that data into another application, then JSON serializing is
probably not a bad choice. If you're using it to store something
that's already pretty specifically defined, like states of a
chessboard, just suck it up and use Huffman coding of the board state,
especially if you are expecting to run into size constraints.

In general though, I'd be cautious. JSON is, after all, representing
data fundamentally as a nebulous mapping, right? Since you're using
db, you've got a nebulous mapping system right there! And if your data
is tricky enough that you're trying to pass off the serialization
burden to another representation (assuming your application doesn't
pass around JSON blobs internally), it might be something like image
data, in that it can probably be serialized better a different way.

Name: Anonymous 2013-11-23 8:48

>>35
Thank you, now I'm more confident about using JSON: it seems to be the most scalable, portable, and fast option for what I'm trying to accomplish.

Name: Anonymous 2013-11-23 12:20

Serious post: Why Lisp? Why functional programming in our current computer technology? Why is there no SICP 3rd edition yet?

Name: Anonymous 2013-11-23 13:28

>>37
K&R is long due for a 3rd Edition. But I guess since Ritchie, is ded, even if Kernighan made a new edition, you can't call it K&R... ;_;

Name: Anonymous 2013-11-23 13:50

>>37
How can you not like Scheme after reading chapters 4 and 5 of SICP?

Name: >>28 2013-11-23 15:09

>>33
I wasn't asking.

>>36
Or SQLite for that matter. [spoiler]Wasn't it previously published here all the lightweight DB engines⸮[/spoiler]

>>37
Why Lisp?
not a correct question. Try "Why use Lisp?" on a search engine. We have answered this question xx times.

Why functional programming in our current computer technology?
Pffft hahahaha. https://encrypted.google.com/search?hl=en&q=current%20computer%20technology
About 273,000,000 results (0.32 seconds)

Why is there no SICP 3rd edition yet?
There's, and it's in FIoC. You are welcome to update your onw with R7RS &/| R2004.

et al.
Bet you creeps did not know about Common Lisp HyperSpec:
http://www.lispworks.com/documentation/common-lisp.html

Name: >>31 2013-11-23 19:58

>>30
Now that I explained GC-time list compaction, how do you feel about it?

This has the potential to turn into a debate on whether handles are a good idea.

Name: Anonymous 2013-11-24 1:05

I'm familiar with object-oriented programming, but what is functional programming? Are they compatible? Are they reconcilable? Do individual programmers generally favor one over the other, or do they utilise each when appropriate? Are the any other styles or philosophies of note or of relevance?

Sorry if those are silly questions, I'm a mere hobbyist who will never even hope to one day achieve Satori.

Name: Anonymous 2013-11-24 1:21

>>42
I'm familiar with object-oriented programming, but what is functional programming?
Object-oriented programming is when things are centered around objects and their composition (inheritance, for example), and functions/procedures/methods are defined in terms of/around objects. Functional programming is when emphasis is put on functions instead and their composition, and objects/structures are just things that functions operate on. Purely functional programming is the extremest form of this, where all code is part of functions (in the mathematical sense) and so there is no mutation ("assignment"). Turns out that all of the above are equal in computational power (i.e. there are no computations that one of them can do but the other ones can't), so this is really just about clarity and efficiency and all those other things.

Are they compatible? Are they reconcilable?
Yes; an excellent example is Common Lisp and the CLOS.

Do individual programmers generally favor one over the other, or do they utilise each when appropriate?
The average programmer has the IQ of a highly-trained rhesus monkey. That being said, a Haskell programmer will almost always use functional programming (even when clarity/performance are hurt) while a Java programmer will almost use object-oriented programming (because they don't know any better).

Are the any other styles or philosophies of note or of relevance?
Read up about defmacro. Also read SICP (or if you find it too hard, something like Land of Lisp).

Name: Anonymous 2013-11-24 3:03

>>43
Thank you for the fantastic response. The defmacro functional programming article really helped shed a bit more light on the topic for me. (Un)fortunately I am as Java-ignorant as anyone can be so any nuance or implication of the given examples went over my head. I feel like I'm right on the brink of getting it, but that last puzzle piece of understanding still looks like a corner when I've already completed in the border.

even when clarity/performance are hurt
Is this due to the flexibility and ease of debugging that was mentioned in the article, or am I missing something?

Name: Anonymous 2013-11-24 3:16

>>44
What article are you referring to?

Name: Anonymous 2013-11-24 3:19

>>22
Doushiou. I always lose the address of the malloc'd object somewhere in the program..
Fonbuk.c

#include <stdio.h>
#include <string.h>

typedef struct _record {
char *firstname;
char *lastname;
char *mobilenum;
struct _record *Next;
} Record;

void newentry(Record *Rec);
int insert(Record *Rec, char * lname, char * fname, char * mobile);
void viewall(Record *Rec);

int main()
{
char c;
Record *Phonebook = NULL;

while(1) {
printf("%s\n", "Phonebook: ");
printf("%s\n", "\t[1] Insert");
printf("%s\n", "\t[2] Display");
printf("%s\n", "\t[3] Exit");

do {
scanf("%c", &c);
} while (!((c == '1') || (c == '2') || (c == '3')));

switch (c) {
case '1':
newentry(Phonebook);
break;
case '2':
viewall(Phonebook);
break;
case '3':
return 0;
}
}
}

void newentry(Record *Rec)
{
char lname[30], fname[30], mobile[15];
int error;

clrscr();
printf("%s", "Last Name: ");
scanf("%s", &lname);
printf("%s", "First Name: ");
scanf("%s", &fname);
printf("%s", "Mobile No.: ");
scanf("%s", &mobile);
error = insert(Rec, lname, fname, mobile);
if (error > 0) {
printf("%s\n", "Not enough memory.");
getch();
}
}

int insert(Record *Rec, char * lname, char * fname, char * mobile)
{
/*
RETURN 0 IF SUCCESSFUL.
*/
Record *New, *Temp;
int i;

New = (Record *) malloc(sizeof (Record));

/* If malloc returns an invalid pointer */
if (!New) {
return 1;
}

/* Allocate memory for strings and
copy the arguments into them.
*/
New->lastname = (char *) malloc(strlen(lname) + 1);
strcpy(New->lastname, lname);
printf("%s", New->lastname);
New->firstname = (char *) malloc(strlen(fname) + 1);
strcpy(New->firstname, fname);
New->mobilenum = (char *) malloc(strlen(mobile) + 1);
strcpy(New->lastname, mobile);
New->Next = NULL;

/* If malloc returns an invalid pointer on the strings.*/
i = !(New->lastname) || !(New->firstname) || !(New->mobilenum);
if (i) {
return 1;
}

if (Rec == NULL) {
Rec = New;
} else {
Temp = Rec;
while (Temp->Next != NULL) {
Temp = Temp->Next;
}
Temp->Next = New;
}

return 0;
}

void viewall(Record *Rec)
{
Record *Temp;

clrscr();
printf("%s\t\t", "Last Name");
printf("%s\t\t", "First Name");
printf("%s\n", "Mobile Number");
Temp = Rec;
while (Temp->Next != NULL) {
printf("%s\t\t", Temp->lastname);
printf("%s\t\t", Temp->firstname);
printf("%s\n", Temp->mobilenum);
Temp = Temp->Next;
}
}

Name: Anonymous 2013-11-24 6:48

Name: Anonymous 2013-11-24 9:06

>>46
Nvm /prog/, I got it working. It took me some time to figure it out while avoiding **-pointers as per >>23's advice but I just gave in.

Anyway, since this is a Q&A, can /prog/ please review my code for shit? How do I improve myself? Am I an annoying fag who should stop posting?
Also, please don't mind for me using a linked list.

Fonbuk.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _record {
char *firstname;
char *lastname;
char *mobilenum;
struct _record *Next;
} Record;

void newentry(Record **Rec);
int insert(Record **Rec, char * lname, char * fname, char * mobile);
void viewall(Record **Rec);

int main()
{
char c;
Record *Phonebook = NULL;

while(1) {
system("cls");
printf("%s\n", "Phonebook: ");
printf("%s\n", "\t[1] Insert");
printf("%s\n", "\t[2] Display");
printf("%s\n", "\t[3] Exit");

do {
scanf("%c", &c);
} while (!((c == '1') || (c == '2') || (c == '3')));

switch (c) {
char lname[30], fname[30], mobile[15];
int error;
case '1':
newentry(&Phonebook);
break;
case '2':
viewall(&Phonebook);
break;
case '3':
clrscr();
}
if (c == '3')
break;
}

return 0;
}

void newentry(Record **Rec)
{
/* I am now a two-star programmer. (NOT a good thing) */
char lname[30], fname[30], mobile[15];
int error;

clrscr();
printf("%s", "Last Name: ");
scanf("%s", &lname);
printf("%s", "First Name: ");
scanf("%s", &fname);
printf("%s", "Mobile No.: ");
scanf("%s", &mobile);
error = insert(Rec, lname, fname, mobile);
if (error > 0) {
printf("%s\n", "Not enough memory.");
getch();
}
}

int insert(Record **Rec, char * lname, char * fname, char * mobile)
{
/*
RETURN 0 IF SUCCESSFUL.
*/
Record *New, *Temp;
int i;

New = (Record *) malloc(sizeof (Record));

/* If malloc returns an invalid pointer... */
if (!New) {
return 1;
}

/* Allocate memory for strings and
copy the arguments into them.
*/
New->lastname = (char *) malloc(strlen(lname) + 1);
strcpy(New->lastname, lname);
New->firstname = (char *) malloc(strlen(fname) + 1);
strcpy(New->firstname, fname);
New->mobilenum = (char *) malloc(strlen(mobile) + 1);
strcpy(New->mobilenum, mobile);
New->Next = NULL;

/* If malloc returns an invalid pointer on the strings... */
i = !(New->lastname) || !(New->firstname) || !(New->mobilenum);
if (i) {
return 1;
}

if (*Rec == NULL) {
*Rec = New;
} else {
Temp = *Rec;
while (Temp->Next != NULL) {
Temp = Temp->Next;
}
Temp->Next = New;
}

return 0;
}

void viewall(Record **Rec)
{
Record *Temp;

system("cls");
printf("%s\t\t", "Last Name");
printf("%s\t\t", "First Name");
printf("%s\n", "Mobile Number");
Temp = *Rec;
while (Temp != NULL) {
printf("%s\t\t", Temp->lastname);
printf("%s\t\t", Temp->firstname);
printf("%s\n", Temp->mobilenum);
Temp = Temp->Next;
}
}

Name: Anonymous 2013-11-24 9:12

>>47
I was referring to defmacro the macro-creation macro in Common Lisp, not defmacro the website. I don't know how accurate/good that page is because I have too much work to do and too little spare time to read it.

(Un)fortunately I am as Java-ignorant as anyone can be so any nuance or implication of the given examples went over my head. I feel like I'm right on the brink of getting it, but that last puzzle piece of understanding still looks like a corner when I've already completed in the border.
If you are truly new to programming, try reading SICP[1] or, if it's too rough, Land of Lisp[2], like I said before. And, of course, do at least some of the exercises as you go along.

Is this due to the flexibility and ease of debugging that was mentioned in the article, or am I missing something?
Programming is all about tradeoffs. Come to think of it, anything in the world is all about tradeoffs. When you code in C, you are trading off readability, security and terseness for that extra vroom vroom. When you code in Java, you trade off, uh, everything for (the illusion of) portability. When you code in Haskell, you trade off a lot of readability for (type) safety, theoretical purity, and terseness. Overusing functional programming can certainly lead to unreadable and/or unsafe and/or slow code, as would taking any one programming approach to be your hammer and pretending everything else is a nail (or in the case of C++, a thumb).

[1] https://mitpress.mit.edu/sicp/full-text/book/book.html
[2] http://landoflisp.com/

Name: Anonymous 2013-11-24 10:01

>>49
When you code in C
trading off security
And that's why C is the most used language for security programming

Come to think of it, anything in the world is all about tradeoffs
wow so wize

Name: Anonymous 2013-11-24 15:45

How's the board going, /prog/riders? Are you enjoying the total lack of moderation? I completely forgot I was hosting this place for about the past month.

The server space and domain are paid off for forever so don't worry about it ever going down in case I forget this place exists.

Name: Anonymous 2013-11-24 16:24

>>49
Who needs Lisp, when you have Dot fucking NET?


public static D[] map<S,D>(S[] xs, Func<S,D> f) {
D[] ys = new D[xs.Length];
int i = 0;
foreach (var x in xs) ys[i++] = f(x);
return ys;
}

Name: Anonymous 2013-11-24 18:31

>>51
The site attracted a few VIP quality posters, which is definitely an improvement over the old /prog/. Once again, thank you for giving us the chance of starting over by using your site.

There have been some occasional shitposts but other than that it's been cool.

Name: Anonymous 2013-11-24 20:03

>>50
And that's why C is the most used language for security programming
And that conclusively proves that people are retards.

Name: Anonymous 2013-11-24 22:34

Why is dynamic typing bad?

I know it introduces bugs in expressions like actually_a_str += 5 where actually_a_str was expected to be an int.

Other than that, is there anything bad about it?
I know it introduces a lot of bugs in a situation like I just mentioned, but are there any good things to say about it?

I dislike dynamic typing myself purely on the grounds of what I just showed, I just want to broaden my horizons like I did with Haskal

Name: Anonymous 2013-11-24 23:35

I prefer dynamic typing because I can always add type-checking macros or even pass the whole program through a static analyzer.

Name: Anonymous 2013-11-25 0:17

>>51
It's going well. One of the key ingredients for the success of a bbs is for the admin to forget it exists for a while. Thanks again for hosting this. I don't post on dis.4chan.org anymore because it's too difficult to obscure my ip there, so I wouldn't be a part of this community if it wasn't for this site.

>>54
Indeed. To be fair though, the alternatives to C generally come with large libraries that are generally written in something c like and can contain vulnerabilities of their own. So there is some merit to writing a very heavily reviewed code base of c with minimal library dependencies.

>>48
you can remove char lname[30], fname[30], mobile[15]; from main.

Also if (c == '3') break; could be optimized with a goto under case '3': that exits the while loop.

If you modified the Record structure to save a pointer to the last node in the list, you could eliminate the linear search for the end in the insert function. It may be good form to separate the Record constructor from the list insertion procedure, as in the future you may wish to make a Record but not necessarily insert it into a list, but that's not a big deal.

viewall can just take a Record* since it doesn't need to modify the pointer to the list.

but it looks good enough. Oh and at some point you should write procedures for freeing the memory used by your datastructure.

Name: Anonymous 2013-11-25 0:26

>>55
Dynamic typing is bad for the following reasons:

1. Some bugs that could be caught via static typing may not be caught at compilation time, and may turn up at run time. For some applications, failure at run time (that could have been prevented with more analysis) is not an option and this is not acceptable.

2. If the compiler is not able to determine the types of variables, the performance of the program may be degraded relative to how it would be if the compiler was given the set of types each variable could obtain explicitly. For some applications where high performance or minimal resource use is required, this extra overhead that could be prevented is not acceptable.

But if you are writing a quick script and think you a good enough coder to avoid bugs due to 1, and don't care about loss of performance due to 2, then dynamic typing can improve your productivity to an extent because you can just quickly write something up and not bother with type declarations. However, for large projects, type declarations serve as good documentation and type errors at compilation time will actually improve your productivity, as otherwise you'll be debugging type errors caught at runtime.

So in short, dynamic typing is good for shitty and short php scripts that no one cares about, and is bad for everything else.

Name: Anonymous 2013-11-25 0:35

How can UTF8 represent every unicode character if it is only 8 bits?

Name: Anonymous 2013-11-25 0:42

>>58
1. Static analyzer. Put the static analyzer in your makefile to prevent the code from even compiling.
2. By insisting that the code (for a specific program) fully passes static analysis and by 'wiring' the aforementioned static analyzer into the compiler, the compiler should now be able to infer all types in the program.

So in short, dynamic typing is good for shitty and short php scripts that no one cares about, and is bad for everything else.
So in short, static typing is good for shitty and short C programs that no one cares about, and is bad for everything else.

>>59
UTF-8 encodes each of the 1,112,064 code points in the Unicode character set using one to four 8-bit bytes (a group of 8 bits is known as an "octet" in the Unicode Standard). Code points with lower numerical values (i.e. earlier code positions in the Unicode character set, which tend to occur more frequently) are encoded using fewer bytes. The first 128 characters of Unicode, which correspond one-to-one with ASCII, are encoded using a single octet with the same binary value as ASCII, making valid ASCII text valid UTF-8-encoded Unicode as well.

Name: Anonymous 2013-11-25 2:56

>>60
1. Static analyzer as a compilation check works. However, assuming this is working off of type inference, the type error messages may not be all that clear. If the programmer has written out the type signatures eyself, then the analyzer can point out the conflicting points directly. Otherwise, when types are inferred, the analyzer may infer types that weren't intended by the programmer, and when the conflicts are listed, they might not make sense. For it to really work it needs to be interactive. Or the analyzer would need to list all inferred types so the programmer could look through it and find the ones that doesn't match what they thought, and fix the problem there.

2. That's certainly possible but not really achievable using crap like python. It's a large effort and can only really work if the compiler and analyzer are designed to work together from the start. I think the easiest way to get this would be to have the analyzer output the code in a sub language with explicit types, and then feed this into a secondary compiler.

Name: Anonymous 2013-11-25 3:29

>>59
See >>60 , but tl;dr - it's not only 8 bits. Different codepoints may be represented by different numbers of bytes, which is what makes it hard to get the ith character of a UTF-8 string in less than O(n) time.

Name: Anonymous 2013-11-25 3:57

>>61
For it to really work it needs to be interactive. Or the analyzer would need to list all inferred types so the programmer could look through it and find the ones that doesn't match what they thought, and fix the problem there.
This is actually what I was thinking about, thank you for articulating it so nicely. Sometimes this can be difficult, for example if the code is actually part of macroexpanded code, but it should still be feasible. Most of the time the static analyzer will be complaining about the lack of annotations rather than pointing out mismatches.

I think the easiest way to get this would be to have the analyzer output the code in a sub language with explicit types, and then feed this into a secondary compiler.
Or just let the compiler accept type hints (like CLs have been doing since forever) and use them whenever it can.

Name: Anonymous 2013-11-25 4:38

>>63
Yeah, it should be pretty easy. Every time some sort of definition is encountered, the analyzer can make a note of it, infer all types as far as possible, and then create a list of type signatures for all definitions, per file. These files would correspond to the header file in C, and I think ocaml has something similar with .mli. And if I recall correctly ocaml has a compilation option to generate mli files from ocaml source, although I could be wrong here.

Name: Anonymous 2013-11-25 7:04

>>51
The server space and domain are paid off for forever

How does that work? I thought you could only register a domain at a max of 5 years?

Name: Anonymous 2013-11-25 7:44

>>65
In five years we'll all be dead and the internet will be shut down, so it doesn't matter anyway.

Name: Anonymous 2013-11-25 11:47

>>66
The sad thing is that neither of those will happen (well, maybe some of us will die or commit suicide, but not all of us).

Name: Anonymous 2013-11-25 21:57

Name: Anonymous 2013-11-25 22:31

>>68
Does /jp/ know about these videos? I still don't understand then, but I enjoy them thoroughly.

Name: Anonymous 2013-11-25 22:47

Tell me [spoiler]/prog/[/spoiler, should I buy some Bitcoins now?

Name: conway's game of dicks 2013-11-25 23:07

>>70
We don't know what's going to happen in the next few weeks, but if the trend continues, it should stay stable at that absurd price (~$800 as of today) and rise very slowly to $1000 or so. It's not certain if it will crash again, but if it does, it's likely it will fall to a price that will make you say out loud "shit i wish i would have waited a bit more".

You'd have to make a very risky investment if you want to get some profit[1].
_________
[1] Extracts from MY ANUS: Copyright 1985 - 2013.

Name: Anonymous 2013-11-26 12:18

Why are global variables bad? Everyone just keep saying that it is but no one ever tells me why.

Name: Anonymous 2013-11-26 12:27

>>72
I asked that a long time ago and got bombarded with dozens of reasons, many of which were language specific. The one that stuck with me was
The more global variables you have, the more you have to worry about exactly what each function may do in terms of unexpected side effects. If you have no global variables, you can look at just what a function returns and what it calls. If you have many global variables modified in a function, you have to track each one down across every other part of your program to figure out what a function actually does.
So when I avoid global variables, I do so for reasons of clarity.

Name: Anonymous 2013-11-28 12:16

What the fuck is code golfing and why is it the new fad among hackers?

Name: Anonymous 2013-11-28 12:31

>>74
All responders to this post are honorary recipients of the IHBT medal of meritorious service to Prague.

Name: Anonymous 2013-11-28 13:01

>>74
Kolmogorov complexity.

Name: Anonymous 2013-11-28 18:18

>>73

Ever do embedded systems programming on trash boards? you're pretty much forced to use global variables exclusively

Name: Anonymous 2013-11-28 18:30

>>77
Nope. If an environment forces you to write code a certain way, it can't be helped.

Name: (cddr SCHEMA) 2013-11-29 2:58

>>78
That's what ̶µ̶$PHP said.

Name: Anonymous 2013-11-30 8:04

I want to work as a hacker to a company like Kaspersky. I don't care if they don't make FOSS b-but I am in love with the idea of taking files apart and analysing their payload and shit. I only have a very minimal programming experience, though. What path should I take /prog/?

Name: Anonymous 2013-11-30 8:41

>>80
Wasn't Kaspersky the shithead who suggested that internet access should be deanonymized and that everyone should have 'internet passports'?

Name: Anonymous 2013-11-30 9:55

>>81
Yes and?

Name: Anonymous 2013-11-30 15:32

Name: Anonymous 2013-11-30 19:14

>>82
I wouldn't work for him.

Name: Anonymous 2013-12-01 4:00

>>84

I just said Kaspersky as an example. But I wouldn't mind working for them as long as I get to do what I'd love to do.

Name: Anonymous 2013-12-01 10:39

Just be sure to respect our machines, like we do to yours.
/nsa-looking-to-train-students-in-cyber-ops/
xD

Name: Anonymous 2013-12-02 12:38

Why is interpretation considered bad compared to compilation? What advantage does interpreting have over compiling aside from you can see the output that makes it easy to teach?

Name: Anonymous 2013-12-02 13:46

>>87
Why is interpretation considered bad compared to compilation?
Vroom vroom.

What advantage does interpreting have over compiling aside from you can see the output that makes it easy to teach?
Debugging.

Name: Anonymous 2013-12-04 0:18

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Name: Anonymous 2013-12-04 8:21

>>89
You're the tool.

Name: Anonymous 2013-12-04 11:59

Why aren't you programming in Ruby like a real Nihonjin?

Name: Anonymous 2013-12-05 9:56

>>87
Interpretation is necessary when the user is provided with a console where ey may enter commands at run time to be interpreted as commands within the programming language. Embedded scripting is a good example of interpretation done in the right place. Also cgi scripts and such, although those too can be compiled and cached.

Name: Anonymous 2013-12-05 15:02

>>91
Real Nihonjin write badly formatted Sepples for Win2K.

Name: Anonymous 2013-12-05 20:17

Ruby? Is that what nihongogah use to write super famicom games >>91-domo?

Name: Anonymous 2013-12-11 7:04

Why do you hate Python? Is it really just because of the indentation? You are going to indent your code anyway so why bother? Or do you people really like braced languages so much and would rather argue which bracing style is the best?

Name: VIPPER 2013-12-11 7:08

>>95

if (this_is_a_very_big_function_name (1, things,
more_things,
even_more_things))
if (1 + 2 + 3 == 5 && 2 + 5 + 3 + 10 + 9 + 7 == 4
&& 3 + 9 == 8 || 3 + 5 == 7
|| (1 + 2 == 5 && 8 + 3 + 6 + 2 + 6 + 2 + 7))
;

Name: Anonymous 2013-12-11 11:29

>>96
Why'd anyone who can program do it like that anyway?

Name: VIPPER 2013-12-11 11:57

>>97
because he is not a nigger

Name: VIPPER 2013-12-11 12:07

check my d-bus

Name: VIPPER 2013-12-11 12:09

>>99
nice dbus!

how about mine?

Name: Anonymous 2013-12-11 13:03

>>95
I don't really hate Python, but I'm unsatisfied with it, and there are other languages that fulfill the same role better, so I use them.

Sure, I hate the indentation (I believe that since you aren't supposed to see whitespace at all, it shouldn't have any effect on a program), but the philosophy behind Python (there should be one way to do it, and that way should be obvious) really just strikes me as incorrect. Really, Guido? There should be only one way to do something, and it should be obvious? Then why the fuck didn't you just write my program for me, since it's so obvious, and build it into the language? Writing in Python is a fine experience when you want to do things that the language designers predicted you'd do, but it becomes incredibly awkward if you have to write something they didn't think of.

To their credit, those situations don't come up often, even when you take into account that OOP is slapped onto the language in some places, and not in others. But it only takes one time to run into the brick wall of ``We didn't think you'd want to use this construct like that, so this feature that should be trivial is missing and to build it in yourself would take more space than the rest of your program'' to turn you off.

I can't remember what it was for me. I think I was trying to do something with map and object construction intertwining, and I spent ages beating my head against the documentation, thinking I just didn't know enough Python, and finally I found some blog (by somebody who evidently did know enough Python) and it turned out the only way was to have two layers of objects and use one type as a proxy for the other in a manner that was incredibly awkward. And since ``Not writing awkward code, and being able to write it quickly'' was Python's selling point, and since it had failed at both for my particular task, I dropped it like a sack of rotten potatoes and used Perl for everything I would have used Python for. I'm no better at Perl now than I was at Python then, but I've never run into that problem again.

I know you're probably saying to yourself ``Well, you must have been doing it unpythonically to get into that situation in the first place,'' and you're probably right, but I don't care. As a language, Python advertises itself as being the choice where that doesn't happen, because all the subcomponents of the language are so intuitive that once you know a decent bit about the foundations, everything else just falls into place and you can worry about your algorithms and flow control. There are other languages that fill the same niche as Python, so it doesn't have a lot of leeway on failing to come through on those claims.

Name: Anonymous 2013-12-11 21:24

>>101
Ruby, PHP, or Python.
You are forced at gunpoint to choose. Which one, and why?

Name: not >>101 2013-12-11 21:37

Python; array handling is decent (unlike PHP) and there's no variable scoping mess like in Ruby.

Name: Anonymous 2013-12-11 21:37

>>102
Take the gunshot.

Name: Anonymous 2013-12-11 23:21

>>102
Assuming I can't follow >>104 's advice, I'd pick Python in a heartbeat.

PHP, above everything listed in A Fractal of Bad Design, is (apart from truly perverted setups) a lock into web development. Sure, it's on the backend, so it's not quite the same kind of cancer that Javashit is, but I don't really want to spend the rest of my life writing interfaces to various databases, CMS software, and/or shopping carts.

My reason for despising Ruby is mostly a cop-out; I'll just say that the Ruby community (even beyond Rails) is a cancerous bunch. I do actually have reasons for disliking Ruby, even on a technical level (I hold it to be a prime example of why Reference Implementations are a horrible concept, for example), but I haven't ever bothered to organize my thoughts on the matter, and frankly I don't care to. Ruby doesn't deserve that much of my time.

Python, for all its insufferable smugness, is a language in which I have done some non-trivial things, and therefore know they can be done. I think that for any problem or project that I would be interested in, there are better languages, but that doesn't mean Python is completely useless as a tool for all such problems/projects. PHP is.

Name: Anonymous 2013-12-12 5:42

>>102
PHP

Name: Anonymous 2013-12-15 9:05

>>102

I'd rather use Ruby than anything you listed.

Name: Anonymous 2013-12-16 0:47

>>102
FIOC or Ruby.

PHP is an outright insult and being shat on the face, the others are kind of like calling you a nigger ``jokingly'' and realizing they really mean it after you're deep in.

Name: Anonymous 2013-12-18 1:54

Why do programmers name their variables i when they use for loops? Who started this convention?

Name: Anonymous 2013-12-18 2:16

>>109
Some may argue it started with FORTRAN, COBOL or some other ``oldskool'' language, but it obviously has to do with mathematics. I don't even know why you're asking that question, everyone here should at least have taken a course on linear algebra.

Name: Anonymous 2013-12-18 6:48

>>95
"People hate Python because of forced indentation" has got to be one of the biggest strawmans in programming history, but it is a perfect summary of the Python community, which will ignore any real issue the language suffers from.

I personally dislike Python because it has ridiculous flaws a proper language shouldn't have to deal with. Scoping issues in 2013? List comprehensions with messy semantics in favor of clean higher-order functions? Why is self a thing? Why is nonlocal/global a thing? If forced indentation is so good, why do you have to introduce noops like pass in order to have an empty block? It should be obvious it's empty from the indentation, no? The same thing goes for the colon after each statement. What's the point? Python also lacks a numerical tower, which doesn't go well with the whole "errors only show up when they actually happen" thing you can attribute to Python's lack of static typing and overly dynamic nature - have fun hunting silent errors. Finally, it doesn't offer anything new; there is no feature specific to Python that would make me ignore these flaws for the time being. It's yet another scripting language with no redeeming feature, a ton of flaws, and a poisonous community that suffers from guru worship (a sign that the community is incompetent, similar behavior can be observed in Clojure and C++) and refuses to fix these language flaws.

The list could actually go on, but I don't want to write yet another essay on why Python is "teh suck". Long story short: Indentation is its smallest problem.

Name: Anonymous 2013-12-18 12:26

Why isn't there a FOIC version of C? Is it possible to write C such that it follows everything in da standard except the use curly braces to delimit blocks?

Name: Anonymous 2013-12-18 20:56

>>112
Because that would be dumb, and nobody wants to either make or use such a thing.

Name: Anonymous 2013-12-19 17:19

Is [i]coroutine[/i] considered harmful?

Donald Knuth once said:
Subroutines are special cases of ... coroutines.

I would add:
Coroutines are special cases of ... goto statements.

Name: Anonymous 2013-12-19 17:46

>>114
Most flow control is a special case of goto statements, but considering things harmful as a blanket statement is a terrible idea.

Name: Anonymous 2013-12-20 15:07

>>111
i agree with you that people arguing about FIOC (or really any similar syntactic complaints) have no idea about actual language design or use

what are the "messy" semantics of list comprehensions?

why is self a thing? to reference the current object? if you mean why is explicit self a thing, it's because explicit is better than implicit

global is a thing because more often you are going to be declaring local variables with the same name as global variables than you are going to be reassigning global variables. furthermore it discourages use of global variables to keep mutable state

again, pass being explicit is good for the sake of being explicit, plus it is easier to read "while spinning: pass" than it is "while spinning:"

one of your complaints is colons? seriously?

dynamic typing is not a valid complaint against a language, it's your personal preference

python's benefits are large and comprehensive static libraries, easily readable code, and the ability to directly use low-level procedures and structures in high level code.

i'm not saying python is a perfect language, just that your complaints are ridiculously stupid. here are some valid complaints:

lack of tco
cpython
handling of strings (e.g. 'c'[0][0][0][0][0] == 'c')
comparisons with None and booleans being int (this might have been fixed in 3.x+?)

Name: Anonymous 2013-12-20 15:08

>>116

s/static/standard

Name: Anonymous 2013-12-20 15:32

>>116
I honestly tried to read what you said, but I couldn't finish it because of your complete lack of capitalization and the confusing way you flow in and out of quotes/rhetorical questions. From the little I read, you seem to have completely missed the point >>111 was making about Python's syntax, which is that it has flaws like self which make its design self-contradictory. I would add that a clean syntax is one of Python's core selling points. If being explicit is good, then why is it `pythonic' to use the colon-appendation instead of consistently using a function named something like append? If, on the other hand, syntactic brevity is desired, then as >>111 pointed out, use of : in flow controls is unexpected and makes no sense. If a language which advertises itself on the basis of good syntax can't get good syntax right, why should I bother with it?

I don't know if you bothered to move on to something more interesting by the end of your post. Maybe if you reformat it I'll read it. Probably not.

Name: Anonymous 2013-12-20 16:41

>>118

tell me again how self is contradictory to python's design

again, if your only complaints against a language are about its syntax, you have absolutely no business criticizing it or engaging in discussion about its design. go read baby's first plt textbook until you have something meaningful to contribute

Name: Anonymous 2013-12-20 18:41

>>119
Fuck off back to /g/ nigger.

Name: /prog/ mamma 2013-12-21 0:36

>>119,120
If you two don't stop yer fighten and come in and eat yur dina I'm gonna wring both yo necks!

Name: Anonymous 2013-12-21 12:04

>>119
Here. I'll say it with bullet points.

- Python's syntax varies between explicit and concise to a confusing degree, despite claims by Python that the syntax is clean/beautiful/etc.
- Python brings very little new to the table over other languages, and so advertises its syntax as a key point of the language
- Therefore, criticisms of Python's choice of syntax are valid as criticisms of the language.
- Since syntax is one of the first elements encountered by someone who examines Python, and since Python doesn't really bring anything new to the table as a language, it is perfectly reasonable to arrive at the conclusion that ``Python really isn't a very good language'', as this trivial complaint outweighs the even more trivial benefits.

It is not true to say that our only complaints against the language are about its syntax, but frankly, I don't care. You want me to talk about design choices like Guido's (thankfully canceled) desire to remove lambdas because he doesn't like the way they make code look? Tough. I don't feel like it. My point has already been made.

To put it another way, apply your argument to criticisms of PHP, Java, C, Haskell, Brainfuck, you name it. ``[I]f your only complaints against a language are about poor error handling/SingletonFactories/segfaults/burritos/verbosity, you have absolutely no business criticizing it or engaging in discussion about its design.''

If you ask me why PHP is bad, I'll say ``It has poor error handling.''. That's it. The language offers nothing to me that is not outweighed by poor error handling. Maybe if I'm feeling generous, I'll post a link to the Fractal of Bad Design blog. It is possible that I'm a moron, that PHP is the best language in the universe, and that poor error handling is irrelevant compared to other amazing things PHP can do. That is a calculated risk I've taken in deciding that my time is better spent by ignoring PHP than by trying to better understand its design in the hopes of learning something wonderful.

If you look at >>95 , the question was ``Why do you hate Python?''. I don't use Python because of the shitty syntax and FIOC. I don't use PHP because of the poor error handling. There - the question is answered. If you feel like carefully analyzing deeper flaws in Python, then do so. Maybe we'll link to your blog the next time somebody asks that question.

Finally, I'm sick of your unedited posts. Go read a manual of style until you can contribute meaningfully, as I won't be wasting any more time on them.

Name: Anonymous 2013-12-21 14:40

>>122

again, your argument is that colons at the end of ifs and whiles is too explicit and could be removed (despite it, you know, increasing readability, that being one of python's actual goals)

if python didn't bring anything new, why do you think it's been so widely adopted by software devs, system administrators, and the scientific community? (i'll give you a hint - it did)

finally, my argument extended only to syntax. complaining about error handling is a valid criticism because hiding a failure or stuck state from programmers directly affects the quality of code. complaining about factories is a valid criticism (although not a correct one) because you are specifically lamenting the language designer's decision not to have overloaded constructors. on the other hand, syntax is the most trivial aspect of any programming language, and has no direct effect on code quality or performance (inb4 arguments that it leads to decreased productivity, lol)

finally finally, if you can't read sentences that aren't capitalized suck my dick and get off the internet

Name: Anonymous 2013-12-21 17:50

btw i forgot to mention how retarded you are for whining about fioc

oh no! forced indentation of code! what do you mean everyone already writes code like that because it is the most legible way to write in a statically scoped block structured language? MY FREEDOMS

tip: you're free to write python like this - "while True: foo(); bar();"

Name: Anonymous 2013-12-21 21:01

>>123,124
You talk like you have a bunch of dicks in your mouth.

why do you think it's been so widely adopted by software devs, system administrators, and the scientific community?

AHAHA, you're just retarded as them to think it brought anything ``new'' and as if bringing anything new has to do with it becoming ``widely adopted''. As usual if it's popular it's inferior.

software devs
You mean programmers you corporate retard?

Stupid eurotrash kid.

Name: Anonymous 2013-12-21 21:08

Python is a objectively shitty language and is popular just because it is has a lot of libraries and doesn't take much of a brain to use. It isn't used in serious work either (being used for web work isn't serious, regardless of it being used by amazon or google)

Name: Anonymous 2013-12-21 21:19

it's used by biochemists, physicists, and astronomers every day. btw i also use it at my current employer (tip: its a large number)

Name: Anonymous 2013-12-21 21:24

>>125

indians and undergrads are programmers, i'm a software developer. nay, a software engineer

Name: Anonymous 2013-12-21 21:35

>>127,128
5/10.

Name: Anonymous 2013-12-21 21:40

lol.i know it's hard for you to realize you are definitely 100% wrong about this (with corporations and academia backing this up) but once you graduate (provided you can finally pass that pesky algorithms course) and start actually making software you will see

Name: Anonymous 2013-12-21 23:02

>>126
being used for web work isn't serious, regardless of it being used by amazon or google)

You are not a very smart man.

Name: Anonymous 2013-12-22 0:25

I've noticed there has been a recent influx of imageredditors. Some are trying to fit in and some aren't.

Name: Anonymous 2013-12-22 0:26

>>131
I ace every IQ test I get and my balls are the size of your kidneys. Fuck off, kiddo.

Name: Anonymous 2013-12-22 1:05

>>132
Maybe we're just conspiring to act less intelligent.

>>131
Python should be treated as a dab of glue that connects a library to your application with minimal effort, or as just another quick and dirty scripting language. It should never be used for anything serious, as things that are serious are generally required to scale to a larger size, which isn't one of python's strong points.

Name: Anonymous 2013-12-22 23:55

>>132
The link to this site has probably been bumped on the old /prog/.

Name: VIPPER 2013-12-23 16:05

>>132
You are starting to being annoying

Name: Anonymous 2013-12-23 21:29

>>136
You're the one who's always been annoying. Fuck off.

Name: Anonymous 2013-12-24 6:45

come on now, you don't need to be so irritable.

Name: VIPPER 2013-12-24 10:08

>>137
upset?

Name: Anonymous 2013-12-24 15:56

Are mutable String types bad design?

Name: Anonymous 2013-12-24 16:18

>>139
Yes, I'm upset. That ``lol im so troll XD'' attitude of yours is what pisses me off. How about you contribute once in a while instead of making off-topic comments on every thread you find?

Name: VIPPER 2013-12-24 16:26

>>141
I will just say ``NO U''
that's all, stay mad

Name: Anonymous 2013-12-24 16:56

>>140
I think a `string' should just be a [family of] data structure[s]. Sometimes I want to arbitrarily set certain characters in an enormous string to `B' without changing the length of the string. I should be able to do so without obeying a mandate that `strings must not be mutable!'. Sometimes I want to know that my strings never change once they are created. I should be able to do that as well. Sometimes I want to split strings at arbitrary points and shuffle the pieces without creating 2 (3? 4?) extra copies of the string to do so. I should be able to do all in the same program, even.

I think the problem is that strings are seen to be all of the same datatype, when really they shouldn't be. There are lots of ways to implement a vaguely defined List, so there should be lots of ways to implement a vaguely defined String. I don't often give Java a lot of credit, but I think their StringBuilder is at least on the right track, in that it is an object structure that could allow efficient modifications to parts of the string (including growing/shrinking) while also making an attempt to keep memory usage down.

That said, a lot (perhaps most) of the time strings are used, they aren't mutated at all, so an immutable string type would allow compilers/interpreters to pull some tricks, and programmers would be able to formalize their desire that the text `Fatal Error' not be changed to `Success!'.

Name: Anonymous 2013-12-24 20:17

>>142
Don't worry kiddo you'll get bored of textboards sooner or later.

Name: VIPPER 2013-12-24 20:55

>>144
Okay, have fun

Name: Anonymous 2013-12-25 21:59

How come you can inject generic code into php but can't do so in other scripting languages?

Name: Anonymous 2013-12-26 23:01

>>146
What makes you think this is exclusive to PHP? Every language with an eval function/statement/annotation/type in a Touring-complete type system is potentially vulnerable to code injection.

Name: Anonymous 2013-12-27 0:56

>>147
But you can inject any code you want into php if it is not sanatized properly even without eval, right? With Perl and the like you cant do that without eval or an sql querry or whatever.

Name: Anonymous 2013-12-27 5:12

>>148
No difference. Code written in PHP simply tends to be used in ways that make eval more common than they tend to be in, say, Perl. Combine that with the stellar reputation of PHP coders and your answer becomes clear.

That said, there are plenty of places around the internet, if you look, that offer code injection through languages that are not PHP. I remember a classic one in which an online calculator was implemented by taking the contents of a textbox, erasing the characters ', `, and ", and then passing it raw to Perl's eval. From the time it was posted on /g/, that calculator went from things like performing morse code translation to listing /etc/fstab to starting shells to installing kernel exploits (the kernel was something like 2.2) to finally being overwhelmed by some jackass who decided to test the process limit by forkbombing.

Name: Anonymous 2013-12-30 0:54

I'm a little buzzed up and I don't know exactly how to word this question right. But a new compiler has to be written in older compilers, obviously. Do they become increasingly more inefficient? Can all current compilers be traced back to few initial compilers?

If I compiled the source code of a compiler with a given compiler, then used the new compiler to compiler the original source, and kept doing this, would it become increasingly more inefficient?

What's a good book for studying compiler design?

Name: Anonymous 2013-12-30 1:24

>>150
Principles of Compiler Design, often referred to as The Dragon Book.

Name: Anonymous 2013-12-30 3:00

>>150
The speed with which your compiler compiles code is not related to the speed with which the resulting code runs. You could write a C compiler in JavaScript which would produce code which was faster than JavaScript. Don't, though.

Name: Anonymous 2013-12-30 15:45

>>151
Green, Red, or Purple dragon book?

Name: Anonymous 2013-12-30 21:43

>>153
All of them.

Name: Anonymous 2014-01-10 18:42

How does the following work? The second field (unsigned 1 bit) oscillates between -1 and 0. If one bit is reserved for the sign, how can it change at all?

#include <stdio.h>

struct {
unsigned int a : 1;
int b : 1;
unsigned int c : 2;
int d : 2;
} test;

int main(void) {
int i;
test.a = test.b = test.c = test.d = 0;

for(i = 0; i < 15; i++)
printf("%d:%d:%d:%d\n", test.a++,test.b++,test.c++,test.d++);

return(0);
}


I never understood why the negative min was always one larger than the positive max. From a mathematical point of view, the mins and maxes for a 8 bit signed int should be 11111111 (-127) and 01111111 (127)

Name: >>155 2014-01-10 18:46

First instance of unsigned should read signed

Name: Anonymous 2014-01-10 19:33

>>155
Range of a signed byte is -128 to 127. In signed representation, if the first bit is "1", the operation becomes:

-(2n-1) + (value of n-1 bits of the number)

i.e.,


10000000 = -128 + 0 = -128
10001000 = -128 + 8 = -120
11111111 = -128 + 127 = -1


All 0s in a bitfield is always 0, even in 2's complement. But just 1 in a 1-bit number is equal to:


-(2^0) + 0 = -1


Or, more realistically, because the maximum value of a 1-bit field is 1, and you're forcing the compiler to represent its only available bit as the sign bit, it has no other bits to add to it, so it will always be between 0 and -1.

I wonder if doing this is undefined behaviour?

Name: Anonymous 2014-01-11 16:06

>>155
You are thinking of sign magnitude, where the most significant bit represents the sign of the number while the remaining represent the magnitude. In this scheme, the range of values for negative and positive numbers are equal, but there are two representations for zero, 10000000 and 00000000.

>>157-sama is using 2's complement, where -x is obtained by performing ~x + 1. That is, interpreted as an unsigned value, the bits are flipped and the number is incremented. Using this representation, there is a unique representation for zero, but since there is only one representation for zero, the number of positive values cannot be the same as the number of negative values, since these with the zero representation would give an odd number of total values, which is not a power of two. So there will be an extra positive value or a negative one. In 2's complement, the extra value is negative. This means there is a strictly negative number that is fixed under the absolute value function, so the result of absolute value isn't necessarily positive. Hopefully programmers use integers that are large enough to avoid this behavior.

Name: Anonymous 2014-01-20 4:31

I had an idea for a program... I was going to write a quick program that converted units like:
./convert 120 in mm

I planned on having an external text file where I could add definitions like
in 2.54 cm
cm 10 mm

My intention was not to require the text file to have every possible combination of conversions, but to be able to use multiple conversions in order to get the final conversion. I thought linked lists might be a way to do this. Something like:

typedef struct unit {
char *name;
unit **nodes;
double *factors;
} unit;

The problem is the linked lists wouldn't really be linear or circular, just arbitrarily linked together with some nodes linking to many others. And what's worse, some linked lists would be completely independent from others (different dimensions). Is there a way to search through linked lists like that without an infinite loop?

Name: Anonymous 2014-01-20 5:50

>>159
Thats not a linked list you're talking about but a graph. And there are plenty of (great) ways to search a graph.

Name: Anonymous 2014-01-20 6:28

>>160
Well it's not quite a linked list, but it's not a graph either.

ft may be linked to in, cm, mm, and miles. miles may be linked to ft, km, and m. Maybe m is only linked to km. nm may be linked to mm and light years.

There is a way to search through that without it infinitely looping through it?

Name: Anonymous 2014-01-20 6:33

>>161
I just realized I think this can be searched through easily, but imagine there were every more links that looked circular.

Name: Anonymous 2014-01-20 7:46

>>161
It's definitely a graph.

Name: Anonymous 2014-01-20 12:04

just base everything off the standard units? every unit has a base unit.

http://en.wikipedia.org/wiki/International_System_of_Units

so to convert mm to nautical mile you first find out how many mm to a meter (the std unit) and then convert meter to mile.

you could even do things like "./convert 10 miles per hour to km per week"

Name: Anonymous 2014-01-20 13:42

>>159
What, you mean like units?

$ units
Currency exchange rates from 2013-07-11
2562 units, 85 prefixes, 66 nonlinear units

You have: 120 inches
You want: millimeters
* 3048
/ 0.00032808399


You might look at how they do it.

Name: Anonymous 2014-01-20 21:11

>>165
Or frink.

Don't change these.
Name: Email:
Entire Thread Thread List