Giter Club home page Giter Club logo

v_by_example's Introduction

V by Example

NOTE: This is very outdated and it will be updated and worked upon when V 1.0 is released.

Brazilian Portuguese | Deutsch | English | Bahasa Indonesia | Chinese | Japanese | Italian | French

Learn V by Examples

V by Example is a direct introduction to V by using annotated program examples.

Discord: https://discord.gg/vlang

Section 1

Introduction to V by presenting a few basic examples and exercises.

Section 2

This section discusses the main operators and conditional statements in V.

Section 3

A study on functions and methods and in the most important data structures in V: arrays and struct.

Section 4

In this section, we dive deeper and study the features inside the Array object. Other examples like JSON, Writing/reading files and Testing are covered.

Team

Current list of maintainers/authors:

Contributing

See our CONTRIBUTING.md and start contributing today. We usually elect new maintainers based on contributions.

License

MIT

v_by_example's People

Contributors

delta456 avatar dhonx avatar hachi8833 avatar iredmail avatar ivo-balbaert avatar kimiko88 avatar ksaj avatar mikerogers0 avatar sachinbhutani avatar scroot avatar stepfenshawn avatar tnken avatar vbrazo avatar vinware avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

v_by_example's Issues

How Typo CI actually works

Notice that Typo CI check every commit... not every PR
so we need to work directly on base repo instead of the forked repo to get the advantage of Typo CI
OMG ... why did I just realize this ??? 😄

Translations structure discussion

This issue discusses how we should structure the translation for different languages.

V by Example should be available in different languages to attract more people.

Updating Repo structure

I plan on upgrading the repo structure so people can browse easily.

  1. First Example
- src/
 - chapter/
   - README (the explanation of the example)
   -code/
   -sol/ (solution for the exercise given) 
  1. Using the old repo structure
-src/
 -chapter/
   -README (the explanation of the example)
  - code files with solutions (.v)

Any suggestions or ideas are welcome!

insert function for array

arrays/functions.md:

The example

mut names := ['Samuel', 'John', 'Peter']
    names.insert(2, 'Tom')
    println(names)

should (temporarily) be removed because it gives an error both on Windows and Linux
// names.insert(2, 'Tom') // Nov 16: error in Windows and Linux
(see mut_arrays.v)
/tmp/v/main.tmp.c: In function ‘main__main’:
/tmp/v/main.tmp.c:3277:38: error: lvalue required as unary ‘&’ operand
array_insert (& /* ? */ names , 2 ,& /112 e="void" g="string" */ tos3("Tom") ) ...
(Use v -g to print the entire error message)
V error: C error. This should never happen.

If ok, I can do a pull request for this issue.

Plan for november

This issue discusses the items that we want to work in November.

Please comment below with suggestions.

ps: Please check our october.plan out to see what we've done so far and get some inspiration.

link to corresponding sections

As an improvement special terms in each file could link to other sections that could explain further or provide more explanation (mut links to mutable, etc.)

@donnisnoni95 came up with the idea and we both think this should be discussed. Any ideas?

Make hello world example more simpler

I think the code inside hello_world.v is a bit complex there. because the name is hello world.
I think we can make this simpler by changing some code. 🤔

  • struct might be better to have its own example
  • it would be better if we did not involve the variables there.
  • only comments and print stuff there.

Not all people who want to learn V are people who do not have prior programming skills. Maybe they are new to programming. We don't know, but it would be better to start with something simple. So everyone can learn easily. 😊 ✌️

@vbrazo @Delta456 @ylluminate

Repo Structure 2.0

In one of my next PRs, I will be updating the repo structure again so that it will look more clean and easy to browse.

-- main repo
- examples/
- code/
- exercises/
- pdf/
- README.md
- CONTRIBUTING.md
- CODE_OF_CONDUCT.md
- .gitignore
- LICENSE.md 
- `.plan` files

Suggestions are welcome!

Array.len is not a method - array.md

len is not a method, it's a field in array struct
the code for array struct is:

struct array {
pub:
	// Using a void pointer allows to implement arrays without generics and without generating
	// extra code for every type.
	data         voidptr
	len          int
	cap          int
	element_size int
}

Logic in for traditional example is not ok - conditional_statements.md

The code

mut factorial := 1
mut counter := 1

for i := 0; i < 5; i++ {
factorial=factorial*counter
if i == 6 {
print(factorial)
continue
}
println(i)
}

does not update counter, so factorial is not increased; also i never reaches 6.

The following code:

mut factorial := 1
mut counter := 1

for counter = 1; counter < 6; counter++ {
factorial=factorial * counter
if counter == 5 {
print(factorial)
continue
}
println(counter)
}

produces the desired output:

/*
1
2
3
4
120
*/

example: how to build a library in V

This should include:

  • Creating an application and explaining the pieces that need to be added
  • How to add the library to a package manager
  • How to include and use the library in a new V application

@nedpals perhaps you could help us with this one?

ps: This is a suggestion for an advanced example in V by example.

Admissions

V by Example is already doing a good job in terms of contributions, but we still need more maintainers to keep building this project. Please reach out to us in this issue if you're interested in learning the V language and contributing to this repository.

Besides collaborating in the examples, you can also become an official translator maintainer in your native language. We haven't started translating this repository to different languages, but we're discussing this idea in this issue and we are happy to start doing that with your help.

docs: write a structured README

We need to have a better README that should contain:

  • why V by example? Introduction with explanation.
  • what are V by example responsibilities?

Thoughts on new items?

Update november+december.plan

On order to have better overview what is missing, it would be good to have a up-to-date version of the .plan file.

Using GitBook

I am thinking of using Gitbook for V by Examples project because they would be best for browsing online. What you guys think about it?

Logic in nested-if example in condition_statements.md is faulty

The current code is:

tom_age := 20
ashia_age := 38

if tom_age < ashia_age {
if tom_age < 18 {
println('tom_age < 18 and younger than Ashia.')
} else {
println('tom_age > 18 and older than Ashia.')
}
} else {
println('$tom_age == $ashia_age')
println('Tom and Ashia have the same age.')
}

// Prints out:
// tom_age > 18 and older than Ashia.

This is not true: Tom is younger than Ashia.

A correct nested-if statement could be:

tom_age := 20
ashia_age := 38

if tom_age < ashia_age {
if tom_age < 18 {
println('tom_age < 18 and younger than Ashia.')
} else {
println('tom_age >= 18 and younger than Ashia.')
}
} else if tom_age > ashia_age {
println('$tom_age > $ashia_age')
} else {
println('$tom_age == $ashia_age')
}

This prints out:
// tom_age >= 18 and younger than Ashia.

Including main() in code snippets

I don’t know if I should make a pull request for this issue:

in many cases in code snippets shown main() is not needed and could be left out, giving a somewhat nicer experience to novel users. On the other hand: in struct.md: the code example with struct User doesn’t run as shown: the code should be in a fn main() {}

I would like to know your opinion on this.
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.