Quantcast
[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

2017/01/28: An issue regarding the front page of /jp/ has been fixed. Also, thanks to all who contacted us about sponsorship.

/g/ - Technology


View post   

[ Toggle deleted replies ]
File: 717 KB, 1000x793, dpt3.png [View same] [iqdb] [saucenao] [google] [report]
69304301 No.69304301 [Reply] [Original] [archived.moe] [rbt]

What are you working on, /g/?

Last thread: >>69292807

>> No.69304325
File: 685 KB, 2335x2507, 1546884724891.jpg [View same] [iqdb] [saucenao] [google] [report]
69304325

Getting laid, its not going so well pls help

>> No.69304330

first for OOP (。>﹏<。)

>> No.69304378
File: 104 KB, 750x914, 1506499146438.jpg [View same] [iqdb] [saucenao] [google] [report]
69304378

>>69304301
writing great code

>> No.69304400
File: 333 KB, 500x400, 1545573830577.gif [View same] [iqdb] [saucenao] [google] [report]
69304400

>>69304325
>pls help
getting off /dpt/ might be helpful. maybe, I'm not very familiar with this subject. otherwise try lisp.

>> No.69304409

>>69304325
learn haskell

>> No.69304420
File: 73 KB, 225x225, 1527357058944.png [View same] [iqdb] [saucenao] [google] [report]
69304420

>>69304301
this is always my favourite OP
great job!

>> No.69304435
File: 38 KB, 463x372, 1529557646430.jpg [View same] [iqdb] [saucenao] [google] [report]
69304435

haskell but with lisp syntax

>> No.69304441
File: 134 KB, 1000x494, javascript rocks.png [View same] [iqdb] [saucenao] [google] [report]
69304441

JavaScript rocks!

>> No.69304464

>>69304435
But why?

>> No.69304491
File: 438 KB, 512x512, 1522255708099.png [View same] [iqdb] [saucenao] [google] [report]
69304491

>>69304435
hackett?

>> No.69304546
File: 276 KB, 1066x600, 1512340225350.png [View same] [iqdb] [saucenao] [google] [report]
69304546

>>69304441

>> No.69304581

>>69304435
https://github.com/haskell-lisp/liskell

>> No.69304601

>>69304301
working on my toy compiler

>> No.69304654

>Professor explaining Java to class
>Everything is super fucky and autistic
>smugcnile.jpg
Every god damn time, why is this joke of a language still used?

>> No.69304683

>>69304654
>>Everything is super fucky and autistic
>joke of a language

would you elaborate please

>> No.69304702

>>69304683
Sure
>You can't use comparison operators in Java with the wrapper classes because they check if they're the same memory on the heap
This is retarded

>> No.69304710
File: 29 KB, 1162x890, 1514256260809.gif [View same] [iqdb] [saucenao] [google] [report]
69304710

>I'm better than you because I use C

>> No.69304722

>>69304710
>pic unrelated

>> No.69304732

>>69304435
But I use Haskell to avoid parentheses

>> No.69304742

What should I learn to be able to make money freelancing that isn't web dev?

>> No.69304748

>>69304702
That's the sane behavior. Object references are basically just pointers and that's how pointers compare.

>> No.69304757

>>69304702
C is exactly the same in this regard.

>> No.69304759

How can I make IntelliJ IDEA compile programs faster? Eclipse does it in an instant, IntelliJ by comparison takes forever.

>> No.69304767

>>69304702
but wrappers are objects, not primitives, the equal operator is working as intended.

>> No.69304802

>>69304742
>freelancing
>not webdev
Is that even possible?

>> No.69304807

>>69304702
This is just like C, silly.
strcmp(a, b)
a.equals(b)

>> No.69304846

Thinking on retaking an old project. Basically a RPG database with a nice front-end to facilitate gameplay without stopping every fucking time.

Probably going to use a babby script language since i only know C and am no up to the challenge of dealing with string search and string manipulation in fucking C (the only downside to this god level language).

>> No.69304906

Imagine C, but with objects and safe.

>> No.69304918

>>69304906
C where you can define functions in structs.

>> No.69304955

>>69304906
d?

>> No.69304959

>>69304918
I have a preprocessor that does that by appending the struct name to the function name

>> No.69304969

>>69304378
I worked at a pizza place when that was a popular meme, we got at least 2-3 calls a week from people asking for a boneless pizza and a 2 liter of coke

>>69304435
I'm working on a little lisp DSL and I'm using head/tail instead of car/cdr, so I guess that's haskell-y
The thing with haskell is that its biggest strength lies in its type system, but Lisp's biggest strength is more or less predicated on the lack of a type system. Sounds like an interesting idea, though.

>>69304654
Nim 1.0 will fix this, anon. Everything will be okay.

>> No.69304980

>>69304959
Yikes.

>> No.69304986

>>69304969
>Lisp's biggest strength is more or less predicated on the lack of a type system.
How so?

>> No.69305039

>>69304325

Are you trying to get laid as a top or as a bottom?
Are you looking for guys or for girls?
What methods have you tried?

>> No.69305046

>>69304906
C with traits

>> No.69305090

>>69304702
Well, first, it doesn't check memory.
And, second, I would consider it as a good example, rather than a bad one. Java doesn't hide implementation behind syntactic sugar, how is it a bad thing for academic purposes.

>> No.69305095

>>69304906
>C but safe
you'd have to massively change/mangle the language
or just use Rust

>> No.69305108
File: 844 KB, 500x281, 1530472215343.gif [View same] [iqdb] [saucenao] [google] [report]
69305108

>>69304969
>I'm working on a little lisp DSL and I'm using head/tail instead of car/cdr, so I guess that's haskell-y
just look at this dork

>The thing with haskell is that its biggest strength lies in its type system
not really
>Lisp's biggest strength is more or less predicated on the lack of a type system
even less

>> No.69305130

>>69304986
The way I see it, lisp's power is derived from its simplicity, and the way that the line between code and data is blurred to the point where it's questionable whether there's even a line at all. Types add a third thing into the mix, and it isn't necessarily so clear (at least to me) how they would fit in syntactically. I guess you could cons type information onto stuff, that doesn't help with compile-time verification of behavior.

>> No.69305137

Imagine Haskell, but actually will get you employed.

>> No.69305163

i am learning Go
why do you hate Go its a beautiful language imo.
I should have never doubted the programming God, Ken Thompson

>> No.69305187

>>69305163

The complete lack of generics does not reflect well on the language.

>> No.69305188

>>69305130
https://docs.racket-lang.org/ts-guide/

>> No.69305204

>>69305163
isn't that the language where every single function call ends up having

returnvalue, errorcode = somefunction()
if (errorcode) {...}

because it has no other error handling

>> No.69305205

>>69305137
https://wiki.haskell.org/Haskell_in_industry

>> No.69305236

>>69305108
>not taking the opportunity to remove decades-old cruft
car/cdr are a relic of a bygone time, anon

>>69305137
so... Haskell?

>> No.69305267

>>69305236
ironic considering you're using one of the oldest and dedest langs

>> No.69305332

>>69305236
naming conventions don't make your code "haskell-y"

>> No.69305349

>>69305163
It has most of the weaknesses of C and none of the advantages. Goroutines are cool, but Nim does literally everything else Go does, only it has a useful type system, more powerful abstractions, and support for non-GC and bare metal applications.
t. professional C developer

>> No.69305361

>>69305204
There's 1 p good argument for that style in my view, and that's the whole cost of constructing exceptions thing. In an article they said they had absurd performance issues in Java with IOExceptions and such, so they made Go that way.

Now that doesn't excuse all the other annoying aspects of this shitlang.

>> No.69305403

>>69305361
The semantics of exceptions can easily be decoupled from an implementation like that. Swift basically does that and implements them as a secondary return path with syntax sugar.

>> No.69305410

>>69305163
whereas most mainstream languages really are languages of the 70s, gopher managed to make it worse.
Go's literally Algol

>> No.69305412

>>69305349
>Nim does literally everything else Go does
except having a stable 1.0 and ecosystem making it usable

>> No.69305426

In c++
const TypeName* get_ptr() const { return ptr; }
TypeName* ptr;
auto newPtr = get_ptr();

newPtr is const, right? I assume I can access const methods but I cannot modify it in any way

>> No.69305430

>>69304980
Ever heard of name mangling?

>> No.69305433

Go
what the hell is the difference between capacity and length and why does it reduce the capacity here?
func main() {
s := []int{2, 3, 5, 7, 11, 13}
printSlice(s)

// Slice the slice to give it zero length.
s = s[:0]
printSlice(s)

// Extend its length.
s = s[:4]
printSlice(s)

// Drop its first two values.
s = s[2:]
printSlice(s)

s = s[:]
printSlice(s)
}

func printSlice(s []int) {
fmt.Printf("len=%d cap=%d %v\n", len(s), cap(s), s)
}

>> No.69305456

>>69305426
That's correct.

>> No.69305457
File: 779 KB, 1280x720, 1536218461119.png [View same] [iqdb] [saucenao] [google] [report]
69305457

>>69305361
>the only alternative is exceptions

>> No.69305458

>>69304802
Web dev makes me want to kill myself

>> No.69305462

>15 years ago
>if you made a good library people would accept it into a distributions package repository on Linux
>you actually had to write something of value and good
>now
>npm, cargo, maven, and so forth
>every chucklefuck can upload their own shitty version of anything
>most shit is half broken or never finished
>bugs and exploits all over
>absolute fucking mess
where did it all go wrong

>> No.69305472

>>69305430
The thing that's done automatically by the compiler and not a preprocessor hackjob?

>> No.69305483

>>69305462
that's not wrong though
the responsibility is pushed on the maintainers.
haskell did it right by having both hackage and stackage

>> No.69305487

>>69305462
>i hate freedom
But yeah, have fun trying to gatekeep and QA every single submission to your OS/pm

>> No.69305488

>>69305456
Thanks

>> No.69305518

>>69304441
I unironically like Javascript

>> No.69305520

Can someone suggest a GUI library that isn't GTK or QT for X11?

>> No.69305527

>>69305520
your own.

>> No.69305535

>>69305520
wxwidgets

>> No.69305540

>>69305462
This is still the case for C/C++

>> No.69305562

>>69305403
That sounds pretty good desu senpai.

Also now that I think of it, either types like Scala's (or wawr's) Try can help with that as long as the exception is never actually thrown. (And that can also be theoretically rewritten in the same way I guess)

>> No.69305566

>>69305472
It's a proof of concept. I wouldn't suggest that anyone use C that way. I do a dozen prototypes for every serious compiler that I write. For prototypes of languages that are similar to C, it's easier to just output C.

>> No.69305597

>>69305433
It probably reallocated to avoid extending into the original array. That's my guess.

Could you print the address of the underlying array in the slide (with %p) too and post the output please? (I don't have a way to run Go code rn (thankfully))

>> No.69305599

>>69305562
Using monads to model errors works out pretty comfortably in languages with lean function application syntax like Haskell.

>> No.69305609

>>69305433
I'm not a Go memer, but capacity refers to how many elements have been allocated and length is how many elements have actually been stored.

>> No.69305629

>>69305090
>Java doesn't hide implementation behind syntactic sugar
The reason people get confused is that's exactly what Java does.
In C when you deal with pointers you know it very well. In Java your references are very transparent aside from examples like this.
I don't think they should take pointers away but if you're gonna provide an interface make it consistent. Provide an address of operator to replicate this compare and make operator== call equals.

It's too late now of course. But that's how it should have been done. It just falls out of the choices they made.

>> No.69305630

>>69305462
imagine if the former still was the case everywhere and consider SJWs influx in FLOSS communities
im really OK with current state of affairs

>> No.69305644

>>69305630
i wish 4chan banned ESLs

>> No.69305664

>>69305644
I wish 4channel banned phoneposting.

>> No.69305668

>>69305462
>where did it all go wrong
There's nothing inherently bad about having a pm containing everything in the universe. The problem is that users of the pm aren't discerning. Leftpad and the recent actual malicious attack on npm shows that.
It's a culture problem.

>> No.69305672

>>69305629
I disagree. It's clear in Java what is a reference and what isn't - more so than other languages that follow in its footsteps such as C#.
A consequence of Java's verbosity is clarity. In C# the == operator might silently dereference or it might not. In Java == always means ==, and dereferencing is only ever done with the dot operator.

>> No.69305688

>>69305644
Hi I scored 120 on toefl. Can I post here? Sorry for bad English.

>> No.69305704

>>69305629
Is it a primitive that has been unboxed? It's not a reference
It is an Object? It's a reference

>> No.69305894

>>69305644
>on a site dedicated to Japanese culture
>an ESL culture
>getting upset over ESLs
Let me guess, you hate anime too?

>> No.69305938

I'm waiting for a web page to load.
Does anyone scream in pain internally while waiting for web pages to load?
Web devs are an insult to humanity.

>> No.69305952

>>69305938
try not running a 10 year old computer

>> No.69305973

>>69305952
To load text and images of similar quality to what I did 15 years ago?
No thanks.
If you've contributed to this situation just kill yourself after encouraging your office to do the same.

>> No.69305989

>>69305973
>>69305938
Really sounds like a personal problem. My Ras Pi doesn't even have problems on the web.

>> No.69306004

Tried all day to get a piece of test equipment communicating over a direct TCPIP socket connection. National Instruments VISA application successfully communicates, PyVisa cucks itself somehow even though ALL the config is the same (AFAIK). Is Python just scuffed?

also FUCK labview, FUCK jannies and FUCK National Instruments

>> No.69306006

>>69305520
gtk

>> No.69306024

>>69305938
Most likely it's not a web page loading it's javashit building html on the frontend.

>> No.69306028

If I use two linked lists to add two variable-digit numbers, (say, 34055122 and 135, for example), is there anyway to do this without calculating the length of the linked lists beforehand?

>> No.69306051

>>69305938
>BBBBBUT MUH VIRTUAL DOM
>BBBBUT IT SHOULD BE FASTER
Webmonkeys are morons, sadly.

>> No.69306063

>>69306028

Assuming a doubly linked list of digits, traverse both to the end and then work backwords, with a carry digit

>> No.69306070

>>69306004
>National Instruments
Texas*
FTFY

>> No.69306104
File: 133 KB, 1280x720, 1530387242352.jpg [View same] [iqdb] [saucenao] [google] [report]
69306104

>get new job
>their software is written in Java
>they unironically use Wintendo /v/ toddler toy OS
>call everyone brain-dead Pajeet street shitter (THEY ARE)
>install Arch Linux on their servers
>start full rewrite in C
>fizz buzz proof of concept completed in only 5 days

>fired for not doing my job
>forcefully removed from the premises
???
Why is everyone so fucking retarded? Fucking FUCK.

>> No.69306113

I want to work at IBM
Especially, Red Hat

>> No.69306142

>>69306113
Are you North Indian?

>> No.69306146

I wish nim or crystal would hurry up and mature. I'm tired of using all these shit langs.

>> No.69306149

>>69304301
Lisp is the most powerful programming language.

>> No.69306160

>>69306142
No. But I'm from Bangladesh, currently living in Australia.

>> No.69306177

>>69306146

You could try helping out the development with one of them.

>> No.69306199

>>69306146
You're why nim and crystal aren't maturing
>lmao i want to reap the rewards while contributing nothing to the cause

>> No.69306241
File: 60 KB, 922x332, file.png [View same] [iqdb] [saucenao] [google] [report]
69306241

>>69306024
I'm not that guy.
It varies.
Here's just some times from just now.

I measured to first visible actionable content was available. For CNN that was the entire page practically (white->full with no perceptible step in between). For youtube it was when I could see text or thumbnails (both were seen at the same time). For 4channel it was RMS's face.
And they're obviously not the most egregious examples.
>>69305938
I also find it extremely annoying.

>> No.69306243

>>69306146
if you want to larp as a 1337 hacker do it before the language catches on

>> No.69306250

>>69305130
>>69305188
>>69304986
As I see it, the important thing is you can't check the types at compile time (without severely restricting macro capabilities which would make it pointless; typed Racket appears to mix in untyped code) and you can't really optimize the program (considering that the main part of the program might be created only when you run it) which sounds like a terrible combination with non-strict evaluation. Haskell needs lots of optimizations during compilation to make it work well. Maybe it would be possible with JIT compilation but I have no idea Also, supposedly the main point of Haskell was making a lazy functional language, the rest is consequence of that idea.

>> No.69306273

>>69306146
Why Crystal?

>> No.69306353

>>69305520
FLTK
enlightenment

>> No.69306453

>>69306250
>considering that the main part of the program might be created only when you run it
Macros are expanded at compile time. You can do type checking/specialization after macro expansion.

>> No.69306454

>>69305520
https://github.com/ocornut/imgui

>> No.69306464

Is there any performance difference between Scala and Java when executing similar code?
Is there any performance hit when calling Java from Scala?

>> No.69306496

>>69306464
nobody cares

>> No.69306507
File: 192 KB, 710x384, plsnobully.png [View same] [iqdb] [saucenao] [google] [report]
69306507

>>69306496
I care

>> No.69306509

>>69306454
>Bloat-free in title
>C++
red flag

>> No.69306515

>>69306464
1. Yes. You use a lot of recursion in Scala but without TCO this mandates trampolines, which are slow.
2. Hardly ever. Scala was designed to call Java efficiently.

>> No.69306523

>>69306464
>Is there any performance difference between Scala and Java when executing similar code?
Not inherently.
>Is there any performance hit when calling Java from Scala?
None at all.

>> No.69306532

>>69306509
It seems to provide most of its functionality in form of namespaced free functions.
https://github.com/ocornut/imgui/blob/master/imgui.h
Doesn't look like very C++-y code.

>> No.69306543

>>69306515
There is TCO right? (Well partially, mutually recursive doesn't work and it's not continuation based TCO, but self tail recursion is compiled into a loop no?)

>> No.69306603

>>69306453
Oh yes, now I see this issue isn't related with macros but with eval. You could create an arbitrary program during execution and eval it. Sure you could optimize the part that you are just eval'ing (as a part of eval or as a separate step) but it could access arbitrary data in your program and therefore you wouldn't be able to optimize out pretty much anything.

>> No.69306730

>>69306241
>not suing YouTube classic
>not disabling the polymer cancer

>youtube.com/?disable_polymer=1
>fast as fuck

>> No.69306744

>>69306730
measure.

>> No.69306770

>>69306603
>it could access arbitrary data in your program and therefore you wouldn't be able to optimize out pretty much anything.
I don't see how eval changes anything. If you have (+ x y) and you've declared X and Y to be integers, then the compiler can specialize the + function into a single machine instruction. If you set X or Y to something other than an integer inside of an eval, that is your own error and you deserve whatever happens.
Seriously. Don't use eval.

>> No.69306772

>>69304301
I like to imagine the thread is just full of cute girls tapping away at theyr keyboards.

>> No.69306778

>>69306744
measure what?

YouTube without the polymer thing is fast as hell

>> No.69306792
File: 295 KB, 557x671, 68cd4dd0.jpg [View same] [iqdb] [saucenao] [google] [report]
69306792

I want to make a data structure that holds my program's configuration, it needs to be a tree, be easily iterable, and have a quick access time. I tried doing it with std::map<const char*, Item>, so it compares the actual pointer and I can access it like map["b"]["a"], but that's kind of ghetto and the performance drop is massive.
The best solution I can think of is:
struct Item {
UniversalValue value;
Item items[] = nullptr;
};
enum ConfigItemsID {
a,
b,
};
enum BItemsID {
c,
};
Item config[] = {
{ "13" }, // a
{ "-2", { // b
{ "-6" }, // c
},
};

but this is obviously not a very elegant way.
What is the best way of doing this? I can sacrifice some performance.

>> No.69306899

>>69306770
The thing is, when writing Haskell you often would like the compiler to optimize out some data structures. Lists are the most common example. Lists in Haskell are cool because intermediate lists can be optimized out. However, if at some point you use eval, you can't know what elements of the list you'll access and you might end up needing the intermediate lists (so you must always have them). If Haskell didn't do these optimization it would be terribly slow and hog much more memory.

>> No.69307035

>>69306899
Isn't that just lazy evaluation? I don't see how types help you there. You can do lazy evaluation in lisp, though its not built-in to the language as in Haskell.

>> No.69307044

>>69306792
std::map has an extra level of indirection which slows things down. I'd just do a quick red-black tree. If at any time you're only accessing a subset of the items, try a splay tree.

>> No.69307125

>>69305332
>-y
>I guess
These combined mean "in a loose sense" or "sort of, but not really." I would suggest learning the english language before attempting programming, anon

>>69305412
nimble is a fantastic package manager and the available packages are rock-solid in my experience.
The core fundamentals of Nim have not changed in years, unlike a couple competitors (rust and C++). At least when Nim hits 1.0, it will actually be a clean, well-rounded and expressive language, unlike Go which already is going to need an incompatible second version just to be fucking useful.

>> No.69307165

>>69307044
Yeah but the thing is that I theoretically can just skip all the finding and just straight up get the value I want, like with the example I provided or
struct {
Value a;
struct {
Value c;
} b;
} config;

config.b.c;

But I can't iterate it very easily. I'm sure this would be much easier in Rust or Go or even D, but I'm stuck with C++.

>> No.69307260

>>69306792
Jesus, just write your config file in JSON, YAML, or Lua and load it in. It's a configuration module, performance isn't important. If you are going to be doing a lot of accesses deep into the table, just reference it directly instead of going through all the layers of indirection.

>> No.69307331

>>69306792
anon, you're over-complicating things. remember: benchmark before you optimize. I can guarantee that your config file is not the bottleneck of your program.

>> No.69307354

Are "coroutine" systems that don't yield back to a caller, but yield back to an event loop only really considered "coroutines"? When I think of coroutines I think of Go or Lua. Python generators suck, and it seems like the only usefulness of await is to allow a program to take advantage of downtime when it's waiting for your shitty anime avatar to finish downloading.

>> No.69307371

>>69307165
Config is usually stored in some kind of global map which is read-only after being created. It's iterable, like you want, and very maintainable.

If you have under 20 items of config, though, I would just put it in a struct like you did.

>> No.69307426

>>69307331
No it's not, but finding the values 1000 times a second is just dumb.

>>69307371
What do you mean by global map? Can you give me some reference? And I have a lot more than 20.

>> No.69307454

>>69307426
>but finding the values 1000 times a second is just dumb
Yeah... write your program like a retard and performance will go down.

>What do you mean by global map?
You do know that you can put data outside of a function, right? global data?

>> No.69307481

>>69307260
>load JSON/YAML/lua in C++
Yeah just pull in another dependency for your simple configuration file.
Why not?
Lets embed V8 and use some node.js library for writing it out while we're at it.

>> No.69307483

>>69307426
Why don't you cache the values in variables when you use them? In my system, for example, I fetch a piece of configuration at most once per subsystem.

>> No.69307500

>>69307426
this is a case where a global variable is actually appropriate. Encode your configuration flags into a struct to it's type-safe. parse, write the struct. Simple as that.
If you're paranoid, have an inlined accessor function with an assertion statement that gets thrown if something tries to read the config before it gets written.

>> No.69307503

>>69306792
You sure you wanted std::map and not unordered_map?

>> No.69307535

Have you ever been spoiled by an editor that make it impossible for you to want to use languages that can't be used in that editor or have another editor with the same functionality?

>> No.69307542

>>69307454
>Yeah... write your program like a retard and performance will go down.
So referencing the values is writing your program like a retard?
I'm not going to bother with initializing the aliases to their correct pointers in the map.

>>69307454
>>69307500
>kind of global map
I thought that it's some specific kind of "global map" and that it's a design pattern or something.

>>69307483
That's messy. I don't want to repeat myself while coding, I want to declare the items and initialize them with their default values in one place, also access them directly.

>>69307500
No.

>>69307503
I actually tried unordered_map first.

>> No.69307544

>>69307035
This is true, however, adding lazy eval in a (kind-of) general sense appears simple - look to the clazy library.

>> No.69307567

>>69307481
>simple configuration file

>Is it less than 20 values of known type?
>Are those types easy to parse?
>Is the data totally flat (no hierarchy)?

Okay, you have a very simple config, go ahead a write your own little custom thing, just make sure to document all the fields somewhere. If you said "no", to any of the above, you have a non-trivial configuration and you absolutely should not be writing some jankyass custom parser for that shit in a format no one will ever understand. Use standards, people work well with standards.Code is less shit with standards. If you build process is so fucked that adding a dependency is an issue, that probably needs to be junked as well.

>> No.69307634

>>69307542
>design pattern
it's C++. If you ask 10 people about correct design patterns in 3 revisions of C++, you'll get 30 unique answers. The map is slower, yes, but that's not what actually matters- the difference is negligible. Using a struct will allow the compiler to pick up bugs for you before they occur, since the struct describes only correct keys to the map. It also makes references to the config type-safe, further reducing bug potential. It also means that you'll likely be verifying the config file all in one place before any code relying on the config executes, which helps promote reliable, "not-going-to-write-half-a-file-then-crash" code.

>> No.69307644

>>69307542
>I actually tried unordered_map first.
Why did you change? I don't foresee configurations needing to be read in any particular order.
>>69307567
>Is it less than 20 values of known type?
Why would more values be a serious issue? Especially at such a low limit like 20.
>Are those types easy to parse?
>Is the data totally flat (no hierarchy)?
Sure if your configuration file allows you to specify closures you're clearly in a bind doing it yourself. But if we're talking nested objects at worst (like we'd be constrained to in JSON) it's still trivial. Arguably once you've reached that there's less reason to do it yourself since you're already looking at a substantial implementation.
If this is your normal case you're fucked in the head and your program is probably awful.
So I guess it doesn't really matter then because nobody will use it.

You've really convinced me anon. Someone that would be convinced by you should probably just pull in a JSON parser for any type of configuration.
So, which C++ JSON library do you recommend?

>> No.69307701

>>69307644
>I'm special
>I can do it better than everyone else
>I actually think accessing a field in one-deep map is a serious performance defect
Please use this. For us.
https://github.com/nlohmann/json

>> No.69307780

>>69307567
>>69307634

Imagine this:
struct {
struct {
Value field1 = something;
...
Value field4342 = something;
} nested;
Value field1 = something;
...
Value field24556 = something;
} cfg;

You obviously cannot iterate it, so the only way to save them is doing something like:
Save(cfg.nested.field1);
...
Save(cfg.nested.field213478);
Save(cfg.field1);
...
Save(cfg.field2341241);

The same goes for loading.

Now std::map is much easier to iterate, but the access time is considerably worse, producing dumb inefficient executables that can probably be improved.

>>69307483
The problem still persists, because I have to actually create the caching variables, and that's as messy as the code above.

>>69307701
Saving is easy. That's not the problem. I want the correct data structure.

>> No.69307811

>>69307644
>So, which C++ JSON library do you recommend?
I would recommend not using C++.

>> No.69307849

How good is javascript at creating and handling forms? I just want to create a website full of apps to help run this esports league. I don't think I'll need anything too advanced, but I don't feel like using full java swing just to do it.

>> No.69307850

>>69307780
In software, we often sacrifice perfect performance for maintainability. It's not just laziness. It's the art of getting things done. Otherwise, we'd just use assembly for everything.

>> No.69307858

>>69307780
if you actually need it to be iterable for some reason, then use map. You're overthinking this.

>> No.69307944
File: 14 KB, 501x501, weeeeeeeeeeeeeeeeeeeeee.jpg [View same] [iqdb] [saucenao] [google] [report]
69307944

Are you guys excited for Ada 202x?

>> No.69307983
File: 249 KB, 500x375, 1541907660255.gif [View same] [iqdb] [saucenao] [google] [report]
69307983

>>69307944
install Nim.

>> No.69307989

>>69307983
Maybe once it hits 1.0.

>> No.69308326

Idea: strided types. Instead of structs necessarily being contiguous and having their fields interleave in an array, the field offsets can depend on the array length so as to end up with a structure of arrays layout. The only limitation is that unless you have an entire array of them, you can only refer to them indirectly (sort of like opaque types). Slices into such an array are not contiguous either. They, in turn, would be strided.

This would allow e.g. taking a rectangular slice of a 2D array, and it would be great for vectorization and optimizing for CPU caches.

>> No.69308348

>Just BTFO my entire class in a measly project.

Who here /Bitchin/ ?

>> No.69308360

>>69305458
>Web dev makes me want to kill myself
Why?
t. Freelancing web-dev

>> No.69308468

whats the best ide for c++

>> No.69308471

Have you guys ever read an entire language spec or just learn from what books tell you?

>> No.69308478

>>69308468
visual studio

>> No.69308486

>>69308326
Would be very useful for something like convolutional neural networks or the like.
I fail to see how this is useful outside of those niche usages.

>> No.69308489
File: 317 KB, 793x3106, 1545002376257.png [View same] [iqdb] [saucenao] [google] [report]
69308489

>>69308471
I set a goal and start putting shit together from what i know.
Also pic related

>> No.69308503

>>69308471
>Have you guys ever read an entire language spec
Very few people do and should do this. Only read the documentation of things you are confused about.

>> No.69308516

>>69308503
But what if you never know about a cool feature because you didn't read the spec?

>> No.69308518

>>69308486
They don't need to be widely applicable. Just an option on top of basic aggregate types (structs and arrays) that's there for when you really need it. Unions kind of are in the same boat.

>> No.69308524
File: 95 KB, 720x852, todd disliked that.jpg [View same] [iqdb] [saucenao] [google] [report]
69308524

>>69308489
Amerijeets everyone.

>> No.69308527

>>69306507
thank you anti bully poster, people can be mean

>> No.69308539

>>69308516
because i've read docs before and been like oh most of this isn't relevant to me, this is a waste of time

>> No.69308546

>>69308516
That is why be up to date with the language by being involved. You trying to find the unique/cool stuff alone is way worse than you abusing the fact that 1000 other people is using the language and one of them stumbled upon that obscure feature and asking about it in a chat and someone random nerd, who HAPPENS to know about it answer them.
not even the best programmer know their own language perfectly well.

>> No.69308548

>>69304702
>"C does it this way so it must be good!!!"
Idiots. Rust got this right: if you want a pointer comparison, you explicitly ask for it.

>> No.69308570

>>69308518
I am pretty sure this data structure is only 1 indirection/container away from your regular array
i.e. only need to abstract away the populating of said array

>> No.69308574

>>69308548
Ada*

>> No.69308577

>>69305108
>not really
Any programming language's strengths or weaknesses pretty much depend on the underlying type system, and Haskell's is top.

>> No.69308624

>>69307780
just use macros.

// config.hpp
YBEGIN(cfg)
X(Value, field1, something)
X(Value, field2, something)
...
YEND(cfg)
...

// config_struct.hpp
#define YBEGIN(_) struct {
#define YEND(NAME) } NAME;
#define X(TYPE, NAME, INIT) TYPE NAME = INIT;
#include "config.hpp"
#undef X()
#undef YBEGIN
#undef YEND

// config_save.hpp
#define YBEGIN(NAME) { auto& _obj = NAME;
#define YEND(NAME) }
#define X(TYPE, NAME, INIT) Save(obj.NAME);
#include "config.hpp"
#undef X
#undef YEND
#undef YBEGIN

or something like that

or wait until c++23/5/7 for metaclasses and reflection

>> No.69308629

>>69308570
It's not like you can't do it manually and carefully by using a structure of arrays. Just like how you can use manual offsets into a chunk of memory instead of using a struct. I don't see why not to make it language level. It's basically just a small tweak to how field lookup and array indexing is translated to addressing, plus some type rules to keep it sensible.

>> No.69308641

>>69308577
How does Ada compare to Haskell in terms of type? Both are strongly typed. Types play a big deal in Ada and you can define all kinds of things like subsets, ranges, bit sizes, and so forth.

>> No.69308696

>>69308629
>I don't see why not to make it language level
If you are talking about C++, which I feel like you are. Then I am pretty sure the committee is pretty clear that "niche" usages will not be considered.

>> No.69308707

>>69308577
F* > Idris > Agda > Shit > Hasklet

>> No.69308745

>>69305894
You can tell he's not Japanese because when the Japanese attempt to speak English it's CUTE, and his post wasn't cute. So he should fuck off and learn proper English.

>> No.69308763

>>69308696
No I'm not. I'm talking language design in general.

>> No.69308807
File: 36 KB, 597x579, who.png [View same] [iqdb] [saucenao] [google] [report]
69308807

>>69305644
>>69308745
shut up faggot, not everybody is a native english speaker and we can post here too. one of good things on 4chan, people have different opinions.

>> No.69308826

>>69308807
That's nice and all but learn proper English.

>> No.69308843
File: 65 KB, 387x382, happy anime.jpg [View same] [iqdb] [saucenao] [google] [report]
69308843

>>69308826
anime bring excellent luck

>> No.69308894
File: 58 KB, 149x148, animu.png [View same] [iqdb] [saucenao] [google] [report]
69308894

>Reading a post in comp.lang
>Some guy is angry as fuck about the one major compiler developer forcing GPL down everyones throat

never knew people like this existed

>> No.69308943

>>69308894
nobody cares?

>> No.69308957

>>69308943
Thanks for your reply.

>> No.69308960
File: 433 KB, 1000x1317, 1545378452084.jpg [View same] [iqdb] [saucenao] [google] [report]
69308960

>>69306772
Silly anon, we ARE all cute girls tapping away at our keyboards.
Pic related is me right now

>> No.69309016

>>69304301
I finished and wrote the solution for HTDP 2nd Edition ch. 1 as cleanly as possible. Ch. 1 doesn't make you write functions that take arguments but instead makes you define a bunch of constants and do stuff with them, so I deviated from it slightly.
"Exercise 1"
(define (pythagorean x y)
(sqrt (+ (sqr x) (sqr y))))
(pythagorean 3 4)

"Exercise 2"
(define (underscore-join x y)
(string-append x "_" y))
(underscore-join "hello" "world")

"Exercise 3"
(define str "helloworld")
(define i 5)
(define (underscore-insert x y)
(string-append (substring x 0 y) "_" (substring x y)))
(underscore-insert str i)

"Exercise 4"
(define (del-ith x y)
(string-append (substring x 0 y) (substring x (+ y 1))))
(del-ith str i)

"Exercise 5"
(require 2htdp/image)
(define (tree scale)
(overlay/xy (circle scale "solid" "green")
(/ scale 2) scale
(rectangle scale (* scale 4) "solid" "brown")))
(tree 10)

"Exercise 6"
(define cat [CAT PICTURE) ; PIC OF CAT HERE
(define (image-area x)
(* (image-width x) (image-height x)))
(image-area cat)

"Exercise 7"
(define (mall-OK sunny friday) ; True if (not sunny) and (is friday)
(and (not sunny) friday))
(mall-OK #true #false)
(mall-OK #true #true)
(mall-OK #false #true) ; True

"Exercise 8"
(define (tall-or-wide x)
(cond
[(< (image-height x) (image-width x)) "wide"]
[(= (image-height x) (image-width x)) "square"]
[(> (image-height x) (image-width x)) "tall"]))
(tall-or-wide cat)

"Exercise 9"
(define (in x)
(cond
[(number? x) (if (rational? (sqrt x)) x (* x -1))] ; Make num pos if neg
[(string? x) (string-length x)]
[(image? x) (image-area x)]))
(in 10)
(in -10)
(in "chocolate cake")
(in (tree 10))

"Exercise 10"
(string>? "stay up" "go to sleep") ; I refuse to sleep per exercise instruction

>> No.69309152

Give me your stinkiest shitposts on C#. I'm about to spend a few years amassing uni credits with it.

>> No.69309170

>>69309152
what kind of fucking retard goes to uni for a microsoft-specific language

>> No.69309209
File: 256 KB, 500x561, 1544845082238.jpg [View same] [iqdb] [saucenao] [google] [report]
69309209

>>69309170
Slim pickings, man. It was either this or continued unemployment and general depression.

>> No.69309253

>>69308960
lose some weight

>> No.69309266

>>69308548
Tranny detected

>> No.69309449

>>69309253
Homo

>> No.69309466

>>69304301
Learning React Native. It feels like a step up from web programming, kinda simple and easy. Anyone got any tips?

(I am a CS major so this is a cake walk)

>> No.69309482

Canorzle

>> No.69309488

What's a good way to find a random number between two numbers in Java?

>nextInt(int bound)
I figured this, but it default starts at 0 and you choose the bound. How do you choose the origin and keep it Int?

>> No.69309498

>>69309488
+

>> No.69309536
File: 1012 KB, 1931x1300, cute girl(programmer).jpg [View same] [iqdb] [saucenao] [google] [report]
69309536

>>69309266
you're thinking of haskell anon

>> No.69309572

>>69309488
By not being an idiot. Maybe gender studies is more your speed.

>> No.69309586
File: 117 KB, 300x299, 1530885271762.png [View same] [iqdb] [saucenao] [google] [report]
69309586

>>69309498
fuck sake, for some reason I thought to use a comma and then just left it
>>69309572
damn nigga, who hurt you? talk about being a snowflake, geez.

>> No.69309593

>>69309536
>mentally ill tranny
>haskellfag
checks out

>> No.69309643

>>69309466

You want /wdg/, not /dpt/, Anon.

>> No.69309649

>>69309466
BEGONW

>> No.69309672
File: 211 KB, 718x727, 8C8B36DA-EBE3-4FE2-97B9-E3393B46C79C.png [View same] [iqdb] [saucenao] [google] [report]
69309672

>>69304710
WE MUST GO DEEPER

>> No.69309679
File: 278 KB, 506x662, 0348C587-7E03-4162-AF41-39F7D48729F3.png [View same] [iqdb] [saucenao] [google] [report]
69309679

>>69309672

>> No.69309708
File: 800 KB, 1919x1079, D03AA189-7C0A-4681-AFC3-98E0C7EE65B1.png [View same] [iqdb] [saucenao] [google] [report]
69309708

Man, I like coding in Python, JavaScript, and Assembly. Even among programmer outcasts I don’t fit in.

>> No.69309771

>>69309672
>>69309679
>>69309708
dumb phoneposters

>> No.69309830

Redbull me on nim. Has it been used in video game development yet?

>> No.69309875

>>69309830
https://github.com/fragworks/frag
https://github.com/VPashkov/awesome-nim#game-development
There's really nothing stopping you from learning and making games in it.

>> No.69309886

>>69309875
Thanks senpai

>> No.69309901

>>69309886
There's also https://github.com/nim-lang/sdl2 if you find those too immature.
and https://github.com/oprypin/nim-csfml
But library bindings are pretty gross, and i'd avoid them if you can.
There's also https://github.com/nimious/vulkan

>> No.69310029

>>69309901
nim is too immature

>> No.69310038

>>69310029
Not really.
They're not really breaking things anymore, and there's not a whole lot of major 1.0 goals left.
The language is pretty much at .7-.8 right now.
Unless by immature you mean
>I want python-tier do-everything-for-me libs
then sure.

>> No.69310043

>>69309875
>engines but no games

>> No.69310058

>>69310043
https://github.com/StefanSalewski/nim-chess3
https://github.com/krux02/opengl-sandbox/blob/master/examples/tetris.nim
https://gitlab.com/define-private-public/LGJ2017
https://github.com/ftsf/nico
https://impbox.itch.io/smalltrek
https://impbox.itch.io/moving-in
https://impbox.itch.io/vektor2089

>> No.69310059

>>69310038
It's not even stable 1.0, it's immature after nearly a decade lmao.

>> No.69310097

>>69310058
>ludum dare entries, chess and tetris
embarrassing

>> No.69310109

>>69310097
>it doesn't count unless it's a AAA game made by atleast 300 people, selling atleast 10 million copies and making atleast 500m dollars
don't hurt yourself with all those posts.

>> No.69310254

>>69310109
a few indie games would be acceptable at least

>> No.69310265

>>69310254
what the fuck are you on about? Those are indie games?
Or do you mean you want to see people pay $100 to get on Steam so they can be """"certified""""?

>> No.69310388

>>69304301
I'm like 92% done with the first CS assignment of the year!
It's basically Six-Degrees of Kevin Bacon, but with a bunch of memory management while also using a bunch of C++ features like lambdas and such.
The algorithm's working, but for some reason it's slow as molasses (don't worry, I'm passing everything as a const reference).
I still have like a week to finish, so hopefully this gets sorted out.

>> No.69310494

>>69310388
>it's slow as molasses
>a bunch of C++ features like lambdas and such
Coincidence?

>> No.69310725

>>69310494
The database part of the assignment works like a charm. I'm probably just doing something weird and inefficient in the BFS search.

>> No.69311358

>>69308489
>Google how to do some very simple thing in PURE Javascript
>So you dont have to include stuff and make your program slow and dependend like fucking garbage
>All answers: DUDE JQUERY LMAO

>> No.69311455

I'll tell you what I was doing at work, /g/.

Our software is written in C, C++ and Python.

I'm implementing a popup window for users to view help videos in. We use CEF as the embedded browser for our software

cefpython doesn't seem to expose a handler for detecting when a user has gone into fullscreen mode, so when a user clicks the fullscreen button on a video, it just maximises to the size of the embedded browser window.

I used cefpython's Javascript bindings to get around this.

I bind a Python function into CEF so that it is available from Javascript. I then execute some Javascript to add an event listener that calls the bound Python function whenever the "fullscreenmodechange" event is triggered. This bound Python function then maximises the embedded browser window, and restores it once the user exits fullscreen mode.

I was pretty happy with the result, but when I told one of the other devs, he said I could have just modified cefpython to expose an onfullscreenmodechange handler, since the cefpython we use is our own fork of it.

>> No.69311478

>>69309572
BradPitt please go and stay go

>> No.69311529

>>69311455
An interesting note to add to this:

We use pygtk for our GUI stuff. Cefpython, when given a GTK Window(), will embed itself inside that Window.

Problem is, it will search up the hierarchy of GTK widgets until it finds the top-level window, and embed itself into that. If you have other GTK widgets on your window, they will be hidden by the cefpython browser, as it takes up all of the top level window.

The solution (with a bit of help from another dev) was to add a child widget that has its own GDK Window, and pass that into cefpython to use.

This created a couple of other minor issues though, since a GDK window is like a base window object, whereas a GTK window is an actual widget, and by passing the GDK window into cefpython, a couple of GTK window functions we were using on it no longer worked.

>> No.69311585

>>69311529
Finally, this is a really hard feature to write tests for. It's all GUI based stuff, so I couldn't really write any unit tests for it, since there aren't really any business logic units to test.

Fortunately, we have a GUI test suite, so I just added a GUI test to test opening the window, modifying one of the other widgets, closing it, and then reopening it to check that the changed widget has retained its state.

>> No.69311638

>>69305430
>>69305472
>Ever heard of name mangling?

Python does this with its "super-private" objects.

Any variable or method etc. that starts with two underscores gets the class name prepended to its name.

>> No.69312015

does anyone have beginner/intermediate exercises for c++

>> No.69312120

>>69307125
>when Nim hits 1.0, it will actually be a clean, well-rounded and expressive
And when your lord Jesus comes down to Earth it will be end of all wicked man.

Meanwhile in actual reality 1.0 is not in foreseeable future and Nim is still far from being "actually clean" with its plethora of pragmas and case/underscore insensitivity.

>> No.69312158

https://youtu.be/oxpsHk1yq88
>clang-tidy checks to avoid
>start off stating the obvious, that you shouldn't use platform/company specific checks for no good reason
>proceeds to defend horrible ideas when he gets specific
>counter arguments presented are among the weakest
Hope nobody falls for this.
I was hoping he'd shine some light on the nuances of these checks.

>> No.69312290

>>69312015
just make some open source project you like

>> No.69312345
File: 1.82 MB, 2000x1250, wpid-beautiful-tree-painting.jpg [View same] [iqdb] [saucenao] [google] [report]
69312345

I have a small problem. I want to overwrite a file using x86 Linux assembly language.

I've found that it can be done this way:
>1. Get permissions of the file I want to overwrite.
>2. Delete ("unlink") the file.
>3. Create empty file with the same name and permissions as deleted one.
>4. Open newly created file.
>5. Write into newly created file.
>6. Close it.

That should work. I was wondering is there a better way... so pls tell me if there is.

>> No.69312512

Fucked up a coding test in an interview.
I didn't get a fully correct solution out and he helped me with some of it at the end.
Will I ever get better at this? Or am I just destined to fail these perpetually?

>> No.69312522

>>69312512
practice

>> No.69312563

>>69312345
Doesn't the open syscall have a "truncate" mode?

>> No.69312618

>>69312563
Yeah, it does. Thanks, I didn't notice it.

>> No.69312724

>really enjoy a language
>large amounts of it were plagued by commercialism and kept secret or behind huge paywalls
>by the time it became free and open source it lost popularity
>it's basically held up by one company now
>industry is slowly moving away from it as well to SEPPLES and Java
>depression kicks in
>all that hardwork for years is now no longer valued
feels really bad, now I know what LISPers went through.

>> No.69312792
File: 899 KB, 487x560, 15471854782560.gif [View same] [iqdb] [saucenao] [google] [report]
69312792

Git. What's the difference between origin and origin/master? I've googled a bit but it didn't help.

master - local master, contains my local changes
origin/master - remote master, points to the last version in the remote repo
origin - ???

>> No.69312825

Am I correct in feeling the common C practice of using the function return values for error codes with the actual function output being put into some variable pointed to by an argument is a horrible mangling of the whole idea of functions?

It smells of making the primary functionality of a function a side effect.

>> No.69312843

>>69312792
Also
origin master - ??? ???

>> No.69312903

>>69312792
>>69312843
'origin' is just the default name for a remote repository.

When you run git clone you can name the repository with the -o parameter, if you don't it gets named origin.

>> No.69312907

>>69312825
You're right but without sum or even tuple types what are you supposed to do?

>> No.69313024

>>69312907
You have structs, the main problem is lack of error handling options.

The only real alternative is setjmp sorcery, then you can hack your way to something like exception handling and actually return the results of a function like a human being.

>> No.69313067

>>69313024
Structs are useless for error handling unless you can destructure them easily. That's why tuples tend to be better for this purpose.

>> No.69313081

>>69312903
Git is confusing. So 'origin/master', 'origin master' and 'origin' all mean the same thing?

>> No.69313099

I was born 40 years too late to enjoy the fun part of programming.

>> No.69313107

>>69313081
'origin/master' and 'origin master' yes
'origin' is just remote name, and can have other branches than master

>> No.69313165

>>69312120
>case/underscore insensitivity
I honestly forgot that was even in the language, because everything is written in camel case. Regardless, the ability to mask style inconsistencies in libraries is actually quite nice. Makes my code cleaner and more consistent. I hated it when I first started with Nim, but now that I've seen it in action, I can tell it's a miniscule aspect of the language, it isn't intrusive at all, and in the rare occurrence that I notice it, it's being helpful.
>1.0
The fundamentals of the language haven't changed in a good 2 years now. At this point, they're just cleaning up async, adding concepts, and improving error messages.
>pragmas are bad
Pragmas and effects are my favorite thing about Nim. They allow for implicit constraints on program behavior, and they afford a level compile-time verification that can't be done in most imperative languages (e.g. they're used in the async HTTP server module to keep you from closing the server inside a callback). Yet, at the same time, since they aren't keywords, I don't have to use them if I don't want to. They're there when I need them, and they're out of the way when I don't need them. Between concepts, pragmas, and effects, Nim has all the advantages of OCaml with less verbosity.

>> No.69313196
File: 45 KB, 1024x575, a_lot.jpg [View same] [iqdb] [saucenao] [google] [report]
69313196

>>69313107
I see. Thank you, master.

>> No.69313201

>>69313165
>They're there when I need them, and they're out of the way when I don't need them
Sounds like something a C++ programmer would say.
And there are hardly any uglier languages than C++.

>> No.69313204

>>69310725
Bfs is slow and inefficient

>> No.69313329

>>69309679
do the monsters get uglier the harder it gets

>> No.69313354

>>69312724
you know you can learn something for yourself instead of industry

>> No.69313372

>>69309679
Doesn't seem too bad though

>> No.69313375

the fuck is marshalling

>> No.69313479

>>69312724
OCaml?

>> No.69313535

>>69313201
In C++ when things are "out of the way" they still have a strong tendency to leak into other parts of the program, e.g. template barf out of nowhere. For that reason, I don't like C++'s abstractions since they don't cleanly mask implementation. For the most part, Nim doesn't do that. It certainly does it does it to a lesser degree than C++.
With C++, entire subsets of the language can go unused even in large projects. In Nim, pragmas are used off and on throughout virtually every project- they provide value regardless of what you're doing.
I also don't like C++ because its "features" are poorly integrated with each other. Nim's features fit together more cleanly, and each part of the language is orthogonal.
With C++, you have struct and class. In Nim, it's just object.
In C++, you have references, plus a whole pile of STL reference counting stuff. In Nim, it's just ref.
In C++, you have half a dozen different ways to inititialize structs, and at least 2-3 different ways to initialize everything else. In Nim, there is one syntax for initialization.
I could keep going, but you get the idea. Nim is a pretty intricate language relative to C (which is my primary language at work, though I do use a bit of Nim at work as well), but unlike C++, Nim's feature set is sane.

>> No.69313672

I've a question for you, please help me
The following code randomizes unique values from an array and adds them to another one
It's like simulating a deck of cards
public static void randomizeHands(int[] vectorRepartidor, int mazoValor[]) {
Random random = new Random();

vectorRepartidor[0] = random.nextInt(mazoValor.length);

for (int newNumber = 1; newNumber < vectorRepartidor.length; newNumber++) {

vectorRepartidor[newNumber] = random.nextInt(mazoValor.length);
for (int checker = 0; checker < newNumber; checker++) {
if (vectorRepartidor[newNumber] == vectorRepartidor[checker]) {
vectorRepartidor[newNumber] = random.nextInt(mazoValor.length);
checker = 0;

}

}


}
}


Why is the first element of the array randomized first alone and not on the FOR below?
If I dont ranomize it outside it may repeat itself with one of the rest
Can anyone explain why?

>> No.69313712
File: 116 KB, 500x465, thinking emoji.png [View same] [iqdb] [saucenao] [google] [report]
69313712

>>69304435
>haskell but with lisp syntax
https://github.com/LuxLang/lux
https://www.youtube.com/watch?v=T-BZvBWiamU
Anyone tried it?

>> No.69313795

>>69312825
The purpose of C is to be easier to understand than Assembly.

>> No.69313973
File: 290 KB, 1852x1951, DwVWPQiVsAAnljD.jpg orig.jpg [View same] [iqdb] [saucenao] [google] [report]
69313973

Anyone has experience with self-hosting version management and ancillary stuff? There's rather few user reports on this kind of thing.

I'm looking into self-hosting a Mercurial server in Wangblows, plus the basics like a bug tracker, forum, automated builds etc for if/when I start a team or make it public.

JetBrains seems to have a trio of softwares which integrate with each other,which are free to small teams, and which seem to cover almost everything, except an actual Mercurial server. I'm particularly interested in its code-aware navigation.

>> No.69314070

>>69313672
arrays start at 0 remember?


Because it's never randomised inside the loop, duh. ¿Do you see that newNumber starts at 1? ¿Do you see that it only increases? ¿If so why do you expect vectorRepartidor[newNumber] = ... too magically effect vectorRepartidor[0]?

>> No.69314085

for me its using malloc()

>> No.69314166

>>69314070
But if I remove the first random assignment and make the FOR start at 0, I get the first and only the first value of the array repeated with the rest of the numbers given
Try it out yourself and see that it happens
it should look like this
public static void randomizeHands(int[] vectorRepartidor, int mazoValor[]) {
Random random = new Random();

// COMMENTED vectorRepartidor[0] = random.nextInt(mazoValor.length);

for (int newNumber = 0; newNumber < vectorRepartidor.length; newNumber++) {

vectorRepartidor[newNumber] = random.nextInt(mazoValor.length);
for (int checker = 0; checker < newNumber; checker++) {
if (vectorRepartidor[newNumber] == vectorRepartidor[checker]) {
vectorRepartidor[newNumber] = random.nextInt(mazoValor.length);
checker = 0;

}

}


}
}

>> No.69314336

Wrt optimization, is there any difference between LTO and doing a unity build?

>> No.69314368

>>69314336
Both techniques give the same opportunities for interprocedural optimization.

>> No.69314389

>>69308360
are you pajeet?
which stack?

>> No.69314451

I wrote a userscript to get around 4chan's 30 second API caching. I'm currently testing it against the native extension.
// ==UserScript==
// @name 4chan Cache Buster
// @namespace https://www.4chan.org/
// @match *://boards.4chan.org/*/thread/*
// @match *://boards.4channel.org/*/thread/*
// @run-at document-start
// @grant none
// ==/UserScript==

function randBytes(length) {
return Array.apply(null, Array(length)).map(function() {
return Math.floor(Math.random() * 256)
})
}

document.addEventListener('4chanMainInit', function() {
let originalGet = $.get;
$.get = function(url, callbacks, headers) {
if (url.startsWith('//a.4cdn.org/')) {
let cacheBuster = '?' + encodeURIComponent(btoa(String.fromCharCode.apply(null, randBytes(9))));
url += cacheBuster
}
return originalGet(url, callbacks, headers)
}
});

>> No.69314476
File: 29 KB, 741x568, aputhink.png [View same] [iqdb] [saucenao] [google] [report]
69314476

What is my sequence of actions when I try to study the source js code to understand its inner workings?

>> No.69314494

>>69314476
nobody cares

>> No.69314518

>>69314494
Nigger detected

>> No.69314520

>>69314166
Oh ok. That's very odd: I'm relatively experienced and I don't see how why this happens like that. I assume the checker loop on newNumber == 0 should be a no-op and the subsequent ones should be equivalent to the previous code but apparently that's not the case. It's also possible the call-site of the function is causing issues, especially when passing mutable arrays by reference like that idk.

Try a debugger or a println-sprinkling session. Unfortunately I am unable to run Javagina code rn and I'm also out of time. ¿Anyone can help the good hombre?

>> No.69315011

>try to use github to sync project between laptop and pc
>cant figure out how to use git
>use usb instead

>> No.69315017

Which language will be best for gtk application?
Is vala a sane choice?

>> No.69315164

>>69313672
>>69314166
I have no idea what your code is supposed to do

Why don't you write some psuedocode first?

>> No.69315425

>>69315011
git is for version control. you should be using it for your project anyway

then you host your repo on github or whatever and can pull down to whatever machine you want

>> No.69315449

>>69315164
It's supposed to take values from mazoValor and add them to vectorRepartidor, then check if that value is already there and if it is, re-random until it's not
it's to simulate a deck of cards dealing hands
it works and all but i just need to understand why does the first number randomized needs to stay out of the FOR loop otherwise it may get repeated

>> No.69315518

any games written on haskell?

>> No.69315590

>>69315449
>It's supposed to take values from mazoValor and add them to vectorRepartidor
You're only using the length of mazoValor in your code, which is why I'm confused

What do you want the function to do? As in, you give it some inputs, what do you want back? Without describing how it should actually do it

>> No.69315618

>>69314336
Gonna hook a question onto yours.
I don't recall from where I heard it but I recall Intels approach to whole program optimization was criticized (in a friendly way) by a Clang developer when asked about LTO. I believe the complaint was that it wasn't scalable and there was talk about how compilers can't spend forever working on the result because humans are waiting for it.
That's really confusing to me right now because I thought LTO was just letting optimizations happen at link time instead. Naively that just sounds like you're given the function bodies of other objects files to consider in optimizations which would be an optimization that is allowed the full source to consider (aside from dynamic libraries).
Where would whole program optimization fit in then? Is this just me being confused about the terminology where LTO is a form of whole program optimization?

>> No.69315628

>>69314476
Go to /wdg/, ecmascript and it's environment is theirs.

>> No.69315659

>>69315590
so mazoValor.length is 40 and is filled with different values (cards), vectorRepartidor.length is 18 and all it's values are 0
I want the function to take unique values from mazoValor and add them to vectorRepartidor
It already does this but what I struggle to understand is why the first value needs to be assigned outside the function, because if you don't for some reason it may fail and only the first value of vectorRepartidor gets repeated with another one when the function is done

>> No.69315678
File: 41 KB, 374x374, 1545777847077.jpg [View same] [iqdb] [saucenao] [google] [report]
69315678

ok if
>car is car
>cdr is cudder
>cadr is cadder
>caddr is cadader
how do you pronounce caar, cdar or cddaar? please help, this is very important.

>> No.69315692

>>69315678
car
see-dar
see-dar

>> No.69315818

>>69315678
ca-ar
cuddar
cududa-ar? does anybody even use shit like cddaar?

>> No.69315870

>>69315659
>so mazoValor.length is 40 and is filled with different values (cards), vectorRepartidor.length is 18 and all it's values are 0
Since you don't need the contents of vectorRepartidor you should just pass the length of the array (int) you want to be returned. Create the new array in the function

Then it's a matter of working out the best way to choose n random indexes of mazoValor and returning their contents in the new array

But since you're describing it as a card game, seems like the wrong approach. Typically you shuffle a deck, and deal cards from the top, right? Why not shuffle the deck of cards and take the first n cards from the array?

You'd use an array list instead since they are dynamic (can change size at runtime)

>> No.69315897

>>69315870
Thanks for the help, you've given me a lot to think about

>> No.69315977

who here doin homework? I've already done half of my 3 credit course before school even opens on Monday

>> No.69316078

>int: By default, the int data type is a 32-bit signed two's complement integer, which has a minimum value of -231 and a maximum value of 231-1. In Java SE 8 and later, you can use the int data type to represent an unsigned 32-bit integer, which has a minimum value of 0 and a maximum value of 232-1. Use the Integer class to use int data type as an unsigned integer. See the section The Number Classes for more information. Static methods like compareUnsigned, divideUnsigned etc have been added to the Integer class to support the arithmetic operations for unsigned integers.


thiis is actually dogshit

why not just have a primitive unsigned int

>> No.69316275

>>69316078
Do you really need that one extra bit of values? I think using signed integers helps against bugs and is more convenient for magic or error values. When was the last time you needed an array longer than pow(2, 31)?

>> No.69316557

>>69315518
tic tac toe

>> No.69316681

>>69310109
dude chess and tetris are games you make in a weekend in your spare time. They don't prove a language is any good for making games.

>> No.69316701

>>69316681
>dude you can make games in it, but it doesn't mean it's good for making games
Do you think about the shit you post, or is it all just auto-pilot?

>> No.69316729

What are some cases where a tracing GC excels?

>> No.69316742

Is there a better way to use LIKE from a SQL query to match numers only, other than using [0-9] ?
I'm trying to use # on my C# program but I'm not getting any values back.
Works fine on the database manager tho.

"SELECT * FROM TABLE WHERE COL1 LIKE 'AA###BBB' "

>> No.69316746
File: 107 KB, 645x1000, brainletcastle.jpg [View same] [iqdb] [saucenao] [google] [report]
69316746

>>69316701
Saying that it's good for games because it can do tetris is like saying that a language is good for making operating systems because it can open a file.

>> No.69316794

>>69316729
Slightly related: https://www.ibm.com/developerworks/java/library/j-jtp09275/index.html

>> No.69316809

>>69316746
>brainlet picture
way to invalidate any interest i had in this conversation.
But there's nothing holding nim back. GC is completely optional, and it just compiles to C right now, so ~like C performance. Yeah you have to put in work, and most things aren't as mature right now. But you're an absolute mong if you think Nim can't do """"""'serious"""""" games. Also if you look harder, you'll see there's more than chess and tetris there.

>> No.69316814

>>69316275
that's not what i meant

it's just that it would be better than having an Integer class, in terms of design purely and possibly performance wise, but idk

>> No.69316964

>>69313196
this is an interesting read, it helped me clear up a lot of confusions I had about git. It's also a very interesting SE read
http://aosabook.org/en/git.html

>> No.69316970

>>69316814
In terms of performance it's probably the same, depending on use. I imagine you could use dynamic dispatch on an Integer type in Java which would be silly.
I would say I'm more comfortable with having an unsigned primitive than not.
>>69316275
>helps against bugs and is more convenient for magic or error values
It doesn't help against bugs at all in any way. You still have the same amount of value coverage to deal with just more niche cases because negative numbers are different from positive. At least in C you could report overflow as an error with an int but in Java it's defined i think.
>magic values
Sure. But you could sacrifice the same amount of bits in an unsigned value and get the same range. What you got was a <0 comparison on the return rather than >DESCRIPTIVE_SYMBOL. It's not a clear loss/win. But I would argue that for may cases <0 doesn't automatically imply error in people's heads. Not if they're dealing with signed integers as intended in other context anyway.
>array
Ints are used for things other than indexes.

>> No.69316986

>>69316809
If it's just a toy language that compiles to C to get the actual work done then why wouldn't I just use C?

>> No.69317009

>>69316986
It's not a toylang, as it's self-hosted, they just choose to compile to C right now for whatever reason.
And because they syntax is much better, and it has more features than C that actually aren't bloat like sepples.

>> No.69317035

>>69316986
Not that anon.
That's a pretty stupid question.
Why write C when you could write asm? It'll all be machine code in the end and asm is 1:1 with machine code.
The point is that the high level languages like C buy you expressive ability usually. Some introduce models that help broadening the scope of compiler optimization (see haskell for instance).

>> No.69317084

>>69317035
>high level languages like C buy you expressive ability usually
No shit,what expressive ability does it offer over C that should convince me to learn a whole new language?

>> No.69317096

>>69316809
>it compiles to C so it's as fast as C
That's not how it works.

>> No.69317117

>>69317096
please read the reply chain before responding you mong. >>69316809
>~like C performance

>> No.69317155

>>69316986
Compiling to C doesn't make a language a toy. If you have a great idea for a language and want to start with an existing ecosystem with a minimal amount of compiler work, compiling to C is probably the best route to take.
Think of it this way. There are hundreds and hundreds of shit programming languages. You want to get your idea out there *now* and start building a community. Why waste time building a sophisticated compiler that nobody will ever use?

>> No.69317165

>>69317084
I don't know. I'm pretty sure anon was arguing that though.
>no shit
But the way you expressed it meant that you didn't find it obvious yourself.
The reason you argued you could use C yourself is because C was an intermediate in the compile process.
If you meant 'why would Nim be better than C' you'd have ignored the fact that C 'does the work', and just expressed yourself cleanly. But then it would be more obvious you've got nothing to say. If you weren't wrong here you didn't really say anything.
Don't back down brainlet. Defend your point. Why C over asm?

>> No.69317185

>>69317096
Just like compiling to assembly doesn't make a language fast.
nim is fairly C-like, so the C compiler can do a ton of heavy lifting. For contrast, Haskell originally compiled to C but was slower because it used a trampoline.

>> No.69317189

>>69305412
Nim is quite stable despite that. Code written 2 years ago will still typically compile today which is something you can't say for most new languages in development where you're lucky if something you wrote last week still works.

>> No.69317206

>>69317155
>compiling to C would be probably be the best way
Imo it would be some IR. llvm is fine. When you compile to C you adopt its specifics. Maybe nim fits this well. It could even be consciously designed to be similar to C.
But do a new language without those goals it doesn't make much sense.

>> No.69317211

>>69317084
https://nim-lang.org/docs/tut1.html#advanced-types
https://nim-lang.org/docs/tut2.html#object-oriented-programming (no it's not like sepples)
https://nim-lang.org/docs/tut2.html#templates
https://nim-lang.org/docs/tut2.html#macros
https://nim-lang.org/docs/tut1.html#procedures-discard-statement
And if you care about webshit, it has first class-backend support for JS
And it has UFCS.
Not an exhaustive list by any means though.

>> No.69317222

i got no idea what im doing but how to combine alias in json files please? they both start with "/me/head":

>> No.69317293

>>69317165
translating to another high level language is different, you're gonna want the language to be more similar to C if you use it at as an intermediate language. I'd imagine it'd be hard to translate lisp or haskell code to C. I can't see why you'd ever do that instead of llvm or something.
>>69317155
Why not LLVM?

>> No.69317427

>>69317293
>I'd imagine it'd be hard to translate lisp
i've translated a lisp into C
i did it for reasons of straight forwardness and in terms of speed, it's about as fast as python (meaning slow)
i'm thinking adding types would make it significantly faster still (putting it closer to a nim)

what are these reasons of straight forwardness
gcc:
>provides tco at -O3
>provides substantial optimizations
>fairly easy to make library shit like IO and threads
>i don't atcually know llvm

looking at nim, it really is very convenient for compiling to C and i would have probably gone for something like it instead of a lisp if i i were to redo my compiler

also if you are really wanting to create an actual performant nim-like or lisp like language you can even use some third party GC and not bother with reinventing your own, while focusing on language features

>> No.69317515

new thread when? :3

>> No.69317678
File: 386 KB, 474x474, 1530164987290.png [View same] [iqdb] [saucenao] [google] [report]
69317678

>>69317515
page 10

>> No.69317725

new
>>69317719
>>69317719
>>69317719

>> No.69317753

>>69317515
Why dont you make it and post link here before the limit is reach

>>
Name (leave empty)
Comment (leave empty)
Name
E-mail
Subject
Comment
Password [?]Password used for file deletion.
reCAPTCHA
Action