From aaa192ad82cace7d1fb51b126f38388ca4945d33 Mon Sep 17 00:00:00 2001 From: halfmexican Date: Thu, 2 May 2024 23:30:34 -0500 Subject: [PATCH 1/7] add developer-guides dir --- source/developer-guides/index.rst | 7 +++++++ source/index.rst | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 source/developer-guides/index.rst diff --git a/source/developer-guides/index.rst b/source/developer-guides/index.rst new file mode 100644 index 0000000..dfea5e3 --- /dev/null +++ b/source/developer-guides/index.rst @@ -0,0 +1,7 @@ +Developer Guides +================ + +.. toctree:: + :maxdepth: 2 + + vala-for-java-devs/index diff --git a/source/index.rst b/source/index.rst index ef8916a..db8dac5 100644 --- a/source/index.rst +++ b/source/index.rst @@ -6,6 +6,7 @@ Vala Documentation About Installation Guide + Developer Guides Introduction ------------ @@ -23,7 +24,7 @@ Sections - `Tutorials `_ - `Tooling `_ - `Contributor Guide `_ -- `Developer Guides `_ +- `Developer Guides `_ External Resources ------------------ From 24f91f62521d7581082e19cf6cbf9acea0331996 Mon Sep 17 00:00:00 2001 From: halfmexican Date: Thu, 2 May 2024 23:31:24 -0500 Subject: [PATCH 2/7] Add first few pages --- .../01-00-source-file-and-compilation.rst | 79 +++++++++++++++++++ .../01-01-simple-data-types.rst | 46 +++++++++++ .../vala-for-java-devs/index.rst | 15 ++++ 3 files changed, 140 insertions(+) create mode 100644 source/developer-guides/vala-for-java-devs/01-00-source-file-and-compilation.rst create mode 100644 source/developer-guides/vala-for-java-devs/01-01-simple-data-types.rst create mode 100644 source/developer-guides/vala-for-java-devs/index.rst diff --git a/source/developer-guides/vala-for-java-devs/01-00-source-file-and-compilation.rst b/source/developer-guides/vala-for-java-devs/01-00-source-file-and-compilation.rst new file mode 100644 index 0000000..5a3fae2 --- /dev/null +++ b/source/developer-guides/vala-for-java-devs/01-00-source-file-and-compilation.rst @@ -0,0 +1,79 @@ +Source File and Compilation +============================ + +Source Files +------------ + +Java: ``*.java`` + +Vala: ``*.vala`` + +Compilation +----------- + +Java: compiled to JVM byte code (``.class`` files) + +.. code-block:: bash + + $ javac SourceFile1.java SourceFile2.java + +Vala: compiled to native code via C code as intermediate code + +.. code-block:: bash + + $ valac source1.vala source2.vala -o program + +Vala's standard object system is GObject, compiled Vala libraries are valid C libraries. + +Using Libraries +--------------- + +Java: ``.jar`` files + +.. code-block:: bash + + $ javac -classpath foo-1.0.jar;bar-3.0.jar SourceFile.java + +Vala: packages (C libraries with ``.vapi`` files) + +.. code-block:: bash + + $ valac --pkg foo-1.0 --pkg bar-3.0 source.vala + +Java: + +.. code-block:: java + + import javax.swing.*; + + package org.foo.bar; + + // ... + +Vala: namespaces, not related to directory hierarchy, no reverse domain name scheme + +.. code-block:: vala + + using Gtk; + + namespace Foo.Bar { + // ... + } + +Vala namespaces may contain methods without classes. They are implicitly static. + +Default Import +-------------- + +Java: package ``java.lang.*`` imported by default + +Vala: namespace ``GLib`` imported by default + +Main Entry Point +---------------- + +Java: ``public static void main(String[] args)`` + +Vala: ``static int main (string[] args)`` + +May be outside a class, may be private, may return ``int`` (exit code), ``args`` argument is optional diff --git a/source/developer-guides/vala-for-java-devs/01-01-simple-data-types.rst b/source/developer-guides/vala-for-java-devs/01-01-simple-data-types.rst new file mode 100644 index 0000000..56b536f --- /dev/null +++ b/source/developer-guides/vala-for-java-devs/01-01-simple-data-types.rst @@ -0,0 +1,46 @@ +Simple Data Types +================= + +Basic Types +----------- + +In Vala, the sizes of standard types (``int``, ``long``, etc.) are architecture-dependent. To get the size of a type in bytes, you can use the ``sizeof`` operator. For example: + +.. code-block:: vala + + int size = sizeof (int); + +Vala provides additional types with architecture-independent guaranteed sizes: + +- Signed: ``int8``, ``int16``, ``int32``, ``int64`` +- Unsigned: ``uint8``, ``uint16``, ``uint32``, ``uint64`` + +Note that there is no ``byte`` type in Vala. Instead, you can use ``uint8`` or ``int8``. + +Vala uses ``bool`` instead of ``boolean`` for boolean values. + +Vala also has an additional basic type called ``unichar``, which represents a Unicode character. + +Constant Modifier +----------------- + +In Vala, the ``const`` keyword is used to declare constants, similar to ``final`` in Java. + +Methods on Basic Types +---------------------- + +Vala's basic types have methods that can be called directly on the values. For example: + +.. code-block:: vala + + int a = (-4).abs (); + string s = a.to_string (); + int b = int.max (5, 7); // static method call on 'int' + +In the above code: + +- ``(-4).abs ()`` calls the ``abs`` method on the integer value ``-4``, returning its absolute value. +- ``a.to_string ()`` converts the integer ``a`` to a string representation. +- ``int.max (5, 7)`` calls the static ``max`` method on the ``int`` type, returning the maximum value between ``5`` and ``7``. + +These are just a few examples of the methods available on Vala's basic types. diff --git a/source/developer-guides/vala-for-java-devs/index.rst b/source/developer-guides/vala-for-java-devs/index.rst new file mode 100644 index 0000000..850143b --- /dev/null +++ b/source/developer-guides/vala-for-java-devs/index.rst @@ -0,0 +1,15 @@ +Vala for Java Developers +======================== +Vala is an object-oriented programming language with a syntax that is very similar to Java. As a Java developer, you will find many familiar concepts and constructs in Vala, making it easier to learn and transition to this language. + +Despite these similarities, there are also some differences between Vala and Java, such as Vala's use of reference counting for memory management instead of garbage collection.. + +Throughout this guide, we will explore the similarities and differences between Vala and Java, helping you leverage your Java knowledge to quickly become proficient in Vala programming. + + +.. toctree:: + :maxdepth: 1 + :hidden: + + 01-00-source-file-and-compilation + 01-01-simple-data-types From 143c96ee1882a573518ae14f0408c87f11d2212b Mon Sep 17 00:00:00 2001 From: halfmexican Date: Thu, 2 May 2024 23:44:19 -0500 Subject: [PATCH 3/7] fix merge conflict --- source/index.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/source/index.rst b/source/index.rst index 5927350..e6dc542 100644 --- a/source/index.rst +++ b/source/index.rst @@ -6,11 +6,8 @@ Vala Documentation About Installation Guide -<<<<<<< HEAD Developer Guides -======= Tutorials ->>>>>>> upstream/main Introduction ------------ From 8594a03ff18e97ef01ebeabd53cc0135921bf03c Mon Sep 17 00:00:00 2001 From: halfmexican Date: Thu, 2 May 2024 23:59:02 -0500 Subject: [PATCH 4/7] add :numbered: --- source/developer-guides/vala-for-java-devs/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/developer-guides/vala-for-java-devs/index.rst b/source/developer-guides/vala-for-java-devs/index.rst index 850143b..235853a 100644 --- a/source/developer-guides/vala-for-java-devs/index.rst +++ b/source/developer-guides/vala-for-java-devs/index.rst @@ -9,7 +9,7 @@ Throughout this guide, we will explore the similarities and differences between .. toctree:: :maxdepth: 1 - :hidden: - + :numbered: + 01-00-source-file-and-compilation 01-01-simple-data-types From b14b2313fa6be7557521833ec16f6c0d5221ca52 Mon Sep 17 00:00:00 2001 From: half_mexican Date: Sat, 11 May 2024 19:10:35 -0500 Subject: [PATCH 5/7] Port more pages --- ...rst => 01-source-file-and-compilation.rst} | 2 + ...ata-types.rst => 02-simple-data-types.rst} | 1 + .../vala-for-java-devs/03-strings.rst | 34 ++++++ .../vala-for-java-devs/04-arrays.rst | 44 +++++++ .../05-naming-conventions.rst | 44 +++++++ .../vala-for-java-devs/06-foreach.rst | 16 +++ .../vala-for-java-devs/07-inheritance.rst | 20 ++++ .../08-code-organization.rst | 50 ++++++++ .../vala-for-java-devs/08-methods.rst | 77 +++++++++++++ .../vala-for-java-devs/09-type-inference.rst | 108 ++++++++++++++++++ .../vala-for-java-devs/index.rst | 11 +- 11 files changed, 405 insertions(+), 2 deletions(-) rename source/developer-guides/vala-for-java-devs/{01-00-source-file-and-compilation.rst => 01-source-file-and-compilation.rst} (98%) rename source/developer-guides/vala-for-java-devs/{01-01-simple-data-types.rst => 02-simple-data-types.rst} (99%) create mode 100644 source/developer-guides/vala-for-java-devs/03-strings.rst create mode 100644 source/developer-guides/vala-for-java-devs/04-arrays.rst create mode 100644 source/developer-guides/vala-for-java-devs/05-naming-conventions.rst create mode 100644 source/developer-guides/vala-for-java-devs/06-foreach.rst create mode 100644 source/developer-guides/vala-for-java-devs/07-inheritance.rst create mode 100644 source/developer-guides/vala-for-java-devs/08-code-organization.rst create mode 100644 source/developer-guides/vala-for-java-devs/08-methods.rst create mode 100644 source/developer-guides/vala-for-java-devs/09-type-inference.rst diff --git a/source/developer-guides/vala-for-java-devs/01-00-source-file-and-compilation.rst b/source/developer-guides/vala-for-java-devs/01-source-file-and-compilation.rst similarity index 98% rename from source/developer-guides/vala-for-java-devs/01-00-source-file-and-compilation.rst rename to source/developer-guides/vala-for-java-devs/01-source-file-and-compilation.rst index 5a3fae2..7521983 100644 --- a/source/developer-guides/vala-for-java-devs/01-00-source-file-and-compilation.rst +++ b/source/developer-guides/vala-for-java-devs/01-source-file-and-compilation.rst @@ -77,3 +77,5 @@ Java: ``public static void main(String[] args)`` Vala: ``static int main (string[] args)`` May be outside a class, may be private, may return ``int`` (exit code), ``args`` argument is optional + +INSERT IMAGE HERE \ No newline at end of file diff --git a/source/developer-guides/vala-for-java-devs/01-01-simple-data-types.rst b/source/developer-guides/vala-for-java-devs/02-simple-data-types.rst similarity index 99% rename from source/developer-guides/vala-for-java-devs/01-01-simple-data-types.rst rename to source/developer-guides/vala-for-java-devs/02-simple-data-types.rst index 56b536f..196a13b 100644 --- a/source/developer-guides/vala-for-java-devs/01-01-simple-data-types.rst +++ b/source/developer-guides/vala-for-java-devs/02-simple-data-types.rst @@ -26,6 +26,7 @@ Constant Modifier In Vala, the ``const`` keyword is used to declare constants, similar to ``final`` in Java. + Methods on Basic Types ---------------------- diff --git a/source/developer-guides/vala-for-java-devs/03-strings.rst b/source/developer-guides/vala-for-java-devs/03-strings.rst new file mode 100644 index 0000000..2867914 --- /dev/null +++ b/source/developer-guides/vala-for-java-devs/03-strings.rst @@ -0,0 +1,34 @@ +Strings +======== + ++------------------+---------------------------+ +| Java | Vala | ++==================+===========================+ +| Data type: String| Data type: string (lower | +| | case) | ++------------------+---------------------------+ +| Equality test: | Equality test: | +| str1.equals(str2)| str1 == str2 | ++------------------+---------------------------+ + +String comparisons compare content, not reference. You can compare strings lexicographically with ``<``, ``>``, ``<=``, ``>=`` etc. Strings can be used with switch. + +Vala strings are UTF-8 encoded. + +Vala supports verbatim strings: ``"""..."""`` + +.. code-block:: vala + + string verbatim = """Verbatim strings don't evaluate escape sequences + like \n, \t, ... and may span multiple lines. + The line breaks are part of the string. + You can use quotation marks (") and backslashes (\) + inside a verbatim string without escaping them."""; + +Vala supports string templates: ``@"..."``. String templates may contain expressions, prefixed by a ``$`` sign. + +.. code-block:: vala + + string name = "John"; + stdout.printf (@"Welcome, $name!"); + stdout.printf (@"3 + 2 = $(3 + 2)"); \ No newline at end of file diff --git a/source/developer-guides/vala-for-java-devs/04-arrays.rst b/source/developer-guides/vala-for-java-devs/04-arrays.rst new file mode 100644 index 0000000..cbf311e --- /dev/null +++ b/source/developer-guides/vala-for-java-devs/04-arrays.rst @@ -0,0 +1,44 @@ +Arrays +====== + +Dynamic Growth +-------------- + +You can add elements to arrays dynamically by using the ``+=`` operator. The array will be reallocated with sizes of powers of two: + +.. code-block:: vala + + int[] squares = {}; + for (int i = 0; i < 100; i++) { + squares += i * i; + } + +No Boundary Checking +-------------------- + +However, there is no runtime boundary checking for arrays in Vala: + +.. code-block:: vala + + int[] a = new int[10]; + a[20] = 1; // not safe! + +(Optional boundary checking is planned for a future version of Vala.) + +Multi-Dimensional Arrays +------------------------ + +Java: jagged multi-dimensional arrays ``[][]`` (arrays of arrays) + +.. code-block:: java + + int[][] matrix = new int[3][]; + for (int[] row : matrix) { + row = new int[4]; + } + +Vala: rectangular multi-dimensional arrays ``[,]``, ``[,,]``, etc. (allocated as one contiguous memory block), jagged array support planned + +.. code-block:: vala + + int[,] matrix = new int[3,4]; diff --git a/source/developer-guides/vala-for-java-devs/05-naming-conventions.rst b/source/developer-guides/vala-for-java-devs/05-naming-conventions.rst new file mode 100644 index 0000000..eb29571 --- /dev/null +++ b/source/developer-guides/vala-for-java-devs/05-naming-conventions.rst @@ -0,0 +1,44 @@ +Naming Conventions +================== + +Java +---- + +* classes, interfaces, enums: ``CamelCase`` +* methods, local variables, fields: ``mixedCamelCase`` +* constants, enum values: ``UPPER_CASE`` + +Example: + +.. code-block:: java + + public class MyClass { + private static final int MAX_VALUE = 100; + private String myField; + + public void myMethod() { + int localVariable = 42; + } + } + +Vala +---- + +* classes, interfaces, structs, enums, delegate types, namespaces: ``CamelCase`` +* methods, local variables, fields, properties, signals: ``lower_case`` +* constants, enum values: ``UPPER_CASE`` + +Example: + +.. code-block:: vala + + public class MyClass { + private const int MAX_VALUE = 100; + private string my_field; + + public void my_method() { + int local_variable = 42; + } + } + +No non-ASCII letters for identifiers allowed. You can use Vala keywords as identifiers if you prefix them with ``@``. The at sign is not considered as part of the name. diff --git a/source/developer-guides/vala-for-java-devs/06-foreach.rst b/source/developer-guides/vala-for-java-devs/06-foreach.rst new file mode 100644 index 0000000..c0caf0b --- /dev/null +++ b/source/developer-guides/vala-for-java-devs/06-foreach.rst @@ -0,0 +1,16 @@ +Foreach +======= + +Java: + +.. code-block:: java + + for (int i : numbers) { + } + +Vala: + +.. code-block:: vala + + foreach (int i in numbers) { + } diff --git a/source/developer-guides/vala-for-java-devs/07-inheritance.rst b/source/developer-guides/vala-for-java-devs/07-inheritance.rst new file mode 100644 index 0000000..862c28a --- /dev/null +++ b/source/developer-guides/vala-for-java-devs/07-inheritance.rst @@ -0,0 +1,20 @@ +Inheritance +=========== + +Java: ``extends``, ``implements``:: + + public class Demo extends Foo implements Bar { + public Demo() { + super(); + } + } + +Vala: colon followed by comma separated list, both for super class and interfaces:: + + public class Demo : Foo, Bar { + public Demo () { + base (); + } + } + +``super`` is called ``base`` in Vala. diff --git a/source/developer-guides/vala-for-java-devs/08-code-organization.rst b/source/developer-guides/vala-for-java-devs/08-code-organization.rst new file mode 100644 index 0000000..7737fa7 --- /dev/null +++ b/source/developer-guides/vala-for-java-devs/08-code-organization.rst @@ -0,0 +1,50 @@ +Code Organization +----------------- + +Files +----- + +Java: + - one toplevel class per file + - file name resembles class name + +Vala: + - a Vala source file may contain multiple classes + - file name doesn't need to resemble a class name + +Hierarchy +-------- + +Java: + - packages, represented by directory hierarchy + - reverse domain name scheme + +.. code-block:: java + + import javax.swing.*; + + package org.foo.bar; + // ... + +Vala: + - namespaces, not related to directory hierarchy + - no reverse domain name scheme + +.. code-block:: vala + + using Gtk; + + namespace Foo.Bar { + // ... + } + +Vala namespaces may contain methods without classes. They are implicitly static. + +Default Import +-------------- + +Java: + - package ``java.lang.*`` imported by default + +Vala: + - namespace ``GLib`` imported by default diff --git a/source/developer-guides/vala-for-java-devs/08-methods.rst b/source/developer-guides/vala-for-java-devs/08-methods.rst new file mode 100644 index 0000000..4be0e73 --- /dev/null +++ b/source/developer-guides/vala-for-java-devs/08-methods.rst @@ -0,0 +1,77 @@ +Methods +====== + +Method overloading +----------------- + +Java: + +.. code-block:: java + + public class Demo { + public void draw(String text) { } + public void draw(Shape shape) { } + + /* Method overloading + chaining for convenience methods with less arguments */ + void f(int x, String s, double z) { } + void f(int x, String s) { + f(x, s, 0.5); + } + void f(int x) { + f(x, "hello"); + } + } + +Vala: + +.. code-block:: vala + + public class Demo : Object { + public void draw_text (string text) { + } + public void draw_shape (Shape shape) { + } + + /* Method with argument default values */ + void f (int x, string s = "hello", double z = 0.5) { + } + } + +Vala does not support method overloading because libraries written in Vala are intended to be usable by C programmers as well with meaningful function names. + + +Method overriding +---------------- + +Java: + +.. code-block:: java + + public class Super { + public int myMethod(int x, int y) { } + public final void anotherMethod() { } + } + + public class Sub extends Super { + @Override + public int myMethod(int x, int y) { + super.myMethod(x, y); + // ... + } + } + +Vala: + +.. code-block:: vala + + public class Super : Object { + public virtual int my_method (int x, int y) { } + public void another_method () { } + } + + public class Sub : Super { + public override int my_method (int x, int y) { + base.my_method (x, y); + // ... + } + } diff --git a/source/developer-guides/vala-for-java-devs/09-type-inference.rst b/source/developer-guides/vala-for-java-devs/09-type-inference.rst new file mode 100644 index 0000000..0c70049 --- /dev/null +++ b/source/developer-guides/vala-for-java-devs/09-type-inference.rst @@ -0,0 +1,108 @@ +Type Inference +=========================== + +Type Inference +-------------- + +Vala supports a mechanism called type inference (implicit typing) for local variables: Local variables may be declared using the ``var`` keyword instead of the type name if the compiler can deduce (infer) the type from the initial assignment. This helps avoiding unnecessary redundancy and is especially useful for generic types. Examples: + +.. code-block:: vala + + var obj = new Object (); + var map = new HashMap (); + var str = "hello, world"; + var arr = new int[10]; + +instead of: + +.. code-block:: vala + + Object obj = new Object (); + HashMap map = new HashMap (); + string str = "hello, world"; + int[] arr = new int[10]; + +Still, everything is statically typed. + + + +Object Base Class +----------------- + +Java: implicit inheritance from ``Object`` (``java.lang.Object``): + +.. code-block:: java + + public class Foo { + // ... + } + +Vala: no implicit inheritance from ``Object`` (``GLib.Object``): + +.. code-block:: vala + + public class Foo : Object { + // ... + } + +What happens if you don't inherit from ``Object``? Nothing terrible. These classes will be slightly more lightweight, however, they will lack some features such as property change notifications, and your objects won't have a common base class. Usually inheriting from ``Object`` is what you want. + +Multiple Constructors +------------------- + +Java: constructor overloading: + +.. code-block:: java + + public class Foo { + public Foo() { } + public Foo(int foo) { } + public Foo(String bar) { } + } + + new Foo(); + new Foo(42); + new Foo("hello"); + +Vala: named constructors instead of constructor overloading: + +.. code-block:: vala + + public class Foo : Object { + public Foo () { } + public Foo.with_foo (int foo) { } + public Foo.from_bar (string bar) { } + } + + new Foo (); + new Foo.with_foo (42); + new Foo.from_bar ("hello"); + +Constructor Chaining +-------------------- + +Java: this(): + +.. code-block:: java + + class Foo { + public Foo() { + this("bar"); + } + + public Foo(string bar) { + } + } + +Vala: this() or this.name_addition(): + +.. code-block:: vala + + class Foo : Object { + public Foo () { + this.with_bar ("bar"); + } + + public Foo.with_bar (string bar) { + } + } diff --git a/source/developer-guides/vala-for-java-devs/index.rst b/source/developer-guides/vala-for-java-devs/index.rst index 235853a..abdb1ad 100644 --- a/source/developer-guides/vala-for-java-devs/index.rst +++ b/source/developer-guides/vala-for-java-devs/index.rst @@ -11,5 +11,12 @@ Throughout this guide, we will explore the similarities and differences between :maxdepth: 1 :numbered: - 01-00-source-file-and-compilation - 01-01-simple-data-types + 01-source-file-and-compilation + 02-simple-data-types + 03-strings + 04-arrays + 05-naming-conventions + 06-foreach + 07-inheritance + 08-methods + 09-type-inference \ No newline at end of file From 53bfde5acc6e52447979e51696ca073639f3d91e Mon Sep 17 00:00:00 2001 From: half_mexican Date: Sat, 11 May 2024 19:20:36 -0500 Subject: [PATCH 6/7] Fix index and edit pages --- source/developer-guides/index.rst | 1 + source/developer-guides/vala-for-java-devs/08-methods.rst | 6 +++--- .../vala-for-java-devs/09-type-inference.rst | 3 --- .../{08-code-organization.rst => 10-code-organization.rst} | 0 4 files changed, 4 insertions(+), 6 deletions(-) rename source/developer-guides/vala-for-java-devs/{08-code-organization.rst => 10-code-organization.rst} (100%) diff --git a/source/developer-guides/index.rst b/source/developer-guides/index.rst index db77828..2ff3411 100644 --- a/source/developer-guides/index.rst +++ b/source/developer-guides/index.rst @@ -4,4 +4,5 @@ Developer Guides .. toctree:: :glob: :maxdepth: 2 + vala-for-java-devs/index diff --git a/source/developer-guides/vala-for-java-devs/08-methods.rst b/source/developer-guides/vala-for-java-devs/08-methods.rst index 4be0e73..a19aacf 100644 --- a/source/developer-guides/vala-for-java-devs/08-methods.rst +++ b/source/developer-guides/vala-for-java-devs/08-methods.rst @@ -1,8 +1,8 @@ Methods -====== +========= Method overloading ------------------ +------------------- Java: @@ -41,7 +41,7 @@ Vala does not support method overloading because libraries written in Vala are i Method overriding ----------------- +------------------- Java: diff --git a/source/developer-guides/vala-for-java-devs/09-type-inference.rst b/source/developer-guides/vala-for-java-devs/09-type-inference.rst index 0c70049..e956386 100644 --- a/source/developer-guides/vala-for-java-devs/09-type-inference.rst +++ b/source/developer-guides/vala-for-java-devs/09-type-inference.rst @@ -1,9 +1,6 @@ Type Inference =========================== -Type Inference --------------- - Vala supports a mechanism called type inference (implicit typing) for local variables: Local variables may be declared using the ``var`` keyword instead of the type name if the compiler can deduce (infer) the type from the initial assignment. This helps avoiding unnecessary redundancy and is especially useful for generic types. Examples: .. code-block:: vala diff --git a/source/developer-guides/vala-for-java-devs/08-code-organization.rst b/source/developer-guides/vala-for-java-devs/10-code-organization.rst similarity index 100% rename from source/developer-guides/vala-for-java-devs/08-code-organization.rst rename to source/developer-guides/vala-for-java-devs/10-code-organization.rst From 82663989b94536fbec8f736da762288f79049f48 Mon Sep 17 00:00:00 2001 From: Colin Kiama Date: Wed, 6 Nov 2024 09:26:23 +0000 Subject: [PATCH 7/7] Restructure Java Developers guide to match the file structure of the other developer guides --- .../vala-for-java-devs.rst} | 17 ++++------------- .../01-source-file-and-compilation.rst | 0 .../vala-for-java-devs/02-simple-data-types.rst | 0 .../vala-for-java-devs/03-strings.rst | 0 .../vala-for-java-devs/04-arrays.rst | 0 .../05-naming-conventions.rst | 0 .../vala-for-java-devs/06-foreach.rst | 0 .../vala-for-java-devs/07-inheritance.rst | 0 .../vala-for-java-devs/08-methods.rst | 0 .../vala-for-java-devs/09-type-inference.rst | 8 ++++---- .../vala-for-java-devs/10-code-organization.rst | 5 +++-- source/developer-guides/index.rst | 4 ++-- source/index.rst | 3 +-- 13 files changed, 14 insertions(+), 23 deletions(-) rename source/developer-guides/{vala-for-java-devs/index.rst => documentation/vala-for-java-devs.rst} (74%) rename source/developer-guides/{ => documentation}/vala-for-java-devs/01-source-file-and-compilation.rst (100%) rename source/developer-guides/{ => documentation}/vala-for-java-devs/02-simple-data-types.rst (100%) rename source/developer-guides/{ => documentation}/vala-for-java-devs/03-strings.rst (100%) rename source/developer-guides/{ => documentation}/vala-for-java-devs/04-arrays.rst (100%) rename source/developer-guides/{ => documentation}/vala-for-java-devs/05-naming-conventions.rst (100%) rename source/developer-guides/{ => documentation}/vala-for-java-devs/06-foreach.rst (100%) rename source/developer-guides/{ => documentation}/vala-for-java-devs/07-inheritance.rst (100%) rename source/developer-guides/{ => documentation}/vala-for-java-devs/08-methods.rst (100%) rename source/developer-guides/{ => documentation}/vala-for-java-devs/09-type-inference.rst (97%) rename source/developer-guides/{ => documentation}/vala-for-java-devs/10-code-organization.rst (96%) diff --git a/source/developer-guides/vala-for-java-devs/index.rst b/source/developer-guides/documentation/vala-for-java-devs.rst similarity index 74% rename from source/developer-guides/vala-for-java-devs/index.rst rename to source/developer-guides/documentation/vala-for-java-devs.rst index abdb1ad..050fc20 100644 --- a/source/developer-guides/vala-for-java-devs/index.rst +++ b/source/developer-guides/documentation/vala-for-java-devs.rst @@ -1,4 +1,4 @@ -Vala for Java Developers +Vala for Java Developers ======================== Vala is an object-oriented programming language with a syntax that is very similar to Java. As a Java developer, you will find many familiar concepts and constructs in Vala, making it easier to learn and transition to this language. @@ -6,17 +6,8 @@ Despite these similarities, there are also some differences between Vala and Jav Throughout this guide, we will explore the similarities and differences between Vala and Java, helping you leverage your Java knowledge to quickly become proficient in Vala programming. - .. toctree:: + :glob: :maxdepth: 1 - :numbered: - - 01-source-file-and-compilation - 02-simple-data-types - 03-strings - 04-arrays - 05-naming-conventions - 06-foreach - 07-inheritance - 08-methods - 09-type-inference \ No newline at end of file + + vala-for-java-devs/* diff --git a/source/developer-guides/vala-for-java-devs/01-source-file-and-compilation.rst b/source/developer-guides/documentation/vala-for-java-devs/01-source-file-and-compilation.rst similarity index 100% rename from source/developer-guides/vala-for-java-devs/01-source-file-and-compilation.rst rename to source/developer-guides/documentation/vala-for-java-devs/01-source-file-and-compilation.rst diff --git a/source/developer-guides/vala-for-java-devs/02-simple-data-types.rst b/source/developer-guides/documentation/vala-for-java-devs/02-simple-data-types.rst similarity index 100% rename from source/developer-guides/vala-for-java-devs/02-simple-data-types.rst rename to source/developer-guides/documentation/vala-for-java-devs/02-simple-data-types.rst diff --git a/source/developer-guides/vala-for-java-devs/03-strings.rst b/source/developer-guides/documentation/vala-for-java-devs/03-strings.rst similarity index 100% rename from source/developer-guides/vala-for-java-devs/03-strings.rst rename to source/developer-guides/documentation/vala-for-java-devs/03-strings.rst diff --git a/source/developer-guides/vala-for-java-devs/04-arrays.rst b/source/developer-guides/documentation/vala-for-java-devs/04-arrays.rst similarity index 100% rename from source/developer-guides/vala-for-java-devs/04-arrays.rst rename to source/developer-guides/documentation/vala-for-java-devs/04-arrays.rst diff --git a/source/developer-guides/vala-for-java-devs/05-naming-conventions.rst b/source/developer-guides/documentation/vala-for-java-devs/05-naming-conventions.rst similarity index 100% rename from source/developer-guides/vala-for-java-devs/05-naming-conventions.rst rename to source/developer-guides/documentation/vala-for-java-devs/05-naming-conventions.rst diff --git a/source/developer-guides/vala-for-java-devs/06-foreach.rst b/source/developer-guides/documentation/vala-for-java-devs/06-foreach.rst similarity index 100% rename from source/developer-guides/vala-for-java-devs/06-foreach.rst rename to source/developer-guides/documentation/vala-for-java-devs/06-foreach.rst diff --git a/source/developer-guides/vala-for-java-devs/07-inheritance.rst b/source/developer-guides/documentation/vala-for-java-devs/07-inheritance.rst similarity index 100% rename from source/developer-guides/vala-for-java-devs/07-inheritance.rst rename to source/developer-guides/documentation/vala-for-java-devs/07-inheritance.rst diff --git a/source/developer-guides/vala-for-java-devs/08-methods.rst b/source/developer-guides/documentation/vala-for-java-devs/08-methods.rst similarity index 100% rename from source/developer-guides/vala-for-java-devs/08-methods.rst rename to source/developer-guides/documentation/vala-for-java-devs/08-methods.rst diff --git a/source/developer-guides/vala-for-java-devs/09-type-inference.rst b/source/developer-guides/documentation/vala-for-java-devs/09-type-inference.rst similarity index 97% rename from source/developer-guides/vala-for-java-devs/09-type-inference.rst rename to source/developer-guides/documentation/vala-for-java-devs/09-type-inference.rst index e956386..7b4d38f 100644 --- a/source/developer-guides/vala-for-java-devs/09-type-inference.rst +++ b/source/developer-guides/documentation/vala-for-java-devs/09-type-inference.rst @@ -1,5 +1,5 @@ Type Inference -=========================== +============== Vala supports a mechanism called type inference (implicit typing) for local variables: Local variables may be declared using the ``var`` keyword instead of the type name if the compiler can deduce (infer) the type from the initial assignment. This helps avoiding unnecessary redundancy and is especially useful for generic types. Examples: @@ -45,7 +45,7 @@ Vala: no implicit inheritance from ``Object`` (``GLib.Object``): What happens if you don't inherit from ``Object``? Nothing terrible. These classes will be slightly more lightweight, however, they will lack some features such as property change notifications, and your objects won't have a common base class. Usually inheriting from ``Object`` is what you want. Multiple Constructors -------------------- +--------------------- Java: constructor overloading: @@ -86,7 +86,7 @@ Java: this(): public Foo() { this("bar"); } - + public Foo(string bar) { } } @@ -99,7 +99,7 @@ Vala: this() or this.name_addition(): public Foo () { this.with_bar ("bar"); } - + public Foo.with_bar (string bar) { } } diff --git a/source/developer-guides/vala-for-java-devs/10-code-organization.rst b/source/developer-guides/documentation/vala-for-java-devs/10-code-organization.rst similarity index 96% rename from source/developer-guides/vala-for-java-devs/10-code-organization.rst rename to source/developer-guides/documentation/vala-for-java-devs/10-code-organization.rst index 7737fa7..33c7fac 100644 --- a/source/developer-guides/vala-for-java-devs/10-code-organization.rst +++ b/source/developer-guides/documentation/vala-for-java-devs/10-code-organization.rst @@ -1,5 +1,5 @@ Code Organization ------------------ +================= Files ----- @@ -13,7 +13,7 @@ Vala: - file name doesn't need to resemble a class name Hierarchy --------- +--------- Java: - packages, represented by directory hierarchy @@ -48,3 +48,4 @@ Java: Vala: - namespace ``GLib`` imported by default + diff --git a/source/developer-guides/index.rst b/source/developer-guides/index.rst index 2ff3411..90ec38d 100644 --- a/source/developer-guides/index.rst +++ b/source/developer-guides/index.rst @@ -4,5 +4,5 @@ Developer Guides .. toctree:: :glob: :maxdepth: 2 - - vala-for-java-devs/index + + * diff --git a/source/index.rst b/source/index.rst index f1b9720..2c90465 100644 --- a/source/index.rst +++ b/source/index.rst @@ -7,7 +7,6 @@ Vala Documentation Home About Installation Guide - Developer Guides Tutorials Tooling Contributor Guide @@ -31,7 +30,7 @@ Sections - `Tooling `_ - `Contributor Guide `_ - `Developer Guides `_ -- `FAQ `_ +- `FAQ `_ External Resources ------------------