[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y / ] [Home]
4chanarchives logo

Daily Programming Thread


Thread replies: 348
Thread images: 34

File: 1334682645405.jpg (475KB, 1024x1076px) Image search: [Google] [Yandex] [Bing]
1334682645405.jpg
475KB, 1024x1076px
Old /dpt/ at >>51974888

What are you working on?
>>
LEGIT THREAD
>>
Any programming challenges, /g/uys?
>>
>>51980294
Create an wordsearch generator
>>
>>51980217
I'm working on an abstraction for web browser View rendering, and an abstraction for communications between web browser and server, both use the Adapter pattern.

I'm also working on glueing multiple modules together (including the two mentioned above) to form a framework
>>
File: hun.webm (3MB, 1066x600px) Image search: [Google] [Yandex] [Bing]
hun.webm
3MB, 1066x600px
Ask your favorite programming literate anything.
>>
>>51980483
LL or LALR?
>>
>>51980483
Kill yourself.
>please, no bully
Kill yourself.
>>
>>51980330
>>
>>51980536
yes
>>
File: PYsvgTz.png (2MB, 1218x3205px) Image search: [Google] [Yandex] [Bing]
PYsvgTz.png
2MB, 1218x3205px
>>51980427
>both use the Adapter pattern.
muh oop
>>
>>51980611
>most of these patterns are natural constructs in functional programming
>>
File: 1431557016533.png (127KB, 546x486px) Image search: [Google] [Yandex] [Bing]
1431557016533.png
127KB, 546x486px
>>51980294
why don't you just study something you're interested?
If you really want it just google it.
>>
>>51980611
>51980611
thanks for the pic
>>
So i have a Qt application with 50+ ui elements, with tables, input fields. Also im loading huge, 100MB+ images and processing them in different stages. I need to create a save/load project function and im not sure how i should do it.

I dont know if saving the data to a zip file or just putting them into a folder would be best. Either way with all the images the save would take almost 1Gb.

Also how do i save and set the state of the ui elements without hiccups? I need to block signals globally thats for sure.
>>
>>51980536
Alright, here it goes.

>I'm walking up to the entrance and two trench coats move in from my right, a man and a woman.
>The shopping center is extremely ritzy so I think nothing of it.
>The guy does this really weird maneuver and holds the door for the girl and steps in front of me and walks in.
>Think to myself about how that was strange
>I'm on the first floor looking at math books; finish then head to the technology section upstairs.
>up the escalator, to the left, two bookstacks
>round the corner into the aisle formed by these stacks
>See the figures from early and I stop frozen in my tracks
>Guy and girl both wearing trench coats with t shirts, jeans, and gym shoes
>Girl is your average not-attractive-whatsoever girl, nothing special about her
>The guy: receding hair line, greasy, slicked-back with his lack-of-shower pomade; posture like the golem of bad posture (GOLEM YE BE GONE)
>She's leafing through C++ books
>Of fucking course. He's looking through Linux books
>Linux Command Line, some other Linux book
>He looks at what she's doing
>Grabs a giant C++ for dummies book, seriously that thing is like a medical journal
>"THIS IS A GOOD BOOK."
>"That's for beginners."
>He shuffles a couple of steps away and keeps looking at Linux books.
>Offers to buy her any two books
>She mumbles something and they scuttle away

I was mortified.
>>
File: 2015-05-27 15.36.57.png (123KB, 1065x816px) Image search: [Google] [Yandex] [Bing]
2015-05-27 15.36.57.png
123KB, 1065x816px
>>51980659
So no bitching about go?
>>
An IoT-enabled dragon dildo
>>
Why the fuck can't I have an unused import in my Go project? I added it because I need it in 5 mins, just going to try this other thing out first.
>>
>>51980611
OOP was a mmistake
>>
Hey /dpt/, I could use a small nudge in the right direction.

I have a large data set which contains pairs of IDs, representing connections between nodes. I can also look up the value of each node.

How would I go about efficiently calculating:
- Which nodes are exactly X connections away from a specific node (while going the shortest route)
- Which nodes are exactly X connections away from *any* node with a specific value

I'm having trouble finding resources for this specific case. Any ideas on algorithms to use, or just general approach to the problem? I'd rather not brute-force it and have my program take hours to complete.
>>
>haskell
>all libraries are shit
>muh whitespace
>many bugs in any single iteration of GHC
>laziness makes it unnecessarily hard to reason about runtime/memory requirements
>typesystem isn't as strong as it could be

>ocaml
>Object caml
>nobody actually knows how to use, or uses, objects
>no parallelism in 2015
>different operators for floats and ints
>standard library is borderline unusable, so everyone uses either batteries or core, with lwt or async for concurrency, in any combination, increasing fragmentation
>effort gets repeated from scratch every few years instead of being built upon (see: parallelism, jane street and some dude for his PhD both tried, both from scratch, and ocamlpro's current attempt is also from scratch)
>poor windows support, i.e. poor multiplat capabilities

>sml
>lolnodocs
>10 incompatible implementations
>one fast, parallel implementation, but it doesn't have a repl
>one windows-heavy implementation that's quite fast and has parallelism and a repl, but poor (if existent at all) non-windows support, and very poor target platform support
>no middleground
>no libraries

>1ML
>NEVER EVER

Why is the ML family of languages so cucked?
Why is the lisp family of languages even more cucked (shit or missing type system, no TCO in clojure, barely functional constructs in CL and no standard update since 1994 with no plans to, most don't do parallelism either, none have a significant userbase except CL and racket, a lot are full of bugs and leak memory, etc.)?
Why is there no good functional programming language that is actually usable in practice?

Is functional programming just a meme?
>>
>>51980773
It's too generic to bitch about.
>>
>>51980921
You can't, it's NP-complete.
>>
>>51980965
Fug. So, what are my options then? Just accept any solution's going to be super slow?
>>
>>51980949
>all libraries are shit
What

>muh whitespace
Can be subverted using {;}

>laziness
Strictness annotations, strict modules/functions

>type system
It's still got the strongest out of those options, by far
>>
What language would be useful to learn?
>>
File: 1430846672005.jpg (129KB, 527x620px) Image search: [Google] [Yandex] [Bing]
1430846672005.jpg
129KB, 527x620px
>>51980714
np, have this one too

>>51981071
literally any. Learn a couple different paradigms too, so you can use the one the fits better the problem
so java, c++, c#, python, clojure, common lisp, racket, prolog, julia, whatever
>>
>>51976518
// assuming p = fmt.Printf
for i:=97;i<123;i++{
p("%c\n",i)
}


>>51980773
Go is perfect.

>>51981071
Go
>>
>>51981071
Learn Awk if you haven't already. You will be glad you did.
>>
>>51980965
>>51981007
Wait, no. My list of connections is static and will never change, so I could just calculate the connection counts once, store the results, and work with those. Duh.
>>
>>51980844
Just use go imports.
>>
>>51981275
ignore it, it's a new troll, just like "you can't average two numbers in C", "this compiles in gcc: <some C++ shit>" and so on
>>
>>51981322
It's completely true, though.
>>
>>51980844
haha very funny xD
well meme'd, my friend
upboated, +1!
>>
What are some obscure programming languages that you like, /dpt/?
>>
>>51981375
Erlang/Elixir. You should learn it because it's used in telephony!
>>
>>51981375
I really like Agda.
>>
>>51981375
Julia
>>
>>51981409
What is it like to use compared to Haskell? Are libraries in Agda tightly coupled?
>>
>>51981424
It's not really comparable to Haskell besides the fact that it's functional and the syntax is similar. Like, you wouldn't ever use it for something that Haskell is perfectly good for.
>>
>>51981409
Seconded.
>>
>>51981375
Nitra, looks promising as fuck for developing whatever languages you'll ever need. It's far from completion though.
>>
>he needs a debugger to understand code
Better flip burgers m8
>>
>>51980427

> 2015
> hard dependency on jQuery
>>
>>51980611
>>51981141
>pics
>memorizing a load of trivial word definitions instead of having actual skill
this is what normies actually believe
>>
>>51981506
Pff, int 0x80 is my debugger.
>>
>>51981551
>normies
curryniggers actually. most normies would be incapable of learning/memorizing those concepts properly
>>
>>51981551
patterns are not for "pick one to continue writing this program", they are for communication/code documentation instead.
>>
>>51981646
Patterns are for shoehorning ordinary functional concepts into OOP. Most of them are just closures. And, for example, Chain of Responsibility is a monoid.
>>
>>51981702
> for shoehorning
No, they are for describing common patterns in OOP design. Whether those are easier to implement in/native to functional programming is irrelevant.
>>
>>51981450
Just use flex and bison you fucking hipster.
>>
>>51981726
Why have all these different names for obscure special cases of object relationships when they are mostly straightforward and self-explanatory using functional concepts?
>>
File: 1450608948672.jpg (85KB, 600x859px) Image search: [Google] [Yandex] [Bing]
1450608948672.jpg
85KB, 600x859px
So I just downloaded the entire gentoomens library, all 32.7 gigs. Gonna seed for at least as long it took me to DL.

So, any pointers on where to start?
>>
I GOT AN EMAIL TELLING ME TO STOP TORRENTING FROM MY UNIVERSITY INTERNET. WTF? WHAT KIND OF SHIT IS THIS? DENMARK IS SUCH A NAZI COUNTRY. What can I do to get away with stuff like this?
>>
>>51981743
> flex and bison
Why not x86 assembler? Just read what Nitra actually is (going to be).

>>51981749
Because those naming conventions developed being ignorant of functional programming, and therefore don't require the user of an OOP language with little/no support of functional concepts to learn them.
>>
>>51981775
>university
They let 11 year-olds into university in Denmark?
>>
>>51981783
>Why not x86 assembler?
Because then it won't work on ARM
>>
>>51981783
>an OOP language with little/no support of functional concepts
I don't think this is a thing any more.
>>
>>51981749
i think OOP is great but things like these diagrams and stupid names n shit for basic concepts pisses me off
>>
>>51981797
shut up and tell me what to do
>>
>>51981800
I don't follow java development, is it actually catching up? Then probably. Still it's not like patterns appeared yesterday, they were useful for something at one time for sure.

>>51981799
Good point.
>>
>>51981825
Java finally has lambdas, yes. The types are still a bit wonky, since lambdas implement a "functional interface" which is any given interface with only one method.
>>
>>51981775
use a VPN or something? but the amount of traffic will still be suspicious if you download/upload a lot
>>
>>51981775
torrents use lots of resources
>>
>>51981883
>>51981890
which VPN? and how do i decrease the resources?
>>
>>51981783
Nitra is literally a parser generator and works exactly like flex+bison. Fuck off back to shilllang, shill.
>>
>>51981904
>which VPN
set up your own if you need to
>how do i decrease the resources
download less
>>
>>51982007
how do you set up your own so you can download?
>>
>>51981905
Out of a grammar description you write in a nice-looking DSL instead of flex+bison shitshow you get
>an _extensible_ parser with automated error recovery.
As in, you can add a compiled module describing extensions to a language which will be picked up for easily adding/removing features from your language on demand.
+non-shit error reporting.

an automatically generated Resharper plugin (for now, later it should be Visual Studio extension afaik) for your language with
>syntax highlighting, symbol highlighting (such as class and method names etc.), navigation (goto declaration, find usages, etc.), validation and real-time error reporting/highlighting.

all this on top of regular parser generator's job of getting you AST + Parse tree with symbols etc
idk if you weren't retarded you'd be shilling for it too
>>
>>51982065
>an automatically generated Resharper plugin (for now, later it should be Visual Studio extension afaik) for your language with
This is pretty neat, although I'd be more chuffed if there was a parser combinator library that could generate plugins like that.
>>
>>51982065
[shilling intensifies]
>Why have you not installed Windows(tm) 10(r) and the best IDE, Visual(c) Studio(tm) yet, good goy?
Have you considered killing yourself yet? You should, I bet you'd have a lot of fun!
>>
>>51982094
>Visual Studio
>Not the best IDE
>>
>>51982065
>>51982073
And for ordinary text editors, not just fucking Microsoft ecosystem bullshit.
>>
>>51982094
>Visual(c) Studio(tm)
I share you distaste for the platform but the developers say that they ARE developing Nitra as backend-indpendent as they can and there will be api to allow supporting other IDEs. Although it's going to be a long wait because time to finish Nitra + time someone writes llvm (or w/e) backend + some writes support for w/e IDE gonna take awhile.
>>
I know Vim decently and Emacs a little. Will I gain much if I switch from Vim to Emacs with Evil mode?
>>
>>51982188
You will gain nothing and lose much.
>>
>>51982153
Holy shit, you're so retarded it hurts!
>>
>>51982306
I hope it hurts a lot, fucking nigger.
>>
>>51982293
What would I lose?
>>
>>51982356
dignity
>>
File: lua.png (15KB, 563x210px) Image search: [Google] [Yandex] [Bing]
lua.png
15KB, 563x210px
Can someone help me with this? I created a function that return 3 values and store in a property of table "brick", but how can I access those values from "brick.color"?
>>
>>51982356
The ability to feature in 4chan reaction images depicting you tipping your fedora and overlaid with the text "I use Emacs"
>>
>>51982356
Your keybinds because evil mode is garbage. Tabs, folds, minibuffers, buffers like the error and location buffer, jumping to a matching delimiter (you'll have to write the function yourself), and your tendon.
>>
how does one start to use SQL? my employer wants me to learn this. what program do i use/where do i download a DB to tinker with?
>>
>>51982485
See this cock? You can suck it.
>>
>>51982485
>learn SQL
nigga it's just english, you just tell it what to do and it does it
>>
>>51982401
Brick is a table.
That table has an index named color with 1 value assigned to it (yes one, not three, you disregard the latter two).
You iterate over the brick table as if it was an array of elements.
You then try to print brick.color[0] which is an integer, not a table.

Also, Lua indexes start from 1. Read the tutorial & introduction, you've no idea what you're doing as of yet.
>>
>>51982516
You sound angry. Wanna talk about it, sport?
>>
File: HFO5Rz8.png (356KB, 691x426px) Image search: [Google] [Yandex] [Bing]
HFO5Rz8.png
356KB, 691x426px
>>51982516
sorry, can't see that infected quist
>>
>>51982562
I know Lua indexes starts from 1, the for loop was just my way to discover if I can do something, but I didn't know the last two are excluded in the assignment.
>>
>>51982608
Your loop doesn't make much sense anyway, you iterate over the brick table (which has just one element named color), and for each iteration you print brick.color[0]. I think you want something like this instead:

local function GetRandomColor()
return math.random(0, 255), math.random(0, 255), math.random(0, 255)
end

local brick = {}
brick.color = {}
brick.color[1], brick.color[2], brick.color[3] = GetRandomColor()

for _, v in pairs(brick.color) do
io.write(('Color: %d\n'):format(v))
end
>>
File: dsfff.gif (403KB, 640x360px) Image search: [Google] [Yandex] [Bing]
dsfff.gif
403KB, 640x360px
How do I learn JS?
>>
>>51980483
What animu is that?
>>
>>51982643
F12 in the browser console and start typing.
>>
>>51982628
Yes, this:
brick.color = {}
brick.color[1], brick.color[2], brick.color[3] = GetRandomColor()

this was the last thing I was thinking. Thanks
>>
I know this might be beyond basic but I've literally just started with this.

In C programming, why don't my equations show decimal places?

e.g when I do variable=10/4 I get 2, and not 2.5.
>>
File: 3428975.png (621KB, 626x482px) Image search: [Google] [Yandex] [Bing]
3428975.png
621KB, 626x482px
>>51982682
Please learn what things like data types, variables, and assignment are before posting here
>>
>>51980921
>Which nodes are exactly X connections away from a specific node (while going the shortest route)
https://en.wikipedia.org/wiki/Breadth-first_search
>Which nodes are exactly X connections away from *any* node with a specific value
execute the above for every node; you might be able to throw some optimizations in, if it's a unidirectional graph
>>
File: e.png (165KB, 1920x1160px) Image search: [Google] [Yandex] [Bing]
e.png
165KB, 1920x1160px
>>51982655
What do I type senpai?
>>
>>51982682
Because you're doing an integer division which results in an integer, you want to do this:
variable = 10 / 4.f
>>
>>51981758
0x7ffe65be4f48

xDDD
>>
>>51982712

sudo apt-get install gentoo
>>
>>51982720
>48-bit pointer
What is this shit?
>>
>>51982712
setInterval(function(){alert("lol penis")}, 3000)
>>
>>51982738
why not just

while(true) { alert("lol penis"); }

senpai?
>>
>>51982712
var x = "";
for(var i = 2; i < 100; ++i) {
var p = True, m = Math.sqrt(i);
for(var j = 2; j <= m; ++j) {
if(i % j == 0) { p = False; break; }
}
if(p) { x += i + ","; }
}
alert(x);

::))))
>>
>>51982757
Because the statement in the console will never terminate and your browser will just crash.
>>
File: mvp.png (547B, 107x32px) Image search: [Google] [Yandex] [Bing]
mvp.png
547B, 107x32px
>>51982696

Not really helpful.

>>51982718

Thanks, that worked for me. Say I don't know if the final answer is an integer or not, is it useful to append any equations with .f or is this a bad idea?
>>
>>51982774
>
p = True

should be
p = true

>
p = False

should be
p = false
>>
>>51982628
brick.color = {GetRandomColor()}
>>
>>51982728
leading zeros are omitted
>>
>>51982728
% cat /proc/cpuinfo
address sizes : 39 bits physical, 48 bits virtual
>>
>>51982791
>Not really helpful.
No seriously, read up on types, it will all make sense then.
>>
>>51982485
DBA here.

answer incoming
>>
>>51982791
>Say I don't know if the final answer is an integer or not, is it useful to append any equations with .f or is this a bad idea?
Eh do you mean if a particular equation has only integer solutions or not?
In terms of programming it's what YOU want as the result - if truncation towards zero is ok, use integers.
If you want floating point, use floats.
If you want exact rationals, use a pair of numerator/denom numbers, etc.
>>
>>51982836
Where's the advantage in using 48 bit pointers instead of just the full 64? Which applications take advantage of the spared storage?
>>
>>51982774
You're supposed to declare all your variables at the top of a function scope and you're supposed to use triple equals, baka.
>>
>2016
>not using Java
>https://www.techempower.com/benchmarks/#section=data-r11&hw=peak&test=plaintext
>>
>>51982867
>You're supposed to declare all your variables at the top of a function scope
Not unless you or your users are really too dumb to understand JS's scope rules without doing that. You should be using the let keyword wherever possible, anyway.

>you're supposed to use triple equals
Yes.
>>
>>51980427
>2010+5
>jquery at all
>>
>>51982867
>you're supposed to use triple equals
only when the types differ
>>
>>51982791
you are not using equations, stop using that word
>>
>>51982728
No motherboard even has 64 bit wide physical bus lanes today, canonical form for all 64 bit implementations has top 16 bits all 1's or 0's (and in terms of virtual address space 64 bit kernels tend to assume the if top 16 bits are all 1's or 0's it either belongs to the kernel or userspace or has other kinds of protection tags)
>>
>>51982899
No, always, otherwise you're incurring performance hits and easily introducing bugs thanks to Javascript's desire to coerce your values into nonsense.

"Infinity" == Infinity
true


Thanks Javascript!
>>
>>51982866
Gotta ask that the jews at intel.
Maybe some savings in the page-frame-table and memory address translation?
>>
I don't have a VM handy right now. Is this correct syntax under UNIX to remove group read rights and give group execute rights in one command?

chmod file g-r,g+x

or would it look like this
chmod file g-r+x
>>
>>51982907

Why aren't I? My line says d=(4+(5*6))/3.f;

I'm equating one side of an expression to another, that's the definition of an equation right?
>>
>>51982925
This is like every single weakly typed languages, not just ES.
>>
>>51982925
>otherwise you're incurring performance hits
How does not comparing the type worsen performance, or do I have a too simplistic view of comparison operators?
>>
File: 1450534949272.jpg (110KB, 561x426px) Image search: [Google] [Yandex] [Bing]
1450534949272.jpg
110KB, 561x426px
It's late, I'm bored, and I'm slightly autistic
here's a poll for trivial shit for you gsg

http://poal.me/snis8x
http://poal.me/snis8x
http://poal.me/snis8x
http://poal.me/snis8x

Why a class and not some free func/what I have in mind for usage:
>feed in control points, it caches a matrix resulting from multiplying the geometry and basis matrices for that curve & control points
>get a set of sample points for the curve based on a fed in sample count or get samples individually
>other stuff on that curve like the derivative/tangent to the curve
>>
>>51982945
latter, switch the file path and the mask's places though
>>
>>51982932
>Maybe some savings in the page-frame-table and memory address translation?
Yeah that makes sense, didn't think of other hardware using the pointers.
>>
File: Girls.png (490KB, 449x401px) Image search: [Google] [Yandex] [Bing]
Girls.png
490KB, 449x401px
>>51981506
>>
>>51982951
Yeah, but JS is the only one that does it poorly.
"5" + 5 => 10
"5" .. 5 => 55
"5" == 5 => false
>>
>>51982885
>You should be using the let keyword wherever possible, anyway.
Not really senpai, there isn't much support for it yet.
>>
File: Selection_021.png (6KB, 286x145px) Image search: [Google] [Yandex] [Bing]
Selection_021.png
6KB, 286x145px
>>51982978

PHP however thinks true = false
"foo" == TRUE, and "foo" == 0… but, of course, TRUE != 0.
>>
>>51982955
=== doesn't compare the types, then perform == if they're the same. It's a comparison operator without coercion. Because == still has to check the types of both arguments, and then tries various ways of coercing each one, it's slower than ===.
>>
>>51982992
> What is a transpiler?
>>
>>51982978
>
"5" + 5 => 10
"5" .. 5 => 55
"5" == 5 => false

Which implementation is that?
>>
>>51982967
thanks
>>
>>51982992
>>51982712
>>51982643
Please, mc fucking kill yourself.
>>
>>51983009
>Because == still has to check the types of both arguments, and then tries various ways of coercing each one, it's slower than ===.
I see, thanks
>>
php is gr8
>>
>>51983004
>true = false
what
>>
>>51982845

OK I get it now. Even though I declared c as a float, I am getting an integer as an answer because I am dividing an integer by an integer.

float c;

c = (4 + (5 * 6)) / 3.f;
>>
File: 1450463515813.png (583KB, 740x571px) Image search: [Google] [Yandex] [Bing]
1450463515813.png
583KB, 740x571px
>>51983039
>it's not even symmetric
>>
>>51983004
That's pretty dumb. Who thought it was a good idea for equality to coerce types?

>>51983017
It's Lua
>>
>>51983039
Not even JS is retarded enough to make things like "a" == true evaluate to true (although a non-empty string is a truthy value).
>>
>>51983039
>>51983059
Okay, nevermind it's not that bad
Still
>>
>>51983045
in PHP:
> echo "foo" == TRUE;
1
> echo "foo" == 0;
1
> echo 0 == FALSE;
1

Therefore TRUE == FALSE.
PHP is complete shit.
>>
>>51983093
this, desu
>>
>>51983093
you take that back
>>
>>51983104
>desu
oh since when is t~b~h replaced with desu?
>>
>>51983129
literally months ago
>>
>>51983129
desu senpai cuck
>>
>>51983129
>t~b~h
No idea what that is tbqh familia
>>
>>51982643
This is a good exercise:
https://jsfiddle.net/m66tpc4c/1/
>>
I'm in need of some optimization algorithm help.

I have x number of objects that have a start and an end coordinate. I need to determine the order of these objects so that the distance in between them (distance from the end of object 1 to the start of object 2 + from the end of object 2 to the start of object 3 and so on..) is as short is possible.

I can't really brute force it, because the number of ordering permutations is the factorial of the number of objects, so it grows ridiculously large after a small amount of objects.

What can I do? Does anyone know of any algorithms for this task?
>>
>>51981775

What the fuck uni do you go to? Most don't give a fuck about torrents as long as you keep it in moderation
>>
>>51982978
>JS is the only one that does it poorly

>>51983004
>>51983093

I'm pretty sure it's just weakly typed languages in general, anon.
>>
>>51983197
In JS true is not equal to false. Neither is it in Python.
>>
>>51983197
I'm sure that there are SOME weakly typed languages out there that don't violate transitivity.

Also, C is weakly typed but doesn't suffer from any of this shit thanks to static typing.
>>
>>51983129
Awhile ago, cuck was filtered too but I persistently whined on /qa/ and got it back.
>>
>>51983197
>JS is the only one that does it poorly
I don't know what runtime this anon is using, but it's neither Firefox nor Chrome.
("5" == 5) == True in both.
>>
>>51983179
>Aw, Snap!
>>
>>51983216
JS doesn't violate transitivity as far as I know (unless you count NaN, I guess).

>>51983211
Python is strongly typed, not weakly typed. You're mixing up strong/weak vs. static/dynamic.
>>
>>51983219
good job anon, I knew you could do it
>>
File: uruguay_04.jpg (36KB, 700x471px) Image search: [Google] [Yandex] [Bing]
uruguay_04.jpg
36KB, 700x471px
what do you do when you're really tired but have like 2 weeks to finish something big and really really important?

I don't want to hire indians or anyone really, my codebase is too shit for that
>>
>>51983219
Great effort m8
>>
>php
0 === ceil(0)
is false
>>
>>51983292
>like 2 weeks

What is the issue here? Get to it, you lazy sack of shit.
>>
>>51983292
what do you have to do and in what language
>>
>>51983292
make someone else to do it for you, for free
>>
File: 1372988731571.gif (109KB, 209x193px) Image search: [Google] [Yandex] [Bing]
1372988731571.gif
109KB, 209x193px
>php
md5('240610708') == md5('QNKCDZO')

The secret is that
md5('240610708') is '0e462097431906509019562988736854' and
md5('QNKCDZO') is '0e830400451993494058024219903391'.

Both are of the form 0e{bunch of digits}, a valid scientific notation. So when PHP's == decides to convert both sides to numbers to see if it can get a match, they're both converted to float(0), and thus the equality is true.
>>
I'm using visual studio for C, am I a bad person?
>>
>>51983420
No, you're just stupid.
>>
>>51983402
Fortunately, PHP also has === which should always be used.

>>51983420
I dunno about bad person, but Microsoft's C/C++ implementations are notoriously behind the times.
>>
>>51983446
>which should always be used.
Why does == exist then?
>>
>>51983446

Oh really? It's only temporary for a single semester. We've been told that we will be using better tool chains once we start doing embedded C.
>>
>>51980949

>scala
>>
>>51983474
Because PHP was made by idiots for idiots, and has an absurd paradigm of abandoning all pretense of consistency or logic in favor of "making sense" (in the way 2 == "2" makes sense).
>>
>>51983474
It's kinda useful when comparing input from a 3rd party and you don't care too much about type.

> wonder if the dba was a fucktard and made that column a varchar instead of an int...
> never fear, == is here
>>
File: 1438441304668.png (181KB, 256x733px) Image search: [Google] [Yandex] [Bing]
1438441304668.png
181KB, 256x733px
How do I learn HTML?
>>
>>51983525
They could have also made it a string and your PHP code would happily report true for "dicks" == TRUE and keep chugging. Never use ==.
>>
>>51983420
Microsoft ignores anything past C89
>>
>>51983541
dude html is so easy its laughable. go do to the god damn codeacademy tutorial and you'll be an expert
>>
>>51983541
right click -> view page source
>>
>>51980949
>>ocaml
>>Object caml
>>nobody actually knows how to use, or uses, objects
sorry to tell you this but the C++/Java style of OO is actually a minor niche of what OO was originally designed to be in the orginal Carl Hewitt's actor model. C++ basically bolted on a very static concept of OO by combining C structs with functions. The OO system in Ocaml is far in advance of the rudimentary OO that has become standard in most languages

>>no parallelism in 2015
if you want to build huge scalable servers you should be using Erlang/Elixir

>>different operators for floats and ints
part of the type inference system, floats and ints would have to be explicity defined without these operators

>>standard library is borderline unusable, so everyone uses either batteries or core, with lwt or async for concurrency, in any combination, increasing fragmentation
by unusable you mean there is no standard library ecosystem that does everything for you do you dont have to write any of your own libraries. This is a sad fact that universities produce code monkeys who are incapable of even implementing a library on their own and are completely dependent on having others make black box libraries that they use blindly without even understanding how these libraries are implemented. Its should be noted that most bloated software today is a result of overuse of libraries and implicit trust that libraries will always seamlessly integrate with eachother.

>>effort gets repeated from scratch every few years instead of being built upon (see: parallelism, jane street and some dude for his PhD both tried, both from scratch, and ocamlpro's current attempt is also from scratch)
The fact that Ocaml has a set of different sets of libraries is a testament to the fact that Ocaml is not concerned with non-changing standards but is always striving for personalized interpretations that evolve the language

>>poor windows support, i.e. poor multiplat capabilities
dead platform
>>
>>51983573
I was about to post this
>>
>>51983575
>>>no parallelism in 2015
>if you want to build huge scalable servers you should be using Erlang/Elixir

>trying to defend no parallelism
I SHIGIDIGGIDY
>>
>>51983575
>part of the type inference system
Well apparently type class inference works just fine.
>>
>>51983575
>C++ basically bolted on a very static concept of OO by combining C structs with functions.

Not that there's anything wrong with that, considering 99% of C projects ended up being tons of structs + related functions.
>>
>>51982648
Utawarerumono: Itsuwari no Kamen
>>
>>51983640
>Status: Currently Airing
dropped.
thanks, anyway <3
>>
>>51983560
> example that has nothing to do with the situation from the quoted post

Tell me why anyone would actually compare something that might be an integer or a string to TRUE.
>>
Besides that book of autism, SICP, what are your favourite programming books, /g/?
>>
>>51983723
"dicks" == 0 is true, too. So if you're testing for equality to 0 and use == just in case they made the field a string and put "0" in it, you'll get fucked. Stop trying to justify shitty coding practice through contrived examples.
>>
>>51983622
>Well apparently type class inference works just fine.
except ML types not need to be grouped like Haskell type classes which makes ML programs more translatable and composable with outside programs because ML is more deeply based in theorem proving then lazy evaluation
>>
>>51983730
composing programs
>>
>>51983772
Okay, well, they need not be grouped, but that's why you have to use different operators for different types.
>>
>>51983730
dater strukurs n amgavibems
>>
>>51983730
Structure and Interpretation of computer programs is pretty good book too.
>>
>>51983818
What is that, Swedish?
>>
>>51983219
nice
>>
Using tried and tested solutions to problems means you're a "backwards thinking" conservative in politics.

Why is it socially acceptable to use tried and tested solutions in programming, /g/?
>>
>>51983772
>>51983804
Also what about ML is more related to theorem proving than Haskell?
>>
>>51983874
Because they work
>>
>>51983855
it's not swedish. google translate won't detect it properly but i'm guessing it's some very poorly written non-scandinavian language like dutch or someshit
>>
>>51983292
post it on open source or a code review site, and ask whats wrong with it, someone will fix it for you because autism
>>
>>51982945
>>51982967
^ is correct, should look like

chmod g-r+x file
>>
>>51983874

Think of it this way: 'functional revolution' shitters are liberals.

Sometimes it's better to be a conservative.
>>
>>51983219
Circa 2007
>>
>>51983877
because thats what ML was designed for, it was an automated theorem prover. the language just happened to turn out to be a good general purpose language as well
>>
>>51983874
good programmers are often conservative. fags use unproven shit like haskell, racket, crystal
>>
>>51983907
It's always better to be a conservative.
>>
>>51983945
>theorem prover based on only System F
What
>>
>>51980949
>durr
>>51983575
>write any of your own libraries
Cripple fight.
>>
>>51983896
MUH DATER STRUGERS AM AMGAMIBIMS
>>
>>51983945
>>51983982
>it was conceived to develop proof tactics
Being a tactic language is completely different from being a theorem prover.
>>
>>51984009
or some stereotypical swedish-like gibberish made up by an english-speaking person
>>
hey guys i have an idea for a really cool game but i need one of you to make it
>>
>>51984080
that'll be $100k a year plus tax
>>
>>51984053
Data structures and algorithms.
Is that more clear for you?
fug.
>>
>>51984090
Nah man, we'll split the profits, it'll end up being much better for you I promise!
>>
>>51984108
I'll start on the logo now.
>>
I'll be learning lua soon, what ide/editor should I use?
>>
>>51984080
What if
You add 2hu assets
And let them fight against each other
>>
>>51984108
your idea by itself is worth nothing

either you do the work or you pay someone up front for the work

it's unlikely you can find a serious partner unless you can bring something to the table like artwork or something other than just the idea
>>
I have a controversial idea for a website, which I know will cause a huge fuss and get a lot of traffic.

I don't want people finding out I'm the owner, but I also want it to be a legit website.

What do?
>>
>>51984090
I'll pay you in exposure and cheap beer
>>
AoC Day 21 somewhat refined solutions. I could still make it nicer by reading weapon, cost and armor data from a file:
w=[[8,4,0],[10,5,0],[25,6,0],[40,7,0],[74,8,0]]

a=[[0,0,0],[13,0,1],[31,0,2],[53,0,3],[75,0,4],[102,0,5]]

r=[[0,0,0],[0,0,0],
[25,1,0],[50,2,0],[100,3,0],
[20,0,1],[40,0,2],[80,0,3]]

def fight(myDam, myArm):
myHP,hisHP,hisDam,hisArm=100,104,8,1
myTDam,hisTDam=max(myDam-hisArm,1),max(hisDam-myArm,1)
myHits=hisHP/myTDam+(hisHP%myTDam>0)
hisHits=myHP/hisTDam+(myHP%hisTDam>0)
return myHits<=hisHits

minCost=9999
maxCost=0

for i in range(len(w)):
for j in range(len(a)):
for k in range(len(r)):
for l in range(len(r)):
if k!=l:
currCost,currDam,currArm=(sum(m[n] for m in (w[i],a[j],r[k],r[l])) for n in range(3))

if fight(currDam, currArm):
minCost=min(minCost,currCost)
else:
maxCost=max(maxCost,currCost)

print minCost
print maxCost
>>
>>51984080
Dear Sir,
I will develop your game for $200 in any language.
>>
>>51984201
>but I also want it to be a legit website.
make a list of things that you need for this, like hosting, certificates, etc
And then see if you can pay with bitcoins, if you can use something like [email protected]
>>
>>51984219
brainfuck. failure to complete this by Jan 1st will result in termination.
>>
>>51984201
you can get the domain name registered with the provider's name instead of yours. might cost a bit extra. i just registered mine normally and i got a fairly non-descript registrant name (not my full name)
>>
>>51982774
Speaking as a developer of 20 years. I must comment on the absolute horror that is your code. In all of my time as a programmer, my eyes have not been set on text as nausea inducing as yours. I truly hope that you stumped upon here from /v/ /pol/ or /b/ and if so, may you kindly go back. I sit here in disbelief at how any sentient humanoid can cobble together anything as disgusting as what you have presented.
>>
>>51984215
>refined
>4 nested loops
>>
>>51984219
Wtf is up with indians calling everybody 'sir' in every sentence btw? Do they all go through the same 'formal english' class that teaches them that?
>>
>>51983402
>md5('240610708') == md5('QNKCDZO')

Damn, I never realised type juggling could be this evil. Are all weakly typed languages vulnerable to this kind of problems? Or has PHP gone too far? I mean, I understand casting string to float/int, but what happens here is casting string to expression: 0 * 10^a.
>>
>>51984249
Can you please tell me what I should improve?
>>
>>51984219
make a crysis 3 clone from scratch in x86 assembly
>>
>>51984297
Your life goals.
>>
>>51984258
ffs lad, alright I'll cut it down more
>>
>>51984313
Thank you for your contribution to this thread.
>>
>>51984270
weak and dynamic typing is always disgusting
>>
Did trap fag finally lose
>>
>>51984367
he still gets to make them and the jans seem to keep trap threads posted before the bump limit while deleting non-trap threads like >>51978383 but he's getting nowhere near each and every thread like he used to
>>
I have a question here.

I'd like to generate a mistake-based password in a text spelling a word I enter.

What I mean for example is a text with mistakes, and when you put the mistaken letters together, it spells a word.

Any idea where to start? This is a bit tricky.
>>
File: hui.jpg (46KB, 306x523px) Image search: [Google] [Yandex] [Bing]
hui.jpg
46KB, 306x523px
We're going uncomfy slow again.
>>
>>51984452
You're making barely any sense.
Give an example for a text with mistakes.
>>
File: 1409904101002.jpg (205KB, 750x1189px) Image search: [Google] [Yandex] [Bing]
1409904101002.jpg
205KB, 750x1189px
>>51984476
>hui.jpg
pfui
>>
>>51984478
Yeah, this is a bit hard to explain. Basically it's an old way to put messages in text, mostly used during WW2.

Example:

I want to hide the word TREE in my text.

My text could be something like this:

" Dear John;

I'd like to have your atention for a second, because what I am about to say is really impotant. Excpt if you don't have any time this week, could you pleas go and visit mom this weekend? I'd appreciate that.

Yours Truly,
Sally "

You can also mistake letters like this: Heartakhe instead of Heartache for example.

It's just a bit hard to see how I can do this. The text would always be the same, but depending of the word, it would randomly put mistakes in the text to spell that word.
>>
>>51984476
>tfw no nationalist qt3.14 programmer gf
Why even live?
>>
Why does:

int x;

for (x=0;x=10;x++)
{
printf("test\n");
};

Yield an infinite loop and not stop when x=10?
>>
>>51984540
find the first occurance of T, remove/replace it, repeat for R E E
>>
>>51984562
set x to 0
while (set x to 10)
print test
increment x
does (set x to 10) evaluate to true? -> yes
continue loop


replace x=10 with
x < 10
>>
File: ds.jpg (80KB, 634x758px) Image search: [Google] [Yandex] [Bing]
ds.jpg
80KB, 634x758px
>>51984476
>>51984551

I wish there were more girls like her tbqh.
>>
>>51984596

Got that thanks, I just don't understand why an = gives an infinite loop.
>>
>>51984613
You're assigning a value to a variable. Doing so is successful and evaluates to true. Therefore the condition x = 10 is always met.
If you'd compile with
-Wall -Wextra
there'd probably be a warning.
>>
>>51984613
because (x = 10) returns the value assigned to x, 10 which is not 0 therefore it == true.
>>
>>51982946
it's assignment you fucking retard
you're better off learning haskell, that has 'equations'
>>
File: dd.png (93KB, 500x422px) Image search: [Google] [Yandex] [Bing]
dd.png
93KB, 500x422px
I just thought of something embarrassing and screamed into my pillow.
>>
>>51984623
>Doing so is successful and evaluates to true.
Not quite. See >>51984624.
>>
>>51984328
>>51984258
Done, but it's extremely ugly now:
from itertools import product
#data ranges and stats hard-coded in
data=list(i.split() for i in open("Advent21.txt").read().split("\n"))
a,r=[[0,0,0]],[[0,0,0],[0,0,0]]
w=list(list(int(i) for i in i[1:]) for i in data[1:6])
a.extend(list(list(int(i) for i in i[1:]) for i in data[8:13]))
r.extend(list(list(int(i) for i in i[2:]) for i in data[15:21]))

def fight(myDam, myArm):
myHP,hisHP,hisDam,hisArm=100,104,8,1
myTDam,hisTDam=max(myDam-hisArm,1),max(hisDam-myArm,1)
myHits=hisHP/myTDam+(hisHP%myTDam>0)
hisHits=myHP/hisTDam+(myHP%hisTDam>0)
return myHits<=hisHits

minCost=9999
maxCost=0

for i in product(range(len(w)),range(len(a)),range(len(r)),range(len(r))):
if i[2]!=i[3]:
currCost,currDam,currArm=(sum(m[n] for m in (w[i[0]],a[i[1]],r[i[2]],r[i[3]])) for n in range(3))

if fight(currDam, currArm):
minCost=min(minCost,currCost)
else:
maxCost=max(maxCost,currCost)

print minCost
print maxCost


Advent21.txt
Weapons:    Cost  Damage  Armor
Dagger 8 4 0
Shortsword 10 5 0
Warhammer 25 6 0
Longsword 40 7 0
Greataxe 74 8 0

Armor: Cost Damage Armor
Leather 13 0 1
Chainmail 31 0 2
Splintmail 53 0 3
Bandedmail 75 0 4
Platemail 102 0 5

Rings: Cost Damage Armor
Damage +1 25 1 0
Damage +2 50 2 0
Damage +3 100 3 0
Defense +1 20 0 1
Defense +2 40 0 2
Defense +3 80 0 3
>>
>>51984566
What if I enter a letter that the text doesn't contain?

Like let's imagine I enter ZOMBIE and that there is no Z in my text.
>>
>>51984628
Haskell does not solve equations.
>>
>>51984630
Ah, right, thanks.
>>
>>51980761

I can't answer your question directly but I do know for sure that QT had a feature that will allow you to save/load UI states. Google it.
>>
>>51984628

You have issues.
>>
Why doesn't the inline extension have an option to embed .webm files, /dpt/?

It seems like an easy thing to implement that people would actually use.

>Why would people link to .webm files when they can just upload them as a file?
No sound.
>>
>>51984562
>int x;
>for (x=0;x=10;x++)
>{
>printf("test\n");
>};
Cause you programmed a neverending loop!
>>
Which programming language do cucks use?
>>
>>51983874
"politically conservative" does not necessarily mean "socially conservative" or "economically conservative"
>>
>>51984562
lmao kek'd
>>
File: 2FTTD.png (34KB, 1232x402px) Image search: [Google] [Yandex] [Bing]
2FTTD.png
34KB, 1232x402px
No programming today.
Studying and deriving some functions for a table of La Place transforms.
>>
>>51984645
then it's obviously an unsolvable problem

http://ideone.com/YxfzMd

shit ain't hard
>>
>>51984772

While that's true, I always find it entertaining that if you generally identify as a conservative, but support something that liberals might also support (say marriage equality or dude weed lmao) they are thoroughly convinced you support these things 'for the wrong reasons.'

Too good.
>>
new thread when ?
>>
>>51984867
dunno lol
>>
>>51980217
>>51980217

Just here to tell a newbie programming joke.

"Hey, have you worked on loops recently?"
"Not for a while."
>>
>>51984633
lads what do you think?

also to use it for your own individual input, change the last 3 numbers in the list to the dragon's HP, damage and armor respectively:
myHP,hisHP,hisDam,hisArm=100,104,8,1
>>
File: MEMES!.jpg (126KB, 1200x798px) Image search: [Google] [Yandex] [Bing]
MEMES!.jpg
126KB, 1200x798px
>>51984877
>pic
>>51984898
fucking lolz
>>
>>51984562
= IS FUCKING ASSIGNMENT
STOP
THIS
FUCKING
SHIT
READ A FUCKING BOOK YOU RETARD
>>
>>51985057

hmm yes

I can see what you are saying

but why
>>
>>51984765
c++
>>
>>51985083
Seriously?
>>
>>51985083
because you have working eyes
>>
Trying to make an old Motorola Droid running Gingerbread usable for shitposting and ssh shit.
>>
>>51985190
how is this programming related
>>
>>51985204
>how is programming programming-related
>>
If I have two vectors that both contain pointers to the same objects (basically, I have two of the same vector), does that take up twice as much RAM as just having one vector full of the pointers?
>>
>>51985233
I'm making gingerbread houses.
>>
>>51980659
54 plz
>>
>>51985161

Yeah yeah
>>
>>51984562
while (x = 10) means as long as the operation (x = 10) keeps succeeding, it will always evaluate to true, making an infinite loop.
>>
File: haxor.jpg (333KB, 1888x1232px) Image search: [Google] [Yandex] [Bing]
haxor.jpg
333KB, 1888x1232px
New thread:
>>51985347
>>51985347
>>51985347
>>51985347
>>51985347
>>
>>51985371
Dumbass
>>
>>51985371
We're not even at bump limit
FUCK OFF
>>
>>51985395
10 posts lmao
>>
>>51985334
there's a difference between = and ==
>>
>>51985424

Oh wow, thanks. I am truly a dumbass.
>>
>>51984823
this is because ameriburgers are too dumb to hold two political ideologies in their head at the same time.
>>
>>51980427
>_.defaults

Why not:
function View({ holder = 'body', tagName = 'div' }) {
...
};


>_.extend

Why not Object.assign?
>>
>>51984562
> /g/ - technology
>>
>>51980862
So edgy
>>
>>51983575
>had to write a complete C model checker in OCaml
I like OCaml, kind of, but theres no denying that the standard library is bullshit and not being able to rely on libraries cripples your progress.
>>
>>51985440
good strongly typed languages like C# wouldn't let that code compile in the first place.
>>
>>51985515
Assignments shouldn't have values in the first place, they should be void. It's just a hack to allow you write shit like "a = b = 10".
>>
>>51982657
>>51982796
l2lua
local function GetRandomColor()
return {math.random(0, 255), math.random(0, 255), math.random(0, 255)}
end

local brick = {}

brick.color = GetRandomColor()
for _, v in ipairs(brick.color) do
print(v)
end
>>
>>51985550
disgusting
>>
>>51982866
You can use the rest as an instruction, allowing you to use a single fetch to operate on a pointer.
>>
>>51983514
Terminally broken as has been noted many times. Julia too, before you mention it.
>>
>>51985611
If it were up to me, there would be no assignments. Just variable binding.
let <variable> = <value> in <expression>
>>
>>51985704
What's the difference?
>>
>>51985797
Lots of things that I'm interested in as a type theorist as well as a performance miser don't work if you can change the value of a variable, especially by assuming that a variable is a piece of memory on the stack. Like, you can't have a dependent type depend on a mutable variable, taking pointers to stack variables is dangerous, and if you have immutable variables they're much easier to optimally allocate registers for.

If you want to use the stack as a memory scratch space, use alloca().
>>
>>51984128
I get that lo/g/os reference desu
>>
>>51985855
oh, you just mean immutable variables? Those are nice. All languages should have immutable variables by default, that you have to opt out of. Like F#, Ocaml etc
>>
>>51985083
>but why

A long time ago, everybody realized that := was supposed to be assignment and then a group of niggers ruined everything by making it =, which meant that equality now had to be checked with ==.

The end.
>>
>>51985855
>If you want to use the stack as a memory scratch space, use alloca().
I know you. You're the retarded who was spouting this shit in a few days ago.

having mutable variables is useful as fuck. Way easier and safer than alloca(). Immuable is best, but if you have to mutatate, at least have a non shit way of doing it.
>>
>>51983566
I think it's not even fully compliant with C89
>>
>>51985919
in F# assignment and comparison both use =. You just can't mutate with =, so everything works out okay.
>>
>>51985890
Well, yeah, having immutable variables is the same as saying you don't have assignment. I'd go even further than that and say that you shouldn't be able to opt out of immutability without explicitly allocating memory.

I'm totally on board with using the same variable name twice, and simply shadowing the original, though. That doesn't break anything, since you're not actually moving a new value into the same storage.

>>51985932
I'm curious to hear why you think it's safer than something like alloca(). With alloca(), it's very easy to use capabilities to ensure that stack memory doesn't escape its scope, without complicating the language itself. Not if you can simply declare a variable and take an address to it. You could say "well don't allow taking addresses of variables", but then you're back to using alloca() or, even worse, making everything on the heap.
>>
>>51985464
>>51981534
>>51982890
thanks for that, you guys are right, and give me something i can actually work with, im just trying to get better, if there's any more please tell me
>>
>>51985988
>but then you're back to using alloca() or, even worse, making everything on the heap.
Why is anything on the heap?

Using variables is better because type safety. The compiler will stop you assigning different data types to the variable. It also gives the compiler more information about what happen at compile time.
>>
>>51986066
>pointers can't be type safe
Okay buddy. I'm not talking about C.

When I say alloca I'm generally talking about using the stack explicitly as a place to allocate blocks of memory, instead of making every variable take up stack space, which you can then modify using a pointer.

You think that I don't know about the benefits of typing when I mentioned both type theory and performance?
>>
On a scale of shit to very shit, how shit is my code? It's supposed to take a value of resistance, then tolerance, and generate any random ten numbers between the upper and lower tolerances.

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

void main()

{
int v;
int t;
int x;
float rlow;
float rhigh;

srand((unsigned int)time(NULL)); //Initialise rand function; only needs to be perfromed once at the start. (unsigned int) silences warning about data loss from converting time.

printf("Enter resistance (ohms):\t");
scanf_s("%d", &v);
printf("Enter tolerance (%%):\t\t");
scanf_s("%d", &t);
printf("\n");

rlow = v*(1 - (t / 100.f));
rhigh = v*(1 + (t / 100.f));

for (x=0;x<10;x++)
{
float r = (rand())/(RAND_MAX / (rhigh - rlow))+rlow;
printf("Possible Value = %.2f\n", r);
fflush(stdin);
};

getchar();
}
>>
>>51986107
>When I say alloca I'm generally talking about using the stack explicitly as a place to allocate blocks of memory, instead of making every variable take up stack space
What's the advantage? Why allocate to the stack, when you can just have a mutable variable that does that behind the scenes? It also lets the compiler know exactly how much stack space your function will use. How is getting a pointer to space on the stack not just meaninglessly more complicated and less abstract?

How is a type safe pointer to space allocated on the stack any different to a mutable variable? That's essentially what they are.
>>
>>51986200
The real problem with mutable variables is that they vastly complicate the language design, especially in a functional language based on some type theory, where variables have a very specific semantics that includes being immutable and referentially transparent.

It all has to compile down to alloca() in the end, anyways. With sufficient FFI, the language itself doesn't even have to assume the presence of a stack; it can all be part of library code, thus making it more portable.

I could see them being a syntactic extension that just abstracts stack manipulation, but I don't see the benefit of THAT, either. Now you've got two completely different and incompatible things that just look the same. Not sure how this is supposed to improve code.

>It also lets the compiler know exactly how much stack space your function will use.
Even C99+ can't guarantee anything, with variable length arrays. This simply isn't something that is necessary.
>>
>>51986408
>The real problem with mutable variables is that they vastly complicate the language design
F# has mutable variables with nothing more that the "mutable" keyword and the "<-" assignment operator.
let mutable x = 0
printfn "%x" x //0
x <- 1
printfn "%x" x//1

Looks pretty simple to me. Hardly complicates the language much. But tell me what is wrong with this, and how would you write something like this with your ideal language?
>>
>>51986469
%i rather
>>
>>51986151
    int v;
int t;
int x;
float rlow;
float rhigh;

disgusting
>>
>>51984967
I'm glad at least one person appreciated my joke.
>>
how do i average 3 ints in c
>>
>>51986668
It's literally impossible. You'll have to write the function in python and call it from C.
>>
>>51986692
How do you do it in Assembly
>>
should I try/catch everything in my videogame or just go in balls deep?
>>
>>51986792
You just throw everything and make a giant try-catch in the main
>>
>>51986792
Why do you need to try catch anything in a videogame?
>>
>>51986853
changing resolution, restarting the audio if the output device is messed up, state changes, that sort of thing
>>
>>51986909
>changing resolution
Why do you need it there?
>restarting the audio if the output device is messed up
makes sense
>state changes
why there?
>>
>>51986927
it's just anticipating incompatibility between operating systems, some sort of bug in either my program or the library interpreter

like if the library couldn't retrieve the resolution of the screen it's outputting on and it gets set higher than what is supported by the display the application would throw an error, right?

or if when doing a state change if it can't find the next .class for whatever reason

it shouldn't happen but you can't see every possible bug before it happens
I think I'll start using them, I convinced myself
>>
>>51987098
Why do you want to catch those kinds of errors? You should only attempt to catch errors you can handle. If the screen resolution changes in a fucked up way, you want you game to crash, not keep running with a black screen or whatever with no dump of crash data.
>>
File: ii.jpg (99KB, 600x800px) Image search: [Google] [Yandex] [Bing]
ii.jpg
99KB, 600x800px
>>51986834
This, with the error message "Something happened."
>>
File: Untitled.png (659KB, 1366x739px) Image search: [Google] [Yandex] [Bing]
Untitled.png
659KB, 1366x739px
>>51987159
no, see it just catches the failed change and goes back to how it was before
>>
>>51987331
You're hired!
>>
>>51987353
If that's the only way to do it, that's fine.
>>
>>51987353
>beginner Java game
pls no
Thread replies: 348
Thread images: 34
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y / ] [Home]

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
If a post contains illegal content, please click on its [Report] button and follow the instructions.
This is a 4chan archive - all of the content originated from them. If you need information for a Poster - you need to contact them.
This website shows only archived content and is not affiliated with 4chan in any way.
If you like this website please support us by donating with Bitcoin at 1XVgDnu36zCj97gLdeSwHMdiJaBkqhtMK