[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 314
Thread images: 14

File: 1474950435300.jpg (156KB, 934x1000px) Image search: [Google]
1474950435300.jpg
156KB, 934x1000px
Old thread: >>57948378

What are you working on, /g/?
>>
Am I the only one who enjoys talking and reading about programming more than actually doing it?

I just can't come up with anything.
>>
>>57955720
Second for D
>>
I decided to make it so that my stippling algo couldn't overlap, but then it ended up just not working and it ran forever.

:(
>>
>>57955783
this. i enjoy it as a hobby, which involves almost an equal amount of discussion and participation (in my opinion)
>>
>>57955783
>>57955803
I understand why Haskell is so popular on /dpt/ now.
>>
What are some interesting C projects to try after getting through the basics?

I was thinking about doing something with SDL or the Windows API, but what else is out there?
>>
>>57955783
This.
I spend so much time being a performance expert on here without having coded shit that runs fast.
Except a program that averages ints to floats in 1.3cycles per int. Completely trivial stuff.

I feel like a fraud but it's obvious I'm helping people too.
>>
>>57955882
https://handmadehero.org
Not a project but its a good source of information.
>>
File: you wouldn't steal a car.png (119KB, 563x378px) Image search: [Google]
you wouldn't steal a car.png
119KB, 563x378px
>>57955839
Programming in Haskell is actually enjoyable, unlike programming in most imperative languages
>>
>>57955789
>D
I've been thinking about learning it.
I'm just not sure where to go to do that though.
>>
>The people who can code games usually have terrible ideas because they spend all their time coding
>The people who actually have good ideas can't code them because they spend most of their time playing or thinking about games

Pretty interesting. I'll give you morons some advice. Wanna make a lot of money? Code an io game like agar.io. They're piss easy to code. The guy who made slither.io rakes in $100,000/day, look it up. Even a mediocre game can net you $100/day which is enough to live on, solely through advertising. So why aren't you coding one?

I'm working on one now btw.
>>
>>57955948
https://tour.dlang.org
http://ddili.org/ders/d.en/index.html
Have fun famalam
>>
>>57955936
>>57955720
Le ebin himegobo meme XDDD

Kill yourself, you retarded fag memespouter.
You're on the level of frogposters.
>>
>>57955720
Turns out that TCP stress testings' upper limit is the number of open file descriptors at one time. How can I allow more file descriptors to be open at the same time?
>>
>>> x = [1,2,3,4,5,6,7]
>>> x[0:4] = 6, 7
>>> x
[6, 7, 5, 6, 7]
>>>

Beat this.
>>
>>57955996
What does any of that mean?
>>
>>57955996
Beat what?
>>
>>57955964
This is so untrue anon.

The only reason idea guys ideas are 'good' to you is because they're good on surface level. They're not explored or deeply considered.
>just mimic what's popular
Yeah sure. But you have to realise there's a large amount of unpopular projects that do the same. Maybe yours is one of them? Maybe yours isn't.

Games are primarily marketing anyway. Look at Orion:Pelude. A videogame that got famous for promising a lot and being complete kickstarter shit.

Now its actually getting somewhere and it's fame is pulling it. Of course they're still shit, most games are shit. And they're still promising more than they can deliver. But gamers are stupid.
>>
>>57955993
Epol, iocompletionports.
Whatever threaded io system your platform uses.
>>
I'm trying to get a large library going to try to evaluate word frequency of my favorite authors. I have no idea how to store it though. After I run a pdf/epub/mobi through my project it looks like this.

{ 
"title" : "The Hitchhiker's Guide to the Galaxy",
"author" : "douglas adams",
"words" :
{
"the": 3949,
"and": 2244,
"to": 1976,
"of": 1962,
"it": 1457,
"that": 1134,
etc............


Any advice on how I should be storing this if I want to query it against a bunch of other similar objects? Since I wrote the thing in javascript I was gonna just mongodb, but I'm having a cunt of a time because of the dynamic keys being created for the counts.
>>
>>57955964
>>57956034
Just as a demonstration:
http://iogames.space
>>
>tfw writing a program in Haskell to read the Vulkan spec from the XML registry to generate Rust bindings
>>
File: fs.png (287KB, 900x1140px) Image search: [Google]
fs.png
287KB, 900x1140px
What's the best way to create objects in JavaScript, /dpt/?

Like this:

let loliFactory = function(name, age) {
let _name;
let _age;

let getName = function() {
return _name;
};

let setName = function(name) {
_name = name;
};

let getAge = function() {
return age;
};

let setAge = function(age) {
if(age <= 11) {
_age = age;
} else {
throw age + " is too old to be a loli";
}
};

setName(name);
setAge(age);

return {
getName,
setName,
getAge,
setAge
};
};


Or:

let Loli = function(name, age) {
if(this instanceof Loli) {
this.setName(name);
this.setAge(age);
} else {
throw "You forgot the new keyword, retard."
}
}

Loli.prototype.getName = function() {
return this.name;
};

Loli.prototype.setName = function(name) {
this.name = name;
};

Loli.prototype.getAge = function() {
return this.age;
};

Loli.prototype.setAge = function(age) {
if(age <= 11) {
this.age = age;
} else {
throw age + " is too old to be a loli";
}
};
>>
>>57956054
Hashtable.
Look up a word. Use the index for all of them.
Collisions should be solved in a clever way but it's probably fairly irrelevant.
>>
>>57955964
>implying I'm not doing that right now
I just have to fix camera issues and add networking capability, and my WebGL engine will be ready to go in a dimension above .io games.
I'm planning on preventing botting and preventing adblock in one fell swoop by making an advertising captcha.
>>
>>57956116
>making an advertising captcha
Kill yourself
>>
>>57956096
Whats the point of factories in non-MMM languages?
Don't get me wrong. OOP is just dumb. But one of the only reasons I've seen for factories is the efficient allocation of resources. Every other plus is just something that the concept doesn't do well at.
>>
>>57956034
So basically what you're saying is that regardless of the fact that ideas people spend all their time thinking of their ideas they're so bad at that that they can't even produce solid ideas?
>>
>>57955993
/etc/security/limits.d/
>>
>>57956096
class Loli {
constructor(name, age) {
this.name = name
this.age = age
}
}
>>
>>57956190
I would change "locks", right?
>>
>>57956209
Classes in JavaScript are a meme and were only added to appease Java monkeys who refuse to learn about prototypes.
>>
File: dpt programming advice.png (6KB, 433x91px) Image search: [Google]
dpt programming advice.png
6KB, 433x91px
>>57956209
>>
>>57956123
>indie programmers should work for free
>and not be compensated for server costs
Also, there'd be a captcha anyway to prevent the rampant botting plaguing no-login multiplayer games, the captcha might as well be high-value advertising.

It'd be way less annoying than other forms of advertising.
What would you rather, a badly coded flash advert that eats up your performance, constantly flashes bright colours, and never fucking leaves your view; or just once having to type the name of the product you see in an image?
>>
>>57956249
classes are a meme in general...
>>
>>57956258
class Loli {
constructor(name, age) {
this.name = name
this.age = age
this.virgin = true
}

rape() {
this.virgin = false
}
}
>>
>>57956276
SENPAI NOOOOOO ;_;
>>
>>57956249
ES6 class syntax is objectively better than Prototype syntax, though.
>>
File: 1404500743843.png (834KB, 768x1024px) Image search: [Google]
1404500743843.png
834KB, 768x1024px
>>57956209
class Loli {
constructor(name, age) {
if (age > 13) { throw ValueError; }
this.name = name
this.age = age
}
}
>>
Working with C# forms at the moment. What are some other interfaces other than the standard Windows interface that I can grab for VisualStudio and make some decent looking programs.
>>
int independence; // declaration of independence
>>
>>57956352
class Loli {
string name;
uint age;

this(string name, uint age) {
this.name = name;
this.age = age;
}

invariant {
assert(age <= 13);
}
}
>>
>>57956190
I changed it, but it looks like SDLNet is causing a buffer overflow. Here's the valgrind output
==7970== Process terminating with default action of signal 6 (SIGABRT)
==7970== at 0x60AF428: raise (raise.c:54)
==7970== by 0x60B1029: abort (abort.c:89)
==7970== by 0x60F17E9: __libc_message (libc_fatal.c:175)
==7970== by 0x619256B: __fortify_fail (fortify_fail.c:37)
==7970== by 0x619056F: __chk_fail (chk_fail.c:28)
==7970== by 0x61924B6: __fdelt_chk (fdelt_chk.c:25)
==7970== by 0x542BC9C: SDLNet_CheckSockets (in /usr/lib/x86_64-linux-gnu/libSDL2_net-2.0.so.0.0.1)

Thoughts? The passed socket isn't null.
>>
Is there an optimal way to set up an 'if else' check that you plan on using a lot?

if (n == 0) return;
else {
n = n / 10;
}


Would it be better to check if n != 0 since that's more likely to occur and means the program won't have to perform two checks instead of one? Most of the time at least.
>>
for(string tfw = "H"; tfw.length < NewZealand.population.chinese; tfw = "A"+tfw){
3DPrinter.print(tfw.toMesh)
}
>>
>>57956386
That's pretty sweet. Is it even supported in any browsers?
>>
>>57956417
If you are compiling with GCC or Clang, add this to a header file
#define likely(x)      __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)

These are compiler hints that structure the code in a more efficient way. You call it with:
if(likely(true)){}
>>
>>57956352
>C is the programming language that programmers who program programming languages program in
>>
>>57956417
Micro optimization, focus on coding and logic instead of trivial shit
>>
>>57956417
You should be looking for things like
https://msdn.microsoft.com/en-us/library/1b3fsfxw.aspx
There's no actual way to tell the compiler to prefer a specific condition without it.
Of course the compiler has to compile to code that logically does the same thing so large if else statements will have some kind of chain to them.
>>
PROGRAMMING CHALLENGE

Write a program that takes input text from standard input and outputs the text transposed. Rows become columns and columns become rows. Example:
Input:
A B C
D E F

Output:
A D
B E
C F


See https://en.wikipedia.org/wiki/Transpose
>>
>>57956439
idk, it's D
>>
>>57956487
What's the desired output for

Input:
A B C D
E F G H
>>
>>57956430
I laughed
>>
jerkin on a vidjjigame for iOS, Swift is nice, Swift can't EZ into concurrency like Go tho

Optionals: fuck you for the first 2 weeks then you get it and you're praising chris lattner jesus
>>
>>57956487
Store everything in a 2D array where \n denotes an increment to the y variable.
When you print print with x and y flipped.
>>
>>57955720
Please don't use an anime image next time.
>>
XML is fucking shit.
>>
>>57956521
Whats so good about it anon?
>>
>>57956451
Yeah but does it make a difference or will the compiler do some crazy shit to my code anyway?

>>57956474
But without telling the compiler anything, would it be more efficient, even slightly, to have the most likely outcome checked first?
>>
>>57956511
Columns are (non-newline) whitespace-delineated. Number of spaces and tabs doesn't matter, it's still one column break.

So:
A E
B F
C G
D H
>>
imagine you have a game in your website.

and your website is filled with ads.

if only one person visits the website (not me, but my cousin), can you make money off it?
>>
>>57956552
>But without telling the compiler anything, would it be more efficient, even slightly, to have the most likely outcome checked first?
I'd assume that the compiler picks an order arbitrarily. I'd expect them to know that users like you presume this to be the case so maybe yes? I haven't checked though.

If you're lazy just check the disassembly for a large number of cases.
>>
>>57956451
>trivial shit
>implying this can't be effective
Use it in tight loops
>>
>>57956524
Do it.
>>
Does anyone know of a ML classifier library that I can use to classify data? For instance Classifier.train({time:"2:00am", country: "Nigeria"}, :fraud)

Everything I find seems to only classify strings
>>
>>57956552
Also if I were a compiler I'd probably start checking the least complex case either way. Since else is just if(!expression) it would be second. But an else if with barely anything to it would probably have me prioritise it if it's clearly only true when the initial if is untrue.
>>
>>57956487
main = interact (unlines . map unwords . transpose . map words . lines)
>>
>>57956590
I should add that language doesn't really matter as long as it's not too esoteric or java
>>
>>57956598
Haskell solutions not accepted due to not being able to do I/O.
>>
>>57956612
interact :: (String -> String) -> IO ()
>>
>>57956598
>hasklel code that calls thousands of lines in the back

lmao
>>
>>57956542
Swift is nice because of trailing-closure syntax and optionals. It has some stupid OOP shit like inheritance still in it but they purposefully limit it to single inheritance and you can prevent inheritance with the final keyword. Optionals at first are ugly, because they use ? and ! as keywords/operators. But once you give in to the power of the tea you see that Int? is either a valid Integer, or is nil and now you can fucking get all that magic jazz of nil pointers without the insanity of nil pointers.

If it had Go's concurrency primitives I might cry.
>>
>>57956634
>C code that calls thousands of movs in the back
lmao
>>
>>57956632
>more Haskell
Still not accepted.
>>
>>57956634
And I'm sure you handcraft all your code in Assembly, right?
>>
>>57956650
t. the shortest solution I can do in my language is 1000 lines so I have to hate on other langs
>>
>>57956636
Swift just sounds like a worse Rust to me.
>>
I made a program to find duplicates of images. For some reason freeimage can't open files in a different directory?
>>
>>57956665
have you read any Rust? it looks like trash, humans read code
>>
>>57956668
>I made a program to find duplicates of images.
hmm let's see

>get hashes from images
>see if there are two equal

wow
>>
>>57956634
this
>using abstractions
>>
>>57956676
I use Rust and I can read it just fine.
>>
>>57956665
Did you mean a better Rust?
>>
>>57956690
Better how?
>>
>>57956634
>how dare your library be better than mine
>>
What else should I add senpai?

let loliFactory = function(name, age, virgin) {
let _name;
let _age;
let _virgin = virgin;
let _health = 100;

let getName = function() {
return _name;
};

let setName = function(name) {
_name = name;
};

let getAge = function() {
return age;
};

let setAge = function(age) {
if(age <= 11) {
_age = age;
} else {
throw age + " is too old to be a loli.";
}
};

let takeDamage = function(n) {
console.log(_name + " took " + n + " damage!");
setHealth(_health - n);
}

let setHealth = function(health) {
_health = health;

if(_health <= 0) {
console.log(_name + " has died.");
} else {
console.log(_name + "'s health is at " + _health + ".");
}
}

let getHealth = function() {
return _health;
}

let isAlive = function() {
if(_health <= 0) {
_alive = false;
} else {
_alive = true;
}

return _alive;
}

let rape = function() {
console.log(_name + " was raped!" )

if(_virgin === true) {
console.log(_name + " lost her virginity.")
_virgin = false;
}

takeDamage(20);
}

setName(name);
setAge(age);

return {
getName,
setName,
getAge,
setAge,
takeDamage,
setHealth,
isAlive,
rape
}
};

let charlotte = loliFactory("Charlotte", 9, true);

while(charlotte.isAlive()) {
charlotte.rape();
}
>>
>>57956698
Using it doesn't put the witch in charge.
>>
>>57956711
What?
>>
>>57956706
>using ES6
>not using classes

why
>>
>>57956634
t. C faggot who reinvents the wheel every project he does
>>
>>57956716
The left. The SJWs. Come on.
>>
>>57956689
lol Rustfags can't even write fizz buzz without referencing documentation, "what was that arcane enchantment to print again?"
>>
>>57956731
Nice meme, fag.
>>
>>57956726
Classes are one of ES6's bad parts.

Douglas Crockford says so.
>>
>>57956728
emphasis on faggot. C is OK with libraries
>>
>>57956728
>>57956704
>>57956651
>>57956648
i programmed the assembly code your computer is running right now.

specifically, the drivers micro-code
>>
>>57956743
Ah, well if someone else said so....
>>
>>57956487
data = '''A B C
D E F'''

print(list(map(list, zip(*[x.split(' ') for x in data.split('\n')]))))
>>
>>57956749
thanks Bill
>>
>>57956749
Which driver?
>>
>>57956749
GNU/(You)
>>
>>57956764
>challenge wants IO
>doesn't do IO
python babies, everyone
>>
>>57956764
Doesn't work on Python3*

*not Turing complete.
>>
>>57956796
I tried to explain this to the Haskellfag, but he just wouldn't listen.
>>
>>57956800
>Doesn't work on Python3*
yes it does
>>
>>57955720
still can't get my sql code to work right
IF OBJECT_ID('spLineItems') IS NOT NULL
DROP PROC spLineItems;
GO

CREATE PROC spLineItems
@InvoiceDateMin smalldatetime = NULL, --default minimum date
@InvoiceDateMax smalldatetime = NULL --default max date(current date)

AS
IF @InvoiceDateMin = NULL AND @InvoiceDateMax IS NOT NULL
BEGIN
SET @InvoiceDateMin = '1990-1-1'

SELECT VendorName, InvoiceNumber, InvoiceDate, InvoiceLineItemAmount,
InvoiceLineItemDescription
FROM Vendors
JOIN Invoices ON Vendors.VendorId = Invoices.VendorId
JOIN InvoiceLineItems ON Invoices.InvoiceId = InvoiceLineItems.InvoiceID
WHERE InvoiceDate BETWEEN @InvoiceDateMin AND @InvoiceDateMax
ORDER BY InvoiceDate ASC;
END
ELSE IF @InvoiceDateMax = NULL AND @InvoiceDateMin IS NOT NULL
BEGIN
SET @InvoiceDateMax = GETDATE()

SELECT VendorName, InvoiceNumber, InvoiceDate, InvoiceLineItemAmount,
InvoiceLineItemDescription
FROM Vendors
JOIN Invoices ON Vendors.VendorId = Invoices.VendorId
JOIN InvoiceLineItems ON Invoices.InvoiceId = InvoiceLineItems.InvoiceID
WHERE InvoiceDate BETWEEN '1990-01-01' AND @InvoiceDateMax
ORDER BY InvoiceDate ASC;
END
ELSE
BEGIN
SELECT VendorName, InvoiceNumber, InvoiceDate, InvoiceLineItemAmount,
InvoiceLineItemDescription
FROM Vendors
JOIN Invoices ON Vendors.VendorId = Invoices.VendorId
JOIN InvoiceLineItems ON Invoices.InvoiceId = InvoiceLineItems.InvoiceID
ORDER BY InvoiceDate ASC;
END;

With this it only returns as if @invoicedateMin is null no matter what I do

I'm desperate here how do i fix this?
>>
>>57956764
>print (list)
But that doesn't produce what was asked for at all.
>>
>>57956743
https://www.youtube.com/watch?v=bo36MrBfTk4#t=28m50s source, I tracked it down because this was news to me. He doesn't like inheritance from what I can tell.
>>
>>57956796
Ok.

import sys

data = []
for line in sys.stdin:
data.append(line.split(' '))

print(list(map(list, zip(*data)))
>>
>>57956818
Impossible, it's not Turing complete.
>>
>>57956706
>loli.rape()
>implying that the loli is doing the raping
rape should be a function that takes a loli.
>>
>>57956845
>not a one-liner
Into the trash it goes.
>>
*tries to implement a Turing machine in python 3*
>>
>>57956867
print(list(map(list, zip(*[line.split(' ') for line in __import__('sys').stdin]))))
>>
>>57956873
Unfortunately it's been established that it isn't possible.

Godspeed, Anon.
>>
>>57956764
data = '''A B C
D E F'''
print (
"".join(
["".join(i) +'\n'for i in zip(
*[x+" "*(
len(
max(
data.splitlines(), key=len)
)-len(x)
) for x in data.splitlines()
]
)]
)
)
>>
>>57956684
Thanks man. Just one more thing [spoiler](you)[/spoiler]
>>
how to practice haskell?
>>
>>57956909
write programs
>>
>>57956884
>over 76 chars
Disgusting.
>>
>>57956914
fuark that was quick
thanks
>>
guys, how do I make my haskell oneliner >>57956598
to wait untill all IO is done in order for it to do the transformation?

I already added Strict in -#LANGUAGE
but it doesn't work
>>
>>57956487
main = getContents >>= putStrLn . unlines . map unwords . transpose . map words . lines
>>
>>57956860
But then we have to create and handle rapists. We don't want that.

OOP sucks.
>>
>>57956917
data = '''A B C
D E F'''

print(zip(*[x.split(' ') for x in data.split('\n')]))



output
[('A', 'D'), ('B', 'E'), ('C', 'F')]
>>
>>57956943
It doesn't need to.
>>
>>57956917
main=interact$unlines.map unwords.transpose.map words.lines

60 chars
beat this
>>
>>57956957
import Data.List
main = interact (unlines . transpose . lines)
>>
>>57956981
Oh, wow, I thought "interact" was some abstract function you were all making up to shorten it. Didn't realize it actually exists, whoa.
>>
>>57957010
kys
>>
>decide to do things properly this time
>spend some time pondering about the program flow
>write out spec
>halfway through implementing figure out a better way to do half of the things
>cowboy up a messy prototype then refactor it into tidiness AGAIN

Where does the time when you actually follow a spec you've written out come?
>>
>>57956967
Does not take input from standard in.
Output not in prescribed format.

>>57956978
See >>57956612

>>57956957
You're embarrassingly late. Plus you've apparently never heard of 'interact'.

>>57956981
Columns are whitespace-delineated, as stated earlier.
>>
>>57957037
Haskell clearly can do I/O you mouth breather.
>>
>>57957037
suck my dick
>>
>>57957050
>purely functional
>can do I/O
Go read a book.

>>57957058
Ew groce.
>>
>>57957070
Either your definition of purely functional is wrong or Haskell isn't purely functional, then.
>>
>>57957086
Clearly.
>>
>>57957095
Glad we cleared that up.
>>
>>57957112
Next time you might want to check for blatant contradictions in your argument *before* you start.
>>
>>57957022
You've discovered the flaws of upfront design!
"Exploratory programming learning" has now been unlocked.

Consider just writing a very lose 'spec' where you define the io between systems. The only reason to plan like that is to reduce coupling. And when you write out your program like you did here you can't really see your problems.

View this:
https://hero.handmade.network/episode/code/day026
It's really worth a watch. The video after that one is also very useful.
>>
>>57957116
I only asserted that Haskell can do I/O, which is proven by any one of these programs.
>>
>>57956860
Is this better senpai?

let loliFactory = function(name, age, isVirgin) {
let _name;
let _age;
let _isVirgin = isVirgin;
let _health = 100;

let getName = function() {
return _name;
};

let setName = function(name) {
_name = name;
};

let getAge = function() {
return age;
};

let setAge = function(age) {
_age = age;
};

let takeDamage = function(n, name) {
console.log(_name + " took " + n + " damage from " + name + "!");
setHealth(_health - n);
}

let setHealth = function(health) {
_health = health;

if(_health <= 0) {
console.log(_name + " has died.");
} else {
console.log(_name + "'s health is at " + _health + ".");
}
}

let getHealth = function() {
return _health;
}

let isAlive = function() {
if(_health <= 0) {
_alive = false;
} else {
_alive = true;
}
return _alive;
}

let getVirginity = function() {
return _isVirgin;
}

let setVirginity = function(isVirgin) {
_isVirgin = isVirgin;
}

let rape = function(loli) {
console.log(loli.getName() + " was raped by " + _name + "!");

if(loli.getVirginity() === true) {
console.log(_name + " took " + loli.getName() + "'s virginity.")
loli.setVirginity(false);
}

loli.takeDamage(20, _name);
}

setName(name);
setAge(age);

return {
getName,
setName,
getAge,
setAge,
takeDamage,
setHealth,
isAlive,
getVirginity,
setVirginity,
rape
}
};

let chloe = loliFactory("Chloe", 11, false)
let charlotte = loliFactory("Charlotte", 9, true);

while(charlotte.isAlive()) {
chloe.rape(charlotte)
}
>>
>>57957070
HTML solution for you
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Vertical Text Generator</title>
<style>
.vertical {
width: 50px;
font-size: 50px;
word-wrap: break-word;
letter-spacing: 20px;
float:left;
}
</style>
<script language="javascript">
function showIt(text)
{
text = '<div class="vertical">' + text;
text = text.replace(/\r?\n/g, '</div><div class="vertical">');
document.getElementById('showingPlace').innerHTML = text;
}
</script>
</head>

<body>

A B C
D E F
<br />
<textarea id="theInput" onBlur="showIt(this.value)"
onChange="showIt(this.value)"></textarea>

<div id="showingPlace"></div>

</body>
</html>



to use this enter the text in the text box and then click with the mouse outside of it to transpose it
>>
>>57957120
>"Exploratory programming learning" has now been unlocked.
Nah I've always been doing that. I'm only trying upfront design.

Mind you I can follow a spec (I'm a professional programmer and have to do so at work), just not one I've written myself for a pet project.
>>
>>57957132
What?

Next you'll be claiming that it has some sort of 'interact' function, and that I was informing people of it in the same post as asserting that Haskell can't perform I/O.
>>
File: 1477183687803.png (534KB, 1156x999px) Image search: [Google]
1477183687803.png
534KB, 1156x999px
>>57957151
I'm not sure why I'm still responding but yes, you did.
>>
What does /dpt/ think of Visual Studio Code? What extensions do you recommend?
>>
>>57957149
>I can follow a spec
Nobody who cares about software quality can when writing new software.
The spec has to be tested first.
>>
>>57957161
I use it exclusively now, haven't needed any extensions besides various syntax language modes yet.
>>
File: TiVrXyf.png (13KB, 822x389px) Image search: [Google]
TiVrXyf.png
13KB, 822x389px
>>57957161
>Visual Studio Code
you mean botnet code?

>adds telemetry to your code to see what the hell are you writing
>>
>>57957177
VSCode isn't even close to the same thing as MSVC.
>>
>>57957160
What Anime is this.
>>
>>57957160
Perhaps I should have said "Next time you might want to check for suspiciously flagrant self-contradiction in my argument *before* you start."
>>
>>57957192
Prison School
>>
>>57957177
That was MSVC, not VS Code in particular, and not that I can defend microsoft, but the telemetry hooks were just empty placeholders, no actual telemetry here
>>
>>57957177
That's only when you ask for it.
It has a profiler tool that does that.
>>
>>57957201
I don't recognise the art style and prison school looks scary. It's like middleschool all over again.
>>
>>57956016
he is setting indexes x 0 to 4 of x to 6 and 7.
>>
>>57957192
good morning call
>>
File: op.png (269KB, 1156x999px) Image search: [Google]
op.png
269KB, 1156x999px
>>57957160
your png is now optimized
>>
Common Lisp, Scheme or Racket?
>>
Since no-one seemed to be able to complete the last one, here's another PROGRAMMING CHALLENGE:

Atbash is a simple substitution cipher. It works by substituting the first letter of an alphabet for the last letter, the second letter for the second to last and so on, effectively reversing the alphabet. Implement this cipher, taking input (one word on each line) from stdin, and outputting ciphered words to stdout. Example:

Input:
foobar
wizard
gsrh rh zm vcznkov lu gsv zgyzhs xrksvi

Output:
ullyzi
draziw
this is an example of the atbash cipher
>>
>>57957296
Don't know why 4chan doesn't automatically optimize images to save bandwidth desu.
>>
>>57957329
none. Java so you can get a job.
>>
>>57957342
probably a lot of overhead, given how many uploads they get a second
>>
>>57957292
Still doesn't quite seem right..
>>
>>57957333
Do you want it to preserve case? What should it do with special characters? (punctuation, unicode emojiis, whatever)
>>
How do I learn about natural language processing?
>>
>>57957399
Don't care, don't care. If it's undefined by the spec, you can't do what you like.
>>
>>57957370
Well they probably have CPU to spare. There's not that much going on given this format is relatively unchanged since the 90's
>>
>>57957351
no, racket, then clojure, then java
clojure can get you a job
>>
>>57957333
python 2.7

print (''.join(
map(
lambda x: dict(
zip(__import__('string').letters[:26],
__import__('string').letters[:26][::-1])
)[x] if dict(
zip(__import__('string').letters[:26],
__import__('string').letters[:26][::-1])
).has_key(x) else x,raw_input()
)
)
)
>>
>>57957417
+1 for first, -10 for 'Jesus Christ, my eyes'.

Currently leading with -9.
>>
>>57957421
it just werks

i thought the goal has one-liners
>>
>>57957433
That reminds me, -11 for being 12 lines.

Currently leading at -20.
>>
>>57957433
mind explaning anon? runs great but i have no idea how it works
>>
>>57957450
He just added whitespace for readability.

print (''.join(map(lambda x: dict(zip(__import__('string').letters[:26],__import__('string').letters[:26][::-1]))[x] if dict(zip(__import__('string').letters[:26],__import__('string').letters[:26][::-1])).has_key(x) else x,raw_input())))
>>
>>57957450
It's a one liner clearly anon. Don't be retarded
>>
Should I learn C# or Haskell?
>>
>>57957489
Where's the fun in not being retarded?

>>57957484
Scrap the -11, then: -148 for being 228 characters.
Currently leading at -157.
>>
>>57957463
i obfuscated the code on purpose

deobfuscated
word = raw_input
letters = 'abcdefghijklmnopqrstuvwxyz'
letters_reversed = letters[::-1]
sub = dict(zip(letters,letters_reversed))
print ''.join(map(lambda x: sub[x] if sub.has_key(x) else x,word))

Lamba x returns either the ciphered character if it exists, otherwise it returns the original character itself.

Map performs the lambda on all chars in the input string sequence returning a list.

Join concatenates the list resulting in a string with the result to print.
>>
>>57957513
c# for job
haskell for enlightement & fun
>>
>>57956824
>>57956824
bumping because i legit don't know what i'm doing wrong
>>
>>57957536
oh thats not too hard

thank you
>>
File: 1457570329783.jpg (370KB, 1280x1707px) Image search: [Google]
1457570329783.jpg
370KB, 1280x1707px
Sorry if this is the wrong place to ask but what are some good books for java to keep practicing/learning with moderate base knowledge?
>>
I don't get why everyone in this thread uses such difficult languages like C, Java and Haskell... is it to make yourselves seem smart? JavaScript is such a powerful and easy language... are you retarded?
>>
>>57955885
It does kind of get difficult to take on big projects if you don't have the motivation to start huge things and aren't in a professional environment.
>>
@57957700
(You)
>>
>>57957333
table = zip am zn ++ zip zn am
where am = ['a'..'m']
zn = ['z','y'..'n']

abash = maybe ' ' id . flip lookup table

main = interact (unlines . map (map abash) . lines)
>>
>>57957404
google it
>>
>>57957758
That's pretty sane, but why not:
table = zip ['a'..'z'] ['z','y'..'a']


+1 for sane, -1 for 'table', -4 for being 5 lines, and -0 for not making my eyes bleed.

Currently leading with -4.
>>
>>57957758
fromMaybe x = maybe x id
>>
>>57957810
there's no rassoc in haskell
>>
>>57957825
not in prelude
>>
>>57957835
You don't need rassoc. Think about the lookup. THINK ABOUT IT.
>>
>>57957850
It's also actually shorter to type out the RHS than the LHS.
>>
>>57957810
sorry, I that never crossed me
>>
>>57957810
table = zip ['a'..'z'] ['z','y'..'a']

atbash = maybe ' ' id . flip lookup table

main = interact (unlines . map (map atbash) . lines)
>>
Who in their right mind thought dynamically typed languages were a good idea?
>>
>>57957893
for flexibility
>>
>>57957898
>
>>
>>57957898
Flexibility, like being able to cause errors?
>>
File: imrs.jpg (212KB, 1484x1029px) Image search: [Google]
imrs.jpg
212KB, 1484x1029px
>>57957892
That is almost exactly what I came up with.

Except mine was crammed onto two lines.
>>
>>57957893
The same person who didn't realise that type inference could just as easily sate his laziness.
>>
>>57957913
its good for lisp langs, where macros a imperative
>>
>>57957898
Dynamic typing gives you the opposite of flexibility, because with it you must make your functions work with all inputs. There is no room for flexibility.
>>
>>57957920
what, you put table directly onto atbash
>>
>>57957958
Easier just to paste it.
main = interact $ unlines . map (map $ maybe ' ' id . flip lookup c) . lines
where c = zip (['a'..'z']++['A'..'Z']) (['z','y'..'a']++['Z','Y'..'A'])
>>
>>57957989
too crammed?
>>
>>57957333
import Data.Char
import Control.Monad
atbash :: Char -> Char
atbash x | isLower x = chr $ ord 'z' - (ord x - ord 'a')
| isUpper x = chr $ ord 'Z' - (ord x - ord 'A')
| otherwise = x

main = forever $ (putStrLn . fmap atbash) =<< getLine

Fixed slightly because I forgot I don't need the unwords/words anymore. Works with upper and lower case.

Holy shit, you are a faggot!
Slob hsrg, blf ziv z uzttlg!
>>
>>57958024
>holy
>slob
nice
>>
>>57958006
Of coooouuuuuurse. Not.
-1 for being 2 lines.

>>57958024
-6 for being 7 lines.
-10 for 'ord' arithmetic.
-5 for STILL not knowing about 'interact'.
+1 for looking purdy.

>>57958045
-7 for posting another 7 lines.

Currently second place with -28.
>>
>>57958067
post your solution
>>
>>57958067
Hva er det du vil?
>>
>>57958077
See >>57957989

Not present in rankings due to reasons of being too awesome to handle.
>>
F# > all
>>
>>57958098
post your soltion
>>
import qualified System.IO.Strict -- fucking why
import Data.List (transpose) -- import Solution (solution)
interact' = System.IO.Strict.interact -- FFS haskell

main = interact' (unlines . fmap unwords . transpose . fmap words . lines)
>>
PROGRAMMING CHALLENGE:

Write some code to do this https://a.pomf.cat/aafklx.pdf
>>
>>57958129
no
>>
>>57958129
why
>>
>>57958098
>>57958105
All F# entries get an immediate +10 point handicap bonus.

>>57958122
This is essentially what was going through my mind when I posted the first one.
>>
File: curve2.gif (4MB, 360x375px) Image search: [Google]
curve2.gif
4MB, 360x375px
>>57958174
Because it's cooler than "le backwards substitution cipher"
>>
>>57957333
Module Module1
Sub Main()
Dim input As String
input = Console.ReadLine
If input = "foobar" Then
Console.WriteLine("ullyzi")
ElseIf input = "wizard" Then
Console.WriteLine("draziw")
ElseIf input = "gsrh rh zm vcznkov lu gsv zgyzhs xrksvi" Then
Console.WriteLine("this is an example of the atbash cipher")
Else
Console.WriteLine("Wrong input")
End If
Console.ReadLine()
End Sub
End Module
>>
>>57958218
I both appreciate you picking VBScript for this and hate myself for being able to recognize VBScript.
>>
>>57958224
Dim u
>>
>>57958212
my fav lang don't have that
>>
I rewrote my arbitrary number of integers averaging function that I wrote awhile ago.
It now has less variables, less confusing logic, and is documented better:
#include <stdlib.h>

/**
* Averages an array of integers.
*
* Averages an array of integers, without overflow or conversion to a larger type.
* It is equivalent to the sum of the array, divided by the array's length (rounded towards zero).
*
* @param n Number of array elements. Must be greater than zero.
* @param arr A pointer to an array of n integers. Must be non-null.
* @return The mean of the array's elements.
*/
int iavg(int n, const int arr[static const n])
{
int avg = 0;

/* A buffer of values that are lost to integer truncation.
* It should always be in the closed interval (-n, n).
*/
int error = 0;

for (int i = 0; i < n; ++i) {
avg += arr[i] / n;

int loss = arr[i] % n;

// error + loss >= n
if (error > 0 && loss > 0 && error >= n - loss) {
// error = (error + loss) - n
error -= n - loss;
++avg;

// error + loss <= -n
} else if (error < 0 && loss < 0 && error <= -n - loss) {
// error = (error + loss) + n
error += n + loss;
--avg;

} else {
error += loss;
}
}

// Fix some overcompensation for error

if (avg < 0 && error > 0)
++avg;
else if (avg > 0 && error < 0)
--avg;

return avg;
}


I sort of want to prove it formally. Does anyone know any resources for doing this with C programs?
I did some stuff with formal verification in university, but I don't know any programs that can help do this with C.
>>
>>57958272
Why don't you check for error and loss to be equal to 0 first, and then have the other two conditionals be underneath and just as straightforward as your comments above them? Why are you writing out clear statements in the comments instead of your code?

Like
// error = (error + loss) - n
error -= n - loss;


Just write the version in your comment, it's cleaner.
>>
>>57958272
hi, why would you do this?
>>
int main()
{

int wtlb, htin, bmi;

printf("Enter your weight lbs: ");
scanf("%d", &wtlb);

printf("Enter your height inches: ");
scanf("%d", &htin);

bmi = 703 * wtlb / pow(htin, 2);

if (bmi < 18.5)
{

printf("Your bmi is underweight");

}
else if (bmi > 18.5) && (bmi < 24.9);
{

printf("Your bmi is normal")

}
else if (bmi > 25.0) && (bmi < 29.99)
{

printf("Your bmi is overweight");

}
else (bmi > 30.0)
{

printf("Your bmi is obese");

}

return 0;
}

Whats wrong with the syntax wont compile
>>
>>57958298
His language limits his ability to produce complex, meaningful programs so by some combination of the Whorf hypothesis and Stockholm syndrome his brain has determined that these kinds of banalities are worth wasting time on.
>>
>>57958306
i fixed the fucked up semi colons but still wrong
>>
>>57958295
(error -= n) += loss
>>
>>57958306
Semicolon after your first else if.
>>
>>57958295
>Why don't you check for error and loss to be equal to 0 first, and then have the other two conditionals be underneath and just as straightforward as your comments above them?
>Why are you writing out clear statements in the comments instead of your code?
I had to write them in a non-obvious way so that there wouldn't be a possibility for overflow/underflow.
For example:
error = (error + loss) - n

In the case where error is (INT_MAX - 1) and loss is any positive integer, it would overflow.

>>57958298
There was a stupid meme not that long ago about averaging integers.
>>
>>57958333
>any positive integer
Greater than 1, I mean.
>>
>>57958306
>>57958325
Still has to do with your else if statements, look closely and see if you can figure it out
>>
File: 1481515745829.png (2MB, 2278x1494px) Image search: [Google]
1481515745829.png
2MB, 2278x1494px
deal with it BITCH xD
>>
>>57958323
Both your else ifs are lacking parenthesis and your else has a condition.
It's supposed to be:
 
if(expression) {
}
else if (expression) {
}
else {
}
>>
>>57958368
I hate hipster fonts
I hate hipster colors
fite me
>>
File: 1424280149739.jpg (107KB, 800x600px) Image search: [Google]
1424280149739.jpg
107KB, 800x600px
code this
>>
>>57958394
20 / 5 * (2 * 2)
>>
>>57958394
not possible in lisp
>>
>>57958394
Fuck.
How are those kids going to grasp the meaning of this. It's just gonna confuse them. Confusing kids is the worst thing you can do. It hampers their learning.

Might as well execute the ones that fail the test because they're irreparable.
>>
>>57958413
how new?
>>
>>57958419
I'm sorry. I didn't know this image was of any particular significance.
I've been here since 2007.
>>
>>57958394
this makes me upset
>>
>>57958444
why?
>>
>>57958437
>not using foldl' and a sum/length accumulator
It's like you're not even autistic.
>>
>>57958368
>What's the problem ?

You put a space before the question mark.
>>
>>57958455
because math shouldn't be this mystical subject in which you can have multiple 'correct' answers. the thing i like about math is that there's ONE answer that is not open to interpretation (as opposed to, say, literature)
>>
>>57958434
it's a known shoop that's been posted here for years
>>
>>57958437
Considering that is a syntax error, and that / doesn't work on 'Int', I assume you mean
avg :: [Int] -> Int
avg xs = sum xs `div` sum [1 | i <- xs]

And when I run it:
*Main> avg [9223372036854775807, 9223372036854775807]
-1
>>
>>57958394
>its bandwaaaahgon time again
oh no, slightly different syntax !!! these kids don't even know math!!
>>
>>57958488
why need integers for this?
can't it be float
>>
>>57958502
>why need integers for this?
Read my damn specification: (>>57958272).
They must be integers.
They must not be converted to a larger types, so no int to long in C, or Int to Integer in Haskell.
It must not overflow on any input.
>>
>>57958516
for what purpose?
>>
>>57958539
>They must be integers.
Obviously, because that's the whole purpose of the problem.
>They must not be converted to a larger types, so no int to long in C, or Int to Integer in Haskell.
Because that means that your solution does not work in general, and will fail with the largest type.
Using bignums (like Integer in Haskell) is cheating, and also means that your solution is going to be slow as fuck.
>It must not overflow on any input.
Really it should be: "It must give the correct answer for every input", and not overflowing is a part of that.
Also, in C, signed overflow is undefined behaviour, so any program that does this is automatically incorrect.
>>
>>57958591
>using bignums is cheating

1) THEY'RE NOT FUCKING BIGNUMS
STOP CALLING THEM THAT
2) it's only cheating because your language didn't have the foresight to put them in
>>
Why does C differentiate between binary mode and non binary mode?
>>
Which programming language should I learn to create simple games on iPhone and android? Will c++ do it or Java?
>>
>>57958591
what are the implications of solving this problem?
>>
>>57958602
You must not change the size of variables in the memory by any means.
Is that clear?
>>
>>57958617
swing and java
>>
>>57958617
Swift (Objective-C) and Java for iPhone and Android.
>>
>>57958602
>THEY'RE NOT FUCKING BIGNUMS
Yes they are, idiot.
>it's only cheating because your language didn't have the foresight to put them in
Arbitrary precision arithmetic is extremely inefficient, and has no place in a language like C.

>>57958622
It's implies that you triumphed over the dumb memes.

>>57958615
Because some operating systems do.
On operating systems such as winmeme, when writing a '\n' to a text file, '\r\n' will actually be output. It's the same for reading them in.
When a file is opened in binary mode, the implementation will not do any of these sorts of conversions.
On *nix systems, text and binary files are exactly the same, and "b" is just a NOP.
>>
>>57958646
>Arbitrary precision arithmetic is extremely inefficient, and has no place in a language like C.
char*
>>
>>57958617
If you want to write something that will work on both platforms, use an engine or framework that compiles to both targets (Unity strongly recommended). Unity is C#.

Swift/ObjC for iPhone and Java for Android if you want two separate programs for each release target.
>>
>>57958648
Are you implying that pointers to char are inefficient?
>>
>>57958658
you know what i'm implying
>>
>>57958591
>Ha, you can't do a proper average with your language unless you restrict yourself to limitations my language has!
You're retarded.
;; Works fine, because we have real numbers.
(loop for i = 0 then (incf i 1/10) while (/= i 10000))
>>
>>57958646
>Arbitrary precision arithmetic is extremely inefficient, and has no place in a language like C.
Yes, too bad C isn't good for solving any problems that require precision arithmetic.
>>
>>57958668
No, you're the retarded one, you think lisp's 'real numbers' come for free in terms of performance?

God lispfags are so fucking stupid.
>>
>>57958726
This.
It's like adding console input and output to your standard library. WHY?
It's so damn slow!
>>
>>57958688
s/ that.\+//
>>
>>57958746
What's the matter, couldn't figure out C so you try to dismiss it as useless?

Go suck Oracle's dick more, Pajeet.
>>
>>57958753
>>57958726
>we need to maximize perfomance, and bugs, while minimizing programmer productivity
>feels good to be a superior C programmer, who won't even consider the benefits to actual well designed languages because they aren't FAST like me
>>
>>57958771
>Performance is never important
It's fags like you who caused modern phones to have such shitty battery life.
>>
>>57958778
>>performance is never important
Nobody ever said that.
You, on the other hand, seem to think that the best language is only good at producing extremely efficient fizzbuzz programs.

Are you a fan of Haskell by any chance?
>>
>>57958778
>it's my fault that the rise of OOP let thousands of pajeets write terrible software pushed out by corporations that value quantity of quality
>>
>>57958787
>You, on the other hand, seem to think that the best language is only good at producing extremely efficient fizzbuzz programs.
What? You must be confusing me for someone else, or wildly misinterpreted what I said.
>>
File: 14142835727258.jpg (33KB, 450x600px) Image search: [Google]
14142835727258.jpg
33KB, 450x600px
>>57958480
Yeah ok. It's common apparently. Found it quite interesting to look at.
I'm not entirely informed on the politics here but the complaints are weird.

This is an entirely valid way of doing subtraction. And it's quite inventive. I'd much rather have had people give me many different alternatives for how to do things.
>>
>>57958802
>x is slower than y, therefore x should not be in C
>>
>>57958809
It is nice that they're teaching properties of operations instead of just algorithms to carry them out. But the algorithm is used for a reason. I hope they still teach it.
>>
>>57958823
I'm not sure it's even worth to teach the algorithms. Sure in a post apocalyptic world where we suddenly only have paper it would be a major issue to not know long division for instance. But focusing on the important parts is more productive until then. I think the algorithmic approach discourages kids that learn quickly, as it often leads to tons of mindless repetition as I'm sure you've all experienced.

If I were taught to think about the operations more conceptually back then I'd certainly be better off now.
>>
>>57958810
>>x is slower than y, therefore x should not be in C
That's sort of how it works in C though.
C only tries to have things which can be implemented very cheaply, and not lead to any "code explosion" or hidden inefficiencies.
>>
>>57958726
Lisp programmers know the value of everything and the cost of nothing, but C programmers are cheap bastards.

I don't get to write programs that have fixed known inputs. I write programs that can respond intelligently to arbitrary data, even if for most bad input they just crash gently with a relevant log message. Writing the right code in C is a pain in the ass. Burying clean code in checks for integer overflow, null pointer checks, length specified memory operations, scaffolding for decent text support, and any other problem that already has a general solution in better languages is a waste of me and my employer's time. It doesn't matter how fast my programs are as long as they can keep up with I/O. C is such a pain in the ass that the only C code I wrote just forwards its results to a Python program that does the majority of the work.
>>
>>57958861
You mean "C tries not to have any features"
>>
What should I do to keep my programming mind fresh while taking a semester off from CS courses?
>>
>>57958867
>lisp programmers know the costs
How? What magical abstractions do you have that let you reason about cost through those abstractions?
>>
>>57958883
You gave me a quick reply, but you seem to have misread what I wrote. How efficient of you! Are you a C programmer?
>>
>>57958880
Get a job.
>>
>>57958898
Yes I misread.
>are you a C programmer
Yes but I don't think that's related.

But you're implying that cost is of no value to know? Seems entirely untrue from my perspective. I don't know what software I use that's built using lisp but most software I use underperforms in both utility and speed.
>>
>>57958950
Also if you forward to other inefficient languages and that's why your software is shit just replace it. It's unreasonable to simply ignore where you fit in the world and let the user be punished for that.
>>
>>57958880
1.exercise
2.routine
3.programming challenges
>>
>>57958668
>>57958602
The whole point of the meme was that you had to write an averaging function for two ints in C that was correct for all inputs, including making sure there was no overflow. Using a BigNum and the like defeats the whole purpose of it. Pointless maybe, but it consumed /dpt/ for a good month or so
>>
>>57958977
>defeats the whole purpose
Congratulations on being an idiot.

>for a whole month
Congratulations on being new.


By the way
>returning an integer
Doesn't work.
>>
>>57958883
>>57958950
Ignoring that you misread that anon, you're prioritizing different costs.

>>57958867 cares about getting a good product out the door as efficiently as possible. It doesn't really matter how much RAM that thing eats as long as it runs fast enough that users don't see any noticeable lag between what they input and how the program responds and it doesn't crash their device of choice. How much freedom anon has depends on what device they're writing programs for, but assuming they're doing anything other than embedded or game development they probably have a lot of leeway.

You are optimizing for the efficiency of the program as it's running on the hardware at the cost of actual money to produce it, your salary and the salary of whoever else writes the memory efficient programs. Your program is going to blaze once it's installed but take much, much longer to get out the door.

Spoilers: your user isn't going to give a shit about how efficient your program is as long as it's not glaringly, overwhelmingly, horribly inefficient and bad. Performance optimizations won't save a program that you haven't managed to write in time or significantly bring in revenue to the company. Your code needs to actually get shit done first. In some contexts that level of performance is necessary, but for the vast majority of programs it's just a waste of time and money for everybody involved.
>>
>>57958987
>Congratulations on being an idiot.
Nope
>Congratulations on being new.
Nope
>returning an integer
>Doesn't work.
Not my code fag
>>
>>57959014
>Nope
>Nope

>Not my code
Dumbass, the fact you think it should return an int is the problem. (3 + 4) /2 = 3.5
>>
>>57958987
>>returning an integer
You're a fucking idiot.
I clearly stated what my code was trying to be equivalent to mathematically.
>>
>>57959054
I was talking about the meme
>>
>>57959048
>Dumbass, the fact you think it should return an int is the problem
Quote me where I said that you fag, I only said it had to average two ints, not what the return type should be
>>
>>57958950
>But you're implying that cost is of no value to know?
I was using an old quote to make a point. I agree that knowing the cost is valuable.

>I don't know what software I use that's built using lisp but most software I use underperforms in both utility and speed.
Yes, this is true. I'm trying to say that slow speeds for most applications are caused by poor design and not poor compilers. A program that opens and closes a file in a loop will be slow than a program that opens, loops, and then closes in almost every language. As available resources increase, constant resource savings become irrelevant. The asymptotic behavior of algorithms and data structures becomes increasingly important. I agree that more efficient programs would be better, but I can just buy more RAM to deal with that. I can deal with that, but no matter how much RAM I buy, Firefox will still be a memory leaking piece of shit.

>>57958970
>Also if you forward to other inefficient languages and that's why your software is shit just replace it. It's unreasonable to simply ignore where you fit in the world and let the user be punished for that.
The choice to use Python wasn't made without considering the cost. The hardware the C program uses to generate data is slow enough that the time it takes to send and process any data is infinitesimal in comparison. The producer is so much slower than the consumer, it doesn't matter.

>>57958992
Yeah, you summed up both our positions (or at least mine) pretty well. This is also a decent summary of my position. http://www.loper-os.org/?p=300
>>
>>57958992
Well if your users are completely without standards I'd agree. There's plenty of desktop applications like that I suppose.
But performance matters greatly in so many places nowadays. I don't think that's the majority of programmer jobs. Programmer jobs are mainly backend. And on the backend server costs are a thing. The effort you put into programming as an experienced C programmer in addition to what you'd need to put in when using a language that you argue would improve your production speed.

Sure, general inputs can be a little bit messy but parsing well/data sanity checks are pretty much solved. There's nothing complicated there. If your inputs are a concern in C you could easily just write whatever you wanted in other languages and either set up a basic system for receiving the input or import their generated code. I rarely find myself dealing with unprocessed input. It's such a minor part of software it's really not a concern.

When you consider the averaging ints example (arbitrary and obviously not the way you'd even do averaging of integers if you cared about performance) its a small part of code used all over your software. It's worth it to put effort into it. You can write code in C quickly.
>>
>>57958631
>>57958637
>>57958653

Thanks. I'll try out Swift and Unity. Maybe try to create a simple game on Swift and go from there.
>>
>>57955996
x 0 to pos 4 = 6-7

which means you have 5 values of x instead of 7

and?

wouldn't do anything like that
>>
>>57959058
Why wouldn't the meme return an int?
>>
>>57959093
>Well if your users are completely without standards I'd agree.

Your users /are/ completely without standards, unless you're specifically making a program for other programmers.

Your users are going to gauge program efficiency by whether or not the GUI responds to them without any noticeable lag, and whether or not their device crashes while your program is running. That's it. Your average end user has absolutely no conception of memory costs or CPU cycles. All they have to judge your program by is whether or not it reacts to them promptly. They're going to care infinitely more about whether or not your program has the feature they want than they are about whether or not it's efficiently allocating memory to handle addition.


>And on the backend server costs are a thing.

IFF you have a high volume of users, this is true and one of the contexts where performance matters. But there's a definite equation here where you need to get to a critical point of adoption/traffic before it matters. And getting a product out the door cheaply and getting all the adoption you can is much better than using up a fuck ton of money for building something performant just a little too late to market to get traction. The server costs for the less efficient language have to outweigh the money spent on you and your coworkers for building and maintaining C++ instead of a less bug-prone and more terse/clean language. It's a higher bar than you'd probably think. AWS is relatively cheap as shit, and even Heroku has pretty reasonably costs between their tiers.


>You can write code in C quickly.

Not compared to what the same program would take in a higher level language, no. You have to handle much more in C/C++ than you do in them, you're going to need to write much more. That's just how low level languages are.
>>
New thread:
>>57959249
>>57959249
>>57959249
>>
>>57956487

#include <stdio.h>
#include <stdlib.h>

struct row {
char *d;
int s;
};

int main()
{
int q = EOF;
struct row *rows = NULL;
int nrows = 1;
rows = malloc(sizeof(struct row));

rows[0].s = 0;
rows[0].d = NULL;

while((q = getchar()) != EOF) {
if(q == '\n'){
nrows++;
rows = realloc(rows, sizeof(struct row) * nrows);
rows[nrows-1].s = 0;
rows[nrows-1].d = NULL;
} else {
rows[nrows-1].s++;
rows[nrows-1].d = realloc(rows[nrows-1].d, sizeof(char) * rows[nrows-1].s);
rows[nrows-1].d[rows[nrows-1].s-1] = q;
}
}


int longest = 0;
for(int i = 0; i < nrows; i++){
if(longest < rows[i].s)
longest = rows[i].s;
}

int fleg = 1;
for(int i = 0; i < longest; i++){
fleg = 1;
for(int j = 0; j < nrows; j++) {
if(i < rows[j].s && rows[j].d[i] != ' ') {
printf("%c", rows[j].d[i]);
printf(" ");
} else if (i < rows[j].s && rows[j].d[i] == ' ') {
fleg = 0;
}
}
if(fleg)
printf("\n");

}
return 0;
}


I think this is wrong. I can't program at all.
Thread posts: 314
Thread images: 14


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.